TrackToTrackComparisonHists

generalME

matchingME

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
//
// Original Author:  John Alison, Mia Tosi
//         Created:  27 July 2020
//
//

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"
#include "DataFormats/Scalers/interface/LumiScalers.h"
#include "DataFormats/OnlineMetaData/interface/OnlineLuminosityRecord.h"
#include "DQMServices/Core/interface/MonitorElement.h"
#include "DQMServices/Core/interface/DQMStore.h"
#include "DQMServices/Core/interface/DQMEDAnalyzer.h"

// system include files
#include <memory>
#include <iostream>
#include <sstream>
#include <string>

//
// class declaration
//
class DQMStore;
namespace reco {
  class Track;
  class BeamSpot;
  class Vertex;
}  // namespace reco
class DQMStore;
class GenericTriggerEventFlag;

class TrackToTrackComparisonHists : public DQMEDAnalyzer {
public:
  struct generalME {
    std::string label;
    MonitorElement *h_tracks, *h_pt, *h_eta, *h_phi, *h_dxy, *h_dz, *h_dxyWRTpv, *h_dzWRTpv, *h_charge, *h_hits;
    MonitorElement *h_dRmin, *h_dRmin_l;
    MonitorElement* h_pt_vs_eta;
    MonitorElement *h_onlinelumi, *h_PU, *h_ls;
  };

  struct matchingME {
    std::string label;
    MonitorElement *h_hits_vs_hits, *h_pt_vs_pt, *h_eta_vs_eta, *h_phi_vs_phi;
    MonitorElement *h_dPt, *h_dEta, *h_dPhi, *h_dDxy, *h_dDz, *h_dDxyWRTpv, *h_dDzWRTpv, *h_dCharge, *h_dHits;
  };

  typedef std::vector<std::pair<int, std::map<double, int>>> idx2idxByDoubleColl;

  explicit TrackToTrackComparisonHists(const edm::ParameterSet&);
  ~TrackToTrackComparisonHists() override;

  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
  static void fillHistoPSetDescription(edm::ParameterSetDescription& pset);

protected:
  void beginJob(const edm::EventSetup& iSetup);
  void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override;
  void bookHistograms(DQMStore::IBooker& iBooker, edm::Run const& iRun, edm::EventSetup const& iSetup) override;

  void fillMap(const edm::View<reco::Track>& tracks1,
               const edm::View<reco::Track>& tracks2,
               idx2idxByDoubleColl& map,
               float dRMin);

  void initialize_parameter(const edm::ParameterSet& iConfig);
  void bookHistos(DQMStore::IBooker& ibooker, generalME& mes, TString label, std::string& dir);
  void book_generic_tracks_histos(DQMStore::IBooker& ibooker, generalME& mes, TString label, std::string& dir);
  void book_matching_tracks_histos(DQMStore::IBooker& ibooker, matchingME& mes, TString label, std::string& dir);

  void fill_generic_tracks_histos(generalME& mes,
                                  reco::Track* trk,
                                  reco::BeamSpot* bs,
                                  reco::Vertex* pv,
                                  unsigned int ls,
                                  double onlinelumi,
                                  double PU,
                                  bool requirePlateau = true);
  void fill_matching_tracks_histos(
      matchingME& mes, reco::Track* mon, reco::Track* ref, reco::BeamSpot* bs, reco::Vertex* pv);

  DQMStore* dqmStore_;

  edm::InputTag monitoredTrackInputTag_;
  edm::InputTag referenceTrackInputTag_;

  //these are used by MTVGenPs
  edm::EDGetTokenT<edm::View<reco::Track>> monitoredTrackToken_;
  edm::EDGetTokenT<edm::View<reco::Track>> referenceTrackToken_;
  edm::EDGetTokenT<reco::BeamSpot> monitoredBSToken_;
  edm::EDGetTokenT<reco::BeamSpot> referenceBSToken_;
  edm::EDGetTokenT<reco::VertexCollection> monitoredPVToken_;
  edm::EDGetTokenT<reco::VertexCollection> referencePVToken_;
  edm::EDGetTokenT<LumiScalersCollection> lumiScalersToken_;
  edm::EDGetTokenT<OnlineLuminosityRecord> onlineMetaDataDigisToken_;

private:
  //  edm::ParameterSet conf_;
  const bool isCosmics_;
  std::string topDirName_;
  double dRmin_;
  double pTCutForPlateau_;
  double dxyCutForPlateau_;
  double dzWRTPvCut_;
  bool requireValidHLTPaths_;
  bool hltPathsAreValid_ = false;
  std::unique_ptr<GenericTriggerEventFlag> genTriggerEventFlag_;

  // reference tracks All and matched
  generalME referenceTracksMEs_;
  generalME matchedReferenceTracksMEs_;

  // monitored tracks All and unmatched
  generalME monitoredTracksMEs_;
  generalME unMatchedMonitoredTracksMEs_;

  // Track matching statistics
  matchingME matchTracksMEs_;

  double Eta_rangeMin, Eta_rangeMax;
  unsigned int Eta_nbin;
  double Pt_rangeMin, Pt_rangeMax;
  unsigned int Pt_nbin;  //bool useInvPt;   bool useLogPt;
  double Phi_rangeMin, Phi_rangeMax;
  unsigned int Phi_nbin;
  double Dxy_rangeMin, Dxy_rangeMax;
  unsigned int Dxy_nbin;
  double Dz_rangeMin, Dz_rangeMax;
  unsigned int Dz_nbin;

  double ptRes_rangeMin, ptRes_rangeMax;
  unsigned int ptRes_nbin;
  double phiRes_rangeMin, phiRes_rangeMax;
  unsigned int phiRes_nbin;
  double etaRes_rangeMin, etaRes_rangeMax;
  unsigned int etaRes_nbin;
  double dxyRes_rangeMin, dxyRes_rangeMax;
  unsigned int dxyRes_nbin;
  double dzRes_rangeMin, dzRes_rangeMax;
  unsigned int dzRes_nbin;
  unsigned int ls_rangeMin, ls_rangeMax;
  unsigned int ls_nbin;
  double PU_rangeMin, PU_rangeMax;
  unsigned int PU_nbin;
  double onlinelumi_rangeMin, onlinelumi_rangeMax;
  unsigned int onlinelumi_nbin;
};