Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:40

0001 /****************************************************************************
0002  *
0003  * This is a part of CTPPS offline software.
0004  * Authors:
0005  *   Laurent Forthomme (laurent.forthomme@cern.ch)
0006  *   Nicola Minafra (nicola.minafra@cern.ch)
0007  *   Mateusz Szpyrka (mateusz.szpyrka@cern.ch)
0008  *
0009  ****************************************************************************/
0010 
0011 #include "RecoPPS/Local/interface/CTPPSDiamondTrackRecognition.h"
0012 
0013 //----------------------------------------------------------------------------------------------------
0014 
0015 CTPPSDiamondTrackRecognition::CTPPSDiamondTrackRecognition(const edm::ParameterSet& iConfig)
0016     : CTPPSTimingTrackRecognition<CTPPSDiamondLocalTrack, CTPPSDiamondRecHit>(iConfig),
0017       excludeSingleEdgeHits_(iConfig.getParameter<bool>("excludeSingleEdgeHits")) {}
0018 
0019 //----------------------------------------------------------------------------------------------------
0020 
0021 void CTPPSDiamondTrackRecognition::clear() {
0022   CTPPSTimingTrackRecognition<CTPPSDiamondLocalTrack, CTPPSDiamondRecHit>::clear();
0023   mhMap_.clear();
0024 }
0025 
0026 //----------------------------------------------------------------------------------------------------
0027 
0028 void CTPPSDiamondTrackRecognition::addHit(const CTPPSDiamondRecHit& recHit) {
0029   if (excludeSingleEdgeHits_ && recHit.toT() <= 0.)
0030     return;
0031   // store hit parameters
0032   hitVectorMap_[recHit.ootIndex()].emplace_back(recHit);
0033 }
0034 
0035 //----------------------------------------------------------------------------------------------------
0036 
0037 int CTPPSDiamondTrackRecognition::produceTracks(edm::DetSet<CTPPSDiamondLocalTrack>& tracks) {
0038   int numberOfTracks = 0;
0039   DimensionParameters param;
0040 
0041   auto getX = [](const CTPPSDiamondRecHit& hit) { return hit.x(); };
0042   auto getXWidth = [](const CTPPSDiamondRecHit& hit) { return hit.xWidth(); };
0043   auto setX = [](CTPPSDiamondLocalTrack& track, float x) { track.setPosition(math::XYZPoint(x, 0., 0.)); };
0044   auto setXSigma = [](CTPPSDiamondLocalTrack& track, float sigma) {
0045     track.setPositionSigma(math::XYZPoint(sigma, 0., 0.));
0046   };
0047 
0048   for (const auto& hitBatch : hitVectorMap_) {
0049     // separate the tracking for each bunch crossing
0050     const auto& oot = hitBatch.first;
0051     const auto& hits = hitBatch.second;
0052 
0053     auto hitRange = getHitSpatialRange(hits);
0054 
0055     TrackVector xPartTracks;
0056 
0057     // produce tracks in x dimension
0058     param.rangeBegin = hitRange.xBegin;
0059     param.rangeEnd = hitRange.xEnd;
0060     producePartialTracks(hits, param, getX, getXWidth, setX, setXSigma, xPartTracks);
0061 
0062     if (xPartTracks.empty())
0063       continue;
0064 
0065     const float yRangeCenter = 0.5f * (hitRange.yBegin + hitRange.yEnd);
0066     const float zRangeCenter = 0.5f * (hitRange.zBegin + hitRange.zEnd);
0067     const float ySigma = 0.5f * (hitRange.yEnd - hitRange.yBegin);
0068     const float zSigma = 0.5f * (hitRange.zEnd - hitRange.zBegin);
0069 
0070     for (const auto& xTrack : xPartTracks) {
0071       math::XYZPoint position(xTrack.x0(), yRangeCenter, zRangeCenter);
0072       math::XYZPoint positionSigma(xTrack.x0Sigma(), ySigma, zSigma);
0073 
0074       const int multipleHits = (mhMap_.find(oot) != mhMap_.end()) ? mhMap_[oot] : 0;
0075       CTPPSDiamondLocalTrack newTrack(position, positionSigma, 0.f, 0.f, oot, multipleHits);
0076 
0077       // find contributing hits
0078       HitVector componentHits;
0079       for (const auto& hit : hits)
0080         if (newTrack.containsHit(hit, tolerance_) && (!excludeSingleEdgeHits_ || hit.toT() > 0.))
0081           componentHits.emplace_back(hit);
0082       // compute timing information
0083       float mean_time = 0.f, time_sigma = 0.f;
0084       bool valid_hits = timeEval(componentHits, mean_time, time_sigma);
0085       newTrack.setValid(valid_hits);
0086       newTrack.setTime(mean_time);
0087       newTrack.setTimeSigma(time_sigma);
0088 
0089       tracks.push_back(newTrack);
0090     }
0091   }
0092 
0093   return numberOfTracks;
0094 }