CMS 3D CMS Logo

Public Member Functions | Protected Attributes | Private Attributes

HResolution Class Reference

#include <Histograms.h>

Inherits ROOT::TH1F.

List of all members.

Public Member Functions

virtual Int_t Fill (Double_t x, Double_t y)
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)
 HResolution (std::string dirName_, std::string name, std::string whereIs)
 HResolution (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=0)
virtual Int_t Write (const char *name=0, Int_t option=0, Int_t bufsize=0)
 ~HResolution ()
 ~HResolution ()

Protected Attributes

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

Private Attributes

DQMStoredbe_
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 1433 of file Histograms.h.


Constructor & Destructor Documentation

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 = 0 
) [inline]

Definition at line 1435 of file Histograms.h.

References diffDir_, diffHisto_, dir, dir2D_, dir_, histo2D_, and resoHisto_.

                                                                               :
    dir_(dir),
    dir2D_(0),
    diffDir_(0)
  {
    if( dir_ != 0 ) {
      dir2D_ = (TDirectory*) dir_->Get("2D");
      if(dir2D_ == 0) dir2D_ = dir_->mkdir("2D");
      diffDir_ = (TDirectory*) dir_->Get("deltaXoverX");
      if(diffDir_ == 0) diffDir_ = dir->mkdir("deltaXoverX");
    }
    diffHisto_ = new TProfile(name+"_prof", title+" profile", totBins, xMin, xMax, yMin, yMax);
    histo2D_ = new TH2F(name+"2D", title, totBins, xMin, xMax, 4000, yMin, yMax);
    resoHisto_ = new TH1F(name, title, totBins, xMin, xMax);
  }
HResolution::~HResolution ( ) [inline]

Definition at line 1452 of file Histograms.h.

References diffHisto_, histo2D_, and resoHisto_.

                 {
    delete diffHisto_;
    delete histo2D_;
    delete resoHisto_;
  }
HResolution::HResolution ( std::string  dirName_,
std::string  name,
std::string  whereIs 
) [inline]

Definition at line 167 of file Histograms.h.

References DQMStore::book1D(), DQMStore::book2D(), DQMStore::cd(), dbe_, TrackerOfflineValidation_Dqm_cff::dirName, eta(), h2Eta, h2EtaVsPhi, h2EtaVsPt, h2P, h2Phi, h2PhiVsEta, h2PhiVsPt, h2Pt, h2PtVsEta, h2PtVsPhi, hCharge, hEta, hP, hPhi, hPt, cmsCodeRules::cppFunctionSkipper::operator, phi, Geom::pi(), DQMStore::setCurrentFolder(), theName, and where.

                                                                  :theName(name.c_str()),where(whereIs.c_str()){
    
    dbe_ = edm::Service<DQMStore>().operator->();
    dbe_->cd();
    std::string dirName=dirName_;
    //dirName+="/";
    //dirName+=name.c_str();
    
    dbe_->setCurrentFolder(dirName.c_str());
    
    double eta = 15.; int neta = 800;
    double phi = 12.; int nphi = 400;
    double pt = 60.; int npt = 2000;

    hEta = dbe_->book1D(theName+"_Eta_"+where,"#eta "+theName,neta,-eta,eta); // 400
    hPhi = dbe_->book1D(theName+"_Phi_"+where,"#phi "+theName,nphi,-phi,phi); // 100

    hP = dbe_->book1D(theName+"_P_"+where,"P "+theName,400,-4,4);  // 200
    hPt = dbe_->book1D(theName+"_Pt_"+where,"P_{t} "+theName,npt,-pt,pt); // 200

    hCharge = dbe_->book1D(theName+"_charge_"+where,"Charge "+theName,4,-2.,2.);


    h2Eta = dbe_->book2D(theName+"_Eta_vs_Eta"+where,"#eta "+theName+" as a function of #eta",200,-2.5,2.5,neta,-eta,eta);
    h2Phi = dbe_->book2D(theName+"_Phi_vs_Phi"+where,"#phi "+theName+" as a function of #phi",100,-Geom::pi(),Geom::pi(),nphi,-phi,phi);
    
    h2P = dbe_->book2D(theName+"_P_vs_P"+where,"P "+theName+" as a function of P",1000,0,2000,400,-4,4);
    h2Pt = dbe_->book2D(theName+"_Pt_vs_Pt"+where,"P_{t} "+theName+" as a function of P_{t}",1000,0,2000,npt,-pt,pt);
    
    h2PtVsEta = dbe_->book2D(theName+"_Pt_vs_Eta"+where,"P_{t} "+theName+" as a function of #eta",200,-2.5,2.5,npt,-pt,pt);
    h2PtVsPhi = dbe_->book2D(theName+"_Pt_vs_Phi"+where,"P_{t} "+theName+" as a function of #phi",100,-Geom::pi(),Geom::pi(),npt,-pt,pt);

    h2EtaVsPt = dbe_->book2D(theName+"_Eta_vs_Pt"+where,"#eta "+theName+" as a function of P_{t}",1000,0,2000,neta,-eta,eta);
    h2EtaVsPhi = dbe_->book2D(theName+"_Eta_vs_Phi"+where,"#eta "+theName+" as a function of #phi",100,-Geom::pi(),Geom::pi(),neta,-eta,eta);
    
    h2PhiVsPt = dbe_->book2D(theName+"_Phi_vs_Pt"+where,"#phi "+theName+" as a function of P_{t}",1000,0,2000,nphi,-phi,phi);
    h2PhiVsEta = dbe_->book2D(theName+"_Phi_vs_Eta"+where,"#phi "+theName+" as a function of #eta",200,-2.5,2.5,nphi,-phi,phi);
  }
