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 
23 
26 
29 
30 #include <iostream>
31 #include <sstream>
32 #include <string>
33 #include <TH1F.h>
34 #include <TH2F.h>
35 
36 
37 class DQMStore;
39  public:
42  {
46  pileupinfo_Token = iC.consumes<std::vector<PileupSummaryInfo> >(label_pileupinfo);
47  for (unsigned int www=0;www<label.size();www++){
49  }
50  }
51 
53  label(pset.getParameter< std::vector<edm::InputTag> >("label")),
54  bsSrc(pset.getParameter< edm::InputTag >("beamSpot")),
55  label_tp_effic(pset.getParameter< edm::InputTag >("label_tp_effic")),
56  label_tp_fake(pset.getParameter< edm::InputTag >("label_tp_fake")),
57  label_pileupinfo(pset.getParameter< edm::InputTag >("label_pileupinfo")),
58  associators(pset.getParameter< std::vector<std::string> >("associators")),
59  out(pset.getParameter<std::string>("outputFile")),
60  parametersDefiner(pset.getParameter<std::string>("parametersDefiner")),
61  muonHistoParameters(pset.getParameter<edm::ParameterSet>("muonHistoParameters")),
62  ignoremissingtkcollection_(pset.getUntrackedParameter<bool>("ignoremissingtrackcollection",false))
63 
64  {
65  minEta = muonHistoParameters.getParameter<double>("minEta");
66  maxEta = muonHistoParameters.getParameter<double>("maxEta");
67  nintEta = muonHistoParameters.getParameter<int>("nintEta");
68  useFabsEta = muonHistoParameters.getParameter<bool>("useFabsEta");
69  minPt = muonHistoParameters.getParameter<double>("minPt");
70  maxPt = muonHistoParameters.getParameter<double>("maxPt");
71  nintPt = muonHistoParameters.getParameter<int>("nintPt");
72  useLogPt = muonHistoParameters.getUntrackedParameter<bool>("useLogPt",false);
73  useInvPt = muonHistoParameters.getParameter<bool>("useInvPt");
74  minNHit = muonHistoParameters.getParameter<double>("minNHit");
75  maxNHit = muonHistoParameters.getParameter<double>("maxNHit");
76  nintNHit = muonHistoParameters.getParameter<int>("nintNHit");
77  //
78  minDTHit = muonHistoParameters.getParameter<double>("minDTHit");
79  maxDTHit = muonHistoParameters.getParameter<double>("maxDTHit");
80  nintDTHit = muonHistoParameters.getParameter<int>("nintDTHit");
81  //
82  minCSCHit = muonHistoParameters.getParameter<double>("minCSCHit");
83  maxCSCHit = muonHistoParameters.getParameter<double>("maxCSCHit");
84  nintCSCHit = muonHistoParameters.getParameter<int>("nintCSCHit");
85  //
86  minRPCHit = muonHistoParameters.getParameter<double>("minRPCHit");
87  maxRPCHit = muonHistoParameters.getParameter<double>("maxRPCHit");
88  nintRPCHit = muonHistoParameters.getParameter<int>("nintRPCHit");
89  //
90  minLayers = muonHistoParameters.getParameter<double>("minLayers");
91  maxLayers = muonHistoParameters.getParameter<double>("maxLayers");
92  nintLayers = muonHistoParameters.getParameter<int>("nintLayers");
93  minPixels = muonHistoParameters.getParameter<double>("minPixels");
94  maxPixels = muonHistoParameters.getParameter<double>("maxPixels");
95  nintPixels = muonHistoParameters.getParameter<int>("nintPixels");
96  minPhi = muonHistoParameters.getParameter<double>("minPhi");
97  maxPhi = muonHistoParameters.getParameter<double>("maxPhi");
98  nintPhi = muonHistoParameters.getParameter<int>("nintPhi");
99  minDxy = muonHistoParameters.getParameter<double>("minDxy");
100  maxDxy = muonHistoParameters.getParameter<double>("maxDxy");
101  nintDxy = muonHistoParameters.getParameter<int>("nintDxy");
102  minDz = muonHistoParameters.getParameter<double>("minDz");
103  maxDz = muonHistoParameters.getParameter<double>("maxDz");
104  nintDz = muonHistoParameters.getParameter<int>("nintDz");
105  minRpos = muonHistoParameters.getParameter<double>("minRpos");
106  maxRpos = muonHistoParameters.getParameter<double>("maxRpos");
107  nintRpos = muonHistoParameters.getParameter<int>("nintRpos");
108  minZpos = muonHistoParameters.getParameter<double>("minZpos");
109  maxZpos = muonHistoParameters.getParameter<double>("maxZpos");
110  nintZpos = muonHistoParameters.getParameter<int>("nintZpos");
111  minPU = muonHistoParameters.getParameter<double>("minPU");
112  maxPU = muonHistoParameters.getParameter<double>("maxPU");
113  nintPU = muonHistoParameters.getParameter<int>("nintPU");
114  //
115  ptRes_rangeMin = muonHistoParameters.getParameter<double>("ptRes_rangeMin");
116  ptRes_rangeMax = muonHistoParameters.getParameter<double>("ptRes_rangeMax");
117  ptRes_nbin = muonHistoParameters.getParameter<int>("ptRes_nbin");
118  etaRes_rangeMin = muonHistoParameters.getParameter<double>("etaRes_rangeMin");
119  etaRes_rangeMax = muonHistoParameters.getParameter<double>("etaRes_rangeMax");
120  etaRes_nbin = muonHistoParameters.getParameter<int>("etaRes_nbin");
121  phiRes_rangeMin = muonHistoParameters.getParameter<double>("phiRes_rangeMin");
122  phiRes_rangeMax = muonHistoParameters.getParameter<double>("phiRes_rangeMax");
123  phiRes_nbin = muonHistoParameters.getParameter<int>("phiRes_nbin");
124  cotThetaRes_rangeMin = muonHistoParameters.getParameter<double>("cotThetaRes_rangeMin");
125  cotThetaRes_rangeMax = muonHistoParameters.getParameter<double>("cotThetaRes_rangeMax");
126  cotThetaRes_nbin = muonHistoParameters.getParameter<int>("cotThetaRes_nbin");
127  dxyRes_rangeMin = muonHistoParameters.getParameter<double>("dxyRes_rangeMin");
128  dxyRes_rangeMax = muonHistoParameters.getParameter<double>("dxyRes_rangeMax");
129  dxyRes_nbin = muonHistoParameters.getParameter<int>("dxyRes_nbin");
130  dzRes_rangeMin = muonHistoParameters.getParameter<double>("dzRes_rangeMin");
131  dzRes_rangeMax = muonHistoParameters.getParameter<double>("dzRes_rangeMax");
132  dzRes_nbin = muonHistoParameters.getParameter<int>("dzRes_nbin");
133  //
134  usetracker = muonHistoParameters.getParameter<bool>("usetracker");
135  usemuon = muonHistoParameters.getParameter<bool>("usemuon");
136  do_TRKhitsPlots = muonHistoParameters.getParameter<bool>("do_TRKhitsPlots");
137  do_MUOhitsPlots = muonHistoParameters.getParameter<bool>("do_MUOhitsPlots");
138 
139  if (useLogPt) {
140  minPt=log10(std::max(0.01,minPt));
141  maxPt=log10(maxPt);
142  }
143  }
144 
147 
148  template<typename T> void fillPlotNoFlow (MonitorElement* h, T val) {
149  h->Fill(std::min(std::max(val,((T) h->getTH1()->GetXaxis()->GetXmin())),((T) h->getTH1()->GetXaxis()->GetXmax())));
150  }
151 
152  void doProfileX(TH2 * th2, MonitorElement* me){
153  if (th2->GetNbinsX()==me->getNbinsX()){
154  TProfile * p1 = (TProfile*) th2->ProfileX();
155  p1->Copy(*me->getTProfile());
156  delete p1;
157  } else {
158  throw cms::Exception("MuonTrackValidator") << "Different number of bins!";
159  }
160  }
161 
163  doProfileX(th2m->getTH2F(), me);
164  }
165 
166  // virtual double getEta(double eta) {
167  double getEta(double eta) {
168  if (useFabsEta) return fabs(eta);
169  else return eta;
170  }
171 
172  // virtual double getPt(double pt) {
173  double getPt(double pt) {
174  if (useInvPt && pt!=0) return 1/pt;
175  else return pt;
176  }
177 
178  void BinLogX(TH1*h) {
179 
180  TAxis *axis = h->GetXaxis();
181  int bins = axis->GetNbins();
182 
183  float from = axis->GetXmin();
184  float to = axis->GetXmax();
185  float width = (to - from) / bins;
186  float *new_bins = new float[bins + 1];
187 
188  for (int i = 0; i <= bins; i++) {
189  new_bins[i] = TMath::Power(10, from + i * width);
190 
191  }
192  axis->Set(bins, new_bins);
193  delete[] new_bins;
194  }
195 
196  protected:
197 
198  std::vector<edm::InputTag> label;
203  std::vector<std::string> associators;
206  std::vector<edm::EDGetTokenT<edm::View<reco::Track> > > track_Collection_Token;
212 
214 
215  double minEta, maxEta; int nintEta; bool useFabsEta;
216  double minPt, maxPt; int nintPt; bool useLogPt; bool useInvPt;
217  double minNHit, maxNHit; int nintNHit;
223  double minPhi, maxPhi; int nintPhi;
224  double minDxy, maxDxy; int nintDxy;
225  double minDz, maxDz; int nintDz;
226  double minRpos, maxRpos; int nintRpos;
227  double minZpos, maxZpos; int nintZpos;
228  double minPU, maxPU; int nintPU;
229  //
236 
240 
241  //1D
242  std::vector<MonitorElement*> h_tracks, h_fakes, h_nhits, h_charge;
243  std::vector<MonitorElement*> h_recoeta, h_assoceta, h_assoc2eta, h_simuleta, h_misideta;
244  std::vector<MonitorElement*> h_recopT, h_assocpT, h_assoc2pT, h_simulpT, h_misidpT;
245  std::vector<MonitorElement*> h_recohit, h_assochit, h_assoc2hit, h_simulhit, h_misidhit;
246  std::vector<MonitorElement*> h_recophi, h_assocphi, h_assoc2phi, h_simulphi, h_misidphi;
247  std::vector<MonitorElement*> h_recodxy, h_assocdxy, h_assoc2dxy, h_simuldxy, h_misiddxy;
248  std::vector<MonitorElement*> h_recodz, h_assocdz, h_assoc2dz, h_simuldz, h_misiddz;
249  std::vector<MonitorElement*> h_recopu, h_assocpu, h_assoc2pu, h_simulpu, h_misidpu;
250 
251  std::vector<MonitorElement*> h_assocRpos, h_simulRpos, h_assocZpos, h_simulZpos;
252  std::vector<MonitorElement*> h_etaRes;
253 
254  std::vector<MonitorElement*> h_nchi2, h_nchi2_prob, h_losthits;
256  std::vector<MonitorElement*> h_assochi2, h_assochi2_prob;
257  std::vector<MonitorElement*> h_assocFraction, h_assocSharedHit;
258 
259  //2D
260  std::vector<MonitorElement*> nRecHits_vs_nSimHits;
261  std::vector<MonitorElement*> h_PurityVsQuality;
262  std::vector<MonitorElement*> chi2_vs_nhits, etares_vs_eta;
263  std::vector<MonitorElement*> ptres_vs_phi, chi2_vs_phi, nhits_vs_phi, phires_vs_phi;
264 
266  std::vector<MonitorElement*> chi2_vs_eta, nlosthits_vs_eta;
268 
271 
273  std::vector<MonitorElement*> ptpull_vs_phi, phipull_vs_phi, thetapull_vs_phi;
275  std::vector<MonitorElement*> h_ptpullphi, h_phipullphi, h_thetapullphi;
276  std::vector<MonitorElement*> h_ptpull, h_qoverppull, h_thetapull, h_phipull, h_dxypull, h_dzpull;
277 
278 };
279 
280 
281 #endif
void fillPlotNoFlow(MonitorElement *h, T val)
std::vector< MonitorElement * > h_assoc2phi
std::vector< MonitorElement * > h_recoeta
TProfile * getTProfile() const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< MonitorElement * > phipull_vs_phi
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< MonitorElement * > h_assoc2hit
std::vector< MonitorElement * > h_PurityVsQuality
std::vector< MonitorElement * > h_etaRes
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
std::vector< TrackingParticle > TrackingParticleCollection
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
TH1 * getTH1() const
edm::ParameterSet muonHistoParameters
#define noexcept
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
std::vector< MonitorElement * > dzres_vs_pt
std::vector< MonitorElement * > ptres_vs_eta
virtual ~MuonTrackValidatorBase()(false)
Destructor.
void Fill(long long x)
std::vector< MonitorElement * > h_simuldxy
std::vector< MonitorElement * > h_simuldz
std::vector< MonitorElement * > h_thetapulleta
std::vector< MonitorElement * > h_misiddz
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
edm::EDGetTokenT< TrackingParticleCollection > tp_fake_Token
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
T min(T a, T b)
Definition: MathUtil.h:58
std::vector< MonitorElement * > h_charge
std::vector< MonitorElement * > h_ptpulleta
TH2F * getTH2F() const
std::vector< MonitorElement * > h_assocphi
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.
double p1[4]
Definition: TauolaWrapper.h:89
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
int getNbinsX() const
get # of bins in X-axis
std::vector< MonitorElement * > chi2_vs_phi
std::vector< MonitorElement * > h_phipulleta
std::vector< std::string > associators
long double T
std::vector< MonitorElement * > h_assocRpos
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupinfo_Token
std::vector< MonitorElement * > h_assocdxy
edm::EDGetTokenT< TrackingParticleCollection > tp_effic_Token
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