Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef SimGeneral_TrackingAnalysis_TrackingParticleNumberOfLayers_h
0002 #define SimGeneral_TrackingAnalysis_TrackingParticleNumberOfLayers_h
0003 
0004 #include "FWCore/Framework/interface/Event.h"
0005 
0006 #include "DataFormats/Common/interface/ValueMap.h"
0007 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
0008 #include "SimDataFormats/TrackingHit/interface/PSimHit.h"
0009 
0010 class TrackerTopology;
0011 
0012 /**
0013  * This class calculates the number of tracker layers, pixel layers,
0014  * and strip mono+stereo layers "crossed" by TrackingParticle.
0015  *
0016  * The numbers of pixel and strip mono+stereo layers are not available
0017  * from TrackingParticle itself, so they are calculated here in a
0018  * standalone way in order to not to modify the TP dataformat (for
0019  * now). The number of tracker layers is available in TP, but its
0020  * calculation in TrackingTruthAccumulator gives wrong results (too
0021  * many layers) for loopers, so also it is calculated here on the same
0022  * go.
0023  *
0024  * The PSimHits are needed for the calculation, so, in practice, in
0025  * events with pileup the numbers of layers can be calculated only for
0026  * TPs from the signal event (i.e. not for pileup TPs). Fortunately
0027  * this is exactly what is sufficient for MultiTrackValidator.
0028  *
0029  * Eventually we should move to use HitPattern as in reco::TrackBase
0030  * (more information in a compact format), and consider adding it to
0031  * the TrackingParticle itself.
0032  *
0033  * In principle we could utilize the TP->SimHit map produced in
0034  * SimHitTPAssociationProducer instead of doing the association here
0035  * again, but
0036  * - SimTrack SimHits need to looped over in the order defined by
0037  *   SimTrack (to do the same as in TrackingTruthAccumulator). While
0038  *   possible, it would be cumbersome to do (more than just doing the
0039  *   association via SimTrack id)
0040  * - The main customer of this class, MultiTrackValidator, can in
0041  *   principle take a TrackingParticle collection different from the
0042  *   one of SimHitTPAssociationProducer (e.g. after a selection, since
0043  *   MTV does not support TP Refs because of how
0044  *   reco::RecoToSimCollection and reco::SimToRecoCollection are defined
0045  */
0046 class TrackingParticleNumberOfLayers {
0047 public:
0048   TrackingParticleNumberOfLayers(const edm::Event &iEvent,
0049                                  const std::vector<edm::EDGetTokenT<std::vector<PSimHit>>> &simHitTokens);
0050 
0051   enum { nTrackerLayers = 0, nPixelLayers = 1, nStripMonoAndStereoLayers = 2 };
0052   std::tuple<std::unique_ptr<edm::ValueMap<unsigned int>>,
0053              std::unique_ptr<edm::ValueMap<unsigned int>>,
0054              std::unique_ptr<edm::ValueMap<unsigned int>>>
0055   calculate(const edm::Handle<TrackingParticleCollection> &tps, const TrackerTopology &tTopo) const;
0056 
0057 private:
0058   // used as multimap, but faster
0059   std::vector<std::pair<unsigned int, const PSimHit *>> trackIdToHitPtr_;
0060 };
0061 
0062 #endif