CMS 3D CMS Logo

MuonTrackValidatorBase.h
Go to the documentation of this file.
1 #ifndef MuonTrackValidatorBase_h
2 #define MuonTrackValidatorBase_h
3 
9 #include <memory>
10 
15 
18 
24 
27 
30 
31 #include <iostream>
32 #include <sstream>
33 #include <string>
34 #include <TH1F.h>
35 #include <TH2F.h>
36 
40 
41 public:
47  else
49  pileupinfo_Token = iC.consumes<std::vector<PileupSummaryInfo> >(label_pileupinfo);
50  for (unsigned int www = 0; www < label.size(); www++) {
52  }
53  }
54 
56  : label(pset.getParameter<std::vector<edm::InputTag> >("label")),
57  bsSrc(pset.getParameter<edm::InputTag>("beamSpot")),
58  label_tp(pset.getParameter<edm::InputTag>("label_tp")),
59  label_tp_refvector(pset.getParameter<bool>("label_tp_refvector")),
60  label_pileupinfo(pset.getParameter<edm::InputTag>("label_pileupinfo")),
61  associators(pset.getParameter<std::vector<std::string> >("associators")),
62  out(pset.getParameter<std::string>("outputFile")),
63  parametersDefiner(pset.getParameter<std::string>("parametersDefiner")),
64  muonHistoParameters(pset.getParameter<edm::ParameterSet>("muonHistoParameters")),
65  ignoremissingtkcollection_(pset.getUntrackedParameter<bool>("ignoremissingtrackcollection", false))
66 
67  {
68  minEta = muonHistoParameters.getParameter<double>("minEta");
69  maxEta = muonHistoParameters.getParameter<double>("maxEta");
70  nintEta = muonHistoParameters.getParameter<int>("nintEta");
71  useFabsEta = muonHistoParameters.getParameter<bool>("useFabsEta");
72  minPt = muonHistoParameters.getParameter<double>("minPt");
73  maxPt = muonHistoParameters.getParameter<double>("maxPt");
74  nintPt = muonHistoParameters.getParameter<int>("nintPt");
75  useLogPt = muonHistoParameters.getUntrackedParameter<bool>("useLogPt", false);
76  useInvPt = muonHistoParameters.getParameter<bool>("useInvPt");
77  minNHit = muonHistoParameters.getParameter<double>("minNHit");
78  maxNHit = muonHistoParameters.getParameter<double>("maxNHit");
79  nintNHit = muonHistoParameters.getParameter<int>("nintNHit");
80  //
81  minDTHit = muonHistoParameters.getParameter<double>("minDTHit");
82  maxDTHit = muonHistoParameters.getParameter<double>("maxDTHit");
83  nintDTHit = muonHistoParameters.getParameter<int>("nintDTHit");
84  //
85  minCSCHit = muonHistoParameters.getParameter<double>("minCSCHit");
86  maxCSCHit = muonHistoParameters.getParameter<double>("maxCSCHit");
87  nintCSCHit = muonHistoParameters.getParameter<int>("nintCSCHit");
88  //
89  minRPCHit = muonHistoParameters.getParameter<double>("minRPCHit");
90  maxRPCHit = muonHistoParameters.getParameter<double>("maxRPCHit");
91  nintRPCHit = muonHistoParameters.getParameter<int>("nintRPCHit");
92  //
93 
94  minNTracks = muonHistoParameters.getParameter<int>("minNTracks");
95  maxNTracks = muonHistoParameters.getParameter<int>("maxNTracks");
96  nintNTracks = muonHistoParameters.getParameter<int>("nintNTracks");
97  minFTracks = muonHistoParameters.getParameter<int>("minFTracks");
98  maxFTracks = muonHistoParameters.getParameter<int>("maxFTracks");
99  nintFTracks = muonHistoParameters.getParameter<int>("nintFTracks");
100  minLayers = muonHistoParameters.getParameter<double>("minLayers");
101  maxLayers = muonHistoParameters.getParameter<double>("maxLayers");
102  nintLayers = muonHistoParameters.getParameter<int>("nintLayers");
103  minPixels = muonHistoParameters.getParameter<double>("minPixels");
104  maxPixels = muonHistoParameters.getParameter<double>("maxPixels");
105  nintPixels = muonHistoParameters.getParameter<int>("nintPixels");
106  minPhi = muonHistoParameters.getParameter<double>("minPhi");
107  maxPhi = muonHistoParameters.getParameter<double>("maxPhi");
108  nintPhi = muonHistoParameters.getParameter<int>("nintPhi");
109  minDxy = muonHistoParameters.getParameter<double>("minDxy");
110  maxDxy = muonHistoParameters.getParameter<double>("maxDxy");
111  nintDxy = muonHistoParameters.getParameter<int>("nintDxy");
112  minDz = muonHistoParameters.getParameter<double>("minDz");
113  maxDz = muonHistoParameters.getParameter<double>("maxDz");
114  nintDz = muonHistoParameters.getParameter<int>("nintDz");
115  minRpos = muonHistoParameters.getParameter<double>("minRpos");
116  maxRpos = muonHistoParameters.getParameter<double>("maxRpos");
117  nintRpos = muonHistoParameters.getParameter<int>("nintRpos");
118  minZpos = muonHistoParameters.getParameter<double>("minZpos");
119  maxZpos = muonHistoParameters.getParameter<double>("maxZpos");
120  nintZpos = muonHistoParameters.getParameter<int>("nintZpos");
121  minPU = muonHistoParameters.getParameter<double>("minPU");
122  maxPU = muonHistoParameters.getParameter<double>("maxPU");
123  nintPU = muonHistoParameters.getParameter<int>("nintPU");
124  //
125  ptRes_rangeMin = muonHistoParameters.getParameter<double>("ptRes_rangeMin");
126  ptRes_rangeMax = muonHistoParameters.getParameter<double>("ptRes_rangeMax");
127  ptRes_nbin = muonHistoParameters.getParameter<int>("ptRes_nbin");
128  etaRes_rangeMin = muonHistoParameters.getParameter<double>("etaRes_rangeMin");
129  etaRes_rangeMax = muonHistoParameters.getParameter<double>("etaRes_rangeMax");
130  etaRes_nbin = muonHistoParameters.getParameter<int>("etaRes_nbin");
131  phiRes_rangeMin = muonHistoParameters.getParameter<double>("phiRes_rangeMin");
132  phiRes_rangeMax = muonHistoParameters.getParameter<double>("phiRes_rangeMax");
133  phiRes_nbin = muonHistoParameters.getParameter<int>("phiRes_nbin");
134  cotThetaRes_rangeMin = muonHistoParameters.getParameter<double>("cotThetaRes_rangeMin");
135  cotThetaRes_rangeMax = muonHistoParameters.getParameter<double>("cotThetaRes_rangeMax");
136  cotThetaRes_nbin = muonHistoParameters.getParameter<int>("cotThetaRes_nbin");
137  dxyRes_rangeMin = muonHistoParameters.getParameter<double>("dxyRes_rangeMin");
138  dxyRes_rangeMax = muonHistoParameters.getParameter<double>("dxyRes_rangeMax");
139  dxyRes_nbin = muonHistoParameters.getParameter<int>("dxyRes_nbin");
140  dzRes_rangeMin = muonHistoParameters.getParameter<double>("dzRes_rangeMin");
141  dzRes_rangeMax = muonHistoParameters.getParameter<double>("dzRes_rangeMax");
142  dzRes_nbin = muonHistoParameters.getParameter<int>("dzRes_nbin");
143  //
144  usetracker = muonHistoParameters.getParameter<bool>("usetracker");
145  usemuon = muonHistoParameters.getParameter<bool>("usemuon");
146  do_TRKhitsPlots = muonHistoParameters.getParameter<bool>("do_TRKhitsPlots");
147  do_MUOhitsPlots = muonHistoParameters.getParameter<bool>("do_MUOhitsPlots");
148 
149  if (useLogPt) {
150  minPt = log10(std::max(0.01, minPt));
151  maxPt = log10(maxPt);
152  }
153  }
154 
156  virtual ~MuonTrackValidatorBase() noexcept(false) {}
157 
158  template <typename T>
160  h->Fill(std::min(std::max(val, ((T)h->getTH1()->GetXaxis()->GetXmin())), ((T)h->getTH1()->GetXaxis()->GetXmax())));
161  }
162 
163  void doProfileX(TH2* th2, MonitorElement* me) {
164  if (th2->GetNbinsX() == me->getNbinsX()) {
165  TProfile* p1 = (TProfile*)th2->ProfileX();
166  p1->Copy(*me->getTProfile());
167  delete p1;
168  } else {
169  throw cms::Exception("MuonTrackValidator") << "Different number of bins!";
170  }
171  }
172 
174 
175  // virtual double getEta(double eta) {
176  double getEta(double eta) {
177  if (useFabsEta)
178  return fabs(eta);
179  else
180  return eta;
181  }
182 
183  // virtual double getPt(double pt) {
184  double getPt(double pt) {
185  if (useInvPt && pt != 0)
186  return 1 / pt;
187  else
188  return pt;
189  }
190 
191  void BinLogX(TH1* h) {
192  TAxis* axis = h->GetXaxis();
193  int bins = axis->GetNbins();
194 
195  float from = axis->GetXmin();
196  float to = axis->GetXmax();
197  float width = (to - from) / bins;
198  float* new_bins = new float[bins + 1];
199 
200  for (int i = 0; i <= bins; i++) {
201  new_bins[i] = TMath::Power(10, from + i * width);
202  }
203  axis->Set(bins, new_bins);
204  delete[] new_bins;
205  }
206 
207 protected:
208  std::vector<edm::InputTag> label;
213  std::vector<std::string> associators;
216  std::vector<edm::EDGetTokenT<edm::View<reco::Track> > > track_Collection_Token;
222 
224 
227  double minEta, maxEta;
228  int nintEta;
230  double minPt, maxPt;
231  int nintPt;
232  bool useLogPt;
233  bool useInvPt;
234  double minNHit, maxNHit;
235  int nintNHit;
246  double minPhi, maxPhi;
247  int nintPhi;
248  double minDxy, maxDxy;
249  int nintDxy;
250  double minDz, maxDz;
251  int nintDz;
252  double minRpos, maxRpos;
253  int nintRpos;
254  double minZpos, maxZpos;
255  int nintZpos;
256  double minPU, maxPU;
257  int nintPU;
258  //
271 
275 
276  //1D
277  std::vector<MonitorElement*> h_tracks, h_fakes, h_nhits, h_charge;
278  std::vector<MonitorElement*> h_recoeta, h_assoceta, h_assoc2eta, h_simuleta, h_misideta;
279  std::vector<MonitorElement*> h_recopT, h_assocpT, h_assoc2pT, h_simulpT, h_misidpT;
280  std::vector<MonitorElement*> h_recohit, h_assochit, h_assoc2hit, h_simulhit, h_misidhit;
281  std::vector<MonitorElement*> h_recophi, h_assocphi, h_assoc2phi, h_simulphi, h_misidphi;
282  std::vector<MonitorElement*> h_recodxy, h_assocdxy, h_assoc2dxy, h_simuldxy, h_misiddxy;
283  std::vector<MonitorElement*> h_recodz, h_assocdz, h_assoc2dz, h_simuldz, h_misiddz;
284  std::vector<MonitorElement*> h_recopu, h_assocpu, h_assoc2pu, h_simulpu, h_misidpu;
285 
286  std::vector<MonitorElement*> h_assocRpos, h_simulRpos, h_assocZpos, h_simulZpos;
287  std::vector<MonitorElement*> h_etaRes;
288 
289  std::vector<MonitorElement*> h_nchi2, h_nchi2_prob, h_losthits;
290  std::vector<MonitorElement*> h_nmisslayers_inner, h_nmisslayers_outer, h_nlosthits;
291  std::vector<MonitorElement*> h_assochi2, h_assochi2_prob;
292  std::vector<MonitorElement*> h_assocFraction, h_assocSharedHit;
293 
294  //2D
295  std::vector<MonitorElement*> nRecHits_vs_nSimHits;
296  std::vector<MonitorElement*> h_PurityVsQuality;
297  std::vector<MonitorElement*> chi2_vs_nhits, etares_vs_eta;
298  std::vector<MonitorElement*> ptres_vs_phi, chi2_vs_phi, nhits_vs_phi, phires_vs_phi;
299 
302  std::vector<MonitorElement*> chi2_vs_eta, nlosthits_vs_eta;
304 
307 
309  std::vector<MonitorElement*> ptpull_vs_phi, phipull_vs_phi, thetapull_vs_phi;
311  std::vector<MonitorElement*> h_ptpullphi, h_phipullphi, h_thetapullphi;
312  std::vector<MonitorElement*> h_ptpull, h_qoverppull, h_thetapull, h_phipull, h_dxypull, h_dzpull;
313 };
314 
315 #endif
void fillPlotNoFlow(MonitorElement *h, T val)
std::vector< MonitorElement * > h_assoc2phi
std::vector< MonitorElement * > h_recoeta
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< MonitorElement * > phipull_vs_phi
std::vector< MonitorElement * > h_assoc2hit
std::vector< MonitorElement * > h_PurityVsQuality
std::vector< MonitorElement * > h_etaRes
edm::EDGetTokenT< TrackingParticleRefVector > tp_refvector_Token
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< MonitorElement * > h_misiddxy
std::vector< MonitorElement * > h_assochi2_prob
std::vector< MonitorElement * > h_recopT
edm::ESHandle< MagneticField > theMF
std::vector< MonitorElement * > h_nchi2_prob
std::vector< MonitorElement * > dxyres_vs_eta
std::vector< MonitorElement * > h_assoc2dxy
std::vector< edm::EDGetTokenT< edm::View< reco::Track > > > track_Collection_Token
std::vector< MonitorElement * > thetaCotres_vs_eta
void doProfileX(TH2 *th2, MonitorElement *me)
std::vector< MonitorElement * > h_recohit
std::vector< MonitorElement * > dxyres_vs_pt
std::vector< MonitorElement * > h_thetapullphi
std::vector< MonitorElement * > h_fakes
std::vector< MonitorElement * > h_dxypull
std::vector< MonitorElement * > h_phipullphi
std::vector< MonitorElement * > phires_vs_phi
void doProfileX(MonitorElement *th2m, MonitorElement *me)
std::vector< MonitorElement * > h_assoc2pu
edm::ParameterSet muonHistoParameters
std::vector< MonitorElement * > h_nhits
std::vector< MonitorElement * > h_ptpull
std::vector< MonitorElement * > ptpull_vs_phi
std::vector< MonitorElement * > h_assoceta
std::vector< MonitorElement * > h_tracks
std::vector< MonitorElement * > nDThits_vs_eta
dqm::legacy::MonitorElement MonitorElement
std::vector< MonitorElement * > dzres_vs_pt
std::vector< MonitorElement * > ptres_vs_eta
std::vector< MonitorElement * > h_simuldxy
T getUntrackedParameter(std::string const &, T const &) const
virtual ~MuonTrackValidatorBase() noexcept(false)
Destructor.
std::vector< MonitorElement * > h_simuldz
std::vector< MonitorElement * > h_thetapulleta
std::vector< MonitorElement * > h_misiddz
virtual TH2F * getTH2F() const
std::vector< MonitorElement * > nhits_vs_eta
std::vector< MonitorElement * > nhits_vs_phi
std::vector< MonitorElement * > h_nchi2
std::vector< MonitorElement * > h_nmisslayers_inner
std::vector< MonitorElement * > h_qoverppull
std::vector< MonitorElement * > thetapull_vs_eta
std::vector< MonitorElement * > chi2_vs_nhits
std::vector< MonitorElement * > h_misidphi
std::vector< MonitorElement * > h_simulphi
std::vector< edm::InputTag > label
std::vector< MonitorElement * > h_assocSharedHit
std::vector< MonitorElement * > thetapull_vs_phi
std::vector< MonitorElement * > h_misidpu
std::vector< MonitorElement * > h_assoc2dz
MuonTrackValidatorBase(const edm::ParameterSet &pset, edm::ConsumesCollector iC)
Constructor.
std::vector< MonitorElement * > phires_vs_pt
std::vector< MonitorElement * > ptres_vs_phi
std::vector< MonitorElement * > h_assocZpos
std::vector< MonitorElement * > ptpull_vs_eta
std::vector< MonitorElement * > h_recophi
std::vector< MonitorElement * > nRecHits_vs_nSimHits
std::vector< MonitorElement * > dzres_vs_eta
std::vector< MonitorElement * > nME0hits_vs_eta
std::vector< MonitorElement * > h_simulRpos
std::vector< MonitorElement * > nTRK_LayersWithMeas_vs_eta
std::vector< MonitorElement * > chi2_vs_eta
std::vector< MonitorElement * > h_simulhit
std::vector< MonitorElement * > h_charge
std::vector< MonitorElement * > h_ptpulleta
std::vector< MonitorElement * > h_assocphi
edm::EDGetTokenT< TrackingParticleCollection > tp_Token
dqm::legacy::DQMStore DQMStore
std::vector< MonitorElement * > h_assocpT
std::vector< MonitorElement * > h_assocpu
std::vector< MonitorElement * > ptres_vs_pt
std::vector< MonitorElement * > h_simulpT
std::vector< MonitorElement * > dzpull_vs_eta
std::vector< MonitorElement * > h_recodz
std::vector< MonitorElement * > h_losthits
std::vector< MonitorElement * > phires_vs_eta
std::vector< MonitorElement * > h_misideta
std::vector< MonitorElement * > nlosthits_vs_eta
std::vector< MonitorElement * > dxypull_vs_eta
std::vector< MonitorElement * > h_ptpullphi
std::vector< MonitorElement * > h_nlosthits
std::vector< MonitorElement * > etares_vs_eta
std::vector< MonitorElement * > h_misidhit
std::vector< MonitorElement * > h_nmisslayers_outer
HLT enums.
MuonTrackValidatorBase(const edm::ParameterSet &pset)
std::vector< MonitorElement * > h_simulZpos
std::vector< MonitorElement * > h_recodxy
std::vector< MonitorElement * > h_recopu
std::vector< MonitorElement * > h_phipull
std::vector< MonitorElement * > h_dzpulleta
std::vector< MonitorElement * > h_dxypulleta
std::vector< MonitorElement * > h_assocdz
std::vector< MonitorElement * > thetaCotres_vs_pt
std::vector< MonitorElement * > h_dzpull
std::vector< MonitorElement * > nPixel_LayersWithMeas_vs_eta
std::vector< MonitorElement * > h_assoc2pT
std::vector< MonitorElement * > h_assochi2
std::vector< MonitorElement * > h_misidpT
std::vector< MonitorElement * > h_assocFraction
std::vector< TrackingParticle > TrackingParticleCollection
std::vector< MonitorElement * > chi2_vs_phi
std::vector< MonitorElement * > h_phipulleta
std::vector< std::string > associators
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
long double T
std::vector< MonitorElement * > h_assocRpos
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupinfo_Token
std::vector< MonitorElement * > h_assocdxy
std::vector< MonitorElement * > h_thetapull
std::vector< MonitorElement * > nRPChits_vs_eta
std::vector< MonitorElement * > h_simulpu
std::vector< MonitorElement * > h_assochit
std::vector< MonitorElement * > nGEMhits_vs_eta
std::vector< MonitorElement * > nCSChits_vs_eta
std::vector< MonitorElement * > h_simuleta
std::vector< MonitorElement * > phipull_vs_eta
std::vector< MonitorElement * > h_assoc2eta
edm::EDGetTokenT< reco::BeamSpot > bsSrc_Token