Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:33:20

0001 #ifndef MultiTrackValidator_h
0002 #define MultiTrackValidator_h
0003 
0004 /** \class MultiTrackValidator
0005  *  Class that prodecs histrograms to validate Track Reconstruction performances
0006  *
0007  *  \author cerati
0008  */
0009 #include "FWCore/Framework/interface/Event.h"
0010 #include "FWCore/Framework/interface/ESHandle.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 #include "FWCore/Utilities/interface/EDGetToken.h"
0013 #include "FWCore/Framework/interface/Frameworkfwd.h"
0014 
0015 #include "DQMServices/Core/interface/DQMGlobalEDAnalyzer.h"
0016 
0017 #include "Validation/RecoTrack/interface/MTVHistoProducerAlgoForTracker.h"
0018 #include "SimDataFormats/Associations/interface/TrackToTrackingParticleAssociator.h"
0019 #include "SimDataFormats/Associations/interface/VertexToTrackingVertexAssociator.h"
0020 #include "CommonTools/RecoAlgos/interface/CosmicTrackingParticleSelector.h"
0021 #include "SimTracker/Common/interface/TrackingParticleSelector.h"
0022 #include "CommonTools/RecoAlgos/interface/RecoTrackSelectorBase.h"
0023 #include "SimTracker/TrackAssociation/interface/ParametersDefinerForTP.h"
0024 #include "CommonTools/Utils/interface/DynArray.h"
0025 #include "DataFormats/Common/interface/ValueMap.h"
0026 #include "DataFormats/Candidate/interface/Candidate.h"
0027 
0028 class PileupSummaryInfo;
0029 namespace reco {
0030   class DeDxData;
0031 }
0032 
0033 struct MultiTrackValidatorHistograms {
0034   MTVHistoProducerAlgoForTrackerHistograms histoProducerAlgo;
0035   std::vector<dqm::reco::MonitorElement*> h_reco_coll, h_assoc_coll, h_assoc2_coll, h_simul_coll, h_looper_coll,
0036       h_pileup_coll;
0037 };
0038 
0039 class MultiTrackValidator : public DQMGlobalEDAnalyzer<MultiTrackValidatorHistograms> {
0040 public:
0041   using Histograms = MultiTrackValidatorHistograms;
0042 
0043   /// Constructor
0044   MultiTrackValidator(const edm::ParameterSet& pset);
0045 
0046   /// Destructor
0047   ~MultiTrackValidator() override;
0048 
0049   /// Method called once per event
0050   void dqmAnalyze(const edm::Event&, const edm::EventSetup&, const Histograms&) const override;
0051   /// Method called to book the DQM histograms
0052   void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&, Histograms&) const override;
0053 
0054 protected:
0055   // ES Tokens
0056   const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoEsToken;
0057 
0058   std::unique_ptr<ParametersDefinerForTP> parametersDefinerTP_;
0059   const bool parametersDefinerIsCosmic_;
0060 
0061   //these are used by MTVGenPs
0062   // MTV-specific data members
0063   std::vector<edm::InputTag> associators;
0064   edm::EDGetTokenT<TrackingParticleCollection> label_tp_effic;
0065   edm::EDGetTokenT<TrackingParticleCollection> label_tp_fake;
0066   edm::EDGetTokenT<TrackingParticleRefVector> label_tp_effic_refvector;
0067   edm::EDGetTokenT<TrackingParticleRefVector> label_tp_fake_refvector;
0068   edm::EDGetTokenT<TrackingVertexCollection> label_tv;
0069   edm::EDGetTokenT<std::vector<PileupSummaryInfo>> label_pileupinfo;
0070 
0071   std::vector<edm::EDGetTokenT<std::vector<PSimHit>>> simHitTokens_;
0072 
0073   std::vector<edm::InputTag> label;
0074   std::vector<edm::EDGetTokenT<edm::View<reco::Track>>> labelToken;
0075   std::vector<edm::EDGetTokenT<edm::View<TrajectorySeed>>> labelTokenSeed;
0076   edm::EDGetTokenT<reco::BeamSpot> bsSrc;
0077 
0078   edm::EDGetTokenT<edm::ValueMap<reco::DeDxData>> m_dEdx1Tag;
0079   edm::EDGetTokenT<edm::ValueMap<reco::DeDxData>> m_dEdx2Tag;
0080 
0081   const bool ignoremissingtkcollection_;
0082   const bool useAssociators_;
0083   const bool calculateDrSingleCollection_;
0084   const bool doPlotsOnlyForTruePV_;
0085   const bool doSummaryPlots_;
0086   const bool doSimPlots_;
0087   const bool doSimTrackPlots_;
0088   const bool doRecoTrackPlots_;
0089   const bool dodEdxPlots_;
0090   const bool doPVAssociationPlots_;
0091   const bool doSeedPlots_;
0092   const bool doMVAPlots_;
0093   const bool applyTPSelToSimMatch_;
0094 
0095   std::vector<bool> doResolutionPlots_;
0096 
0097   std::unique_ptr<MTVHistoProducerAlgoForTracker> histoProducerAlgo_;
0098 
0099 private:
0100   const TrackingVertex::LorentzVector* getSimPVPosition(const edm::Handle<TrackingVertexCollection>& htv) const;
0101   const reco::Vertex::Point* getRecoPVPosition(const edm::Event& event,
0102                                                const edm::Handle<TrackingVertexCollection>& htv) const;
0103   void tpParametersAndSelection(
0104       const Histograms& histograms,
0105       const TrackingParticleRefVector& tPCeff,
0106       const edm::Event& event,
0107       const edm::EventSetup& setup,
0108       const reco::BeamSpot& bs,
0109       std::vector<std::tuple<TrackingParticle::Vector, TrackingParticle::Point>>& momVert_tPCeff,
0110       std::vector<size_t>& selected_tPCeff) const;
0111   size_t tpDR(const TrackingParticleRefVector& tPCeff,
0112               const std::vector<size_t>& selected_tPCeff,
0113               DynArray<float>& dR_tPCeff,
0114               DynArray<float>& dR_tPCeff_jet,
0115               const edm::View<reco::Candidate>* cores) const;
0116   void trackDR(const edm::View<reco::Track>& trackCollection,
0117                const edm::View<reco::Track>& trackCollectionDr,
0118                DynArray<float>& dR_trk,
0119                DynArray<float>& dR_trk_jet,
0120                const edm::View<reco::Candidate>* cores) const;
0121 
0122   std::vector<edm::EDGetTokenT<reco::TrackToTrackingParticleAssociator>> associatorTokens;
0123   std::vector<edm::EDGetTokenT<reco::SimToRecoCollection>> associatormapStRs;
0124   std::vector<edm::EDGetTokenT<reco::RecoToSimCollection>> associatormapRtSs;
0125 
0126   edm::EDGetTokenT<edm::ValueMap<unsigned int>> tpNLayersToken_;
0127   edm::EDGetTokenT<edm::ValueMap<unsigned int>> tpNPixelLayersToken_;
0128   edm::EDGetTokenT<edm::ValueMap<unsigned int>> tpNStripStereoLayersToken_;
0129 
0130   using MVACollection = std::vector<float>;
0131   using QualityMaskCollection = std::vector<unsigned char>;
0132   std::vector<std::vector<std::tuple<edm::EDGetTokenT<MVACollection>, edm::EDGetTokenT<QualityMaskCollection>>>>
0133       mvaQualityCollectionTokens_;
0134 
0135   std::string dirName_;
0136 
0137   bool useGsf;
0138   const double simPVMaxZ_;
0139 
0140   edm::EDGetTokenT<edm::View<reco::Candidate>> cores_;
0141   double ptMinJet_;
0142   // select tracking particles
0143   //(i.e. "denominator" of the efficiency ratio)
0144   TrackingParticleSelector tpSelector;
0145   CosmicTrackingParticleSelector cosmictpSelector;
0146   TrackingParticleSelector dRtpSelector;
0147   std::unique_ptr<RecoTrackSelectorBase> dRTrackSelector;
0148 
0149   edm::EDGetTokenT<SimHitTPAssociationProducer::SimHitTPAssociationList> _simHitTpMapTag;
0150   edm::EDGetTokenT<edm::View<reco::Track>> labelTokenForDrCalculation;
0151   edm::EDGetTokenT<edm::View<reco::Vertex>> recoVertexToken_;
0152   edm::EDGetTokenT<reco::VertexToTrackingVertexAssociator> vertexAssociatorToken_;
0153 };
0154 
0155 #endif