Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-18 22:30:55

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 
0094   std::vector<bool> doResolutionPlots_;
0095 
0096   std::unique_ptr<MTVHistoProducerAlgoForTracker> histoProducerAlgo_;
0097 
0098 private:
0099   const TrackingVertex::LorentzVector* getSimPVPosition(const edm::Handle<TrackingVertexCollection>& htv) const;
0100   const reco::Vertex::Point* getRecoPVPosition(const edm::Event& event,
0101                                                const edm::Handle<TrackingVertexCollection>& htv) const;
0102   void tpParametersAndSelection(
0103       const Histograms& histograms,
0104       const TrackingParticleRefVector& tPCeff,
0105       const edm::Event& event,
0106       const edm::EventSetup& setup,
0107       const reco::BeamSpot& bs,
0108       std::vector<std::tuple<TrackingParticle::Vector, TrackingParticle::Point>>& momVert_tPCeff,
0109       std::vector<size_t>& selected_tPCeff) const;
0110   size_t tpDR(const TrackingParticleRefVector& tPCeff,
0111               const std::vector<size_t>& selected_tPCeff,
0112               DynArray<float>& dR_tPCeff,
0113               DynArray<float>& dR_tPCeff_jet,
0114               const edm::View<reco::Candidate>* cores) const;
0115   void trackDR(const edm::View<reco::Track>& trackCollection,
0116                const edm::View<reco::Track>& trackCollectionDr,
0117                DynArray<float>& dR_trk,
0118                DynArray<float>& dR_trk_jet,
0119                const edm::View<reco::Candidate>* cores) const;
0120 
0121   std::vector<edm::EDGetTokenT<reco::TrackToTrackingParticleAssociator>> associatorTokens;
0122   std::vector<edm::EDGetTokenT<reco::SimToRecoCollection>> associatormapStRs;
0123   std::vector<edm::EDGetTokenT<reco::RecoToSimCollection>> associatormapRtSs;
0124 
0125   edm::EDGetTokenT<edm::ValueMap<unsigned int>> tpNLayersToken_;
0126   edm::EDGetTokenT<edm::ValueMap<unsigned int>> tpNPixelLayersToken_;
0127   edm::EDGetTokenT<edm::ValueMap<unsigned int>> tpNStripStereoLayersToken_;
0128 
0129   using MVACollection = std::vector<float>;
0130   using QualityMaskCollection = std::vector<unsigned char>;
0131   std::vector<std::vector<std::tuple<edm::EDGetTokenT<MVACollection>, edm::EDGetTokenT<QualityMaskCollection>>>>
0132       mvaQualityCollectionTokens_;
0133 
0134   std::string dirName_;
0135 
0136   bool useGsf;
0137   const double simPVMaxZ_;
0138 
0139   edm::EDGetTokenT<edm::View<reco::Candidate>> cores_;
0140   double ptMinJet_;
0141   // select tracking particles
0142   //(i.e. "denominator" of the efficiency ratio)
0143   TrackingParticleSelector tpSelector;
0144   CosmicTrackingParticleSelector cosmictpSelector;
0145   TrackingParticleSelector dRtpSelector;
0146   std::unique_ptr<RecoTrackSelectorBase> dRTrackSelector;
0147 
0148   edm::EDGetTokenT<SimHitTPAssociationProducer::SimHitTPAssociationList> _simHitTpMapTag;
0149   edm::EDGetTokenT<edm::View<reco::Track>> labelTokenForDrCalculation;
0150   edm::EDGetTokenT<edm::View<reco::Vertex>> recoVertexToken_;
0151   edm::EDGetTokenT<reco::VertexToTrackingVertexAssociator> vertexAssociatorToken_;
0152 };
0153 
0154 #endif