Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-10 02:20:38

0001 //
0002 // Original Author:  John Alison, Mia Tosi
0003 //         Created:  27 July 2020
0004 //
0005 //
0006 
0007 // user include files
0008 #include "FWCore/Framework/interface/Frameworkfwd.h"
0009 #include "FWCore/Framework/interface/Event.h"
0010 #include "FWCore/Framework/interface/MakerMacros.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 #include "FWCore/Utilities/interface/EDGetToken.h"
0013 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0014 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0015 #include "DataFormats/Scalers/interface/LumiScalers.h"
0016 #include "DataFormats/OnlineMetaData/interface/OnlineLuminosityRecord.h"
0017 #include "DQMServices/Core/interface/MonitorElement.h"
0018 #include "DQMServices/Core/interface/DQMStore.h"
0019 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0020 
0021 // system include files
0022 #include <memory>
0023 #include <iostream>
0024 #include <sstream>
0025 #include <string>
0026 
0027 //
0028 // class declaration
0029 //
0030 class DQMStore;
0031 namespace reco {
0032   class Track;
0033   class BeamSpot;
0034   class Vertex;
0035 }  // namespace reco
0036 class DQMStore;
0037 class GenericTriggerEventFlag;
0038 
0039 class TrackToTrackComparisonHists : public DQMEDAnalyzer {
0040 public:
0041   struct generalME {
0042     std::string label;
0043     MonitorElement *h_tracks, *h_pt, *h_eta, *h_phi, *h_dxy, *h_dz, *h_dxyWRTpv, *h_dzWRTpv, *h_charge, *h_hits;
0044     MonitorElement *h_dRmin, *h_dRmin_l;
0045     MonitorElement* h_pt_vs_eta;
0046     MonitorElement *h_onlinelumi, *h_PU, *h_ls;
0047   };
0048 
0049   struct matchingME {
0050     std::string label;
0051     MonitorElement *h_hits_vs_hits, *h_pt_vs_pt, *h_eta_vs_eta, *h_phi_vs_phi;
0052     MonitorElement *h_dPt, *h_dEta, *h_dPhi, *h_dDxy, *h_dDz, *h_dDxyWRTpv, *h_dDzWRTpv, *h_dCharge, *h_dHits;
0053   };
0054 
0055   typedef std::vector<std::pair<int, std::map<double, int>>> idx2idxByDoubleColl;
0056 
0057   explicit TrackToTrackComparisonHists(const edm::ParameterSet&);
0058   ~TrackToTrackComparisonHists() override;
0059 
0060   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0061   static void fillHistoPSetDescription(edm::ParameterSetDescription& pset);
0062 
0063 protected:
0064   void beginJob(const edm::EventSetup& iSetup);
0065   void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override;
0066   void bookHistograms(DQMStore::IBooker& iBooker, edm::Run const& iRun, edm::EventSetup const& iSetup) override;
0067 
0068   void fillMap(const edm::View<reco::Track>& tracks1,
0069                const edm::View<reco::Track>& tracks2,
0070                idx2idxByDoubleColl& map,
0071                float dRMin);
0072 
0073   void initialize_parameter(const edm::ParameterSet& iConfig);
0074   void bookHistos(DQMStore::IBooker& ibooker, generalME& mes, TString label, std::string& dir);
0075   void book_generic_tracks_histos(DQMStore::IBooker& ibooker, generalME& mes, TString label, std::string& dir);
0076   void book_matching_tracks_histos(DQMStore::IBooker& ibooker, matchingME& mes, TString label, std::string& dir);
0077 
0078   void fill_generic_tracks_histos(generalME& mes,
0079                                   reco::Track* trk,
0080                                   reco::BeamSpot* bs,
0081                                   reco::Vertex* pv,
0082                                   unsigned int ls,
0083                                   double onlinelumi,
0084                                   double PU,
0085                                   bool requirePlateau = true);
0086   void fill_matching_tracks_histos(
0087       matchingME& mes, reco::Track* mon, reco::Track* ref, reco::BeamSpot* bs, reco::Vertex* pv);
0088 
0089   DQMStore* dqmStore_;
0090 
0091   edm::InputTag monitoredTrackInputTag_;
0092   edm::InputTag referenceTrackInputTag_;
0093 
0094   //these are used by MTVGenPs
0095   edm::EDGetTokenT<edm::View<reco::Track>> monitoredTrackToken_;
0096   edm::EDGetTokenT<edm::View<reco::Track>> referenceTrackToken_;
0097   edm::EDGetTokenT<reco::BeamSpot> monitoredBSToken_;
0098   edm::EDGetTokenT<reco::BeamSpot> referenceBSToken_;
0099   edm::EDGetTokenT<reco::VertexCollection> monitoredPVToken_;
0100   edm::EDGetTokenT<reco::VertexCollection> referencePVToken_;
0101   edm::EDGetTokenT<LumiScalersCollection> lumiScalersToken_;
0102   edm::EDGetTokenT<OnlineLuminosityRecord> onlineMetaDataDigisToken_;
0103 
0104 private:
0105   //  edm::ParameterSet conf_;
0106   std::string topDirName_;
0107   double dRmin_;
0108   double pTCutForPlateau_;
0109   double dxyCutForPlateau_;
0110   double dzWRTPvCut_;
0111   bool requireValidHLTPaths_;
0112   bool hltPathsAreValid_ = false;
0113   std::unique_ptr<GenericTriggerEventFlag> genTriggerEventFlag_;
0114 
0115   // reference tracks All and matched
0116   generalME referenceTracksMEs_;
0117   generalME matchedReferenceTracksMEs_;
0118 
0119   // monitored tracks All and unmatched
0120   generalME monitoredTracksMEs_;
0121   generalME unMatchedMonitoredTracksMEs_;
0122 
0123   // Track matching statistics
0124   matchingME matchTracksMEs_;
0125 
0126   double Eta_rangeMin, Eta_rangeMax;
0127   unsigned int Eta_nbin;
0128   double Pt_rangeMin, Pt_rangeMax;
0129   unsigned int Pt_nbin;  //bool useInvPt;   bool useLogPt;
0130   double Phi_rangeMin, Phi_rangeMax;
0131   unsigned int Phi_nbin;
0132   double Dxy_rangeMin, Dxy_rangeMax;
0133   unsigned int Dxy_nbin;
0134   double Dz_rangeMin, Dz_rangeMax;
0135   unsigned int Dz_nbin;
0136 
0137   double ptRes_rangeMin, ptRes_rangeMax;
0138   unsigned int ptRes_nbin;
0139   double phiRes_rangeMin, phiRes_rangeMax;
0140   unsigned int phiRes_nbin;
0141   double etaRes_rangeMin, etaRes_rangeMax;
0142   unsigned int etaRes_nbin;
0143   double dxyRes_rangeMin, dxyRes_rangeMax;
0144   unsigned int dxyRes_nbin;
0145   double dzRes_rangeMin, dzRes_rangeMax;
0146   unsigned int dzRes_nbin;
0147   unsigned int ls_rangeMin, ls_rangeMax;
0148   unsigned int ls_nbin;
0149   double PU_rangeMin, PU_rangeMax;
0150   unsigned int PU_nbin;
0151   double onlinelumi_rangeMin, onlinelumi_rangeMax;
0152   unsigned int onlinelumi_nbin;
0153 };