CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
DiLeptonHelp::PlotsVsDiLeptonRegion Class Reference

#include <DiLeptonVertexHelpers.h>

Public Member Functions

void bookSet (const TFileDirectory &fs, const TH1 *histo)
 
void fillTH1Plots (const float val, const std::pair< TLorentzVector, TLorentzVector > &momenta)
 
void fillTH2Plots (const float valX, const float valY, const std::pair< TLorentzVector, TLorentzVector > &momenta)
 
etaRegion getEtaRegion (const double eta1, const double eta2)
 
 PlotsVsDiLeptonRegion (const float etaBoundary)
 
 ~PlotsVsDiLeptonRegion ()=default
 

Private Attributes

const float m_etaBoundary
 
const std::vector< std::string > m_etaRegionNames
 
const std::vector< etaRegionm_etaRegions
 
std::map< etaRegion, TH1F * > m_h1_map
 
std::map< etaRegion, TH2F * > m_h2_map
 
bool m_isBooked
 

Detailed Description

Definition at line 54 of file DiLeptonVertexHelpers.h.

Constructor & Destructor Documentation

◆ PlotsVsDiLeptonRegion()

DiLeptonHelp::PlotsVsDiLeptonRegion::PlotsVsDiLeptonRegion ( const float  etaBoundary)
inline

Definition at line 56 of file DiLeptonVertexHelpers.h.

56 : m_etaBoundary(etaBoundary) {}

◆ ~PlotsVsDiLeptonRegion()

DiLeptonHelp::PlotsVsDiLeptonRegion::~PlotsVsDiLeptonRegion ( )
default

Member Function Documentation

◆ bookSet()

void DiLeptonHelp::PlotsVsDiLeptonRegion::bookSet ( const TFileDirectory fs,
const TH1 *  histo 
)
inline

Definition at line 60 of file DiLeptonVertexHelpers.h.

References DiLeptonHelp::END, compareTotals::fs, timingPdfMaker::histo, m_etaRegionNames, m_etaRegions, m_h1_map, m_h2_map, m_isBooked, Skims_PA_cff::name, AlCaHLTBitMon_QueryRunRegistry::string, and runGCPTkAlMap::title.

Referenced by DiMuonVertexValidation::beginJob(), and DiMuonValidation::beginJob().

60  {
61  const std::string name = histo->GetName();
62  const std::string title = histo->GetTitle();
63  const std::string xTitle = histo->GetXaxis()->GetTitle();
64  const std::string yTitle = histo->GetYaxis()->GetTitle();
65  std::string zTitle = "";
66  if (((TObject*)histo)->InheritsFrom("TH2")) {
67  zTitle = histo->GetZaxis()->GetTitle();
68  }
69 
70  for (const auto& etaReg : m_etaRegions) {
71  if (etaReg == etaRegion::END)
72  continue;
73 
74  if (((TObject*)histo)->InheritsFrom("TH2")) {
75  m_h2_map[etaReg] = fs.make<TH2F>(
76  (name + "_" + m_etaRegionNames[etaReg]).c_str(),
77  (title + " (" + m_etaRegionNames[etaReg] + ");" + xTitle + ";" + yTitle + ";" + zTitle).c_str(),
78  histo->GetNbinsX(),
79  histo->GetXaxis()->GetXmin(),
80  histo->GetXaxis()->GetXmax(),
81  histo->GetNbinsY(),
82  histo->GetYaxis()->GetXmin(),
83  histo->GetYaxis()->GetXmax());
84  } else {
85  m_h1_map[etaReg] =
86  fs.make<TH1F>((name + "_" + m_etaRegionNames[etaReg]).c_str(),
87  (title + " (" + m_etaRegionNames[etaReg] + ");" + xTitle + ";" + yTitle).c_str(),
88  histo->GetNbinsX(),
89  histo->GetXaxis()->GetXmin(),
90  histo->GetXaxis()->GetXmax());
91  }
92  }
93 
94  // flip the is booked bit
95  m_isBooked = true;
96  }
std::map< etaRegion, TH2F * > m_h2_map
const std::vector< std::string > m_etaRegionNames
const std::vector< etaRegion > m_etaRegions
std::map< etaRegion, TH1F * > m_h1_map

◆ fillTH1Plots()

void DiLeptonHelp::PlotsVsDiLeptonRegion::fillTH1Plots ( const float  val,
const std::pair< TLorentzVector, TLorentzVector > &  momenta 
)
inline

Definition at line 123 of file DiLeptonVertexHelpers.h.

References DiLeptonHelp::END, getEtaRegion(), m_h1_map, m_isBooked, nano_mu_digi_cff::region, and heppy_batch::val.

Referenced by DiMuonVertexValidation::analyze(), and DiMuonValidation::analyze().

123  {
124  if (!m_isBooked) {
125  edm::LogError("PlotsVsDiLeptonRegion")
126  << "In" << __FUNCTION__ << "," << __LINE__ << "trying to fill a plot not booked!" << std::endl;
127  return;
128  }
129 
130  etaRegion region = getEtaRegion(momenta.first.Eta(), momenta.second.Eta());
131  if (region == etaRegion::END) {
132  edm::LogError("PlotsVsDiLeptonRegion") << "undefined di-muon kinematics" << std::endl;
133  }
134  m_h1_map[region]->Fill(val);
135  }
Log< level::Error, false > LogError
std::map< etaRegion, TH1F * > m_h1_map
etaRegion getEtaRegion(const double eta1, const double eta2)

