CMS 3D CMS Logo

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

#include <Histograms.h>

Inherits Histograms.

Public Member Functions

void Clear () override
 
void Fill (const reco::Particle::LorentzVector &recoP1, const reco::Particle::LorentzVector &genP1, const reco::Particle::LorentzVector &recoP2, const reco::Particle::LorentzVector &genP2) override
 
double Get (const reco::Particle::LorentzVector &recoP1, const TString &covarianceName) override
 
 HCovarianceVSParts (TFile *outputFile, const TString &name, const double &ptMax)
 
 HCovarianceVSParts (const TString &inputFileName, const TString &name)
 Constructor reading the histograms from file. More...
 
void Write () override
 
 ~HCovarianceVSParts () override
 

Protected Attributes

std::map< TString, HCovarianceVSxy * > mapHisto_
 
bool readMode_
 

Detailed Description

This class uses the HCovariance histograms to compute the covariances between the two input muons kinematic quantities. The covariances are computed against pt and eta.

Definition at line 1985 of file Histograms.h.

Constructor & Destructor Documentation

HCovarianceVSParts::HCovarianceVSParts ( TFile *  outputFile,
const TString &  name,
const double &  ptMax 
)
inline

Definition at line 1988 of file Histograms.h.

References ALCARECOTkAlBeamHalo_cff::etaMax, ALCARECOTkAlBeamHalo_cff::etaMin, and ptMin.

