Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:49

0001 #include "L1Trigger/TrackFindingTMTT/interface/ConverterToTTTrack.h"
0002 #include "FWCore/Utilities/interface/Exception.h"
0003 
0004 using namespace std;
0005 
0006 namespace tmtt {
0007 
0008   //=== Convert L1fittedTrack or L1track3D (track candidates after/before fit) to TTTrack format.
0009 
0010   TTTrack<Ref_Phase2TrackerDigi_> ConverterToTTTrack::makeTTTrack(const L1trackBase* trk,
0011                                                                   unsigned int iPhiSec,
0012                                                                   unsigned int iEtaReg) const {
0013     unsigned int nPar, hitPattern;
0014     double d0, z0, tanL, chi2rphi, chi2rz;
0015 
0016     const L1fittedTrack* fitTrk = dynamic_cast<const L1fittedTrack*>(trk);
0017 
0018     // Handle variables that differ for L1fittedTrack & L1track3D
0019     if (fitTrk == nullptr) {
0020       // This is an L1track3D type (track before fit)
0021       nPar = 4;  // Before fit, TMTT algorithm assumes 4 helix params
0022       // Set to zero variables that are unavailable for this track type.
0023       hitPattern = 0;
0024       d0 = 0.;
0025       z0 = 0;
0026       tanL = 0;
0027       chi2rphi = 0.;
0028       chi2rz = 0;
0029     } else {
0030       // This is an L1fittedTrack type (track after fit)
0031       if (not fitTrk->accepted())
0032         throw cms::Exception("LogicError") << "ConverterToTTTrack ERROR: requested to convert invalid L1fittedTrack";
0033       nPar = fitTrk->nHelixParam();  // Number of helix parameters in track fit
0034       hitPattern = fitTrk->hitPattern();
0035       d0 = fitTrk->d0();
0036       z0 = fitTrk->z0();
0037       tanL = fitTrk->tanLambda();
0038       chi2rphi = fitTrk->chi2rphi();
0039       chi2rz = fitTrk->chi2rz();
0040     }
0041 
0042     const double& rinv = invPtToInvR_ * trk->qOverPt();
0043     const double& phi0 = trk->phi0();
0044     constexpr double mva = -1.;  // MVA quality flags not yet set.
0045     const double& magneticField = settings_->magneticField();
0046 
0047     TTTrack<Ref_Phase2TrackerDigi_> track(
0048         rinv, phi0, tanL, z0, d0, chi2rphi, chi2rz, mva, mva, mva, hitPattern, nPar, magneticField);
0049 
0050     // Set references to stubs on this track.
0051     std::vector<TTStubRef> ttstubrefs = this->stubRefs(trk);
0052     track.setStubRefs(ttstubrefs);
0053 
0054     // Note which (eta,phi) sector this track was reconstructed in.
0055     track.setPhiSector(iPhiSec);
0056     track.setEtaSector(iEtaReg);
0057 
0058     track.setStubPtConsistency(-1);  // not yet filled.
0059 
0060     return track;
0061   }
0062 
0063   //=== Get references to stubs on track. (Works for either L1track3D or L1fittedTrack).
0064 
0065   std::vector<TTStubRef> ConverterToTTTrack::stubRefs(const L1trackBase* trk) const {
0066     std::vector<TTStubRef> ttstubrefs;
0067     const std::vector<Stub*>& stubs = trk->stubs();
0068     for (Stub* s : stubs) {
0069       const TTStubRef& ref = s->ttStubRef();
0070       ttstubrefs.push_back(ref);
0071     }
0072     return ttstubrefs;
0073   }
0074 
0075 }  // namespace tmtt