Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 23:31:28

0001 /*! \brief   Implementation of methods
0002  *  \details Here, in the header file, the methods which do not depend
0003  *           on the specific type <T> that can fit the template.
0004  *           Other methods, with type-specific features, are implemented
0005  *           in the source file.
0006  */
0007 
0008 #include "SimTracker/TrackTriggerAssociation/interface/TTTrackAssociationMap.h"
0009 
0010 /// Operations
0011 template <>
0012 const TrackingParticlePtr& TTTrackAssociationMap<Ref_Phase2TrackerDigi_>::findTrackingParticlePtr(
0013     TTTrackPtr aTrack) const {
0014   if (trackToTrackingParticleMap_.find(aTrack) != trackToTrackingParticleMap_.end()) {
0015     return trackToTrackingParticleMap_.find(aTrack)->second;
0016   } else {
0017     return nullTrackingParticlePtr_;
0018   }
0019 }
0020 
0021 template <>
0022 const std::vector<TTTrackPtr>& TTTrackAssociationMap<Ref_Phase2TrackerDigi_>::findTTTrackPtrs(
0023     TrackingParticlePtr aTrackingParticle) const {
0024   if (trackingParticleToTrackVectorMap_.find(aTrackingParticle) != trackingParticleToTrackVectorMap_.end()) {
0025     return trackingParticleToTrackVectorMap_.find(aTrackingParticle)->second;
0026   } else {
0027     return nullVecTTTrackPtr_;
0028   }
0029 }
0030 
0031 /// MC truth
0032 template <>
0033 bool TTTrackAssociationMap<Ref_Phase2TrackerDigi_>::isLooselyGenuine(TTTrackPtr aTrack) const {
0034   /// Check if there is a TrackingParticle
0035   if ((this->findTrackingParticlePtr(aTrack)).isNull())
0036     return false;
0037 
0038   return true;
0039 }
0040 
0041 /// MC truth
0042 template <>
0043 bool TTTrackAssociationMap<Ref_Phase2TrackerDigi_>::isGenuine(TTTrackPtr aTrack) const {
0044   /// Check if there is an associated TrackingParticle
0045   if ((this->findTrackingParticlePtr(aTrack)).isNull())
0046     return false;
0047 
0048   /// Get all the stubs from this track & associated TrackingParticle
0049   const std::vector<TTStubRef>& TRK_Stubs = aTrack->getStubRefs();
0050   const std::vector<TTStubRef>& TP_Stubs =
0051       theStubAssociationMap_->findTTStubRefs(this->findTrackingParticlePtr(aTrack));
0052 
0053   bool one2SStub = false;
0054   for (unsigned int js = 0; js < TRK_Stubs.size(); js++) {
0055     /// We want that all the stubs of the track are included in the container of
0056     /// all the stubs produced by this particular TrackingParticle which we
0057     /// already know is one of the TrackingParticles that released hits
0058     /// in this track we are evaluating right now
0059     /// Now modifying to allow one and only one false 2S stub in the track  idr 06/19
0060     if (std::find(TP_Stubs.begin(), TP_Stubs.end(), TRK_Stubs.at(js)) == TP_Stubs.end()) {
0061       if (!AllowOneFalse2SStub || TRK_Stubs.at(js)->moduleTypePS() || one2SStub)  // Has to be first false 2S stub
0062       {
0063         return false;
0064       } else {
0065         one2SStub = true;
0066       }
0067     }
0068   }
0069 
0070   return true;
0071 }
0072 
0073 template <>
0074 bool TTTrackAssociationMap<Ref_Phase2TrackerDigi_>::isCombinatoric(TTTrackPtr aTrack) const {
0075   /// Defined by exclusion
0076   if (this->isLooselyGenuine(aTrack))
0077     return false;
0078 
0079   if (this->isUnknown(aTrack))
0080     return false;
0081 
0082   return true;
0083 }
0084 
0085 template <>
0086 bool TTTrackAssociationMap<Ref_Phase2TrackerDigi_>::isUnknown(TTTrackPtr aTrack) const {
0087   /// UNKNOWN means that >= 2 stubs are unknown
0088   int unknownstubs = 0;
0089 
0090   const std::vector<TTStubRef>& theseStubs = aTrack->getStubRefs();
0091   for (unsigned int i = 0; i < theseStubs.size(); i++) {
0092     if (theStubAssociationMap_->isUnknown(theseStubs.at(i)) == false) {
0093       ++unknownstubs;
0094       if (unknownstubs >= 2)
0095         return false;
0096     }
0097   }
0098 
0099   return true;
0100 }
0101 
0102 template <>
0103 void TTTrackAssociationMap<Ref_Phase2TrackerDigi_>::setAllowOneFalse2SStub(bool allowFalse2SStub) {
0104   AllowOneFalse2SStub = allowFalse2SStub;
0105 }
0106 
0107 template <>
0108 bool TTTrackAssociationMap<Ref_Phase2TrackerDigi_>::getAllowOneFalse2SStub() {
0109   return AllowOneFalse2SStub;
0110 }