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, make_classfiles::fs, timingPdfMaker::histo, m_etaRegionNames, m_etaRegions, m_h1_map, m_h2_map, m_isBooked, mergeVDriftHistosByStation::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  const auto& toSub = m_etaRegionNames[etaReg];
75 
76  if (((TObject*)histo)->InheritsFrom("TH2")) {
77  m_h2_map[etaReg] = fs.make<TH2F>(
78  (name + "_" + toSub).c_str(),
79  (title + " (" + toSub + ");" + xTitle + " (" + toSub + ") ;" + yTitle + " (" + toSub + ");" + zTitle)
80  .c_str(),
81  histo->GetNbinsX(),
82  histo->GetXaxis()->GetXmin(),
83  histo->GetXaxis()->GetXmax(),
84  histo->GetNbinsY(),
85  histo->GetYaxis()->GetXmin(),
86  histo->GetYaxis()->GetXmax());
87  } else {
88  m_h1_map[etaReg] = fs.make<TH1F>(
89  (name + "_" + toSub).c_str(),
90  (title + " (" + toSub + ");" + xTitle + " (" + toSub + ") ;" + yTitle + " (" + toSub + ")").c_str(),
91  histo->GetNbinsX(),
92  histo->GetXaxis()->GetXmin(),
93  histo->GetXaxis()->GetXmax());
94  }
95  }
96 
97  // flip the is booked bit
98  m_isBooked = true;
99  }
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 126 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().

126  {
127  if (!m_isBooked) {
128  edm::LogError("PlotsVsDiLeptonRegion")
129  << "In" << __FUNCTION__ << "," << __LINE__ << "trying to fill a plot not booked!" << std::endl;
130  return;
131  }
132 
133  etaRegion region = getEtaRegion(momenta.first.Eta(), momenta.second.Eta());
134  if (region == etaRegion::END) {
135  edm::LogError("PlotsVsDiLeptonRegion") << "undefined di-muon kinematics" << std::endl;
136  }
137  m_h1_map[region]->Fill(val);
138  }
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 141 of file DiLeptonVertexHelpers.h.

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

Referenced by DiMuonValidation::analyze().

143  {
144  if (!m_isBooked) {
145  edm::LogError("PlotsVsDiLeptonRegion")
146  << "In" << __FUNCTION__ << "," << __LINE__ << "trying to fill a plot not booked!" << std::endl;
147  return;
148  }
149 
150  etaRegion region = getEtaRegion(momenta.first.Eta(), momenta.second.Eta());
151  if (region == etaRegion::END) {
152  edm::LogError("PlotsVsDiLeptonRegion") << "undefined di-muon kinematics" << std::endl;
153  }
154  m_h2_map[region]->Fill(valX, valY);
155  }
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 103 of file DiLeptonVertexHelpers.h.

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

Referenced by fillTH1Plots(), and fillTH2Plots().

103  {
104  bool isEta1Barrel = std::abs(eta1) <= m_etaBoundary;
105  bool isEta2Barrel = std::abs(eta2) <= m_etaBoundary;
106 
107  if (isEta1Barrel && isEta2Barrel) {
108  return etaRegion::BARBAR;
109  } else if ((isEta1Barrel && eta2 > m_etaBoundary) || (isEta2Barrel && eta1 > m_etaBoundary)) {
110  return etaRegion::BARFWD;
111  } else if ((isEta1Barrel && eta2 < -m_etaBoundary) || (isEta2Barrel && eta1 < -m_etaBoundary)) {
112  return etaRegion::BARBWD;
113  } else if (eta1 > m_etaBoundary && eta2 > m_etaBoundary) {
114  return etaRegion::FWDFWD;
115  } else if (eta1 < -m_etaBoundary && eta2 < -m_etaBoundary) {
116  return etaRegion::BWDBWD;
117  } else if ((eta1 > m_etaBoundary && eta2 < -m_etaBoundary) || (eta2 > m_etaBoundary && eta1 < -m_etaBoundary)) {
118  return etaRegion::FWDBWD;
119  }
120 
121  // Default case if none of the conditions match
122  return etaRegion::END; // Adjust the default based on your logic
123  }
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 171 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 165 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 173 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 174 of file DiLeptonVertexHelpers.h.

Referenced by bookSet(), and fillTH2Plots().

◆ m_isBooked

bool DiLeptonHelp::PlotsVsDiLeptonRegion::m_isBooked
private

Definition at line 172 of file DiLeptonVertexHelpers.h.

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