CMS 3D CMS Logo

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

#include <DiLeptonVertexHelpers.h>

Public Member Functions

void bookFromPSet (const TFileDirectory &fs, const edm::ParameterSet &hpar)
 
void bookPlots (TFileDirectory &fs, const float valmin, const float valmax, const int nxbins, const int nybins)
 
void fillPlots (const float val, const std::pair< TLorentzVector, TLorentzVector > &momenta)
 
 PlotsVsKinematics (flavour FLAV)
 
 PlotsVsKinematics (flavour FLAV, const std::string &name, const std::string &tt, const std::string &ytt)
 
 ~PlotsVsKinematics ()=default
 

Private Types

enum  xAxis {
  Z_PHI, Z_ETA, LP_PHI, LP_ETA,
  LM_PHI, LM_ETA
}
 

Private Attributes

const std::vector< xAxisaxisChoices
 
flavour m_flav
 
std::map< xAxis, TH2F * > m_h2_map
 
bool m_isBooked
 
const std::string m_name
 
const std::string m_title
 
const std::string m_ytitle
 

Detailed Description

Definition at line 51 of file DiLeptonVertexHelpers.h.

Member Enumeration Documentation

◆ xAxis

Enumerator
Z_PHI 
Z_ETA 
LP_PHI 
LP_ETA 
LM_PHI 
LM_ETA 

Definition at line 208 of file DiLeptonVertexHelpers.h.

Constructor & Destructor Documentation

◆ PlotsVsKinematics() [1/2]

DiLeptonHelp::PlotsVsKinematics::PlotsVsKinematics ( flavour  FLAV)
inline

Definition at line 53 of file DiLeptonVertexHelpers.h.

53 : m_name(""), m_title(""), m_ytitle(""), m_isBooked(false), m_flav(FLAV) {}

◆ PlotsVsKinematics() [2/2]

DiLeptonHelp::PlotsVsKinematics::PlotsVsKinematics ( flavour  FLAV,
const std::string &  name,
const std::string &  tt,
const std::string &  ytt 
)
inline

Definition at line 57 of file DiLeptonVertexHelpers.h.

58  : m_name(name), m_title(tt), m_ytitle(ytt), m_isBooked(false), m_flav(FLAV) {
59  if (m_flav < 0) {
60  edm::LogError("PlotsVsKinematics") << "The initialization flavour is not correct!" << std::endl;
61  }
62  }

References m_flav.

◆ ~PlotsVsKinematics()

DiLeptonHelp::PlotsVsKinematics::~PlotsVsKinematics ( )
default

Member Function Documentation

◆ bookFromPSet()

void DiLeptonHelp::PlotsVsKinematics::bookFromPSet ( const TFileDirectory fs,
const edm::ParameterSet hpar 
)
inline

Definition at line 67 of file DiLeptonVertexHelpers.h.

67  {
68  std::string namePostfix;
69  std::string titlePostfix;
70  float xmin, xmax;
71 
72  std::string sed = (m_flav ? "e" : "#mu");
73 
74  for (const auto& xAx : axisChoices) {
75  switch (xAx) {
76  case xAxis::Z_PHI:
77  xmin = -M_PI;
78  xmax = M_PI;
79  namePostfix = m_flav ? "EEPhi" : "MMPhi";
80  titlePostfix = fmt::sprintf("%s%s pair #phi;%s^{+}%s^{-} #phi", sed, sed, sed, sed);
81  break;
82  case xAxis::Z_ETA:
83  xmin = -3.5;
84  xmax = 3.5;
85  namePostfix = m_flav ? "EEEta" : "MuMuEta";
86  titlePostfix = fmt::sprintf("%s%s pair #eta;%s^{+}%s^{-} #eta", sed, sed, sed, sed);
87  break;
88  case xAxis::LP_PHI:
89  xmin = -M_PI;
90  xmax = M_PI;
91  namePostfix = m_flav ? "EPlusPhi" : "MuPlusPhi";
92  titlePostfix = fmt::sprintf("%s^{+} #phi;%s^{+} #phi [rad]", sed, sed);
93  break;
94  case xAxis::LP_ETA:
95  xmin = -2.4;
96  xmax = 2.4;
97  namePostfix = m_flav ? "EPlusEta" : "MuPlusEta";
98  titlePostfix = fmt::sprintf("%s^{+} #eta;%s^{+} #eta", sed, sed);
99  break;
100  case xAxis::LM_PHI:
101  xmin = -M_PI;
102  xmax = M_PI;
103  namePostfix = m_flav ? "EMinusPhi" : "MuMinusPhi";
104  titlePostfix = fmt::sprintf("%s^{-} #phi;%s^{-} #phi [rad]", sed, sed);
105  break;
106  case xAxis::LM_ETA:
107  xmin = -2.4;
108  xmax = 2.4;
109  namePostfix = m_flav ? "EMinusEta" : "MuMinusEta";
110  titlePostfix = fmt::sprintf("%s^{-} #eta;%s^{+} #eta", sed, sed);
111  break;
112  default:
113  throw cms::Exception("LogicalError") << " there is not such Axis choice as " << xAx;
114  }
115 
116  const auto& h2name = fmt::sprintf("%sVs%s", hpar.getParameter<std::string>("name"), namePostfix);
117  const auto& h2title = fmt::sprintf("%s vs %s;%s% s",
118  hpar.getParameter<std::string>("title"),
119  titlePostfix,
120  hpar.getParameter<std::string>("title"),
121  hpar.getParameter<std::string>("yUnits"));
122 
123  m_h2_map[xAx] = fs.make<TH2F>(h2name.c_str(),
124  h2title.c_str(),
125  hpar.getParameter<int32_t>("NxBins"),
126  xmin,
127  xmax,
128  hpar.getParameter<int32_t>("NyBins"),
129  hpar.getParameter<double>("ymin"),
130  hpar.getParameter<double>("ymax"));
131  }
132 
133  // flip the is booked bit
134  m_isBooked = true;
135  }

