CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
HFunctionResolution Class Reference

#include <Histograms.h>

Inheritance diagram for HFunctionResolution:
Histograms HFunctionResolutionVarianceCheck

Public Member Functions

virtual void Clear ()
 
virtual void Fill (const reco::Particle::LorentzVector &p4, const double &resValue, const int charge)
 
 HFunctionResolution (TFile *outputFile, const TString &name, const double &ptMax=100, const int totBinsY=300)
 
virtual void Write ()
 
 ~HFunctionResolution ()
 
- Public Member Functions inherited from Histograms
virtual void Fill (const reco::Particle::LorentzVector &p1, const reco::Particle::LorentzVector &p2)
 
virtual void Fill (const reco::Particle::LorentzVector &p1, const reco::Particle::LorentzVector &p2, const int charge, const double &weight=1.)
 
virtual void Fill (const CLHEP::HepLorentzVector &momentum1, const CLHEP::HepLorentzVector &momentum2)
 
virtual void Fill (const CLHEP::HepLorentzVector &momentum1, const CLHEP::HepLorentzVector &momentum2, const int charge, const double &weight=1.)
 
virtual void Fill (const CLHEP::HepLorentzVector &p1, const reco::Particle::LorentzVector &p2)
 
virtual void Fill (const reco::Particle::LorentzVector &p4, const double &weight=1.)
 
virtual void Fill (const reco::Particle::LorentzVector &p4, const int charge, const double &weight=1.)
 
virtual void Fill (const CLHEP::HepLorentzVector &momentum, const int charge, const double &weight=1.)
 
virtual void Fill (const reco::Particle::LorentzVector &p4, const double &genValue, const double recValue, const int charge)
 
virtual void Fill (const CLHEP::HepLorentzVector &p, const double &likeValue)
 
virtual void Fill (const unsigned int number)
 
virtual void Fill (const reco::Particle::LorentzVector &recoP1, const int charge1, const reco::Particle::LorentzVector &genP1, const reco::Particle::LorentzVector &recoP2, const int charge2, const reco::Particle::LorentzVector &genP2, const double &recoMass, const double &genMass)
 
virtual void Fill (const reco::Particle::LorentzVector &recoP1, const int charge1, const reco::Particle::LorentzVector &recoP2, const int charge2, const double &recoMass, const double &genMass)
 
virtual void Fill (const reco::Particle::LorentzVector &recoP1, const reco::Particle::LorentzVector &genP1, const reco::Particle::LorentzVector &recoP2, const reco::Particle::LorentzVector &genP2)
 
virtual void Fill (const double &x, const double &y)
 
virtual void Fill (const double &x, const double &y, const double &a, const double &b)
 
virtual void Fill (const reco::Particle::LorentzVector &p41, const reco::Particle::LorentzVector &p42, const reco::Particle::LorentzVector &p4Res, const double &weight=1.)
 
virtual void Fill (const CLHEP::HepLorentzVector &momentum1, const CLHEP::HepLorentzVector &momentum2, const CLHEP::HepLorentzVector &momentumRes, const double &weight=1.)
 
virtual double Get (const reco::Particle::LorentzVector &recoP1, const TString &covarianceName)
 
virtual TString GetName ()
 
 Histograms ()
 
 Histograms (const TString &name)
 
 Histograms (TFile *outputFile, const TString &name)
 
virtual void SetWeight (double weight)
 
virtual ~Histograms ()
 

Protected Member Functions

int getXindex (const double &x) const
 
int getYindex (const double &y) const
 

Protected Attributes

double deltaX_
 
double deltaY_
 
TH1F * hReso_
 
TProfile * hResoVSEta_prof_
 
TProfile * hResoVSPhi_prof_
 
TProfile * hResoVSPhiMinus_prof_
 
TProfile * hResoVSPhiPlus_prof_
 
TProfile * hResoVSPt_Bar_prof_
 
TProfile * hResoVSPt_Endc_17_prof_
 
TProfile * hResoVSPt_Endc_20_prof_
 
