CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Attributes | Private Attributes
HResolution Class Reference

#include <Histograms.h>

Inheritance diagram for HResolution:

Public Types

typedef dqm::legacy::DQMStore DQMStore
 
typedef dqm::legacy::MonitorElement MonitorElement
 

Public Member Functions

void Fill (double p, double pt, double eta, double phi, double rp, double rpt, double reta, double rphi, double rcharge)
 
void Fill (double p, double pt, double eta, double phi, double rp, double rpt)
 
void Fill (double rp, double rpt, double reta, double rphi, double rcharge)
 
Int_t Fill (Double_t x, Double_t y) override
 
 HResolution (DQMStore::IBooker &ibooker, std::string dirName_, std::string name, std::string whereIs)
 
 HResolution (DQMStore::IBooker &ibooker, std::string name, TFile *file)
 
 HResolution (const TString &name, const TString &title, const int totBins, const double &xMin, const double &xMax, const double &yMin, const double &yMax, TDirectory *dir=nullptr)
 
Int_t Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0) override
 
 ~HResolution ()
 
 ~HResolution () override
 

Protected Attributes

TDirectory * diffDir_
 
TProfile * diffHisto_
 
TDirectory * dir2D_
 
TDirectory * dir_
 
TH2F * histo2D_
 
TH1F * resoHisto_
 

Private Attributes

MonitorElementh2Eta
 
MonitorElementh2EtaVsPhi
 
MonitorElementh2EtaVsPt
 
MonitorElementh2P
 
MonitorElementh2Phi
 
MonitorElementh2PhiVsEta
 
MonitorElementh2PhiVsPt
 
MonitorElementh2Pt
 
MonitorElementh2PtVsEta
 
MonitorElementh2PtVsPhi
 
MonitorElementhCharge
 
MonitorElementhEta
 
MonitorElementhP
 
MonitorElementhPhi
 
MonitorElementhPt
 
std::string theName
 
std::string where
 

Detailed Description

This histogram class can be used to evaluate the resolution of a variable. It has a TProfile, a TH2F and a TH1F. The TProfile is used to compute the rms of the distribution which is filled in the TH1F (the resolution histogram) in the Write method. If a TDirectory is passed to the constructor, the different histograms are placed in subdirectories.

Definition at line 1802 of file Histograms.h.

Member Typedef Documentation

◆ DQMStore

Definition at line 151 of file Histograms.h.

◆ MonitorElement

Definition at line 152 of file Histograms.h.

Constructor & Destructor Documentation

◆ HResolution() [1/3]

HResolution::HResolution ( const TString &  name,
const TString &  title,
const int  totBins,
const double &  xMin,
const double &  xMax,
const double &  yMin,
const double &  yMax,
TDirectory *  dir = nullptr 
)
inline

Definition at line 1804 of file Histograms.h.

References diffDir_, diffHisto_, DeadROC_duringRun::dir, dir2D_, dir_, histo2D_, Skims_PA_cff::name, resoHisto_, runGCPTkAlMap::title, multiplicitycorr_cfi::xMax, photonAnalyzer_cfi::xMin, multiplicitycorr_cfi::yMax, and photonAnalyzer_cfi::yMin.

1812  : dir_(dir), dir2D_(nullptr), diffDir_(nullptr) {
1813  if (dir_ != nullptr) {
1814  dir2D_ = (TDirectory*)dir_->Get("2D");
1815  if (dir2D_ == nullptr)
1816  dir2D_ = dir_->mkdir("2D");
1817  diffDir_ = (TDirectory*)dir_->Get("deltaXoverX");
1818  if (diffDir_ == nullptr)
1819  diffDir_ = dir->mkdir("deltaXoverX");
1820  }
1821  diffHisto_ = new TProfile(name + "_prof", title + " profile", totBins, xMin, xMax, yMin, yMax);
1822  histo2D_ = new TH2F(name + "2D", title, totBins, xMin, xMax, 4000, yMin, yMax);
1823  resoHisto_ = new TH1F(name, title, totBins, xMin, xMax);
1824  }
TDirectory * dir2D_
Definition: Histograms.h:1863
TDirectory * dir_
Definition: Histograms.h:1862
TDirectory * diffDir_
Definition: Histograms.h:1864
TH1F * resoHisto_
Definition: Histograms.h:1867
TH2F * histo2D_
Definition: Histograms.h:1866
TProfile * diffHisto_
Definition: Histograms.h:1865