◆ fillTH2Plots()

void DiLeptonHelp::PlotsVsDiLeptonRegion::fillTH2Plots ( const float  valX,
const float  valY,
const std::pair< TLorentzVector, TLorentzVector > &  momenta 
)
inline

Definition at line 138 of file DiLeptonVertexHelpers.h.

References DiLeptonHelp::END, getEtaRegion(), m_h2_map, m_isBooked, and nano_mu_digi_cff::region.

Referenced by DiMuonValidation::analyze().

140  {
141  if (!m_isBooked) {
142  edm::LogError("PlotsVsDiLeptonRegion")
143  << "In" << __FUNCTION__ << "," << __LINE__ << "trying to fill a plot not booked!" << std::endl;
144  return;
145  }
146 
147  etaRegion region = getEtaRegion(momenta.first.Eta(), momenta.second.Eta());
148  if (region == etaRegion::END) {
149  edm::LogError("PlotsVsDiLeptonRegion") << "undefined di-muon kinematics" << std::endl;
150  }
151  m_h2_map[region]->Fill(valX, valY);
152  }
Log< level::Error, false > LogError
std::map< etaRegion, TH2F * > m_h2_map
etaRegion getEtaRegion(const double eta1, const double eta2)

◆ getEtaRegion()

etaRegion DiLeptonHelp::PlotsVsDiLeptonRegion::getEtaRegion ( const double  eta1,
const double  eta2 
)
inline

Definition at line 100 of file DiLeptonVertexHelpers.h.

References funct::abs(), DiLeptonHelp::BARBAR, DiLeptonHelp::BARBWD, DiLeptonHelp::BARFWD, DiLeptonHelp::BWDBWD, DiLeptonHelp::END, HLT_2024v12_cff::eta1, HLT_2024v12_cff::eta2, DiLeptonHelp::FWDBWD, DiLeptonHelp::FWDFWD, and m_etaBoundary.

Referenced by fillTH1Plots(), and fillTH2Plots().

100  {
101  bool isEta1Barrel = std::abs(eta1) <= m_etaBoundary;
102  bool isEta2Barrel = std::abs(eta2) <= m_etaBoundary;
103 
104  if (isEta1Barrel && isEta2Barrel) {
105  return etaRegion::BARBAR;
106  } else if ((isEta1Barrel && eta2 > m_etaBoundary) || (isEta2Barrel && eta1 > m_etaBoundary)) {
107  return etaRegion::BARFWD;
108  } else if ((isEta1Barrel && eta2 < -m_etaBoundary) || (isEta2Barrel && eta1 < -m_etaBoundary)) {
109  return etaRegion::BARBWD;
110  } else if (eta1 > m_etaBoundary && eta2 > m_etaBoundary) {
111  return etaRegion::FWDFWD;
112  } else if (eta1 < -m_etaBoundary && eta2 < -m_etaBoundary) {
113  return etaRegion::BWDBWD;
114  } else if ((eta1 > m_etaBoundary && eta2 < -m_etaBoundary) || (eta2 > m_etaBoundary && eta1 < -m_etaBoundary)) {
115  return etaRegion::FWDBWD;
116  }
117 
118  // Default case if none of the conditions match
119  return etaRegion::END; // Adjust the default based on your logic
120  }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

Member Data Documentation

◆ m_etaBoundary

const float DiLeptonHelp::PlotsVsDiLeptonRegion::m_etaBoundary
private

Definition at line 168 of file DiLeptonVertexHelpers.h.

Referenced by getEtaRegion().

◆ m_etaRegionNames

const std::vector<std::string> DiLeptonHelp::PlotsVsDiLeptonRegion::m_etaRegionNames
private
Initial value:
= {"barrel-barrel",
"barrel-forward",
"barrel-backward",
"forward-forward",
"backward-backward",
"forward-backward"}

Definition at line 162 of file DiLeptonVertexHelpers.h.

Referenced by bookSet().

◆ m_etaRegions

const std::vector<etaRegion> DiLeptonHelp::PlotsVsDiLeptonRegion::m_etaRegions
private

◆ m_h1_map

std::map<etaRegion, TH1F*> DiLeptonHelp::PlotsVsDiLeptonRegion::m_h1_map
private

Definition at line 170 of file DiLeptonVertexHelpers.h.

Referenced by bookSet(), and fillTH1Plots().

◆ m_h2_map

std::map<etaRegion, TH2F*> DiLeptonHelp::PlotsVsDiLeptonRegion::m_h2_map
private

Definition at line 171 of file DiLeptonVertexHelpers.h.

Referenced by bookSet(), and fillTH2Plots().

◆ m_isBooked

bool DiLeptonHelp::PlotsVsDiLeptonRegion::m_isBooked
private

Definition at line 169 of file DiLeptonVertexHelpers.h.

Referenced by bookSet(), fillTH1Plots(), and fillTH2Plots().