TProfile * hResoVSPt_Endc_24_prof_
 
TProfile * hResoVSPt_Ovlap_prof_
 
TProfile * hResoVSPt_prof_
 
TH2F * hResoVSPtEta_
 
int ** resoCount_
 
double ** resoVsPtEta_
 
int totBinsX_
 
int totBinsY_
 
double xMin_
 
double yMin_
 
- Protected Attributes inherited from Histograms
TDirectory * histoDir_
 
TString name_
 
TFile * outputFile_
 
double theWeight_
 

Detailed Description

This histogram class fills a TProfile with the resolution evaluated from the resolution functions for single muon quantities. The resolution functions are used by MuScleFit to evaluate the mass resolution, which is the value seen by minuit and through it, corrections are evaluated.
In the end we will compare the histograms filled by this class (from the resolution function, reflecting the parameters changes done by minuit) with those filled comparing recoMuons with genMuons (the real resolutions).

Definition at line 1471 of file Histograms.h.

Constructor & Destructor Documentation

HFunctionResolution::HFunctionResolution ( TFile *  outputFile,
const TString &  name,
const double &  ptMax = 100,
const int  totBinsY = 300 
)
inline

Definition at line 1474 of file Histograms.h.

References mps_fire::i, dataset::name, Histograms::name_, AlignmentTrackSelector_cfi::ptMax, anotherprimaryvertexanalyzer_cfi::xMax, and CMSBoostedTauSeedingParameters_cfi::yMax.

1474  : Histograms(outputFile, name) {
1475  name_ = name;
1476  totBinsX_ = 300;
1477  totBinsY_ = totBinsY;
1478  xMin_ = 0.;
1479  yMin_ = -3.0;
1480  double xMax = ptMax;
1481  double yMax = 3.0;
1482  deltaX_ = xMax - xMin_;
1483  deltaY_ = yMax - yMin_;
1484  hReso_ = new TH1F( name+"_Reso", "resolution", 1000, 0, 1 );
1485  hResoVSPtEta_ = new TH2F( name+"_ResoVSPtEta", "resolution vs pt and #eta", totBinsX_, xMin_, xMax, totBinsY_, yMin_, yMax );
1486  // Create and initialize the resolution arrays
1487  resoVsPtEta_ = new double*[totBinsX_];
1488  resoCount_ = new int*[totBinsX_];
1489  for( int i=0; i<totBinsX_; ++i ) {
1490  resoVsPtEta_[i] = new double[totBinsY_];
1491  resoCount_[i] = new int[totBinsY_];
1492  for( int j=0; j<totBinsY_; ++j ) {
1493  resoVsPtEta_[i][j] = 0;
1494  resoCount_[i][j] = 0;
1495  }
1496  }
1497  hResoVSPt_prof_ = new TProfile( name+"_ResoVSPt_prof", "resolution VS pt", totBinsX_, xMin_, xMax, yMin_, yMax);
1498  hResoVSPt_Bar_prof_ = new TProfile( name+"_ResoVSPt_Bar_prof", "resolution VS pt Barrel", totBinsX_, xMin_, xMax, yMin_, yMax);
1499  hResoVSPt_Endc_17_prof_ = new TProfile( name+"_ResoVSPt_Endc_1.7_prof", "resolution VS pt Endcap (1.4<eta<1.7)", totBinsX_, xMin_, xMax, yMin_, yMax);
1500  hResoVSPt_Endc_20_prof_ = new TProfile( name+"_ResoVSPt_Endc_2.0_prof", "resolution VS pt Endcap (1.7<eta<2.0)", totBinsX_, xMin_, xMax, yMin_, yMax);
1501  hResoVSPt_Endc_24_prof_ = new TProfile( name+"_ResoVSPt_Endc_2.4_prof", "resolution VS pt Endcap (2.0<eta<2.4)", totBinsX_, xMin_, xMax, yMin_, yMax);
1502  hResoVSPt_Ovlap_prof_ = new TProfile( name+"_ResoVSPt_Ovlap_prof", "resolution VS pt Overlap", totBinsX_, xMin_, xMax, yMin_, yMax);
1503  hResoVSEta_prof_ = new TProfile( name+"_ResoVSEta_prof", "resolution VS eta", totBinsY_, yMin_, yMax, 0, 1);
1504  //hResoVSTheta_prof_ = new TProfile( name+"_ResoVSTheta_prof", "resolution VS theta", 30, 0, TMath::Pi(), 0, 1);
1505  hResoVSPhiPlus_prof_ = new TProfile( name+"_ResoVSPhiPlus_prof", "resolution VS phi mu+", 16, -3.2, 3.2, 0, 1);
1506  hResoVSPhiMinus_prof_ = new TProfile( name+"_ResoVSPhiMinus_prof", "resolution VS phi mu-", 16, -3.2, 3.2, 0, 1);
1507  hResoVSPhi_prof_ = new TProfile( name+"_ResoVSPhi_prof", "resolution VS phi", 16, -3.2, 3.2, -1, 1);
1508  }
TString name_
Definition: Histograms.h:122
TProfile * hResoVSPt_Endc_20_prof_
Definition: Histograms.h:1642
TProfile * hResoVSPt_Endc_17_prof_
Definition: Histograms.h:1641
TProfile * hResoVSPt_Bar_prof_
Definition: Histograms.h:1640
TProfile * hResoVSPt_prof_
Definition: Histograms.h:1639
TProfile * hResoVSPt_Ovlap_prof_
Definition: Histograms.h:1644
TProfile * hResoVSPt_Endc_24_prof_
Definition: Histograms.h:1643
TProfile * hResoVSPhi_prof_
Definition: Histograms.h:1649
TProfile * hResoVSPhiMinus_prof_
Definition: Histograms.h:1647
TProfile * hResoVSEta_prof_
Definition: Histograms.h:1645
TProfile * hResoVSPhiPlus_prof_
Definition: Histograms.h:1648
double ** resoVsPtEta_
Definition: Histograms.h:1637
HFunctionResolution::~HFunctionResolution ( )
inline