◆ ~HResolution() [1/2]

HResolution::~HResolution ( )
inlineoverride

Definition at line 1825 of file Histograms.h.

References diffHisto_, histo2D_, and resoHisto_.

1825  {
1826  delete diffHisto_;
1827  delete histo2D_;
1828  delete resoHisto_;
1829  }
TH1F * resoHisto_
Definition: Histograms.h:1867
TH2F * histo2D_
Definition: Histograms.h:1866
TProfile * diffHisto_
Definition: Histograms.h:1865

◆ HResolution() [2/3]

HResolution::HResolution ( DQMStore::IBooker ibooker,
std::string  dirName_,
std::string  name,
std::string  whereIs 
)
inline

Definition at line 154 of file Histograms.h.

References dqm::implementation::IBooker::book1D(), dqm::implementation::IBooker::book2D(), dqm::implementation::NavigatorBase::cd(), TrackerOfflineValidation_Dqm_cff::dirName, PVValHelper::eta, h2Eta, h2EtaVsPhi, h2EtaVsPt, h2P, h2Phi, h2PhiVsEta, h2PhiVsPt, h2Pt, h2PtVsEta, h2PtVsPhi, hCharge, hEta, hP, hPhi, hPt, neta, nphi, phi, Geom::pi(), DiDispStaMuonMonitor_cfi::pt, dqm::implementation::NavigatorBase::setCurrentFolder(), AlCaHLTBitMon_QueryRunRegistry::string, theName, and where.

155  : theName(name), where(whereIs) {
156  ibooker.cd();
157  const std::string &dirName = dirName_;
158  //dirName+="/";
159  //dirName+=name.c_str();
160 
161  ibooker.setCurrentFolder(dirName);
162 
163  double eta = 15.;
164  int neta = 800;
165  double phi = 12.;
166  int nphi = 400;
167  double pt = 60.;
168  int npt = 2000;
169 
170  hEta = ibooker.book1D(theName + "_Eta_" + where, "#eta " + theName, neta, -eta, eta); // 400
171  hPhi = ibooker.book1D(theName + "_Phi_" + where, "#phi " + theName, nphi, -phi, phi); // 100
172 
173  hP = ibooker.book1D(theName + "_P_" + where, "P " + theName, 400, -4, 4); // 200
174  hPt = ibooker.book1D(theName + "_Pt_" + where, "P_{t} " + theName, npt, -pt, pt); // 200
175 
176  hCharge = ibooker.book1D(theName + "_charge_" + where, "Charge " + theName, 4, -2., 2.);
177 
178  h2Eta = ibooker.book2D(
179  theName + "_Eta_vs_Eta" + where, "#eta " + theName + " as a function of #eta", 200, -2.5, 2.5, neta, -eta, eta);
180  h2Phi = ibooker.book2D(theName + "_Phi_vs_Phi" + where,
181  "#phi " + theName + " as a function of #phi",
182  100,
183  -Geom::pi(),
184  Geom::pi(),
185  nphi,
186  -phi,
187  phi);
188 
189  h2P =
190  ibooker.book2D(theName + "_P_vs_P" + where, "P " + theName + " as a function of P", 1000, 0, 2000, 400, -4, 4);
191  h2Pt = ibooker.book2D(
192  theName + "_Pt_vs_Pt" + where, "P_{t} " + theName + " as a function of P_{t}", 1000, 0, 2000, npt, -pt, pt);
193 
194  h2PtVsEta = ibooker.book2D(
195  theName + "_Pt_vs_Eta" + where, "P_{t} " + theName + " as a function of #eta", 200, -2.5, 2.5, npt, -pt, pt);
196  h2PtVsPhi = ibooker.book2D(theName + "_Pt_vs_Phi" + where,
197  "P_{t} " + theName + " as a function of #phi",
198  100,
199  -Geom::pi(),
200  Geom::pi(),
201  npt,
202  -pt,
203  pt);
204 
205  h2EtaVsPt = ibooker.book2D(
206  theName + "_Eta_vs_Pt" + where, "#eta " + theName + " as a function of P_{t}", 1000, 0, 2000, neta, -eta, eta);
207  h2EtaVsPhi = ibooker.book2D(theName + "_Eta_vs_Phi" + where,
208  "#eta " + theName + " as a function of #phi",
209  100,
210  -Geom::pi(),
211  Geom::pi(),
212  neta,
213  -eta,
214  eta);
215 
216  h2PhiVsPt = ibooker.book2D(
217  theName + "_Phi_vs_Pt" + where, "#phi " + theName + " as a function of P_{t}", 1000, 0, 2000, nphi, -phi, phi);
218  h2PhiVsEta = ibooker.book2D(
219  theName + "_Phi_vs_Eta" + where, "#phi " + theName + " as a function of #eta", 200, -2.5, 2.5, nphi, -phi, phi);
220  }
const int nphi
MonitorElement * h2PhiVsPt
Definition: Histograms.h:295
MonitorElement * h2Eta
Definition: Histograms.h:283
MonitorElement * h2EtaVsPhi
Definition: Histograms.h:293
std::string where
Definition: Histograms.h:273
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
MonitorElement * hP
Definition: Histograms.h:278
MonitorElement * hPt
Definition: Histograms.h:279
MonitorElement * h2P
Definition: Histograms.h:286
MonitorElement * hCharge
Definition: Histograms.h:281
MonitorElement * hPhi
Definition: Histograms.h:276
MonitorElement * h2PhiVsEta
Definition: Histograms.h:296
std::string theName
Definition: Histograms.h:272
const int neta
MonitorElement * h2Phi
Definition: Histograms.h:284
MonitorElement * h2Pt
Definition: Histograms.h:287
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
MonitorElement * h2EtaVsPt
Definition: Histograms.h:292
MonitorElement * h2PtVsPhi
Definition: Histograms.h:290
constexpr double pi()
Definition: Pi.h:31
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
MonitorElement * hEta
Definition: Histograms.h:275
MonitorElement * h2PtVsEta
Definition: Histograms.h:289