HResolution::HResolution ( std::string  name,
TFile *  file 
) [inline]

Definition at line 206 of file Histograms.h.

                                          :theName(name.c_str()){ 
    //    dynamic_cast<TH1F*>( file->Get(theName+"") );
  }
HResolution::~HResolution ( ) [inline]

Definition at line 210 of file Histograms.h.

{}

Member Function Documentation

virtual Int_t HResolution::Fill ( Double_t  x,
Double_t  y 
) [inline, virtual]

Definition at line 1457 of file Histograms.h.

References diffHisto_, and histo2D_.

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

                                               {
    diffHisto_->Fill(x, y);
    histo2D_->Fill(x, y);
    return 0;
  }
void HResolution::Fill ( double  rp,
double  rpt,
double  reta,
double  rphi,
double  rcharge 
) [inline]

Definition at line 251 of file Histograms.h.

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

                                                     {
    
    hEta->Fill(reta);
    hPhi->Fill(rphi);
    
    hP->Fill(rp); 
    hPt->Fill(rpt);
    
    hCharge->Fill(rcharge);
  }
void HResolution::Fill ( double  p,
double  pt,
double  eta,
double  phi,
double  rp,
double  rpt 
) [inline]

Definition at line 236 of file Histograms.h.

References MonitorElement::Fill(), h2P, h2Pt, h2PtVsEta, h2PtVsPhi, hP, and hPt.

                                  {
   
    hP->Fill(rp); 
    hPt->Fill(rpt);
    
    h2P->Fill(p,rp); 
    // h2PVsEta->Fill(eta,rp);
    // h2PVsPhi->Fill(phi,rp);

    h2Pt->Fill(pt,rpt);
    h2PtVsEta->Fill(eta,rpt);
    h2PtVsPhi->Fill(phi,rpt);
  }
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 213 of file Histograms.h.

References MonitorElement::Fill(), Fill(), h2Eta, h2EtaVsPhi, h2EtaVsPt, h2P, h2Phi, h2PhiVsEta, h2PhiVsPt, h2Pt, h2PtVsEta, and h2PtVsPhi.

                                                                           {
   
    Fill(rp, rpt, reta, rphi, rcharge);

    
    h2Eta->Fill(eta,reta);
    h2Phi->Fill(phi,rphi);
    
    h2P->Fill(p,rp); 
    h2Pt->Fill(pt,rpt);

    h2PtVsEta->Fill(eta,rpt);
    h2PtVsPhi->Fill(phi,rpt);
    
    h2EtaVsPt ->Fill(pt,reta);
    h2EtaVsPhi->Fill(phi,reta);
    
    h2PhiVsPt ->Fill(pt,rphi);
    h2PhiVsEta->Fill(eta,rphi);
  }