Definition at line 1509 of file Histograms.h.

References mps_fire::i.

1509  {
1510  delete hReso_;
1511  delete hResoVSPtEta_;
1512  // Free the resolution arrays
1513  for( int i=0; i<totBinsX_; ++i ) {
1514  delete[] resoVsPtEta_[i];
1515  delete[] resoCount_[i];
1516  }
1517  delete[] resoVsPtEta_;
1518  delete[] resoCount_;
1519  // Free the profile histograms
1520  delete hResoVSPt_prof_;
1521  delete hResoVSPt_Bar_prof_;
1522  delete hResoVSPt_Endc_17_prof_;
1523  delete hResoVSPt_Endc_20_prof_;
1524  delete hResoVSPt_Endc_24_prof_;
1525  delete hResoVSPt_Ovlap_prof_;
1526  delete hResoVSEta_prof_;
1527  //delete hResoVSTheta_prof_;
1528  delete hResoVSPhiPlus_prof_;
1529  delete hResoVSPhiMinus_prof_;
1530  delete hResoVSPhi_prof_;
1531  }
TProfile * hResoVSPt_Endc_20_prof_
Definition: Histograms.h:1642
TProfile * hResoVSPt_Endc_17_prof_
Definition: Histograms.h:1641
TProfile * hResoVSPt_Bar_prof_
Definition: Histograms.h:1640
TProfile * hResoVSPt_prof_
Definition: Histograms.h:1639
TProfile * hResoVSPt_Ovlap_prof_
Definition: Histograms.h:1644
TProfile * hResoVSPt_Endc_24_prof_
Definition: Histograms.h:1643
TProfile * hResoVSPhi_prof_
Definition: Histograms.h:1649
TProfile * hResoVSPhiMinus_prof_
Definition: Histograms.h:1647
TProfile * hResoVSEta_prof_
Definition: Histograms.h:1645
TProfile * hResoVSPhiPlus_prof_
Definition: Histograms.h:1648
double ** resoVsPtEta_
Definition: Histograms.h:1637