◆ HResolution() [3/3]

HResolution::HResolution ( DQMStore::IBooker ibooker,
std::string  name,
TFile *  file 
)
inline

Definition at line 222 of file Histograms.h.

222  : theName(name) {
223  // dynamic_cast<TH1F*>( file->Get(theName+"") );
224  }
std::string theName
Definition: Histograms.h:272

◆ ~HResolution() [2/2]

HResolution::~HResolution ( )
inline

Definition at line 226 of file Histograms.h.

226 {}

Member Function Documentation

◆ Fill() [1/4]

void HResolution::Fill ( double  p,
double  pt,
double  eta,
double  phi,
double  rp,
double  rpt,
double  reta,
double  rphi,
double  rcharge 
)
inline

Definition at line 228 of file Histograms.h.

References PVValHelper::eta, dqm::impl::MonitorElement::Fill(), Fill(), h2Eta, h2EtaVsPhi, h2EtaVsPt, h2P, h2Phi, h2PhiVsEta, h2PhiVsPt, h2Pt, h2PtVsEta, h2PtVsPhi, AlCaHLTBitMon_ParallelJobs::p, phi, and DiDispStaMuonMonitor_cfi::pt.

229  {
230  Fill(rp, rpt, reta, rphi, rcharge);
231 
232  h2Eta->Fill(eta, reta);
233  h2Phi->Fill(phi, rphi);
234 
235  h2P->Fill(p, rp);
236  h2Pt->Fill(pt, rpt);
237 
238  h2PtVsEta->Fill(eta, rpt);
239  h2PtVsPhi->Fill(phi, rpt);
240 
241  h2EtaVsPt->Fill(pt, reta);
242  h2EtaVsPhi->Fill(phi, reta);
243 
244  h2PhiVsPt->Fill(pt, rphi);
245  h2PhiVsEta->Fill(eta, rphi);
246  }
MonitorElement * h2PhiVsPt
Definition: Histograms.h:295
MonitorElement * h2Eta
Definition: Histograms.h:283
MonitorElement * h2EtaVsPhi
Definition: Histograms.h:293
MonitorElement * h2P
Definition: Histograms.h:286
MonitorElement * h2PhiVsEta
Definition: Histograms.h:296
void Fill(long long x)
MonitorElement * h2Phi
Definition: Histograms.h:284
Int_t Fill(Double_t x, Double_t y) override
Definition: Histograms.h:1830
MonitorElement * h2Pt
Definition: Histograms.h:287
MonitorElement * h2EtaVsPt
Definition: Histograms.h:292
MonitorElement * h2PtVsPhi
Definition: Histograms.h:290
MonitorElement * h2PtVsEta
Definition: Histograms.h:289

