Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:26:55

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/TotemTimingTrackRecognition.h"
0012 
0013 //----------------------------------------------------------------------------------------------------
0014 
0015 TotemTimingTrackRecognition::TotemTimingTrackRecognition(const edm::ParameterSet& iConfig)
0016     : CTPPSTimingTrackRecognition<TotemTimingLocalTrack, TotemTimingRecHit>(iConfig) {}
0017 
0018 //----------------------------------------------------------------------------------------------------
0019 
0020 void TotemTimingTrackRecognition::addHit(const TotemTimingRecHit& recHit) {
0021   if (recHit.time() != TotemTimingRecHit::NO_T_AVAILABLE)
0022     hitVectorMap_[0].emplace_back(recHit);
0023 }
0024 
0025 //----------------------------------------------------------------------------------------------------
0026 
0027 int TotemTimingTrackRecognition::produceTracks(edm::DetSet<TotemTimingLocalTrack>& tracks) {
0028   int numberOfTracks = 0;
0029   DimensionParameters param;
0030 
0031   auto getX = [](const TotemTimingRecHit& hit) { return hit.x(); };
0032   auto getXWidth = [](const TotemTimingRecHit& hit) { return hit.xWidth(); };
0033   auto setX = [](TotemTimingLocalTrack& track, float x) { track.setPosition(math::XYZPoint(x, 0., 0.)); };
0034   auto setXSigma = [](TotemTimingLocalTrack& track, float sigma) {
0035     track.setPositionSigma(math::XYZPoint(sigma, 0., 0.));
0036   };
0037   auto getY = [](const TotemTimingRecHit& hit) { return hit.y(); };
0038   auto getYWidth = [](const TotemTimingRecHit& hit) { return hit.yWidth(); };
0039   auto setY = [](TotemTimingLocalTrack& track, float y) { track.setPosition(math::XYZPoint(0., y, 0.)); };
0040   auto setYSigma = [](TotemTimingLocalTrack& track, float sigma) {
0041     track.setPositionSigma(math::XYZPoint(0., sigma, 0.));
0042   };
0043 
0044   for (const auto& hitBatch : hitVectorMap_) {
0045     const auto& hits = hitBatch.second;
0046     const auto& hitRange = getHitSpatialRange(hits);
0047 
0048     TrackVector xPartTracks, yPartTracks;
0049 
0050     param.rangeBegin = hitRange.xBegin;
0051     param.rangeEnd = hitRange.xEnd;
0052     producePartialTracks(hits, param, getX, getXWidth, setX, setXSigma, xPartTracks);
0053 
0054     param.rangeBegin = hitRange.yBegin;
0055     param.rangeEnd = hitRange.yEnd;
0056     producePartialTracks(hits, param, getY, getYWidth, setY, setYSigma, yPartTracks);
0057 
0058     if (xPartTracks.empty() && yPartTracks.empty())
0059       continue;
0060 
0061     unsigned int validHitsNumber = (unsigned int)threshold_ + 1;
0062 
0063     for (const auto& xTrack : xPartTracks) {
0064       for (const auto& yTrack : yPartTracks) {
0065         math::XYZPoint position(xTrack.x0(), yTrack.y0(), 0.5f * (hitRange.zBegin + hitRange.zEnd));
0066         math::XYZPoint positionSigma(xTrack.x0Sigma(), yTrack.y0Sigma(), 0.5f * (hitRange.zEnd - hitRange.zBegin));
0067 
0068         TotemTimingLocalTrack newTrack(position, positionSigma, 0., 0.);
0069 
0070         HitVector componentHits;
0071         for (const auto& hit : hits)
0072           if (newTrack.containsHit(hit, tolerance_))
0073             componentHits.emplace_back(hit);
0074         if (componentHits.size() < validHitsNumber)
0075           continue;
0076 
0077         float mean_time = 0.f, time_sigma = 0.f;
0078         bool valid_hits = timeEval(componentHits, mean_time, time_sigma);
0079         newTrack.setValid(valid_hits);
0080         newTrack.setTime(mean_time);
0081         newTrack.setTimeSigma(time_sigma);
0082         // in a next iteration, we will be setting validity / numHits / numPlanes
0083         tracks.push_back(newTrack);
0084       }
0085     }
0086   }
0087 
0088   return numberOfTracks;
0089 }