Member Function Documentation

virtual void HFunctionResolution::Clear ( )
inlinevirtual

Implements Histograms.

Definition at line 1612 of file Histograms.h.

1612  {
1613  hReso_->Clear();
1614  hResoVSPtEta_->Clear();
1615  hResoVSPt_prof_->Clear();
1616  hResoVSPt_Bar_prof_->Clear();
1617  hResoVSPt_Endc_17_prof_->Clear();
1618  hResoVSPt_Endc_20_prof_->Clear();
1619  hResoVSPt_Endc_24_prof_->Clear();
1620  hResoVSPt_Ovlap_prof_->Clear();
1621  hResoVSEta_prof_->Clear();
1622  //hResoVSTheta_prof_->Clear();
1623  hResoVSPhiPlus_prof_->Clear();
1624  hResoVSPhiMinus_prof_->Clear();
1625  hResoVSPhi_prof_->Clear();
1626  }
TProfile * hResoVSPt_Endc_20_prof_
Definition: Histograms.h:1642
TProfile * hResoVSPt_Endc_17_prof_
Definition: Histograms.h:1641
TProfile * hResoVSPt_Bar_prof_
Definition: Histograms.h:1640
TProfile * hResoVSPt_prof_
Definition: Histograms.h:1639
TProfile * hResoVSPt_Ovlap_prof_
Definition: Histograms.h:1644
TProfile * hResoVSPt_Endc_24_prof_
Definition: Histograms.h:1643
TProfile * hResoVSPhi_prof_
Definition: Histograms.h:1649
TProfile * hResoVSPhiMinus_prof_
Definition: Histograms.h:1647
TProfile * hResoVSEta_prof_
Definition: Histograms.h:1645
TProfile * hResoVSPhiPlus_prof_
Definition: Histograms.h:1648
virtual void HFunctionResolution::Fill ( const reco::Particle::LorentzVector p4,
const double &  resValue,
const int  charge 
)
inlinevirtual

Reimplemented from Histograms.

Reimplemented in HFunctionResolutionVarianceCheck.

Definition at line 1532 of file Histograms.h.

Referenced by HFunctionResolutionVarianceCheck::Fill().