1988  : Histograms( outputFile, name ) {
1989  int totBinsX = 40;
1990  int totBinsY = 40;
1991  double etaMin = -3.;
1992  double etaMax = 3.;
1993  double ptMin = 0.;
1994 
1995  readMode_ = false;
1996 
1997  // Variances
1998  mapHisto_[name+"Pt"] = new HCovarianceVSxy(name+"Pt_", "Pt", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_, true);
1999  mapHisto_[name+"CotgTheta"] = new HCovarianceVSxy(name+"CotgTheta_", "CotgTheta", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_, true);
2000  mapHisto_[name+"Phi"] = new HCovarianceVSxy(name+"Phi_", "Phi", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_, true);
2001  // Covariances
2002  mapHisto_[name+"Pt-CotgTheta"] = new HCovarianceVSxy(name+"Pt_CotgTheta_", "Pt-CotgTheta", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
2003  mapHisto_[name+"Pt-Phi"] = new HCovarianceVSxy(name+"Pt_Phi_", "Pt-Phi", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
2004  mapHisto_[name+"CotgTheta-Phi"] = new HCovarianceVSxy(name+"CotgTheta_Phi_", "CotgTheta-Phi", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
2005  mapHisto_[name+"Pt1-Pt2"] = new HCovarianceVSxy(name+"Pt1_Pt2_", "Pt1-Pt2", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
2006  mapHisto_[name+"CotgTheta1-CotgTheta2"] = new HCovarianceVSxy(name+"CotgTheta1_CotgTheta2_", "CotgTheta1-CotgTheta2", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
2007  mapHisto_[name+"Phi1-Phi2"] = new HCovarianceVSxy(name+"Phi1_Phi2_", "Phi1-Phi2", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
2008  mapHisto_[name+"Pt12-CotgTheta21"] = new HCovarianceVSxy(name+"Pt12_CotgTheta21_", "Pt12-CotgTheta21", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
2009  mapHisto_[name+"Pt12-Phi21"] = new HCovarianceVSxy(name+"Pt12_Phi21_", "Pt12-Phi21", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
2010  mapHisto_[name+"CotgTheta12-Phi21"] = new HCovarianceVSxy(name+"CotgTheta12_Phi21_", "CotgTheta12-Phi21", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
2011  }
std::map< TString, HCovarianceVSxy * > mapHisto_
Definition: Histograms.h:2132
HCovarianceVSParts::HCovarianceVSParts ( const TString &  inputFileName,
const TString &  name 
)
inline

Constructor reading the histograms from file.

Definition at line 2014 of file Histograms.h.

References analyzePatCleaning_cfg::inputFile, and dataset::name.

2015  {
2016  name_ = name;
2017  TFile * inputFile = new TFile(inputFileName, "READ");
2018  readMode_ = true;
2019 
2020  // Variances
2021  mapHisto_[name_+"Pt"] = new HCovarianceVSxy(inputFile, name_+"Pt_"+name_, name_);
2022  mapHisto_[name_+"CotgTheta"] = new HCovarianceVSxy(inputFile, name_+"CotgTheta_"+name_, name_);
2023  mapHisto_[name_+"Phi"] = new HCovarianceVSxy(inputFile, name_+"Phi_"+name_, name_);
2024  // Covariances
2025  mapHisto_[name_+"Pt-CotgTheta"] = new HCovarianceVSxy(inputFile, name_+"Pt_CotgTheta_"+name_, name_);
2026  mapHisto_[name_+"Pt-Phi"] = new HCovarianceVSxy(inputFile, name_+"Pt_Phi_"+name_, name_);
2027  mapHisto_[name_+"CotgTheta-Phi"] = new HCovarianceVSxy(inputFile, name_+"CotgTheta_Phi_"+name_, name_);
2028  mapHisto_[name_+"Pt1-Pt2"] = new HCovarianceVSxy(inputFile, name_+"Pt1_Pt2_"+name_, name_);
2029  mapHisto_[name_+"CotgTheta1-CotgTheta2"] = new HCovarianceVSxy(inputFile, name_+"CotgTheta1_CotgTheta2_"+name_, name_);
2030  mapHisto_[name_+"Phi1-Phi2"] = new HCovarianceVSxy(inputFile, name_+"Phi1_Phi2_"+name_, name_);
2031  mapHisto_[name_+"Pt12-CotgTheta21"] = new HCovarianceVSxy(inputFile, name_+"Pt12_CotgTheta21_"+name_, name_);
2032  mapHisto_[name_+"Pt12-Phi21"] = new HCovarianceVSxy(inputFile, name_+"Pt12_Phi21_"+name_, name_);
2033  mapHisto_[name_+"CotgTheta12-Phi21"] = new HCovarianceVSxy(inputFile, name_+"CotgTheta12_Phi21_"+name_, name_);
2034  }
std::map< TString, HCovarianceVSxy * > mapHisto_
Definition: Histograms.h:2132
HCovarianceVSParts::~HCovarianceVSParts ( )
inlineoverride

Definition at line 2036 of file Histograms.h.

References trackerHits::histo.

2036  {
2037  for (std::map<TString, HCovarianceVSxy*>::const_iterator histo=mapHisto_.begin();
2038  histo!=mapHisto_.end(); histo++) {
2039  delete (*histo).second;
2040  }
2041  }
std::map< TString, HCovarianceVSxy * > mapHisto_
Definition: Histograms.h:2132

Member Function Documentation

void HCovarianceVSParts::Clear ( )
inlineoverride

Definition at line 2125 of file Histograms.h.

References trackerHits::histo.

2125  {
2126  for (std::map<TString, HCovarianceVSxy*>::const_iterator histo=mapHisto_.begin();
2127  histo!=mapHisto_.end(); histo++) {
2128  (*histo).second->Clear();
2129  }
2130  }
std::map< TString, HCovarianceVSxy * > mapHisto_
Definition: Histograms.h:2132
void HCovarianceVSParts::Fill ( const reco::Particle::LorentzVector recoP1,
const reco::Particle::LorentzVector genP1,
const reco::Particle::LorentzVector recoP2,
const reco::Particle::LorentzVector genP2 
)
inlineoverride

Definition at line 2047 of file Histograms.h.

References MuScleFitUtils::deltaPhiNoFabs(), hiDetachedQuadStep_cff::pt1, and hiDetachedQuadStep_cff::pt2.

2050  {
2051 
2052  double pt1 = recoP1.pt();
2053  double eta1 = recoP1.eta();
2054  double pt2 = recoP2.pt();
2055  double eta2 = recoP2.eta();
2056 
2057  double diffPt1 = (pt1 - genP1.pt())/genP1.pt();
2058  double diffPt2 = (pt2 - genP2.pt())/genP2.pt();
2059 
2060  double genTheta1 = genP1.theta();
2061  double genTheta2 = genP2.theta();
2062  double recoTheta1 = recoP1.theta();
2063  double recoTheta2 = recoP2.theta();
2064 
2065  double genCotgTheta1 = TMath::Cos(genTheta1)/(TMath::Sin(genTheta1));
2066  double genCotgTheta2 = TMath::Cos(genTheta2)/(TMath::Sin(genTheta2));
2067  double recoCotgTheta1 = TMath::Cos(recoTheta1)/(TMath::Sin(recoTheta1));
2068  double recoCotgTheta2 = TMath::Cos(recoTheta2)/(TMath::Sin(recoTheta2));
2069 
2070  // double diffCotgTheta1 = (recoCotgTheta1 - genCotgTheta1)/genCotgTheta1;
2071  // double diffCotgTheta2 = (recoCotgTheta2 - genCotgTheta2)/genCotgTheta2;
2072  double diffCotgTheta1 = recoCotgTheta1 - genCotgTheta1;
2073  double diffCotgTheta2 = recoCotgTheta2 - genCotgTheta2;
2074 
2075  // double diffPhi1 = (recoP1.phi() - genP1.phi())/genP1.phi();
2076  // double diffPhi2 = (recoP2.phi() - genP2.phi())/genP2.phi();
2077  double diffPhi1 = MuScleFitUtils::deltaPhiNoFabs(recoP1.phi(), genP1.phi());
2078  double diffPhi2 = MuScleFitUtils::deltaPhiNoFabs(recoP2.phi(), genP2.phi());
2079 
2080  // Fill the variances
2081  mapHisto_[name_+"Pt"]->Fill(pt1, eta1, diffPt1, diffPt1);
2082  mapHisto_[name_+"Pt"]->Fill(pt2, eta2, diffPt2, diffPt2);
2083  mapHisto_[name_+"CotgTheta"]->Fill(pt1, eta1, diffCotgTheta1, diffCotgTheta1);
2084  mapHisto_[name_+"CotgTheta"]->Fill(pt2, eta2, diffCotgTheta2, diffCotgTheta2);
2085  mapHisto_[name_+"Phi"]->Fill(pt1, eta1, diffPhi1, diffPhi1);
2086  mapHisto_[name_+"Phi"]->Fill(pt2, eta2, diffPhi2, diffPhi2);
2087 
2088  // Fill these histograms with both muons
2089  mapHisto_[name_+"Pt-CotgTheta"]->Fill(pt1, eta1, diffPt1, diffCotgTheta1 );
2090  mapHisto_[name_+"Pt-CotgTheta"]->Fill(pt2, eta2, diffPt2, diffCotgTheta2 );
2091  mapHisto_[name_+"Pt-Phi"]->Fill(pt1, eta1, diffPt1, diffPhi1);
2092  mapHisto_[name_+"Pt-Phi"]->Fill(pt2, eta2, diffPt2, diffPhi2);
2093  mapHisto_[name_+"CotgTheta-Phi"]->Fill(pt1, eta1, diffCotgTheta1, diffPhi1);
2094  mapHisto_[name_+"CotgTheta-Phi"]->Fill(pt2, eta2, diffCotgTheta2, diffPhi2);
2095 
2096  // We fill two (pt, eta) bins for each pair of values. The bin of the
2097  // first and of the second muon. This should take account for the
2098  // assumed symmetry between the exchange of the first with the second muon.
2099  mapHisto_[name_+"Pt1-Pt2"]->Fill(pt1, eta1, diffPt1, diffPt2);
2100  mapHisto_[name_+"Pt1-Pt2"]->Fill(pt2, eta2, diffPt1, diffPt2);
2101  mapHisto_[name_+"CotgTheta1-CotgTheta2"]->Fill(pt1, eta1, diffCotgTheta1, diffCotgTheta2);
2102  mapHisto_[name_+"CotgTheta1-CotgTheta2"]->Fill(pt2, eta2, diffCotgTheta1, diffCotgTheta2);
2103  mapHisto_[name_+"Phi1-Phi2"]->Fill(pt1, eta1, diffPhi1, diffPhi2);
2104  mapHisto_[name_+"Phi1-Phi2"]->Fill(pt2, eta2, diffPhi1, diffPhi2);
2105 
2106  // Fill the following histograms again for each muon (pt, eta) bin. Same
2107  // reason as in the previous case. If the symmetry is true, it does not
2108  // make any difference the order by which we fill the pt and cotgTheta combinations.
2109  mapHisto_[name_+"Pt12-CotgTheta21"]->Fill(pt1, eta1, diffPt1, diffCotgTheta2);
2110  mapHisto_[name_+"Pt12-CotgTheta21"]->Fill(pt2, eta2, diffPt2, diffCotgTheta1);
2111  mapHisto_[name_+"Pt12-Phi21"]->Fill(pt1, eta1, diffPt1, diffPhi2);
2112  mapHisto_[name_+"Pt12-Phi21"]->Fill(pt2, eta2, diffPt2, diffPhi1);
2113  mapHisto_[name_+"CotgTheta12-Phi21"]->Fill(pt1, eta1, diffCotgTheta1, diffPhi2);
2114  mapHisto_[name_+"CotgTheta12-Phi21"]->Fill(pt2, eta2, diffCotgTheta2, diffPhi1);
2115  }
static double deltaPhiNoFabs(const double &phi1, const double &phi2)
Without fabs at the end, used to have a symmetric distribution for the resolution fits and variance c...
std::map< TString, HCovarianceVSxy * > mapHisto_
Definition: Histograms.h:2132
double HCovarianceVSParts::Get ( const reco::Particle::LorentzVector recoP1,
const TString &  covarianceName 
)
inlineoverride

Definition at line 2043 of file Histograms.h.

2043  {
2044  return mapHisto_[name_+covarianceName]->Get(recoP1.pt(), recoP1.eta());
2045  }
std::map< TString, HCovarianceVSxy * > mapHisto_
Definition: Histograms.h:2132
void HCovarianceVSParts::Write ( )
inlineoverride

Definition at line 2116 of file Histograms.h.

References trackerHits::histo.

2116  {
2117  if( !readMode_ ) {
2118  histoDir_->cd();
2119  for (std::map<TString, HCovarianceVSxy*>::const_iterator histo=mapHisto_.begin();
2120  histo!=mapHisto_.end(); histo++) {
2121  (*histo).second->Write();
2122  }
2123  }
2124  }
std::map< TString, HCovarianceVSxy * > mapHisto_
Definition: Histograms.h:2132

Member Data Documentation

std::map<TString, HCovarianceVSxy*> HCovarianceVSParts::mapHisto_
protected

Definition at line 2132 of file Histograms.h.

bool HCovarianceVSParts::readMode_
protected

Definition at line 2133 of file Histograms.h.