virtual Int_t HResolution::Write ( const char *  name = 0,
Int_t  option = 0,
Int_t  bufsize = 0 
) [inline, virtual]

Definition at line 1462 of file Histograms.h.

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

                                                                                 {
    // Loop on all the bins and take the rms.
    // The TProfile bin error is by default the standard error on the mean, that is
    // rms/sqrt(N). If it is created with the "S" option (as we did NOT do), it would
    // already be the rms. Thus we take the error and multiply it by the sqrt of the
    // bin entries to get the rms.
    // bin 0 is the underflow, bin totBins+1 is the overflow.
    unsigned int totBins = diffHisto_->GetNbinsX();
    // std::cout << "totBins = " << totBins << std::endl;
    for( unsigned int iBin=1; iBin<=totBins; ++iBin ) {
      // std::cout << "iBin = " << iBin << ", " << diffHisto_->GetBinError(iBin)*sqrt(diffHisto_->GetBinEntries(iBin)) << std::endl;
      resoHisto_->SetBinContent( iBin, diffHisto_->GetBinError(iBin)*sqrt(diffHisto_->GetBinEntries(iBin)) );
    }
    if( dir_ != 0 ) dir_->cd();
    resoHisto_->Write();
    if( diffDir_ != 0 ) diffDir_->cd();
    diffHisto_->Write();
    if( dir2D_ != 0 ) dir2D_->cd();
    histo2D_->Write();

    return 0;
  }

Member Data Documentation

Definition at line 266 of file Histograms.h.

Referenced by HResolution().

TDirectory* HResolution::diffDir_ [protected]

Definition at line 1487 of file Histograms.h.

Referenced by HResolution(), and Write().

TProfile* HResolution::diffHisto_ [protected]

Definition at line 1488 of file Histograms.h.

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

TDirectory* HResolution::dir2D_ [protected]

Definition at line 1486 of file Histograms.h.

Referenced by HResolution(), and Write().

TDirectory* HResolution::dir_ [protected]

Definition at line 1485 of file Histograms.h.

Referenced by HResolution(), and Write().

Definition at line 279 of file Histograms.h.

Referenced by Fill(), and HResolution().

Definition at line 289 of file Histograms.h.

Referenced by Fill(), and HResolution().

Definition at line 288 of file Histograms.h.

Referenced by Fill(), and HResolution().

Definition at line 282 of file Histograms.h.

Referenced by Fill(), and HResolution().

Definition at line 280 of file Histograms.h.

Referenced by Fill(), and HResolution().

Definition at line 292 of file Histograms.h.

Referenced by Fill(), and HResolution().

Definition at line 291 of file Histograms.h.

Referenced by Fill(), and HResolution().

Definition at line 283 of file Histograms.h.

Referenced by Fill(), and HResolution().

Definition at line 285 of file Histograms.h.

Referenced by Fill(), and HResolution().

Definition at line 286 of file Histograms.h.

Referenced by Fill(), and HResolution().

Definition at line 277 of file Histograms.h.

Referenced by Fill(), and HResolution().

Definition at line 271 of file Histograms.h.

Referenced by Fill(), and HResolution().

TH2F* HResolution::histo2D_ [protected]

Definition at line 1489 of file Histograms.h.

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

Definition at line 274 of file Histograms.h.

Referenced by Fill(), and HResolution().

Definition at line 272 of file Histograms.h.

Referenced by Fill(), and HResolution().

Definition at line 275 of file Histograms.h.

Referenced by Fill(), and HResolution().

TH1F* HResolution::resoHisto_ [protected]

Definition at line 1490 of file Histograms.h.

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

std::string HResolution::theName [private]

Definition at line 268 of file Histograms.h.

Referenced by HResolution().

std::string HResolution::where [private]

Definition at line 269 of file Histograms.h.

Referenced by HResolution().