1532  {
1533  if( resValue != resValue ) return;
1534  hReso_->Fill(resValue);
1535 
1536  // Fill the arrays with the resolution value and count
1537  int xIndex = getXindex(p4.Pt());
1538  int yIndex = getYindex(p4.Eta());
1539  if ( 0 <= xIndex && xIndex < totBinsX_ && 0 <= yIndex && yIndex < totBinsY_ ) {
1540  resoVsPtEta_[xIndex][yIndex] += resValue;
1541  // ATTENTION: we count only for positive muons because we are considering di-muon resonances
1542  // and we use this counter to compute the mean in the end. The resoVsPtEta value is filled with each muon,
1543  // but they must be considered independently (analogous to a factor 2) so in the end we would have
1544  // to divide by N/2, that is why we only increase the counter for half the muons.
1545  // if( charge > 0 )
1546  // No more. Changing it here influences also other uses of this class. The macro FunctionTerms.cc
1547  // multiplies the terms by the 2 factor.
1548 
1549  resoCount_[xIndex][yIndex] += 1;
1550 
1551  // hResoVSPtEta->Fill(p4.Pt(), p4.Eta(), resValue);
1552  hResoVSPt_prof_->Fill(p4.Pt(),resValue);
1553  if(fabs(p4.Eta())<=0.9)
1554  hResoVSPt_Bar_prof_->Fill(p4.Pt(),resValue);
1555  else if(fabs(p4.Eta())>0.9 && fabs(p4.Eta())<=1.4 )
1556  hResoVSPt_Ovlap_prof_->Fill(p4.Pt(),resValue);
1557  else if(fabs(p4.Eta())>1.4 && fabs(p4.Eta())<=1.7 )
1558  hResoVSPt_Endc_17_prof_->Fill(p4.Pt(),resValue);
1559  else if(fabs(p4.Eta())>1.7 && fabs(p4.Eta())<=2.0 )
1560  hResoVSPt_Endc_20_prof_->Fill(p4.Pt(),resValue);
1561  else
1562  hResoVSPt_Endc_24_prof_->Fill(p4.Pt(),resValue);
1563  hResoVSEta_prof_->Fill(p4.Eta(),resValue);
1564  //hResoVSTheta_prof_->Fill(p4.Theta(),resValue);
1565  if(charge>0)
1566  hResoVSPhiPlus_prof_->Fill(p4.Phi(),resValue);
1567  else if(charge<0)
1568  hResoVSPhiMinus_prof_->Fill(p4.Phi(),resValue);
1569  hResoVSPhi_prof_->Fill(p4.Phi(),resValue);
1570  }
1571  }
int getYindex(const double &y) const
Definition: Histograms.h:1632
TProfile * hResoVSPt_Endc_20_prof_
Definition: Histograms.h:1642
TProfile * hResoVSPt_Endc_17_prof_
Definition: Histograms.h:1641
TProfile * hResoVSPt_Bar_prof_
Definition: Histograms.h:1640
double p4[4]
Definition: TauolaWrapper.h:92
TProfile * hResoVSPt_prof_
Definition: Histograms.h:1639
TProfile * hResoVSPt_Ovlap_prof_
Definition: Histograms.h:1644
TProfile * hResoVSPt_Endc_24_prof_
Definition: Histograms.h:1643
TProfile * hResoVSPhi_prof_
Definition: Histograms.h:1649
TProfile * hResoVSPhiMinus_prof_
Definition: Histograms.h:1647
int getXindex(const double &x) const
Definition: Histograms.h:1629
TProfile * hResoVSEta_prof_
Definition: Histograms.h:1645
TProfile * hResoVSPhiPlus_prof_
Definition: Histograms.h:1648
double ** resoVsPtEta_
Definition: Histograms.h:1637
int HFunctionResolution::getXindex ( const double &  x) const
inlineprotected

Definition at line 1629 of file Histograms.h.

References createfilelist::int.

int HFunctionResolution::getYindex ( const double &  y) const
inlineprotected

Definition at line 1632 of file Histograms.h.

References createfilelist::int.

virtual void HFunctionResolution::Write ( )
inlinevirtual

Implements Histograms.

Reimplemented in HFunctionResolutionVarianceCheck.

Definition at line 1573 of file Histograms.h.

References svgfig::canvas(), Histograms::histoDir_, mps_fire::i, N, and Histograms::outputFile_.

Referenced by HFunctionResolutionVarianceCheck::Write().