◆ Fill() [2/4]

void HResolution::Fill ( double  p,
double  pt,
double  eta,
double  phi,
double  rp,
double  rpt 
)
inline

Definition at line 248 of file Histograms.h.

References PVValHelper::eta, dqm::impl::MonitorElement::Fill(), h2P, h2Pt, h2PtVsEta, h2PtVsPhi, hP, hPt, AlCaHLTBitMon_ParallelJobs::p, phi, and DiDispStaMuonMonitor_cfi::pt.

248  {
249  hP->Fill(rp);
250  hPt->Fill(rpt);
251 
252  h2P->Fill(p, rp);
253  // h2PVsEta->Fill(eta,rp);
254  // h2PVsPhi->Fill(phi,rp);
255 
256  h2Pt->Fill(pt, rpt);
257  h2PtVsEta->Fill(eta, rpt);
258  h2PtVsPhi->Fill(phi, rpt);
259  }
MonitorElement * hP
Definition: Histograms.h:278
MonitorElement * hPt
Definition: Histograms.h:279
MonitorElement * h2P
Definition: Histograms.h:286
void Fill(long long x)
MonitorElement * h2Pt
Definition: Histograms.h:287
MonitorElement * h2PtVsPhi
Definition: Histograms.h:290
MonitorElement * h2PtVsEta
Definition: Histograms.h:289

◆ Fill() [3/4]

void HResolution::Fill ( double  rp,
double  rpt,
double  reta,
double  rphi,
double  rcharge 
)
inline

Definition at line 261 of file Histograms.h.

References dqm::impl::MonitorElement::Fill(), hCharge, hEta, hP, hPhi, and hPt.

261  {
262  hEta->Fill(reta);
263  hPhi->Fill(rphi);
264 
265  hP->Fill(rp);
266  hPt->Fill(rpt);
267 
268  hCharge->Fill(rcharge);
269  }
MonitorElement * hP
Definition: Histograms.h:278
MonitorElement * hPt
Definition: Histograms.h:279
MonitorElement * hCharge
Definition: Histograms.h:281
MonitorElement * hPhi
Definition: Histograms.h:276
void Fill(long long x)
MonitorElement * hEta
Definition: Histograms.h:275

◆ Fill() [4/4]

Int_t HResolution::Fill ( Double_t  x,
Double_t  y 
)
inlineoverride

Definition at line 1830 of file Histograms.h.

References diffHisto_, histo2D_, x, and y.

Referenced by HTrack::computePull(), HTrack::computeResolution(), HTrack::computeTDRResolution(), and Fill().

1830  {
1831  diffHisto_->Fill(x, y);
1832  histo2D_->Fill(x, y);
1833  return 0;
1834  }
TH2F * histo2D_
Definition: Histograms.h:1866
TProfile * diffHisto_
Definition: Histograms.h:1865

◆ Write()

Int_t HResolution::Write ( const char *  name = nullptr,
Int_t  option = 0,
Int_t  bufsize = 0 
)
inlineoverride

Definition at line 1835 of file Histograms.h.

References diffDir_, diffHisto_, dir2D_, dir_, histo2D_, resoHisto_, and mathSSE::sqrt().

1835  {
1836  // Loop on all the bins and take the rms.
1837  // The TProfile bin error is by default the standard error on the mean, that is
1838  // rms/sqrt(N). If it is created with the "S" option (as we did NOT do), it would
1839  // already be the rms. Thus we take the error and multiply it by the sqrt of the
1840  // bin entries to get the rms.
1841  // bin 0 is the underflow, bin totBins+1 is the overflow.
1842  unsigned int totBins = diffHisto_->GetNbinsX();
1843  // std::cout << "totBins = " << totBins << std::endl;
1844  for (unsigned int iBin = 1; iBin <= totBins; ++iBin) {
1845  // std::cout << "iBin = " << iBin << ", " << diffHisto_->GetBinError(iBin)*sqrt(diffHisto_->GetBinEntries(iBin)) << std::endl;
1846  resoHisto_->SetBinContent(iBin, diffHisto_->GetBinError(iBin) * sqrt(diffHisto_->GetBinEntries(iBin)));
1847  }
1848  if (dir_ != nullptr)
1849  dir_->cd();
1850  resoHisto_->Write();
1851  if (diffDir_ != nullptr)
1852  diffDir_->cd();
1853  diffHisto_->Write();
1854  if (dir2D_ != nullptr)
1855  dir2D_->cd();
1856  histo2D_->Write();
1857 
1858  return 0;
1859  }
TDirectory * dir2D_
Definition: Histograms.h:1863
T sqrt(T t)
Definition: SSEVec.h:19
TDirectory * dir_
Definition: Histograms.h:1862
TDirectory * diffDir_
Definition: Histograms.h:1864
TH1F * resoHisto_
Definition: Histograms.h:1867
TH2F * histo2D_
Definition: Histograms.h:1866
TProfile * diffHisto_
Definition: Histograms.h:1865

