CMS 3D CMS Logo

MuonTrackValidator.h
Go to the documentation of this file.
1 #ifndef MuonTrackValidator_h
2 #define MuonTrackValidator_h
3 
12 
17 
19  public:
22  dirName_ = pset.getParameter<std::string>("dirName");
23  associatormap = pset.getParameter< edm::InputTag >("associatormap");
24  UseAssociators = pset.getParameter< bool >("UseAssociators");
25  useGEMs_ = pset.getParameter< bool >("useGEMs");
26  useME0_ = pset.getParameter< bool >("useME0");
27  tpSelector = TrackingParticleSelector(pset.getParameter<double>("ptMinTP"),
28  pset.getParameter<double>("ptMaxTP"),
29  pset.getParameter<double>("minRapidityTP"),
30  pset.getParameter<double>("maxRapidityTP"),
31  pset.getParameter<double>("tipTP"),
32  pset.getParameter<double>("lipTP"),
33  pset.getParameter<int>("minHitTP"),
34  pset.getParameter<bool>("signalOnlyTP"),
35  pset.getParameter<bool>("intimeOnlyTP"),
36  pset.getParameter<bool>("chargedOnlyTP"),
37  pset.getParameter<bool>("stableOnlyTP"),
38  pset.getParameter<std::vector<int> >("pdgIdTP"));
40  pset.getParameter<double>("minRapidityTP"),
41  pset.getParameter<double>("maxRapidityTP"),
42  pset.getParameter<double>("tipTP"),
43  pset.getParameter<double>("lipTP"),
44  pset.getParameter<int>("minHitTP"),
45  pset.getParameter<bool>("chargedOnlyTP"),
46  pset.getParameter<std::vector<int> >("pdgIdTP"));
47 
48  minPhi = pset.getParameter<double>("minPhi");
49  maxPhi = pset.getParameter<double>("maxPhi");
50  nintPhi = pset.getParameter<int>("nintPhi");
51  useGsf = pset.getParameter<bool>("useGsf");
52  BiDirectional_RecoToSim_association = pset.getParameter<bool>("BiDirectional_RecoToSim_association");
53 
54  // dump cfg parameters
55  edm::LogVerbatim("MuonTrackValidator") << "constructing MuonTrackValidator: " << pset.dump();
56 
57  // Declare consumes (also for the base class)
58  bsSrc_Token = consumes<reco::BeamSpot>(bsSrc);
59  tp_effic_Token = consumes<TrackingParticleCollection>(label_tp_effic);
60  tp_fake_Token = consumes<TrackingParticleCollection>(label_tp_fake);
61  for (unsigned int www=0;www<label.size();www++){
63  }
64  simToRecoCollection_Token = consumes<reco::SimToRecoCollection>(associatormap);
65  recoToSimCollection_Token = consumes<reco::RecoToSimCollection>(associatormap);
66 
67  _simHitTpMapTag = mayConsume<SimHitTPAssociationProducer::SimHitTPAssociationList>(pset.getParameter<edm::InputTag>("simHitTpMapTag"));
68 
69  MABH = false;
70  if (!UseAssociators) {
71  // flag MuonAssociatorByHits
72  if (associators[0] == "MuonAssociationByHits") MABH = true;
73  // reset string associators to the map label
74  associators.clear();
75  associators.push_back(associatormap.label());
76  edm::LogVerbatim("MuonTrackValidator") << "--> associators reset to: " <<associators[0];
77  } else {
78  for (auto const& associator :associators) {
79  consumes<reco::TrackToTrackingParticleAssociator>(edm::InputTag(associator));
80  }
81  }
82 
83  // inform on which SimHits will be counted
84  if (usetracker) edm::LogVerbatim("MuonTrackValidator")
85  <<"\n usetracker = TRUE : Tracker SimHits WILL be counted";
86  else edm::LogVerbatim("MuonTrackValidator")
87  <<"\n usetracker = FALSE : Tracker SimHits WILL NOT be counted";
88  if (usemuon) edm::LogVerbatim("MuonTrackValidator")
89  <<" usemuon = TRUE : Muon SimHits WILL be counted";
90  else edm::LogVerbatim("MuonTrackValidator")
91  <<" usemuon = FALSE : Muon SimHits WILL NOT be counted"<<std::endl;
92 
93  // loop over the reco::Track collections to validate: check for inconsistent input settings
94  for (unsigned int www=0;www<label.size();www++) {
95  std::string recoTracksLabel = label[www].label();
96  std::string recoTracksInstance = label[www].instance();
97 
98  // tracks with hits only on tracker
99  if (recoTracksLabel=="generalTracks" ||
100  (recoTracksLabel.find("cutsRecoTracks") != std::string::npos) ||
101  recoTracksLabel=="ctfWithMaterialTracksP5LHCNavigation" ||
102  recoTracksLabel=="hltL3TkTracksFromL2" ||
103  (recoTracksLabel=="hltL3Muons" && recoTracksInstance=="L2Seeded"))
104  {
105  if (usemuon) {
106  edm::LogWarning("MuonTrackValidator")
107  <<"\n*** WARNING : inconsistent input tracksTag = "<<label[www]
108  <<"\n with usemuon == true"<<"\n ---> please change to usemuon == false ";
109  }
110  if (!usetracker) {
111  edm::LogWarning("MuonTrackValidator")
112  <<"\n*** WARNING : inconsistent input tracksTag = "<<label[www]
113  <<"\n with usetracker == false"<<"\n ---> please change to usetracker == true ";
114  }
115  }
116 
117  // tracks with hits only on muon detectors
118  else if (recoTracksLabel=="standAloneMuons" ||
119  recoTracksLabel=="standAloneSETMuons" ||
120  recoTracksLabel=="cosmicMuons" ||
121  recoTracksLabel=="hltL2Muons")
122  {
123  if (usetracker) {
124  edm::LogWarning("MuonTrackValidator")
125  <<"\n*** WARNING : inconsistent input tracksTag = "<<label[www]
126  <<"\n with usetracker == true"<<"\n ---> please change to usetracker == false ";
127  }
128  if (!usemuon) {
129  edm::LogWarning("MuonTrackValidator")
130  <<"\n*** WARNING : inconsistent input tracksTag = "<<label[www]
131  <<"\n with usemuon == false"<<"\n ---> please change to usemuon == true ";
132  }
133  }
134 
135  } // for (unsigned int www=0;www<label.size();www++)
136  }
137 
139  ~MuonTrackValidator() override{ }
140 
142  // void beginRun(edm::Run const&, edm::EventSetup const&);
144  void analyze(const edm::Event&, const edm::EventSetup& ) override;
146  void endRun(edm::Run const&, edm::EventSetup const&) override;
147  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
148 
149 private:
151  void getRecoMomentum (const reco::Track& track, double& pt, double& ptError,
152  double& qoverp, double& qoverpError, double& lambda, double& lambdaError,
153  double& phi, double& phiError ) const;
155  void getRecoMomentum (const reco::GsfTrack& gsfTrack, double& pt, double& ptError,
156  double& qoverp, double& qoverpError, double& lambda, double& lambdaError,
157  double& phi, double& phiError) const;
158 
159  private:
165 
167  bool useGEMs_;
168  bool useME0_;
169  double minPhi, maxPhi;
170  int nintPhi;
171  bool useGsf;
172  // select tracking particles
173  //(i.e. "denominator" of the efficiency ratio)
176 
177  // flag new validation logic (bidirectional RecoToSim association)
179  // flag MuonAssociatorByHits
180  bool MABH;
181 
182  //1D
183  std::vector<MonitorElement*> h_nchi2, h_nchi2_prob, h_losthits;
184 
185  //2D
186  std::vector<MonitorElement*> chi2_vs_nhits, etares_vs_eta;
187  std::vector<MonitorElement*> h_ptshifteta;
188  std::vector<MonitorElement*> ptres_vs_phi, chi2_vs_phi, nhits_vs_phi, phires_vs_phi;
189 
190  //Profile2D
191  std::vector<MonitorElement*> ptmean_vs_eta_phi, phimean_vs_eta_phi;
192 
193  //assoc chi2
194  std::vector<MonitorElement*> h_assochi2, h_assochi2_prob;
195 
196  //chi2 and # lost hits vs eta: to be used with doProfileX
197  std::vector<MonitorElement*> chi2_vs_eta, nlosthits_vs_eta;
198  std::vector<MonitorElement*> h_chi2meanh, h_losthits_eta;
199  std::vector<MonitorElement*> h_hits_phi;
200  std::vector<MonitorElement*> h_chi2meanhitsh, h_chi2mean_vs_phi;
201 
202  //resolution of track params: to be used with fitslicesytool
205 
206  //pulls of track params vs eta: to be used with fitslicesytool
208  std::vector<MonitorElement*> ptpull_vs_phi, phipull_vs_phi, thetapull_vs_phi;
210  std::vector<MonitorElement*> h_ptpullphi, h_phipullphi, h_thetapullphi;
211 
212 };
213 
214 
215 #endif
std::vector< MonitorElement * > h_dxypulleta
T getParameter(std::string const &) const
std::vector< MonitorElement * > h_ptpulleta
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
std::vector< MonitorElement * > etares_vs_eta
std::vector< MonitorElement * > ptres_vs_phi
std::vector< edm::EDGetTokenT< edm::View< reco::Track > > > track_Collection_Token
std::vector< MonitorElement * > h_losthits_eta
std::string dump(unsigned int indent=0) const
std::vector< MonitorElement * > h_thetapullphi
std::vector< MonitorElement * > h_ptpullphi
std::vector< MonitorElement * > ptres_vs_eta
std::vector< MonitorElement * > cotThetares_vs_eta
std::vector< MonitorElement * > h_dzpulleta
std::vector< MonitorElement * > h_thetapulleta
std::vector< MonitorElement * > phimean_vs_eta_phi
std::vector< MonitorElement * > phires_vs_pt
std::vector< MonitorElement * > h_assochi2_prob
std::vector< MonitorElement * > cotThetares_vs_pt
std::vector< MonitorElement * > h_ptshifteta
std::vector< MonitorElement * > dxyres_vs_eta
std::vector< MonitorElement * > dzres_vs_pt
std::vector< MonitorElement * > dzres_vs_eta
void getRecoMomentum(const reco::Track &track, double &pt, double &ptError, double &qoverp, double &qoverpError, double &lambda, double &lambdaError, double &phi, double &phiError) const
retrieval of reconstructed momentum components from reco::Track (== mean values for GSF) ...
std::vector< MonitorElement * > thetapull_vs_phi
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< SimHitTPAssociationProducer::SimHitTPAssociationList > _simHitTpMapTag
std::vector< MonitorElement * > h_assochi2
std::vector< MonitorElement * > chi2_vs_phi
std::vector< MonitorElement * > h_phipulleta
std::vector< MonitorElement * > chi2_vs_nhits
std::vector< MonitorElement * > phires_vs_phi
std::vector< MonitorElement * > h_chi2mean_vs_phi
std::vector< MonitorElement * > h_phipullphi
SingleObjectSelector< TrackingParticleCollection,::TrackingParticleSelector > TrackingParticleSelector
CosmicTrackingParticleSelector cosmictpSelector
std::vector< MonitorElement * > nhits_vs_phi
edm::EDGetTokenT< TrackingParticleCollection > tp_fake_Token
std::vector< MonitorElement * > dxyres_vs_pt
std::vector< edm::InputTag > label
std::vector< MonitorElement * > h_nchi2
std::vector< MonitorElement * > h_nchi2_prob
std::vector< MonitorElement * > ptpull_vs_eta
std::vector< MonitorElement * > dxypull_vs_eta
std::vector< MonitorElement * > phipull_vs_eta
~MuonTrackValidator() override
Destructor.
std::vector< MonitorElement * > thetapull_vs_eta
MuonTrackValidator(const edm::ParameterSet &pset)
Constructor.
ObjectSelector< CosmicTrackingParticleSelector > CosmicTrackingParticleSelector
std::vector< MonitorElement * > ptmean_vs_eta_phi
edm::EDGetTokenT< reco::RecoToSimCollection > recoToSimCollection_Token
edm::EDGetTokenT< reco::SimToRecoCollection > simToRecoCollection_Token
std::vector< MonitorElement * > chi2_vs_eta
TrackingParticleSelector tpSelector
std::vector< MonitorElement * > h_losthits
std::vector< MonitorElement * > ptpull_vs_phi
edm::InputTag associatormap
void endRun(edm::Run const &, edm::EventSetup const &) override
Method called at the end of the event loop.
std::vector< MonitorElement * > ptres_vs_pt
std::vector< MonitorElement * > h_chi2meanhitsh
std::vector< MonitorElement * > phires_vs_eta
void analyze(const edm::Event &, const edm::EventSetup &) override
Method called before the event loop.
std::vector< MonitorElement * > h_hits_phi
std::vector< std::string > associators
std::vector< MonitorElement * > nlosthits_vs_eta
std::vector< MonitorElement * > dzpull_vs_eta
edm::EDGetTokenT< TrackingParticleCollection > tp_effic_Token
Definition: Run.h:43
std::vector< MonitorElement * > h_chi2meanh
std::vector< MonitorElement * > phipull_vs_phi
edm::EDGetTokenT< reco::BeamSpot > bsSrc_Token