1573  {
1574  if(histoDir_ != 0) histoDir_->cd();
1575 
1576  hReso_->Write();
1577 
1578  for( int i=0; i<totBinsX_; ++i ) {
1579  for( int j=0; j<totBinsY_; ++j ) {
1580  int N = resoCount_[i][j];
1581  // Fill with the mean value
1582  if( N != 0 ) hResoVSPtEta_->SetBinContent( i+1, j+1, resoVsPtEta_[i][j]/N );
1583  else hResoVSPtEta_->SetBinContent( i+1, j+1, 0 );
1584  }
1585  }
1586  hResoVSPtEta_->Write();
1587 
1588  hResoVSPt_prof_->Write();
1589  hResoVSPt_Bar_prof_->Write();
1590  hResoVSPt_Endc_17_prof_->Write();
1591  hResoVSPt_Endc_20_prof_->Write();
1592  hResoVSPt_Endc_24_prof_->Write();
1593  hResoVSPt_Ovlap_prof_->Write();
1594  hResoVSEta_prof_->Write();
1595  //hResoVSTheta_prof_->Write();
1596  hResoVSPhiMinus_prof_->Write();
1597  hResoVSPhiPlus_prof_->Write();
1598  hResoVSPhi_prof_->Write();
1599 
1600  TCanvas canvas(TString(hResoVSPtEta_->GetName())+"_canvas", TString(hResoVSPtEta_->GetTitle())+" canvas", 1000, 800);
1601  canvas.Divide(2);
1602  canvas.cd(1);
1603  hResoVSPtEta_->Draw("lego");
1604  canvas.cd(2);
1605  hResoVSPtEta_->Draw("surf5");
1606  canvas.Write();
1607  hResoVSPtEta_->Write();
1608 
1609  outputFile_->cd();
1610  }
TFile * outputFile_
Definition: Histograms.h:123
TProfile * hResoVSPt_Endc_20_prof_
Definition: Histograms.h:1642
TProfile * hResoVSPt_Endc_17_prof_
Definition: Histograms.h:1641
TProfile * hResoVSPt_Bar_prof_
Definition: Histograms.h:1640
TProfile * hResoVSPt_prof_
Definition: Histograms.h:1639
TDirectory * histoDir_
Definition: Histograms.h:124
TProfile * hResoVSPt_Ovlap_prof_
Definition: Histograms.h:1644
TProfile * hResoVSPt_Endc_24_prof_
Definition: Histograms.h:1643
TProfile * hResoVSPhi_prof_
Definition: Histograms.h:1649
#define N
Definition: blowfish.cc:9
TProfile * hResoVSPhiMinus_prof_
Definition: Histograms.h:1647
TProfile * hResoVSEta_prof_
Definition: Histograms.h:1645
def canvas(sub, attr)
Definition: svgfig.py:481
TProfile * hResoVSPhiPlus_prof_
Definition: Histograms.h:1648
double ** resoVsPtEta_
Definition: Histograms.h:1637

Member Data Documentation

double HFunctionResolution::deltaX_
protected

Definition at line 1652 of file Histograms.h.

double HFunctionResolution::deltaY_
protected

Definition at line 1652 of file Histograms.h.

TH1F* HFunctionResolution::hReso_
protected

Definition at line 1635 of file Histograms.h.

TProfile* HFunctionResolution::hResoVSEta_prof_
protected

Definition at line 1645 of file Histograms.h.

TProfile* HFunctionResolution::hResoVSPhi_prof_
protected

Definition at line 1649 of file Histograms.h.

TProfile* HFunctionResolution::hResoVSPhiMinus_prof_
protected

Definition at line 1647 of file Histograms.h.

TProfile* HFunctionResolution::hResoVSPhiPlus_prof_
protected

Definition at line 1648 of file Histograms.h.

TProfile* HFunctionResolution::hResoVSPt_Bar_prof_
protected

Definition at line 1640 of file Histograms.h.

TProfile* HFunctionResolution::hResoVSPt_Endc_17_prof_
protected

Definition at line 1641 of file Histograms.h.

TProfile* HFunctionResolution::hResoVSPt_Endc_20_prof_
protected

Definition at line 1642 of file Histograms.h.

TProfile* HFunctionResolution::hResoVSPt_Endc_24_prof_
protected

Definition at line 1643 of file Histograms.h.

TProfile* HFunctionResolution::hResoVSPt_Ovlap_prof_
protected

Definition at line 1644 of file Histograms.h.

TProfile* HFunctionResolution::hResoVSPt_prof_
protected

Definition at line 1639 of file Histograms.h.

TH2F* HFunctionResolution::hResoVSPtEta_
protected

Definition at line 1636 of file Histograms.h.

int** HFunctionResolution::resoCount_
protected

Definition at line 1638 of file Histograms.h.

double** HFunctionResolution::resoVsPtEta_
protected

Definition at line 1637 of file Histograms.h.

int HFunctionResolution::totBinsX_
protected

Definition at line 1650 of file Histograms.h.

int HFunctionResolution::totBinsY_
protected

Definition at line 1650 of file Histograms.h.

double HFunctionResolution::xMin_
protected

Definition at line 1651 of file Histograms.h.

double HFunctionResolution::yMin_
protected

Definition at line 1651 of file Histograms.h.