Member Data Documentation

◆ diffDir_

TDirectory* HResolution::diffDir_
protected

Definition at line 1864 of file Histograms.h.

Referenced by HResolution(), and Write().

◆ diffHisto_

TProfile* HResolution::diffHisto_
protected

Definition at line 1865 of file Histograms.h.

Referenced by Fill(), HResolution(), Write(), and ~HResolution().

◆ dir2D_

TDirectory* HResolution::dir2D_
protected

Definition at line 1863 of file Histograms.h.

Referenced by HResolution(), and Write().

◆ dir_

TDirectory* HResolution::dir_
protected

Definition at line 1862 of file Histograms.h.

Referenced by HResolution(), and Write().

◆ h2Eta

MonitorElement* HResolution::h2Eta
private

Definition at line 283 of file Histograms.h.

Referenced by Fill(), and HResolution().

◆ h2EtaVsPhi

MonitorElement* HResolution::h2EtaVsPhi
private

Definition at line 293 of file Histograms.h.

Referenced by Fill(), and HResolution().

◆ h2EtaVsPt

MonitorElement* HResolution::h2EtaVsPt
private

Definition at line 292 of file Histograms.h.

Referenced by Fill(), and HResolution().

◆ h2P

MonitorElement* HResolution::h2P
private

Definition at line 286 of file Histograms.h.

Referenced by Fill(), and HResolution().

◆ h2Phi

MonitorElement* HResolution::h2Phi
private

Definition at line 284 of file Histograms.h.

Referenced by Fill(), and HResolution().

◆ h2PhiVsEta

MonitorElement* HResolution::h2PhiVsEta
private

Definition at line 296 of file Histograms.h.

Referenced by Fill(), and HResolution().

◆ h2PhiVsPt

MonitorElement* HResolution::h2PhiVsPt
private

Definition at line 295 of file Histograms.h.

Referenced by Fill(), and HResolution().

◆ h2Pt

MonitorElement* HResolution::h2Pt
private

Definition at line 287 of file Histograms.h.

Referenced by Fill(), and HResolution().

◆ h2PtVsEta

MonitorElement* HResolution::h2PtVsEta
private

Definition at line 289 of file Histograms.h.

Referenced by Fill(), and HResolution().

◆ h2PtVsPhi

MonitorElement* HResolution::h2PtVsPhi
private

Definition at line 290 of file Histograms.h.

Referenced by Fill(), and HResolution().

◆ hCharge

MonitorElement* HResolution::hCharge
private

Definition at line 281 of file Histograms.h.

Referenced by Fill(), and HResolution().

◆ hEta

MonitorElement* HResolution::hEta
private

Definition at line 275 of file Histograms.h.

Referenced by Fill(), and HResolution().

◆ histo2D_

TH2F* HResolution::histo2D_
protected

Definition at line 1866 of file Histograms.h.

Referenced by Fill(), HResolution(), Write(), and ~HResolution().

◆ hP

MonitorElement* HResolution::hP
private

Definition at line 278 of file Histograms.h.

Referenced by Fill(), and HResolution().

◆ hPhi

MonitorElement* HResolution::hPhi
private

Definition at line 276 of file Histograms.h.

Referenced by Fill(), and HResolution().

◆ hPt

MonitorElement* HResolution::hPt
private

Definition at line 279 of file Histograms.h.

Referenced by Fill(), and HResolution().

◆ resoHisto_

TH1F* HResolution::resoHisto_
protected

Definition at line 1867 of file Histograms.h.

Referenced by HResolution(), Write(), and ~HResolution().

◆ theName

std::string HResolution::theName
private

Definition at line 272 of file Histograms.h.

Referenced by HResolution().

◆ where

std::string HResolution::where
private

Definition at line 273 of file Histograms.h.

Referenced by HResolution().