Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:43:54

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(reco::TrackCollection tracks1, reco::TrackCollection tracks2, idx2idxByDoubleColl& map, float dRMin);
0069 
0070   void initialize_parameter(const edm::ParameterSet& iConfig);
0071   void bookHistos(DQMStore::IBooker& ibooker, generalME& mes, TString label, std::string& dir);
0072   void book_generic_tracks_histos(DQMStore::IBooker& ibooker, generalME& mes, TString label, std::string& dir);
0073   void book_matching_tracks_histos(DQMStore::IBooker& ibooker, matchingME& mes, TString label, std::string& dir);
0074 
0075   void fill_generic_tracks_histos(generalME& mes,
0076                                   reco::Track* trk,
0077                                   reco::BeamSpot* bs,
0078                                   reco::Vertex* pv,
0079                                   unsigned int ls,
0080                                   double onlinelumi,
0081                                   double PU,
0082                                   bool requirePlateau = true);
0083   void fill_matching_tracks_histos(
0084       matchingME& mes, reco::Track* mon, reco::Track* ref, reco::BeamSpot* bs, reco::Vertex* pv);
0085 
0086   DQMStore* dqmStore_;
0087 
0088   edm::InputTag monitoredTrackInputTag_;
0089   edm::InputTag referenceTrackInputTag_;
0090 
0091   //these are used by MTVGenPs
0092   edm::EDGetTokenT<reco::TrackCollection> monitoredTrackToken_;
0093   edm::EDGetTokenT<reco::TrackCollection> referenceTrackToken_;
0094   edm::EDGetTokenT<reco::BeamSpot> monitoredBSToken_;
0095   edm::EDGetTokenT<reco::BeamSpot> referenceBSToken_;
0096   edm::EDGetTokenT<reco::VertexCollection> monitoredPVToken_;
0097   edm::EDGetTokenT<reco::VertexCollection> referencePVToken_;
0098   edm::EDGetTokenT<LumiScalersCollection> lumiScalersToken_;
0099   edm::EDGetTokenT<OnlineLuminosityRecord> onlineMetaDataDigisToken_;
0100 
0101 private:
0102   //  edm::ParameterSet conf_;
0103   std::string topDirName_;
0104   double dRmin_;
0105   double pTCutForPlateau_;
0106   double dxyCutForPlateau_;
0107   double dzWRTPvCut_;
0108   bool requireValidHLTPaths_;
0109   bool hltPathsAreValid_ = false;
0110   std::unique_ptr<GenericTriggerEventFlag> genTriggerEventFlag_;
0111 
0112   // reference tracks All and matched
0113   generalME referenceTracksMEs_;
0114   generalME matchedReferenceTracksMEs_;
0115 
0116   // monitored tracks All and unmatched
0117   generalME monitoredTracksMEs_;
0118   generalME unMatchedMonitoredTracksMEs_;
0119 
0120   // Track matching statistics
0121   matchingME matchTracksMEs_;
0122 
0123   double Eta_rangeMin, Eta_rangeMax;
0124   unsigned int Eta_nbin;
0125   double Pt_rangeMin, Pt_rangeMax;
0126   unsigned int Pt_nbin;  //bool useInvPt;   bool useLogPt;
0127   double Phi_rangeMin, Phi_rangeMax;
0128   unsigned int Phi_nbin;
0129   double Dxy_rangeMin, Dxy_rangeMax;
0130   unsigned int Dxy_nbin;
0131   double Dz_rangeMin, Dz_rangeMax;
0132   unsigned int Dz_nbin;
0133 
0134   double ptRes_rangeMin, ptRes_rangeMax;
0135   unsigned int ptRes_nbin;
0136   double phiRes_rangeMin, phiRes_rangeMax;
0137   unsigned int phiRes_nbin;
0138   double etaRes_rangeMin, etaRes_rangeMax;
0139   unsigned int etaRes_nbin;
0140   double dxyRes_rangeMin, dxyRes_rangeMax;
0141   unsigned int dxyRes_nbin;
0142   double dzRes_rangeMin, dzRes_rangeMax;
0143   unsigned int dzRes_nbin;
0144   unsigned int ls_rangeMin, ls_rangeMax;
0145   unsigned int ls_nbin;
0146   double PU_rangeMin, PU_rangeMax;
0147   unsigned int PU_nbin;
0148   double onlinelumi_rangeMin, onlinelumi_rangeMax;
0149   unsigned int onlinelumi_nbin;
0150 };