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 (const TString &inputFileName, const TString &name)
 Constructor reading the histograms from file. More...
 
 HCovarianceVSParts (TFile *outputFile, const TString &name, const double &ptMax)
 
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 2086 of file Histograms.h.

Constructor & Destructor Documentation

◆ HCovarianceVSParts() [1/2]

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

Definition at line 2088 of file Histograms.h.

2088  : Histograms(outputFile, name) {
2089  int totBinsX = 40;
2090  int totBinsY = 40;
2091  double etaMin = -3.;
2092  double etaMax = 3.;
2093  double ptMin = 0.;
2094 
2095  readMode_ = false;
2096 
2097  // Variances
2098  mapHisto_[name + "Pt"] =
2099  new HCovarianceVSxy(name + "Pt_", "Pt", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_, true);
2100  mapHisto_[name + "CotgTheta"] = new HCovarianceVSxy(
2101  name + "CotgTheta_", "CotgTheta", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_, true);
2102  mapHisto_[name + "Phi"] =
2103  new HCovarianceVSxy(name + "Phi_", "Phi", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_, true);
2104  // Covariances
2105  mapHisto_[name + "Pt-CotgTheta"] = new HCovarianceVSxy(
2106  name + "Pt_CotgTheta_", "Pt-CotgTheta", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
2107  mapHisto_[name + "Pt-Phi"] =
2108  new HCovarianceVSxy(name + "Pt_Phi_", "Pt-Phi", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
2109  mapHisto_[name + "CotgTheta-Phi"] = new HCovarianceVSxy(
2110  name + "CotgTheta_Phi_", "CotgTheta-Phi", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
2111  mapHisto_[name + "Pt1-Pt2"] =
2112  new HCovarianceVSxy(name + "Pt1_Pt2_", "Pt1-Pt2", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
2113  mapHisto_[name + "CotgTheta1-CotgTheta2"] = new HCovarianceVSxy(name + "CotgTheta1_CotgTheta2_",
2114  "CotgTheta1-CotgTheta2",
2115  totBinsX,
2116  ptMin,
2117  ptMax,
2118  totBinsY,
2119  etaMin,
2120  etaMax,
2121  histoDir_);
2122  mapHisto_[name + "Phi1-Phi2"] = new HCovarianceVSxy(
2123  name + "Phi1_Phi2_", "Phi1-Phi2", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
2124  mapHisto_[name + "Pt12-CotgTheta21"] = new HCovarianceVSxy(
2125  name + "Pt12_CotgTheta21_", "Pt12-CotgTheta21", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
2126  mapHisto_[name + "Pt12-Phi21"] = new HCovarianceVSxy(
2127  name + "Pt12_Phi21_", "Pt12-Phi21", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
2128  mapHisto_[name + "CotgTheta12-Phi21"] = new HCovarianceVSxy(
2129  name + "CotgTheta12_Phi21_", "CotgTheta12-Phi21", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
2130  }

References ALCARECOTkAlBeamHalo_cff::etaMax, ALCARECOTkAlBeamHalo_cff::etaMin, mapHisto_, Skims_PA_cff::name, AlignmentTrackSelector_cfi::ptMax, ptMin, and readMode_.

◆ HCovarianceVSParts() [2/2]

HCovarianceVSParts::HCovarianceVSParts ( const TString &  inputFileName,
const TString &  name 
)
inline

Constructor reading the histograms from file.

Definition at line 2133 of file Histograms.h.

2133  {
2134  name_ = name;
2135  TFile* inputFile = new TFile(inputFileName, "READ");
2136  readMode_ = true;
2137 
2138  // Variances
2139  mapHisto_[name_ + "Pt"] = new HCovarianceVSxy(inputFile, name_ + "Pt_" + name_, name_);
2140  mapHisto_[name_ + "CotgTheta"] = new HCovarianceVSxy(inputFile, name_ + "CotgTheta_" + name_, name_);
2141  mapHisto_[name_ + "Phi"] = new HCovarianceVSxy(inputFile, name_ + "Phi_" + name_, name_);
2142  // Covariances
2143  mapHisto_[name_ + "Pt-CotgTheta"] = new HCovarianceVSxy(inputFile, name_ + "Pt_CotgTheta_" + name_, name_);
2144  mapHisto_[name_ + "Pt-Phi"] = new HCovarianceVSxy(inputFile, name_ + "Pt_Phi_" + name_, name_);
2145  mapHisto_[name_ + "CotgTheta-Phi"] = new HCovarianceVSxy(inputFile, name_ + "CotgTheta_Phi_" + name_, name_);
2146  mapHisto_[name_ + "Pt1-Pt2"] = new HCovarianceVSxy(inputFile, name_ + "Pt1_Pt2_" + name_, name_);
2147  mapHisto_[name_ + "CotgTheta1-CotgTheta2"] =
2148  new HCovarianceVSxy(inputFile, name_ + "CotgTheta1_CotgTheta2_" + name_, name_);
2149  mapHisto_[name_ + "Phi1-Phi2"] = new HCovarianceVSxy(inputFile, name_ + "Phi1_Phi2_" + name_, name_);
2150  mapHisto_[name_ + "Pt12-CotgTheta21"] = new HCovarianceVSxy(inputFile, name_ + "Pt12_CotgTheta21_" + name_, name_);
2151  mapHisto_[name_ + "Pt12-Phi21"] = new HCovarianceVSxy(inputFile, name_ + "Pt12_Phi21_" + name_, name_);
2152  mapHisto_[name_ + "CotgTheta12-Phi21"] =
2153  new HCovarianceVSxy(inputFile, name_ + "CotgTheta12_Phi21_" + name_, name_);
2154  }

References dtResolutionTest_cfi::inputFile, InefficientDoubleROC::inputFileName, mapHisto_, Skims_PA_cff::name, and readMode_.

◆ ~HCovarianceVSParts()

HCovarianceVSParts::~HCovarianceVSParts ( )
inlineoverride

Definition at line 2156 of file Histograms.h.

2156  {
2157  for (std::map<TString, HCovarianceVSxy*>::const_iterator histo = mapHisto_.begin(); histo != mapHisto_.end();
2158  histo++) {
2159  delete (*histo).second;
2160  }
2161  }

References timingPdfMaker::histo, and mapHisto_.

Member Function Documentation

◆ Clear()

void HCovarianceVSParts::Clear ( )
inlineoverride

Definition at line 2244 of file Histograms.h.

2244  {
2245  for (std::map<TString, HCovarianceVSxy*>::const_iterator histo = mapHisto_.begin(); histo != mapHisto_.end();
2246  histo++) {
2247  (*histo).second->Clear();
2248  }
2249  }

References timingPdfMaker::histo, and mapHisto_.

◆ Fill()

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

2170  {
2171  double pt1 = recoP1.pt();
2172  double eta1 = recoP1.eta();
2173  double pt2 = recoP2.pt();
2174  double eta2 = recoP2.eta();
2175 
2176  double diffPt1 = (pt1 - genP1.pt()) / genP1.pt();
2177  double diffPt2 = (pt2 - genP2.pt()) / genP2.pt();
2178 
2179  double genTheta1 = genP1.theta();
2180  double genTheta2 = genP2.theta();
2181  double recoTheta1 = recoP1.theta();
2182  double recoTheta2 = recoP2.theta();
2183 
2184  double genCotgTheta1 = TMath::Cos(genTheta1) / (TMath::Sin(genTheta1));
2185  double genCotgTheta2 = TMath::Cos(genTheta2) / (TMath::Sin(genTheta2));
2186  double recoCotgTheta1 = TMath::Cos(recoTheta1) / (TMath::Sin(recoTheta1));
2187  double recoCotgTheta2 = TMath::Cos(recoTheta2) / (TMath::Sin(recoTheta2));
2188 
2189  // double diffCotgTheta1 = (recoCotgTheta1 - genCotgTheta1)/genCotgTheta1;
2190  // double diffCotgTheta2 = (recoCotgTheta2 - genCotgTheta2)/genCotgTheta2;
2191  double diffCotgTheta1 = recoCotgTheta1 - genCotgTheta1;
2192  double diffCotgTheta2 = recoCotgTheta2 - genCotgTheta2;
2193 
2194  // double diffPhi1 = (recoP1.phi() - genP1.phi())/genP1.phi();
2195  // double diffPhi2 = (recoP2.phi() - genP2.phi())/genP2.phi();
2196  double diffPhi1 = MuScleFitUtils::deltaPhiNoFabs(recoP1.phi(), genP1.phi());
2197  double diffPhi2 = MuScleFitUtils::deltaPhiNoFabs(recoP2.phi(), genP2.phi());
2198 
2199  // Fill the variances
2200  mapHisto_[name_ + "Pt"]->Fill(pt1, eta1, diffPt1, diffPt1);
2201  mapHisto_[name_ + "Pt"]->Fill(pt2, eta2, diffPt2, diffPt2);
2202  mapHisto_[name_ + "CotgTheta"]->Fill(pt1, eta1, diffCotgTheta1, diffCotgTheta1);
2203  mapHisto_[name_ + "CotgTheta"]->Fill(pt2, eta2, diffCotgTheta2, diffCotgTheta2);
2204  mapHisto_[name_ + "Phi"]->Fill(pt1, eta1, diffPhi1, diffPhi1);
2205  mapHisto_[name_ + "Phi"]->Fill(pt2, eta2, diffPhi2, diffPhi2);
2206 
2207  // Fill these histograms with both muons
2208  mapHisto_[name_ + "Pt-CotgTheta"]->Fill(pt1, eta1, diffPt1, diffCotgTheta1);
2209  mapHisto_[name_ + "Pt-CotgTheta"]->Fill(pt2, eta2, diffPt2, diffCotgTheta2);
2210  mapHisto_[name_ + "Pt-Phi"]->Fill(pt1, eta1, diffPt1, diffPhi1);
2211  mapHisto_[name_ + "Pt-Phi"]->Fill(pt2, eta2, diffPt2, diffPhi2);
2212  mapHisto_[name_ + "CotgTheta-Phi"]->Fill(pt1, eta1, diffCotgTheta1, diffPhi1);
2213  mapHisto_[name_ + "CotgTheta-Phi"]->Fill(pt2, eta2, diffCotgTheta2, diffPhi2);
2214 
2215  // We fill two (pt, eta) bins for each pair of values. The bin of the
2216  // first and of the second muon. This should take account for the
2217  // assumed symmetry between the exchange of the first with the second muon.
2218  mapHisto_[name_ + "Pt1-Pt2"]->Fill(pt1, eta1, diffPt1, diffPt2);
2219  mapHisto_[name_ + "Pt1-Pt2"]->Fill(pt2, eta2, diffPt1, diffPt2);
2220  mapHisto_[name_ + "CotgTheta1-CotgTheta2"]->Fill(pt1, eta1, diffCotgTheta1, diffCotgTheta2);
2221  mapHisto_[name_ + "CotgTheta1-CotgTheta2"]->Fill(pt2, eta2, diffCotgTheta1, diffCotgTheta2);
2222  mapHisto_[name_ + "Phi1-Phi2"]->Fill(pt1, eta1, diffPhi1, diffPhi2);
2223  mapHisto_[name_ + "Phi1-Phi2"]->Fill(pt2, eta2, diffPhi1, diffPhi2);
2224 
2225  // Fill the following histograms again for each muon (pt, eta) bin. Same
2226  // reason as in the previous case. If the symmetry is true, it does not
2227  // make any difference the order by which we fill the pt and cotgTheta combinations.
2228  mapHisto_[name_ + "Pt12-CotgTheta21"]->Fill(pt1, eta1, diffPt1, diffCotgTheta2);
2229  mapHisto_[name_ + "Pt12-CotgTheta21"]->Fill(pt2, eta2, diffPt2, diffCotgTheta1);
2230  mapHisto_[name_ + "Pt12-Phi21"]->Fill(pt1, eta1, diffPt1, diffPhi2);
2231  mapHisto_[name_ + "Pt12-Phi21"]->Fill(pt2, eta2, diffPt2, diffPhi1);
2232  mapHisto_[name_ + "CotgTheta12-Phi21"]->Fill(pt1, eta1, diffCotgTheta1, diffPhi2);
2233  mapHisto_[name_ + "CotgTheta12-Phi21"]->Fill(pt2, eta2, diffCotgTheta2, diffPhi1);
2234  }

References MuScleFitUtils::deltaPhiNoFabs(), HLT_2018_cff::eta1, HLT_2018_cff::eta2, mapHisto_, HLT_2018_cff::pt1, and HLT_2018_cff::pt2.

◆ Get()

double HCovarianceVSParts::Get ( const reco::Particle::LorentzVector recoP1,
const TString &  covarianceName 
)
inlineoverride

Definition at line 2163 of file Histograms.h.

2163  {
2164  return mapHisto_[name_ + covarianceName]->Get(recoP1.pt(), recoP1.eta());
2165  }

References mapHisto_.

◆ Write()

void HCovarianceVSParts::Write ( )
inlineoverride

Definition at line 2235 of file Histograms.h.

2235  {
2236  if (!readMode_) {
2237  histoDir_->cd();
2238  for (std::map<TString, HCovarianceVSxy*>::const_iterator histo = mapHisto_.begin(); histo != mapHisto_.end();
2239  histo++) {
2240  (*histo).second->Write();
2241  }
2242  }
2243  }

References timingPdfMaker::histo, mapHisto_, and readMode_.

Member Data Documentation

◆ mapHisto_

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

Definition at line 2252 of file Histograms.h.

Referenced by Clear(), Fill(), Get(), HCovarianceVSParts(), Write(), and ~HCovarianceVSParts().

◆ readMode_

bool HCovarianceVSParts::readMode_
protected

Definition at line 2253 of file Histograms.h.

Referenced by HCovarianceVSParts(), and Write().

HCovarianceVSParts::readMode_
bool readMode_
Definition: Histograms.h:2253
MuScleFitUtils::deltaPhiNoFabs
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...
Definition: MuScleFitUtils.h:118
ALCARECOTkAlBeamHalo_cff.etaMin
etaMin
GeV.
Definition: ALCARECOTkAlBeamHalo_cff.py:32
HLT_2018_cff.pt2
pt2
Definition: HLT_2018_cff.py:8552
HLT_2018_cff.eta1
eta1
Definition: HLT_2018_cff.py:8220
ptMin
constexpr float ptMin
Definition: PhotonIDValueMapProducer.cc:153
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
HLT_2018_cff.pt1
pt1
Definition: HLT_2018_cff.py:8550
HCovarianceVSxy
Definition: Histograms.h:1906
download_sqlite_cfg.outputFile
outputFile
Definition: download_sqlite_cfg.py:5
AlignmentTrackSelector_cfi.ptMax
ptMax
Definition: AlignmentTrackSelector_cfi.py:12
InefficientDoubleROC.inputFileName
inputFileName
Definition: InefficientDoubleROC.py:437
HLT_2018_cff.eta2
eta2
Definition: HLT_2018_cff.py:8221
dtResolutionTest_cfi.inputFile
inputFile
Definition: dtResolutionTest_cfi.py:14
ALCARECOTkAlBeamHalo_cff.etaMax
etaMax
Definition: ALCARECOTkAlBeamHalo_cff.py:33
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
HCovarianceVSParts::mapHisto_
std::map< TString, HCovarianceVSxy * > mapHisto_
Definition: Histograms.h:2252