References axisChoices, Exception, edm::ParameterSet::getParameter(), m_flav, m_h2_map, m_isBooked, M_PI, TFileDirectory::make(), AlCaHLTBitMon_QueryRunRegistry::string, TrackerOfflineValidation_Dqm_cff::xmax, and TrackerOfflineValidation_Dqm_cff::xmin.

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

◆ bookPlots()

void DiLeptonHelp::PlotsVsKinematics::bookPlots ( TFileDirectory fs,
const float  valmin,
const float  valmax,
const int  nxbins,
const int  nybins 
)
inline

Definition at line 138 of file DiLeptonVertexHelpers.h.

139  {
140  if (m_name.empty() && m_title.empty() && m_ytitle.empty()) {
141  edm::LogError("PlotsVsKinematics")
142  << "In" << __FUNCTION__ << "," << __LINE__
143  << "trying to book plots without the right constructor being called!" << std::endl;
144  return;
145  }
146 
147  std::string dilep = (m_flav ? "e^{+}e^{-}" : "#mu^{+}#mu^{-}");
148  std::string lep = (m_flav ? "e^{+}" : "#mu^{+}");
149  std::string lem = (m_flav ? "e^{-}" : "#mu^{-}");
150 
151  static constexpr float maxMuEta = 2.4;
152  static constexpr float maxMuMuEta = 3.5;
153  TH1F::SetDefaultSumw2(kTRUE);
154 
155  // clang-format off
156  m_h2_map[xAxis::Z_ETA] = fs.make<TH2F>(fmt::sprintf("%sVsMuMuEta", m_name).c_str(),
157  fmt::sprintf("%s vs %s pair #eta;%s #eta;%s", m_title, dilep, dilep, m_ytitle).c_str(),
158  nxbins, -M_PI, M_PI,
159  nybins, valmin, valmax);
160 
161  m_h2_map[xAxis::Z_PHI] = fs.make<TH2F>(fmt::sprintf("%sVsMuMuPhi", m_name).c_str(),
162  fmt::sprintf("%s vs %s pair #phi;%s #phi [rad];%s", m_title, dilep, dilep, m_ytitle).c_str(),
163  nxbins, -maxMuMuEta, maxMuMuEta,
164  nybins, valmin, valmax);
165 
166  m_h2_map[xAxis::LP_ETA] = fs.make<TH2F>(fmt::sprintf("%sVsMuPlusEta", m_name).c_str(),
167  fmt::sprintf("%s vs %s #eta;%s #eta;%s", m_title, lep, lep, m_ytitle).c_str(),
168  nxbins, -maxMuEta, maxMuEta,
169  nybins, valmin, valmax);
170 
171  m_h2_map[xAxis::LP_PHI] = fs.make<TH2F>(fmt::sprintf("%sVsMuPlusPhi", m_name).c_str(),
172  fmt::sprintf("%s vs %s #phi;%s #phi [rad];%s", m_title, lep, lep, m_ytitle).c_str(),
173  nxbins, -M_PI, M_PI,
174  nybins, valmin, valmax);
175 
176  m_h2_map[xAxis::LM_ETA] = fs.make<TH2F>(fmt::sprintf("%sVsMuMinusEta", m_name).c_str(),
177  fmt::sprintf("%s vs %s #eta;%s #eta;%s", m_title, lem, lem, m_ytitle).c_str(),
178  nxbins, -maxMuEta, maxMuEta,
179  nybins, valmin, valmax);
180 
181  m_h2_map[xAxis::LM_PHI] = fs.make<TH2F>(fmt::sprintf("%sVsMuMinusPhi", m_name).c_str(),
182  fmt::sprintf("%s vs %s #phi;%s #phi [rad];%s", m_title, lem, lem, m_ytitle).c_str(),
183  nxbins, -M_PI, M_PI,
184  nybins, valmin, valmax);
185  // clang-format on
186 
187  // flip the is booked bit
188  m_isBooked = true;
189  }

