CMS 3D CMS Logo

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

#include <Histograms.h>

Inherits Histograms.

Public Member Functions

void Clear () override
 
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) override
 
void Fill (const reco::Particle::LorentzVector &recoP1, const int charge1, const reco::Particle::LorentzVector &recoP2, const int charge2, const double &recoMass, const double &genMass) override
 
 HMassResolutionVSPart (TFile *outputFile, const TString &name)
 
void Write () override
 
 ~HMassResolutionVSPart () override
 

Protected Attributes

std::map< TString, TH1 * > mapHisto_
 
std::unique_ptr< HDeltamuMinus
 
std::unique_ptr< HDeltamuPlus
 
TString nameSuffix_ [2]
 

Detailed Description

A set of histograms for resolution. The fill method requires the two selected muons, their charges and the reconstructed and generated masses. It evaluates the resolution on the mass vs: Pt of the pair DeltaEta of the pair DeltaPhi of the pair pt, eta and phi of the plus and minus muon separately

Definition at line 2267 of file Histograms.h.

Constructor & Destructor Documentation

◆ HMassResolutionVSPart()

HMassResolutionVSPart::HMassResolutionVSPart ( TFile *  outputFile,
const TString &  name 
)
inline

Definition at line 2269 of file Histograms.h.

2269  : Histograms(outputFile, name) {
2270  // Kinematical variables
2271  nameSuffix_[0] = "Plus";
2272  nameSuffix_[1] = "Minus";
2273  TString titleSuffix[] = {" for mu+", " for mu-"};
2274 
2275  mapHisto_[name] = new TH1F(name, "#Delta M/M", 4000, -1, 1);
2276  mapHisto_[name + "VSPairPt"] =
2277  new HResolution(name + "VSPairPt", "resolution VS pt of the pair", 100, 0, 200, -1, 1, histoDir_);
2278  mapHisto_[name + "VSPairDeltaEta"] = new HResolution(
2279  name + "VSPairDeltaEta", "resolution VS #Delta#eta of the pair", 100, -0.1, 6.2, -1, 1, histoDir_);
2280  mapHisto_[name + "VSPairDeltaPhi"] = new HResolution(
2281  name + "VSPairDeltaPhi", "resolution VS #Delta#phi of the pair", 100, -0.1, 3.2, -1, 1, histoDir_);
2282 
2283  for (int i = 0; i < 2; ++i) {
2284  mapHisto_[name + "VSPt" + nameSuffix_[i]] = new HResolution(
2285  name + "VSPt" + nameSuffix_[i], "resolution VS pt" + titleSuffix[i], 100, 0, 200, -1, 1, histoDir_);
2286  mapHisto_[name + "VSEta" + nameSuffix_[i]] = new HResolution(
2287  name + "VSEta" + nameSuffix_[i], "resolution VS #eta" + titleSuffix[i], 100, -3, 3, -1, 1, histoDir_);
2288  mapHisto_[name + "VSPhi" + nameSuffix_[i]] = new HResolution(
2289  name + "VSPhi" + nameSuffix_[i], "resolution VS #phi" + titleSuffix[i], 100, -3.2, 3.2, -1, 1, histoDir_);
2290  }
2291 
2292  // single particles histograms
2293  muMinus = std::make_unique<HDelta>("muMinus");
2294  muPlus = std::make_unique<HDelta>("muPlus");
2295  }

References mps_fire::i, mapHisto_, muMinus, muPlus, Skims_PA_cff::name, and nameSuffix_.

◆ ~HMassResolutionVSPart()

HMassResolutionVSPart::~HMassResolutionVSPart ( )
inlineoverride

Definition at line 2297 of file Histograms.h.

2297  {
2298  for (std::map<TString, TH1*>::const_iterator histo = mapHisto_.begin(); histo != mapHisto_.end(); histo++) {
2299  delete (*histo).second;
2300  }
2301  }

References timingPdfMaker::histo, and mapHisto_.

Member Function Documentation

◆ Clear()

void HMassResolutionVSPart::Clear ( )
inlineoverride

Definition at line 2379 of file Histograms.h.

2379  {
2380  for (std::map<TString, TH1*>::const_iterator histo = mapHisto_.begin(); histo != mapHisto_.end(); histo++) {
2381  (*histo).second->Clear();
2382  }
2383  muMinus->Clear();
2384  muPlus->Clear();
2385  }

References timingPdfMaker::histo, mapHisto_, muMinus, and muPlus.

◆ Fill() [1/2]

void HMassResolutionVSPart::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 
)
inlineoverride

Definition at line 2303 of file Histograms.h.

2310  {
2311  muMinus->Fill(recoP1, genP1);
2312  muPlus->Fill(recoP2, genP2);
2313 
2314  Fill(recoP1, charge1, recoP2, charge2, recoMass, genMass);
2315  }

References muMinus, and muPlus.

◆ Fill() [2/2]

void HMassResolutionVSPart::Fill ( const reco::Particle::LorentzVector recoP1,
const int  charge1,
const reco::Particle::LorentzVector recoP2,
const int  charge2,
const double &  recoMass,
const double &  genMass 
)
inlineoverride

Definition at line 2317 of file Histograms.h.

