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

Constructor & Destructor Documentation

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

Definition at line 2148 of file Histograms.h.

References mps_fire::i, and dataset::name.

2148  : Histograms( outputFile, name ) {
2149  // Kinematical variables
2150  nameSuffix_[0] = "Plus";
2151  nameSuffix_[1] = "Minus";
2152  TString titleSuffix[] = {" for mu+", " for mu-"};
2153 
2154  mapHisto_[name] = new TH1F (name, "#Delta M/M", 4000, -1, 1);
2155  mapHisto_[name+"VSPairPt"] = new HResolution (name+"VSPairPt", "resolution VS pt of the pair", 100, 0, 200, -1, 1, histoDir_);
2156  mapHisto_[name+"VSPairDeltaEta"] = new HResolution (name+"VSPairDeltaEta", "resolution VS #Delta#eta of the pair", 100, -0.1, 6.2, -1, 1, histoDir_);
2157  mapHisto_[name+"VSPairDeltaPhi"] = new HResolution (name+"VSPairDeltaPhi", "resolution VS #Delta#phi of the pair", 100, -0.1, 3.2, -1, 1, histoDir_);
2158 
2159  for( int i=0; i<2; ++i ) {
2160  mapHisto_[name+"VSPt"+nameSuffix_[i]] = new HResolution (name+"VSPt"+nameSuffix_[i], "resolution VS pt"+titleSuffix[i], 100, 0, 200, -1, 1, histoDir_);
2161  mapHisto_[name+"VSEta"+nameSuffix_[i]] = new HResolution (name+"VSEta"+nameSuffix_[i], "resolution VS #eta"+titleSuffix[i], 100, -3, 3, -1, 1, histoDir_);
2162  mapHisto_[name+"VSPhi"+nameSuffix_[i]] = new HResolution (name+"VSPhi"+nameSuffix_[i], "resolution VS #phi"+titleSuffix[i], 100, -3.2, 3.2, -1, 1, histoDir_);
2163  }
2164 
2165  // single particles histograms
2166  muMinus.reset( new HDelta("muMinus") );
2167  muPlus.reset( new HDelta("muPlus") );
2168  }
std::unique_ptr< HDelta > muPlus
Definition: Histograms.h:2275
std::unique_ptr< HDelta > muMinus
Definition: Histograms.h:2274
TString nameSuffix_[2]
Definition: Histograms.h:2273
std::map< TString, TH1 * > mapHisto_
Definition: Histograms.h:2272
HMassResolutionVSPart::~HMassResolutionVSPart ( )
inlineoverride

Definition at line 2170 of file Histograms.h.

References trackerHits::histo.

2170  {
2171  for (std::map<TString, TH1*>::const_iterator histo=mapHisto_.begin();
2172  histo!=mapHisto_.end(); histo++) {
2173  delete (*histo).second;
2174  }
2175  }
std::map< TString, TH1 * > mapHisto_
Definition: Histograms.h:2272

Member Function Documentation

void HMassResolutionVSPart::Clear ( )
inlineoverride

Definition at line 2248 of file Histograms.h.

References trackerHits::histo.

2248  {
2249  for (std::map<TString, TH1*>::const_iterator histo=mapHisto_.begin();
2250  histo!=mapHisto_.end(); histo++) {
2251  (*histo).second->Clear();
2252  }
2253  muMinus->Clear();
2254  muPlus->Clear();
2255  }
std::unique_ptr< HDelta > muPlus
Definition: Histograms.h:2275
std::unique_ptr< HDelta > muMinus
Definition: Histograms.h:2274
std::map< TString, TH1 * > mapHisto_
Definition: Histograms.h:2272
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 2177 of file Histograms.h.

References HcalObjRepresent::Fill().

2181  {
2182  muMinus->Fill(recoP1, genP1);
2183  muPlus->Fill(recoP2, genP2);
2184 
2185  Fill( recoP1, charge1, recoP2, charge2, recoMass, genMass );
2186  }
std::unique_ptr< HDelta > muPlus
Definition: Histograms.h:2275
std::unique_ptr< HDelta > muMinus
Definition: Histograms.h:2274
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:2177
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 2188 of file Histograms.h.

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