References m_flav, m_h2_map, m_isBooked, m_name, M_PI, m_title, m_ytitle, TFileDirectory::make(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ fillPlots()

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

Definition at line 192 of file DiLeptonVertexHelpers.h.

192  {
193  if (!m_isBooked) {
194  edm::LogError("PlotsVsKinematics")
195  << "In" << __FUNCTION__ << "," << __LINE__ << "trying to fill a plot not booked!" << std::endl;
196  return;
197  }
198 
199  m_h2_map[xAxis::Z_ETA]->Fill((momenta.first + momenta.second).Eta(), val);
200  m_h2_map[xAxis::Z_PHI]->Fill((momenta.first + momenta.second).Phi(), val);
201  m_h2_map[xAxis::LP_ETA]->Fill((momenta.first).Eta(), val);
202  m_h2_map[xAxis::LP_PHI]->Fill((momenta.first).Phi(), val);
203  m_h2_map[xAxis::LM_ETA]->Fill((momenta.second).Eta(), val);
204  m_h2_map[xAxis::LM_PHI]->Fill((momenta.second).Phi(), val);
205  }

References m_h2_map, m_isBooked, and heppy_batch::val.

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

Member Data Documentation

◆ axisChoices

const std::vector<xAxis> DiLeptonHelp::PlotsVsKinematics::axisChoices
private
Initial value:
= {
xAxis::Z_PHI, xAxis::Z_ETA, xAxis::LP_PHI, xAxis::LP_ETA, xAxis::LM_PHI, xAxis::LM_ETA}

Definition at line 209 of file DiLeptonVertexHelpers.h.

Referenced by bookFromPSet().

◆ m_flav

flavour DiLeptonHelp::PlotsVsKinematics::m_flav
private

Definition at line 217 of file DiLeptonVertexHelpers.h.

Referenced by bookFromPSet(), bookPlots(), and PlotsVsKinematics().

◆ m_h2_map

std::map<xAxis, TH2F*> DiLeptonHelp::PlotsVsKinematics::m_h2_map
private

Definition at line 219 of file DiLeptonVertexHelpers.h.

Referenced by bookFromPSet(), bookPlots(), and fillPlots().

◆ m_isBooked

bool DiLeptonHelp::PlotsVsKinematics::m_isBooked
private

Definition at line 216 of file DiLeptonVertexHelpers.h.

Referenced by bookFromPSet(), bookPlots(), and fillPlots().

◆ m_name

const std::string DiLeptonHelp::PlotsVsKinematics::m_name
private

Definition at line 212 of file DiLeptonVertexHelpers.h.

Referenced by bookPlots().

◆ m_title

const std::string DiLeptonHelp::PlotsVsKinematics::m_title
private

Definition at line 213 of file DiLeptonVertexHelpers.h.

Referenced by bookPlots().

◆ m_ytitle

const std::string DiLeptonHelp::PlotsVsKinematics::m_ytitle
private

Definition at line 214 of file DiLeptonVertexHelpers.h.

Referenced by bookPlots().

DiLeptonHelp::PlotsVsKinematics::LP_PHI
Definition: DiLeptonVertexHelpers.h:208
groupFilesInBlocks.tt
int tt
Definition: groupFilesInBlocks.py:144
DiLeptonHelp::PlotsVsKinematics::axisChoices
const std::vector< xAxis > axisChoices
Definition: DiLeptonVertexHelpers.h:209
DiLeptonHelp::PlotsVsKinematics::LM_ETA
Definition: DiLeptonVertexHelpers.h:208
DiLeptonHelp::PlotsVsKinematics::m_ytitle
const std::string m_ytitle
Definition: DiLeptonVertexHelpers.h:214
DiLeptonHelp::PlotsVsKinematics::m_h2_map
std::map< xAxis, TH2F * > m_h2_map
Definition: DiLeptonVertexHelpers.h:219
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
DiLeptonHelp::PlotsVsKinematics::m_isBooked
bool m_isBooked
Definition: DiLeptonVertexHelpers.h:216
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
heppy_batch.val
val
Definition: heppy_batch.py:351
TrackerOfflineValidation_Dqm_cff.xmax
xmax
Definition: TrackerOfflineValidation_Dqm_cff.py:11
Exception
Definition: hltDiff.cc:245
DiLeptonHelp::PlotsVsKinematics::m_title
const std::string m_title
Definition: DiLeptonVertexHelpers.h:213
TFileDirectory::make
T * make(const Args &...args) const
make new ROOT object
Definition: TFileDirectory.h:53
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
DiLeptonHelp::PlotsVsKinematics::m_name
const std::string m_name
Definition: DiLeptonVertexHelpers.h:212
DiLeptonHelp::PlotsVsKinematics::Z_ETA
Definition: DiLeptonVertexHelpers.h:208
DiLeptonHelp::PlotsVsKinematics::LP_ETA
Definition: DiLeptonVertexHelpers.h:208
TrackerOfflineValidation_Dqm_cff.xmin
xmin
Definition: TrackerOfflineValidation_Dqm_cff.py:10
DiLeptonHelp::PlotsVsKinematics::m_flav
flavour m_flav
Definition: DiLeptonVertexHelpers.h:217
DiLeptonHelp::PlotsVsKinematics::Z_PHI
Definition: DiLeptonVertexHelpers.h:208
DiLeptonHelp::PlotsVsKinematics::LM_PHI
Definition: DiLeptonVertexHelpers.h:208