2324  {
2325  if (charge1 == charge2)
2326  std::cout << "Error: must get two opposite charge particles" << std::endl;
2327 
2328  double massRes = (recoMass - genMass) / genMass;
2329 
2330  reco::Particle::LorentzVector recoPair(recoP1 + recoP2);
2331  double pairPt = recoPair.Pt();
2332 
2333  double recoPt[2] = {recoP1.Pt(), recoP2.Pt()};
2334  double recoEta[2] = {recoP1.Eta(), recoP2.Eta()};
2335  double recoPhi[2] = {recoP1.Phi(), recoP2.Phi()};
2336 
2337  // std::cout << "pairPt = " << pairPt << ", massRes = ("<<recoMass<<" - "<<genMass<<")/"<<genMass<<" = " << massRes
2338  // << ", recoPt[0] = " << recoPt[0] << ", recoPt[1] = " << recoPt[1] << std::endl;
2339 
2340  // Index of the histogram. If the muons have charge1 = -1 and charge2 = 1, they already have the
2341  // correct histogram indeces. Otherwise, swap the indeces.
2342  // In any case the negative muon has index = 0 and the positive muon has index = 1.
2343  int id[2] = {0, 1};
2344  if (charge1 > 0) {
2345  id[0] = 1;
2346  id[1] = 0;
2347  }
2348 
2349  double pairDeltaEta = fabs(recoEta[0] - recoEta[1]);
2350  double pairDeltaPhi = MuScleFitUtils::deltaPhi(recoPhi[0], recoPhi[1]);
2351 
2352  mapHisto_[name_]->Fill(massRes);
2353  mapHisto_[name_ + "VSPairPt"]->Fill(pairPt, massRes);
2354  mapHisto_[name_ + "VSPairDeltaEta"]->Fill(pairDeltaEta, massRes);
2355  mapHisto_[name_ + "VSPairDeltaPhi"]->Fill(pairDeltaPhi, massRes);
2356 
2357  // Resolution vs single muon quantities
2358  // ------------------------------------
2359  int index = 0;
2360  for (int i = 0; i < 2; ++i) {
2361  index = id[i];
2362  mapHisto_[name_ + "VSPt" + nameSuffix_[i]]->Fill(recoPt[index], massRes); // EM [index] or [i]???
2363  mapHisto_[name_ + "VSEta" + nameSuffix_[i]]->Fill(recoEta[index], massRes);
2364  mapHisto_[name_ + "VSPhi" + nameSuffix_[i]]->Fill(recoPhi[index], massRes);
2365  }
2366  }

References gather_cfg::cout, MuScleFitUtils::deltaPhi(), mps_fire::i, mapHisto_, and nameSuffix_.

◆ Write()

void HMassResolutionVSPart::Write ( )
inlineoverride

Definition at line 2368 of file Histograms.h.

2368  {
2369  histoDir_->cd();
2370  for (std::map<TString, TH1*>::const_iterator histo = mapHisto_.begin(); histo != mapHisto_.end(); histo++) {
2371  (*histo).second->Write();
2372  }
2373  // Create the new dir and cd into it
2374  (histoDir_->mkdir("singleMuonsVSgen"))->cd();
2375  muMinus->Write();
2376  muPlus->Write();
2377  }

References hippyaddtobaddatafiles::cd(), timingPdfMaker::histo, mapHisto_, muMinus, and muPlus.

Member Data Documentation

◆ mapHisto_

std::map<TString, TH1*> HMassResolutionVSPart::mapHisto_
protected

Definition at line 2402 of file Histograms.h.

Referenced by Clear(), Fill(), HMassResolutionVSPart(), Write(), and ~HMassResolutionVSPart().

◆ muMinus

std::unique_ptr<HDelta> HMassResolutionVSPart::muMinus
protected

Definition at line 2404 of file Histograms.h.

Referenced by Clear(), Fill(), HMassResolutionVSPart(), and Write().

◆ muPlus

std::unique_ptr<HDelta> HMassResolutionVSPart::muPlus
protected

Definition at line 2405 of file Histograms.h.

Referenced by Clear(), Fill(), HMassResolutionVSPart(), and Write().

◆ nameSuffix_

TString HMassResolutionVSPart::nameSuffix_[2]
protected

Definition at line 2403 of file Histograms.h.

Referenced by Fill(), and HMassResolutionVSPart().

HMassResolutionVSPart::muPlus
std::unique_ptr< HDelta > muPlus
Definition: Histograms.h:2405
mps_fire.i
i
Definition: mps_fire.py:428
HMassResolutionVSPart::nameSuffix_
TString nameSuffix_[2]
Definition: Histograms.h:2403
MuScleFitUtils::deltaPhi
static double deltaPhi(const double &phi1, const double &phi2)
Definition: MuScleFitUtils.h:109
gather_cfg.cout
cout
Definition: gather_cfg.py:144
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:278
reco::Particle::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
download_sqlite_cfg.outputFile
outputFile
Definition: download_sqlite_cfg.py:5
HMassResolutionVSPart::Fill
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) override
Definition: Histograms.h:2303
HResolution
Definition: Histograms.h:1802
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
HMassResolutionVSPart::mapHisto_
std::map< TString, TH1 * > mapHisto_
Definition: Histograms.h:2402
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
hippyaddtobaddatafiles.cd
def cd(newdir)
Definition: hippyaddtobaddatafiles.py:40
HMassResolutionVSPart::muMinus
std::unique_ptr< HDelta > muMinus
Definition: Histograms.h:2404