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