2192  {
2193 
2194  if ( charge1 == charge2 ) std::cout << "Error: must get two opposite charge particles" << std::endl;
2195 
2196  double massRes = (recoMass - genMass)/genMass;
2197 
2198  reco::Particle::LorentzVector recoPair( recoP1 + recoP2 );
2199  double pairPt = recoPair.Pt();
2200 
2201  double recoPt[2] = {recoP1.Pt(), recoP2.Pt()};
2202  double recoEta[2] = {recoP1.Eta(), recoP2.Eta()};
2203  double recoPhi[2] = {recoP1.Phi(), recoP2.Phi()};
2204 
2205  // std::cout << "pairPt = " << pairPt << ", massRes = ("<<recoMass<<" - "<<genMass<<")/"<<genMass<<" = " << massRes
2206  // << ", recoPt[0] = " << recoPt[0] << ", recoPt[1] = " << recoPt[1] << std::endl;
2207 
2208  // Index of the histogram. If the muons have charge1 = -1 and charge2 = 1, they already have the
2209  // correct histogram indeces. Otherwise, swap the indeces.
2210  // In any case the negative muon has index = 0 and the positive muon has index = 1.
2211  int id[2] = {0,1};
2212  if ( charge1 > 0 ) {
2213  id[0] = 1;
2214  id[1] = 0;
2215  }
2216 
2217  double pairDeltaEta = fabs(recoEta[0] - recoEta[1]);
2218  double pairDeltaPhi = MuScleFitUtils::deltaPhi(recoPhi[0], recoPhi[1]);
2219 
2220  mapHisto_[name_]->Fill(massRes);
2221  mapHisto_[name_+"VSPairPt"]->Fill(pairPt, massRes);
2222  mapHisto_[name_+"VSPairDeltaEta"]->Fill(pairDeltaEta, massRes);
2223  mapHisto_[name_+"VSPairDeltaPhi"]->Fill(pairDeltaPhi, massRes);
2224 
2225  // Resolution vs single muon quantities
2226  // ------------------------------------
2227  int index = 0;
2228  for( int i=0; i<2; ++i ) {
2229  index = id[i];
2230  mapHisto_[name_+"VSPt"+nameSuffix_[i]]->Fill(recoPt[index], massRes); // EM [index] or [i]???
2231  mapHisto_[name_+"VSEta"+nameSuffix_[i]]->Fill(recoEta[index], massRes);
2232  mapHisto_[name_+"VSPhi"+nameSuffix_[i]]->Fill(recoPhi[index], massRes);
2233  }
2234  }
TString nameSuffix_[2]
Definition: Histograms.h:2273
std::map< TString, TH1 * > mapHisto_
Definition: Histograms.h:2272
static double deltaPhi(const double &phi1, const double &phi2)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
void HMassResolutionVSPart::Write ( )
inlineoverride

Definition at line 2236 of file Histograms.h.

References hippyaddtobaddatafiles::cd(), and trackerHits::histo.

2236  {
2237  histoDir_->cd();
2238  for (std::map<TString, TH1*>::const_iterator histo=mapHisto_.begin();
2239  histo!=mapHisto_.end(); histo++) {
2240  (*histo).second->Write();
2241  }
2242  // Create the new dir and cd into it
2243  (histoDir_->mkdir("singleMuonsVSgen"))->cd();
2244  muMinus->Write();
2245  muPlus->Write();
2246  }
std::unique_ptr< HDelta > muPlus
Definition: Histograms.h:2275
std::unique_ptr< HDelta > muMinus
Definition: Histograms.h:2274
std::map< TString, TH1 * > mapHisto_
Definition: Histograms.h:2272

Member Data Documentation

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

Definition at line 2272 of file Histograms.h.

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

Definition at line 2274 of file Histograms.h.

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

Definition at line 2275 of file Histograms.h.

TString HMassResolutionVSPart::nameSuffix_[2]
protected

Definition at line 2273 of file Histograms.h.