Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef TkConvValidator_H
0002 #define TkConvValidator_H
0003 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0004 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0005 #include "Geometry/CaloTopology/interface/CaloTopology.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "FWCore/Framework/interface/Event.h"
0008 #include "FWCore/Framework/interface/EventSetup.h"
0009 #include "FWCore/Framework/interface/ESHandle.h"
0010 #include "RecoEgamma/EgammaMCTools/interface/PhotonMCTruthFinder.h"
0011 #include "SimDataFormats/Associations/interface/TrackToTrackingParticleAssociator.h"
0012 #include "MagneticField/Engine/interface/MagneticField.h"
0013 #include "DataFormats/Common/interface/RefToBaseVector.h"
0014 #include "DataFormats/Common/interface/RefVector.h"
0015 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0016 #include "DataFormats/VertexReco/interface/Vertex.h"
0017 #include "DataFormats/EgammaCandidates/interface/ConversionFwd.h"
0018 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
0019 #include "DataFormats/JetReco/interface/GenJetCollection.h"
0020 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticleFwd.h"
0021 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0022 #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
0023 #include "TrackingTools/Records/interface/TransientTrackRecord.h"
0024 
0025 //
0026 //DQM services
0027 #include "DQMServices/Core/interface/DQMStore.h"
0028 #include "FWCore/ServiceRegistry/interface/Service.h"
0029 #include "DQMServices/Core/interface/DQMOneEDAnalyzer.h"
0030 
0031 //
0032 #include <map>
0033 #include <vector>
0034 
0035 // forward declarations
0036 class TFile;
0037 class TH1F;
0038 class TH2F;
0039 class TProfile;
0040 class TTree;
0041 class SimVertex;
0042 class SimTrack;
0043 /** \class TkConvValidator
0044  **
0045  **
0046  **  $Id: TkConvValidator
0047  **  \author N.Marinelli - Univ. of Notre Dame
0048  **
0049  ***/
0050 
0051 class TkConvValidator : public DQMOneEDAnalyzer<> {
0052 public:
0053   //
0054   explicit TkConvValidator(const edm::ParameterSet&);
0055   ~TkConvValidator() override;
0056 
0057   void analyze(const edm::Event&, const edm::EventSetup&) override;
0058   void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
0059   void dqmBeginRun(edm::Run const& r, edm::EventSetup const& theEventSetup) override;
0060   void dqmEndRun(edm::Run const& r, edm::EventSetup const& es) override;
0061   void endJob() override;
0062 
0063 private:
0064   //
0065 
0066   float phiNormalization(float& a);
0067   float etaTransformation(float a, float b);
0068   math::XYZVector recalculateMomentumAtFittedVertex(const MagneticField& mf,
0069                                                     const TrackerGeometry& trackerGeom,
0070                                                     const edm::RefToBase<reco::Track>& tk,
0071                                                     const reco::Vertex& vtx);
0072 
0073   std::string fName_;
0074   DQMStore* dbe_;
0075   edm::ESHandle<MagneticField> theMF_;
0076 
0077   int verbosity_;
0078   int nEvt_;
0079   int nEntry_;
0080   int nSimConv_[2];
0081   int nMatched_;
0082   int nRecConv_;
0083   int nRecConvAss_;
0084   int nRecConvAssWithEcal_;
0085 
0086   int nInvalidPCA_;
0087 
0088   edm::ParameterSet parameters_;
0089   edm::ESHandle<CaloGeometry> theCaloGeom_;
0090   edm::ESHandle<CaloTopology> theCaloTopo_;
0091 
0092   std::string conversionCollectionProducer_;
0093   std::string conversionCollection_;
0094   edm::EDGetTokenT<reco::ConversionCollection> conversionCollectionPr_Token_;
0095 
0096   std::string conversionTrackProducer_;
0097 
0098   std::string photonCollectionProducer_;
0099   std::string photonCollection_;
0100   edm::EDGetTokenT<reco::PhotonCollection> photonCollectionPr_Token_;
0101 
0102   edm::EDGetTokenT<reco::VertexCollection> offline_pvToken_;
0103   edm::EDGetTokenT<reco::BeamSpot> beamspotToken_;
0104   edm::EDGetTokenT<edm::SimTrackContainer> g4_simTk_Token_;
0105   edm::EDGetTokenT<edm::SimVertexContainer> g4_simVtx_Token_;
0106   edm::EDGetTokenT<TrackingParticleRefVector> tpSelForEff_Token_;
0107   edm::EDGetTokenT<TrackingParticleRefVector> tpSelForFake_Token_;
0108   edm::EDGetTokenT<edm::HepMCProduct> hepMC_Token_;
0109   edm::EDGetTokenT<reco::GenJetCollection> genjets_Token_;
0110   edm::EDGetTokenT<reco::TrackToTrackingParticleAssociator> trackAssociator_Token_;
0111 
0112   const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magneticFieldToken_;
0113   const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeometryToken_;
0114   const edm::ESGetToken<TransientTrackBuilder, TransientTrackRecord> transientTrackBuilderToken_;
0115   const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> trackerGeometryToken_;
0116 
0117   std::string dqmpath_;
0118 
0119   edm::InputTag label_tp_;
0120 
0121   PhotonMCTruthFinder* thePhotonMCTruthFinder_;
0122 
0123   bool isRunCentrally_;
0124 
0125   double minPhoEtCut_;
0126   double trkIsolExtRadius_;
0127   double trkIsolInnRadius_;
0128   double trkPtLow_;
0129   double lip_;
0130   double ecalIsolRadius_;
0131   double bcEtLow_;
0132   double hcalIsolExtRadius_;
0133   double hcalIsolInnRadius_;
0134   double hcalHitEtLow_;
0135   int numOfTracksInCone_;
0136   double trkPtSumCut_;
0137   double ecalEtSumCut_;
0138   double hcalEtSumCut_;
0139   bool dCotCutOn_;
0140   double dCotCutValue_;
0141   double dCotHardCutValue_;
0142   bool generalTracksOnly_;
0143   bool arbitratedMerged_;
0144   bool arbitratedEcalSeeded_;
0145   bool ecalalgotracks_;
0146   bool highPurity_;
0147   double minProb_;
0148   uint maxHitsBeforeVtx_;
0149   double minLxy_;
0150 
0151   /// global variable for the MC photon
0152   double mcPhi_;
0153   double mcEta_;
0154   double mcConvPt_;
0155   double mcConvR_;
0156   double mcConvZ_;
0157   double mcConvY_;
0158   double mcConvX_;
0159   double mcConvPhi_;
0160   double mcConvEta_;
0161   double mcJetEta_;
0162   double mcJetPhi_;
0163 
0164   edm::RefVector<TrackingParticleCollection> theConvTP_;
0165   //std::vector<TrackingParticleRef>    theConvTP_;
0166 
0167   double minPhoPtForEffic;
0168   double maxPhoEtaForEffic;
0169   double maxPhoZForEffic;
0170   double maxPhoRForEffic;
0171   double minPhoPtForPurity;
0172   double maxPhoEtaForPurity;
0173   double maxPhoZForPurity;
0174   double maxPhoRForPurity;
0175 
0176   double simMinPt_;
0177   double simMaxPt_;
0178 
0179   /// Global variables for reco Photon
0180   double recMinPt_;
0181   double recMaxPt_;
0182 
0183   //
0184   //
0185   MonitorElement* h_nSimConv_[2];
0186   MonitorElement* h_SimConvEtaPix_[2];
0187   //
0188   MonitorElement* h_simTkPt_;
0189   MonitorElement* h_simTkEta_;
0190 
0191   MonitorElement* h_simConvVtxRvsZ_[4];
0192   MonitorElement* h_simConvVtxYvsX_;
0193 
0194   ///   Denominator for efficiencies
0195   MonitorElement* h_AllSimConv_[5];
0196   MonitorElement* h_VisSimConv_[6];
0197   MonitorElement* h_VisSimConvLarge_;
0198   ///   Numerator for efficiencies
0199   MonitorElement* h_SimConvOneTracks_[5];
0200   MonitorElement* h_SimConvOneMTracks_[5];
0201   MonitorElement* h_SimConvTwoTracks_[5];
0202   MonitorElement* h_SimConvTwoMTracks_[5];
0203   MonitorElement* h_SimConvTwoMTracksAndVtxPGT0_[5];
0204   MonitorElement* h_SimConvTwoMTracksAndVtxPGT0005_[5];
0205   MonitorElement* h_SimConvTwoMTracksAndVtxPGT01_[5];
0206   // Numerator for double-counting quantification
0207   MonitorElement* h_SimRecConvOneTracks_[5];
0208   MonitorElement* h_SimRecConvOneMTracks_[5];
0209   MonitorElement* h_SimRecConvTwoTracks_[5];
0210   MonitorElement* h_SimRecConvTwoMTracks_[5];
0211 
0212   // Denominators for conversion fake rate
0213   MonitorElement* h_RecoConvTwoTracks_[5];
0214   // Numerators for conversion fake rate
0215   MonitorElement* h_RecoConvTwoMTracks_[5];
0216 
0217   /// info per conversion
0218   MonitorElement* h_nConv_[3][3];
0219   MonitorElement* h_convEtaMatchSC_[3][3];
0220   MonitorElement* h_convEta_[3][3];
0221   MonitorElement* h_convEta2_[3][3];
0222   MonitorElement* h_convPhi_[3][3];
0223   MonitorElement* h_convR_[3][3];
0224   MonitorElement* h_convZ_[3][3];
0225   MonitorElement* h_convPt_[3][3];
0226   MonitorElement* h_EoverPTracks_[3][3];
0227 
0228   MonitorElement* h_convSCdEta_[3][3];
0229   MonitorElement* h_convSCdPhi_[3][3];
0230 
0231   MonitorElement* h_convRplot_;
0232   MonitorElement* h_convZplot_;
0233 
0234   MonitorElement* h_convPtRes_[3];
0235 
0236   MonitorElement* h_invMass_[3][3];
0237 
0238   MonitorElement* h_DPhiTracksAtVtx_[3][3];
0239   MonitorElement* h2_DPhiTracksAtVtxVsEta_;
0240   MonitorElement* p_DPhiTracksAtVtxVsEta_;
0241   MonitorElement* h2_DPhiTracksAtVtxVsR_;
0242   MonitorElement* p_DPhiTracksAtVtxVsR_;
0243 
0244   MonitorElement* h_DCotTracks_[3][3];
0245   MonitorElement* h2_DCotTracksVsEta_;
0246   MonitorElement* p_DCotTracksVsEta_;
0247   MonitorElement* h2_DCotTracksVsR_;
0248   MonitorElement* p_DCotTracksVsR_;
0249 
0250   MonitorElement* h_distMinAppTracks_[3][3];
0251 
0252   MonitorElement* h_DPhiTracksAtEcal_[3][3];
0253   MonitorElement* h2_DPhiTracksAtEcalVsR_;
0254   MonitorElement* p_DPhiTracksAtEcalVsR_;
0255   MonitorElement* h2_DPhiTracksAtEcalVsEta_;
0256   MonitorElement* p_DPhiTracksAtEcalVsEta_;
0257 
0258   MonitorElement* h_DEtaTracksAtEcal_[3][3];
0259 
0260   MonitorElement* h_convVtxRvsZ_[3];
0261   MonitorElement* h_convVtxYvsX_;
0262   MonitorElement* h_convVtxRvsZ_zoom_[2];
0263   MonitorElement* h_convVtxYvsX_zoom_[2];
0264 
0265   MonitorElement* h_convVtxdX_;
0266   MonitorElement* h_convVtxdY_;
0267   MonitorElement* h_convVtxdZ_;
0268   MonitorElement* h_convVtxdR_;
0269   MonitorElement* h_convVtxdEta_;
0270   MonitorElement* h_convVtxdPhi_;
0271 
0272   MonitorElement* h_convVtxdX_barrel_;
0273   MonitorElement* h_convVtxdY_barrel_;
0274   MonitorElement* h_convVtxdZ_barrel_;
0275   MonitorElement* h_convVtxdR_barrel_;
0276 
0277   MonitorElement* h_convVtxdX_endcap_;
0278   MonitorElement* h_convVtxdY_endcap_;
0279   MonitorElement* h_convVtxdZ_endcap_;
0280   MonitorElement* h_convVtxdR_endcap_;
0281 
0282   MonitorElement* h2_convVtxdRVsR_;
0283   MonitorElement* h2_convVtxdRVsEta_;
0284 
0285   MonitorElement* p_convVtxdRVsR_;
0286   MonitorElement* p_convVtxdRVsEta_;
0287 
0288   MonitorElement* p_convVtxdXVsX_;
0289   MonitorElement* p_convVtxdYVsY_;
0290   MonitorElement* p_convVtxdZVsZ_;
0291   MonitorElement* p_convVtxdZVsR_;
0292 
0293   MonitorElement* p2_convVtxdRVsRZ_;
0294   MonitorElement* p2_convVtxdZVsRZ_;
0295 
0296   MonitorElement* h2_convVtxRrecVsTrue_;
0297 
0298   MonitorElement* h_vtxChi2Prob_[3][3];
0299 
0300   MonitorElement* h_zPVFromTracks_[2];
0301   MonitorElement* h_dzPVFromTracks_[2];
0302   MonitorElement* h2_dzPVVsR_;
0303   MonitorElement* p_dzPVVsR_;
0304 
0305   MonitorElement* h_lxybs_[3][3];
0306   MonitorElement* h_maxNHitsBeforeVtx_[3][3];
0307   MonitorElement* h_leadNHitsBeforeVtx_[3][3];
0308   MonitorElement* h_trailNHitsBeforeVtx_[3][3];
0309   MonitorElement* h_sumNHitsBeforeVtx_[3][3];
0310   MonitorElement* h_deltaExpectedHitsInner_[3][3];
0311   MonitorElement* h_leadExpectedHitsInner_[3][3];
0312   MonitorElement* h_maxDlClosestHitToVtx_[3][3];
0313   MonitorElement* h_maxDlClosestHitToVtxSig_[3][3];
0314   MonitorElement* h_nSharedHits_[3][3];
0315 
0316   //////////// info per track
0317   MonitorElement* nHits_[3];
0318   MonitorElement* p_nHitsVsEta_[3];
0319   MonitorElement* nHitsVsEta_[3];
0320   MonitorElement* p_nHitsVsR_[3];
0321   MonitorElement* nHitsVsR_[3];
0322   MonitorElement* h_tkChi2_[3];
0323   MonitorElement* h_tkChi2Large_[3];
0324   MonitorElement* h2_Chi2VsEta_[3];
0325   MonitorElement* p_Chi2VsEta_[3];
0326   MonitorElement* h2_Chi2VsR_[3];
0327   MonitorElement* p_Chi2VsR_[3];
0328 
0329   MonitorElement* h_TkD0_[3];
0330 
0331   MonitorElement* h_TkPtPull_[3];
0332   MonitorElement* h2_TkPtPull_[3];
0333   MonitorElement* p_TkPtPull_[3];
0334   MonitorElement* h2_PtRecVsPtSim_[3];
0335   MonitorElement* h2_photonPtRecVsPtSim_;
0336 
0337   MonitorElement* h_match_;
0338 
0339   MonitorElement* p2_effRZ_;
0340 
0341   MonitorElement* h_nHitsBeforeVtx_[3];
0342   MonitorElement* h_dlClosestHitToVtx_[3];
0343   MonitorElement* h_dlClosestHitToVtxSig_[3];
0344 };
0345 
0346 #endif