File indexing completed on 2024-04-06 12:33:20
0001 #ifndef Validation_RecoTrack_MTVHistoProducerAlgoForTracker_h
0002 #define Validation_RecoTrack_MTVHistoProducerAlgoForTracker_h
0003
0004
0005
0006
0007
0008
0009
0010 #include "FWCore/Framework/interface/ConsumesCollector.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012
0013 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0014 #include "DataFormats/TrackReco/interface/Track.h"
0015 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
0016 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
0017 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
0018 #include "DataFormats/TrackReco/interface/DeDxData.h"
0019 #include "DataFormats/Common/interface/ValueMap.h"
0020
0021 #include "RecoTracker/TkSeedingLayers/interface/SeedingLayerSetsBuilder.h"
0022
0023 #include "SimTracker/Common/interface/TrackingParticleSelector.h"
0024 #include "CommonTools/CandAlgos/interface/GenParticleCustomSelector.h"
0025 #include "CommonTools/RecoAlgos/interface/RecoTrackSelectorBase.h"
0026
0027 #include "DQMServices/Core/interface/DQMStore.h"
0028
0029 struct MTVHistoProducerAlgoForTrackerHistograms {
0030
0031 using METype = dqm::reco::MonitorElement*;
0032 METype h_ptSIM, h_etaSIM, h_phiSIM, h_tracksSIM, h_vertposSIM, h_bunchxSIM;
0033
0034
0035 std::vector<METype> h_tracks, h_fakes, h_hits, h_charge, h_algo, h_seedsFitFailed, h_seedsFitFailedFraction;
0036 std::vector<METype> h_recoeta, h_reco2eta, h_assoceta, h_assoc2eta, h_simuleta, h_loopereta, h_misideta, h_pileupeta;
0037 std::vector<METype> h_recopT, h_reco2pT, h_assocpT, h_assoc2pT, h_simulpT, h_looperpT, h_misidpT, h_pileuppT;
0038 std::vector<METype> h_recopTvseta, h_reco2pTvseta, h_assocpTvseta, h_assoc2pTvseta, h_simulpTvseta, h_looperpTvseta,
0039 h_misidpTvseta, h_pileuppTvseta;
0040 std::vector<METype> h_recohit, h_assochit, h_assoc2hit, h_simulhit, h_looperhit, h_misidhit, h_pileuphit;
0041 std::vector<METype> h_recolayer, h_assoclayer, h_assoc2layer, h_simullayer, h_looperlayer, h_misidlayer,
0042 h_pileuplayer;
0043 std::vector<METype> h_recopixellayer, h_assocpixellayer, h_assoc2pixellayer, h_simulpixellayer, h_looperpixellayer,
0044 h_misidpixellayer, h_pileuppixellayer;
0045 std::vector<METype> h_reco3Dlayer, h_assoc3Dlayer, h_assoc23Dlayer, h_simul3Dlayer, h_looper3Dlayer, h_misid3Dlayer,
0046 h_pileup3Dlayer;
0047 std::vector<METype> h_recopu, h_reco2pu, h_assocpu, h_assoc2pu, h_simulpu, h_looperpu, h_misidpu, h_pileuppu;
0048 std::vector<METype> h_recophi, h_assocphi, h_assoc2phi, h_simulphi, h_looperphi, h_misidphi, h_pileupphi;
0049 std::vector<METype> h_recodxy, h_assocdxy, h_assoc2dxy, h_simuldxy, h_looperdxy, h_misiddxy, h_pileupdxy;
0050 std::vector<METype> h_recodz, h_assocdz, h_assoc2dz, h_simuldz, h_looperdz, h_misiddz, h_pileupdz;
0051 std::vector<METype> h_recodxypv, h_assocdxypv, h_assoc2dxypv, h_simuldxypv, h_looperdxypv, h_misiddxypv,
0052 h_pileupdxypv;
0053 std::vector<METype> h_recodzpv, h_assocdzpv, h_assoc2dzpv, h_simuldzpv, h_looperdzpv, h_misiddzpv, h_pileupdzpv;
0054 std::vector<METype> h_recodxypvzoomed, h_assocdxypvzoomed, h_assoc2dxypvzoomed, h_simuldxypvzoomed,
0055 h_looperdxypvzoomed, h_misiddxypvzoomed, h_pileupdxypvzoomed;
0056 std::vector<METype> h_recodzpvzoomed, h_assocdzpvzoomed, h_assoc2dzpvzoomed, h_simuldzpvzoomed, h_looperdzpvzoomed,
0057 h_misiddzpvzoomed, h_pileupdzpvzoomed;
0058
0059 std::vector<METype> h_recovertpos, h_assocvertpos, h_assoc2vertpos, h_simulvertpos, h_loopervertpos, h_pileupvertpos;
0060 std::vector<METype> h_recozpos, h_assoczpos, h_assoc2zpos, h_simulzpos, h_looperzpos, h_pileupzpos;
0061 std::vector<METype> h_assocdr, h_assoc2dr, h_simuldr, h_recodr, h_looperdr, h_pileupdr;
0062 std::vector<METype> h_assocdrj, h_assoc2drj, h_simuldrj, h_recodrj, h_looperdrj, h_pileupdrj;
0063 std::vector<METype> h_recochi2, h_assoc2chi2, h_looperchi2, h_misidchi2, h_pileupchi2;
0064 std::vector<METype> h_recochi2prob, h_assoc2chi2prob, h_looperchi2prob, h_misidchi2prob, h_pileupchi2prob;
0065 std::vector<METype> h_pt, h_eta, h_pullTheta, h_pullPhi, h_pullDxy, h_pullDz, h_pullQoverp;
0066 std::vector<METype> h_assoc2_itpu_eta, h_assoc2_itpu_sig_eta, h_assoc2eta_sig;
0067 std::vector<METype> h_assoc2_itpu_vertcount, h_assoc2_itpu_sig_vertcount;
0068 std::vector<METype> h_assoc2_ootpu_eta, h_assoc2_ootpu_vertcount;
0069 std::vector<METype> h_reco_ootpu_eta, h_reco_ootpu_vertcount;
0070 std::vector<METype> h_con_eta, h_con_vertcount, h_con_zpos;
0071
0072 std::vector<METype> h_reco_dzpvcut, h_assoc_dzpvcut, h_assoc2_dzpvcut, h_simul_dzpvcut, h_simul2_dzpvcut,
0073 h_pileup_dzpvcut;
0074 std::vector<METype> h_reco_dzpvsigcut, h_assoc_dzpvsigcut, h_assoc2_dzpvsigcut, h_simul_dzpvsigcut,
0075 h_simul2_dzpvsigcut, h_pileup_dzpvsigcut;
0076
0077 std::vector<METype> h_reco_simpvz, h_assoc_simpvz, h_assoc2_simpvz, h_simul_simpvz, h_looper_simpvz, h_pileup_simpvz;
0078
0079 std::vector<METype> h_reco_seedingLayerSet, h_assoc2_seedingLayerSet, h_looper_seedingLayerSet,
0080 h_pileup_seedingLayerSet;
0081
0082 std::vector<std::vector<METype>> h_reco_mva, h_assoc2_mva;
0083 std::vector<std::vector<METype>> h_reco_mvacut, h_assoc_mvacut, h_assoc2_mvacut, h_simul2_mvacut;
0084 std::vector<std::vector<METype>> h_reco_mva_hp, h_assoc2_mva_hp;
0085 std::vector<std::vector<METype>> h_reco_mvacut_hp, h_assoc_mvacut_hp, h_assoc2_mvacut_hp, h_simul2_mvacut_hp;
0086
0087 std::vector<std::vector<METype>> h_assoc2_mva_vs_pt, h_fake_mva_vs_pt, h_assoc2_mva_vs_pt_hp, h_fake_mva_vs_pt_hp;
0088 std::vector<std::vector<METype>> h_assoc2_mva_vs_eta, h_fake_mva_vs_eta, h_assoc2_mva_vs_eta_hp, h_fake_mva_vs_eta_hp;
0089
0090
0091
0092 std::vector<std::vector<METype>> h_dedx_estim;
0093 std::vector<std::vector<METype>> h_dedx_nom;
0094 std::vector<std::vector<METype>> h_dedx_sat;
0095
0096
0097 std::vector<METype> nrec_vs_nsim;
0098 std::vector<METype> nrecHit_vs_nsimHit_sim2rec;
0099 std::vector<METype> nrecHit_vs_nsimHit_rec2sim;
0100 std::vector<METype> h_duplicates_oriAlgo_vs_oriAlgo;
0101
0102
0103 std::vector<METype> h_assocFraction, h_assocSharedHit;
0104
0105
0106 std::vector<METype> nhits_vs_eta, nPXBhits_vs_eta, nPXFhits_vs_eta, nPXLhits_vs_eta, nTIBhits_vs_eta, nTIDhits_vs_eta,
0107 nTOBhits_vs_eta, nTEChits_vs_eta, nSTRIPhits_vs_eta, nLayersWithMeas_vs_eta, nPXLlayersWithMeas_vs_eta,
0108 nSTRIPlayersWithMeas_vs_eta, nSTRIPlayersWith1dMeas_vs_eta, nSTRIPlayersWith2dMeas_vs_eta, nMTDhits_vs_eta,
0109 nBTLhits_vs_eta, nETLhits_vs_eta;
0110
0111
0112
0113 std::vector<METype> h_nchi2, h_nchi2_prob, h_losthits, h_nmisslayers_inner, h_nmisslayers_outer;
0114
0115
0116 std::vector<METype> chi2_vs_nhits, etares_vs_eta;
0117 std::vector<METype> h_ptshifteta;
0118 std::vector<METype> dxyres_vs_phi, dzres_vs_phi, ptres_vs_phi, chi2_vs_phi, nhits_vs_phi, phires_vs_phi;
0119
0120
0121 std::vector<METype> ptmean_vs_eta_phi, phimean_vs_eta_phi;
0122
0123
0124 std::vector<METype> h_assochi2, h_assochi2_prob;
0125
0126
0127 std::vector<METype> chi2_vs_eta, chi2_vs_pt, chi2_vs_drj, nlosthits_vs_eta;
0128 std::vector<METype> assoc_chi2_vs_eta, assoc_chi2_vs_pt, assoc_chi2_vs_drj, assoc_chi2prob_vs_eta,
0129 assoc_chi2prob_vs_pt, assoc_chi2prob_vs_drj;
0130
0131
0132 std::vector<METype> dxyres_vs_eta, ptres_vs_eta, dzres_vs_eta, phires_vs_eta, cotThetares_vs_eta;
0133 std::vector<METype> dxyres_vs_pt, ptres_vs_pt, dzres_vs_pt, phires_vs_pt, cotThetares_vs_pt;
0134
0135
0136 std::vector<METype> dxypull_vs_eta, ptpull_vs_eta, dzpull_vs_eta, phipull_vs_eta, thetapull_vs_eta;
0137 std::vector<METype> dxypull_vs_pt, ptpull_vs_pt, dzpull_vs_pt, phipull_vs_pt, thetapull_vs_pt;
0138 std::vector<METype> ptpull_vs_phi, phipull_vs_phi, thetapull_vs_phi;
0139 };
0140
0141 class MTVHistoProducerAlgoForTracker {
0142 public:
0143 typedef dqm::reco::DQMStore DQMStore;
0144
0145 MTVHistoProducerAlgoForTracker(const edm::ParameterSet& pset, const bool doSeedPlots);
0146 ~MTVHistoProducerAlgoForTracker();
0147
0148 static std::unique_ptr<RecoTrackSelectorBase> makeRecoTrackSelectorFromTPSelectorParameters(
0149 const edm::ParameterSet& pset);
0150
0151 using Histograms = MTVHistoProducerAlgoForTrackerHistograms;
0152 void bookSimHistos(DQMStore::IBooker& ibook, Histograms& histograms);
0153 void bookSimTrackHistos(DQMStore::IBooker& ibook, Histograms& histograms, bool doResolutionPlots);
0154 void bookSimTrackPVAssociationHistos(DQMStore::IBooker& ibook, Histograms& histograms);
0155 void bookRecoHistos(DQMStore::IBooker& ibook, Histograms& histograms, bool doResolutionPlots);
0156 void bookRecoPVAssociationHistos(DQMStore::IBooker& ibook, Histograms& histograms);
0157 void bookRecodEdxHistos(DQMStore::IBooker& ibook, Histograms& histograms);
0158 void bookSeedHistos(DQMStore::IBooker& ibook, Histograms& histograms);
0159 void bookMVAHistos(DQMStore::IBooker& ibook, Histograms& histograms, size_t nMVAs);
0160
0161 void fill_generic_simTrack_histos(const Histograms& histograms,
0162 const TrackingParticle::Vector&,
0163 const TrackingParticle::Point& vertex,
0164 int bx) const;
0165 void fill_simTrackBased_histos(const Histograms& histograms, int numSimTracks) const;
0166
0167 void fill_recoAssociated_simTrack_histos(const Histograms& histograms,
0168 int count,
0169 const TrackingParticle& tp,
0170 const TrackingParticle::Vector& momentumTP,
0171 const TrackingParticle::Point& vertexTP,
0172 double dxy,
0173 double dz,
0174 double dxyPV,
0175 double dzPV,
0176 int nSimHits,
0177 int nSimLayers,
0178 int nSimPixelLayers,
0179 int nSimStripMonoAndStereoLayers,
0180 const reco::Track* track,
0181 int numVertices,
0182 double dR,
0183 double dR_jet,
0184 const math::XYZPoint* pvPosition,
0185 const TrackingVertex::LorentzVector* simPVPosition,
0186 const math::XYZPoint& bsPosition,
0187 const std::vector<float>& mvas,
0188 unsigned int selectsLoose,
0189 unsigned int selectsHP) const;
0190
0191 void fill_recoAssociated_simTrack_histos(const Histograms& histograms,
0192 int count,
0193 const reco::GenParticle& tp,
0194 const TrackingParticle::Vector& momentumTP,
0195 const TrackingParticle::Point& vertexTP,
0196 double dxy,
0197 double dz,
0198 int nSimHits,
0199 const reco::Track* track,
0200 int numVertices) const;
0201
0202 void fill_duplicate_histos(const Histograms& histograms,
0203 int count,
0204 const reco::Track& track1,
0205 const reco::Track& track2) const;
0206
0207 void fill_generic_recoTrack_histos(const Histograms& histograms,
0208 int count,
0209 const reco::Track& track,
0210 const TrackerTopology& ttopo,
0211 const math::XYZPoint& bsPosition,
0212 const math::XYZPoint* pvPosition,
0213 const TrackingVertex::LorentzVector* simPVPosition,
0214 bool isMatched,
0215 bool isSigMatched,
0216 bool isChargeMatched,
0217 int numAssocRecoTracks,
0218 int numVertices,
0219 int nSimHits,
0220 double sharedFraction,
0221 double dR,
0222 double dR_jet,
0223 const std::vector<float>& mvas,
0224 unsigned int selectsLoose,
0225 unsigned int selectsHP) const;
0226
0227 void fill_dedx_recoTrack_histos(const Histograms& histograms,
0228 int count,
0229 const edm::RefToBase<reco::Track>& trackref,
0230 const std::vector<const edm::ValueMap<reco::DeDxData>*>& v_dEdx) const;
0231
0232 void fill_simAssociated_recoTrack_histos(const Histograms& histograms, int count, const reco::Track& track) const;
0233
0234 void fill_trackBased_histos(const Histograms& histograms,
0235 int count,
0236 int assTracks,
0237 int numRecoTracks,
0238 int numRecoTracksSelected,
0239 int numSimTracksSelected) const;
0240
0241 void fill_ResoAndPull_recoTrack_histos(const Histograms& histograms,
0242 int count,
0243 const TrackingParticle::Vector& momentumTP,
0244 const TrackingParticle::Point& vertexTP,
0245 int chargeTP,
0246 const reco::Track& track,
0247 const math::XYZPoint& bsPosition) const;
0248
0249 void fill_seed_histos(const Histograms& histograms, int count, int seedsFitFailed, int seedsTotal) const;
0250
0251 private:
0252
0253 void getRecoMomentum(const reco::Track& track,
0254 double& pt,
0255 double& ptError,
0256 double& qoverp,
0257 double& qoverpError,
0258 double& lambda,
0259 double& lambdaError,
0260 double& phi,
0261 double& phiError) const;
0262
0263 void getRecoMomentum(const reco::GsfTrack& gsfTrack,
0264 double& pt,
0265 double& ptError,
0266 double& qoverp,
0267 double& qoverpError,
0268 double& lambda,
0269 double& lambdaError,
0270 double& phi,
0271 double& phiError) const;
0272
0273 double getEta(double eta) const;
0274
0275 double getPt(double pt) const;
0276
0277 unsigned int getSeedingLayerSetBin(const reco::Track& track, const TrackerTopology& ttopo) const;
0278
0279
0280 std::unique_ptr<TrackingParticleSelector> generalTpSelector;
0281 std::unique_ptr<TrackingParticleSelector> TpSelectorForEfficiencyVsEta;
0282 std::unique_ptr<TrackingParticleSelector> TpSelectorForEfficiencyVsPhi;
0283 std::unique_ptr<TrackingParticleSelector> TpSelectorForEfficiencyVsPt;
0284 std::unique_ptr<TrackingParticleSelector> TpSelectorForEfficiencyVsVTXR;
0285 std::unique_ptr<TrackingParticleSelector> TpSelectorForEfficiencyVsVTXZ;
0286
0287 std::unique_ptr<RecoTrackSelectorBase> trackSelectorVsEta;
0288 std::unique_ptr<RecoTrackSelectorBase> trackSelectorVsPhi;
0289 std::unique_ptr<RecoTrackSelectorBase> trackSelectorVsPt;
0290
0291 std::unique_ptr<GenParticleCustomSelector> generalGpSelector;
0292 std::unique_ptr<GenParticleCustomSelector> GpSelectorForEfficiencyVsEta;
0293 std::unique_ptr<GenParticleCustomSelector> GpSelectorForEfficiencyVsPhi;
0294 std::unique_ptr<GenParticleCustomSelector> GpSelectorForEfficiencyVsPt;
0295 std::unique_ptr<GenParticleCustomSelector> GpSelectorForEfficiencyVsVTXR;
0296 std::unique_ptr<GenParticleCustomSelector> GpSelectorForEfficiencyVsVTXZ;
0297
0298 double minEta, maxEta;
0299 int nintEta;
0300 bool useFabsEta;
0301 double minPt, maxPt;
0302 int nintPt;
0303 bool useInvPt;
0304 bool useLogPt;
0305 double minHit, maxHit;
0306 int nintHit;
0307 double minPu, maxPu;
0308 int nintPu;
0309 double minLayers, maxLayers;
0310 int nintLayers;
0311 double minPhi, maxPhi;
0312 int nintPhi;
0313 double minDxy, maxDxy;
0314 int nintDxy;
0315 double minDz, maxDz;
0316 int nintDz;
0317 double dxyDzZoom;
0318 double minVertpos, maxVertpos;
0319 int nintVertpos;
0320 bool useLogVertpos;
0321 double minZpos, maxZpos;
0322 int nintZpos;
0323 double mindr, maxdr;
0324 int nintdr;
0325 double mindrj, maxdrj;
0326 int nintdrj;
0327 double minChi2, maxChi2;
0328 int nintChi2;
0329 double minDeDx, maxDeDx;
0330 int nintDeDx;
0331 double minVertcount, maxVertcount;
0332 int nintVertcount;
0333 double minTracks, maxTracks;
0334 int nintTracks;
0335 double minPVz, maxPVz;
0336 int nintPVz;
0337 double minMVA, maxMVA;
0338 int nintMVA;
0339
0340 const bool doSeedPlots_;
0341 const bool doMTDPlots_;
0342 const bool doDzPVcutPlots_;
0343
0344
0345 double ptRes_rangeMin, ptRes_rangeMax;
0346 int ptRes_nbin;
0347 double phiRes_rangeMin, phiRes_rangeMax;
0348 int phiRes_nbin;
0349 double cotThetaRes_rangeMin, cotThetaRes_rangeMax;
0350 int cotThetaRes_nbin;
0351 double dxyRes_rangeMin, dxyRes_rangeMax;
0352 int dxyRes_nbin;
0353 double dzRes_rangeMin, dzRes_rangeMax;
0354 int dzRes_nbin;
0355
0356 double maxDzpvCum;
0357 int nintDzpvCum;
0358 double maxDzpvsigCum;
0359 int nintDzpvsigCum;
0360
0361 std::vector<std::string> seedingLayerSetNames;
0362 using SeedingLayerId =
0363 std::tuple<SeedingLayerSetsBuilder::SeedingLayerId, bool>;
0364 using SeedingLayerSetId = std::array<SeedingLayerId, 4>;
0365 std::map<SeedingLayerSetId, unsigned int> seedingLayerSetToBin;
0366 };
0367
0368 #endif