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 176 of file DiLeptonVertexHelpers.h.

Member Enumeration Documentation

◆ xAxis

Constructor & Destructor Documentation

◆ PlotsVsKinematics() [1/2]

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

◆ PlotsVsKinematics() [2/2]

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

Definition at line 182 of file DiLeptonVertexHelpers.h.

References m_flav.

183  : m_name(name), m_title(tt), m_ytitle(ytt), m_isBooked(false), m_flav(FLAV) {
184  if (m_flav < 0) {
185  edm::LogError("PlotsVsKinematics") << "The initialization flavour is not correct!" << std::endl;
186  }
187  }
Log< level::Error, false > LogError
Definition: TTTypes.h:54

◆ ~PlotsVsKinematics()

DiLeptonHelp::PlotsVsKinematics::~PlotsVsKinematics ( )
default

Member Function Documentation

◆ bookFromPSet()

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

Definition at line 192 of file DiLeptonVertexHelpers.h.

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

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

192  {
193  std::string namePostfix;
194  std::string titlePostfix;
195  float xmin, xmax;
196 
197  std::string sed = (m_flav ? "e" : "#mu");
198 
199  for (const auto& xAx : axisChoices) {
200  switch (xAx) {
201  case xAxis::Z_PHI:
202  xmin = -M_PI;
203  xmax = M_PI;
204  namePostfix = m_flav ? "EEPhi" : "MMPhi";
205  titlePostfix = fmt::sprintf("%s%s pair #phi;%s^{+}%s^{-} #phi", sed, sed, sed, sed);
206  break;
207  case xAxis::Z_ETA:
208  xmin = -3.5;
209  xmax = 3.5;
210  namePostfix = m_flav ? "EEEta" : "MuMuEta";
211  titlePostfix = fmt::sprintf("%s%s pair #eta;%s^{+}%s^{-} #eta", sed, sed, sed, sed);
212  break;
213  case xAxis::LP_PHI:
214  xmin = -M_PI;
215  xmax = M_PI;
216  namePostfix = m_flav ? "EPlusPhi" : "MuPlusPhi";
217  titlePostfix = fmt::sprintf("%s^{+} #phi;%s^{+} #phi [rad]", sed, sed);
218  break;
219  case xAxis::LP_ETA:
220  xmin = -2.4;
221  xmax = 2.4;
222  namePostfix = m_flav ? "EPlusEta" : "MuPlusEta";
223  titlePostfix = fmt::sprintf("%s^{+} #eta;%s^{+} #eta", sed, sed);
224  break;
225  case xAxis::LM_PHI:
226  xmin = -M_PI;
227  xmax = M_PI;
228  namePostfix = m_flav ? "EMinusPhi" : "MuMinusPhi";
229  titlePostfix = fmt::sprintf("%s^{-} #phi;%s^{-} #phi [rad]", sed, sed);
230  break;
231  case xAxis::LM_ETA:
232  xmin = -2.4;
233  xmax = 2.4;
234  namePostfix = m_flav ? "EMinusEta" : "MuMinusEta";
235  titlePostfix = fmt::sprintf("%s^{-} #eta;%s^{+} #eta", sed, sed);
236  break;
237  default:
238  throw cms::Exception("LogicalError") << " there is not such Axis choice as " << xAx;
239  }
240 
241  const auto& h2name = fmt::sprintf("%sVs%s", hpar.getParameter<std::string>("name"), namePostfix);
242  const auto& h2title = fmt::sprintf("%s vs %s;%s% s",
243  hpar.getParameter<std::string>("title"),
244  titlePostfix,
245  hpar.getParameter<std::string>("title"),
246  hpar.getParameter<std::string>("yUnits"));
247 
248  m_h2_map[xAx] = fs.make<TH2F>(h2name.c_str(),
249  h2title.c_str(),
250  hpar.getParameter<int32_t>("NxBins"),
251  xmin,
252  xmax,
253  hpar.getParameter<int32_t>("NyBins"),
254  hpar.getParameter<double>("ymin"),
255  hpar.getParameter<double>("ymax"));
256  }
257 
258  // flip the is booked bit
259  m_isBooked = true;
260  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::map< xAxis, TH2F * > m_h2_map
const std::vector< xAxis > axisChoices
#define M_PI

◆ bookPlots()

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

Definition at line 263 of file DiLeptonVertexHelpers.h.

References compareTotals::fs, m_flav, m_h2_map, m_isBooked, m_name, M_PI, m_title, m_ytitle, and AlCaHLTBitMon_QueryRunRegistry::string.

264  {
265  if (m_name.empty() && m_title.empty() && m_ytitle.empty()) {
266  edm::LogError("PlotsVsKinematics")
267  << "In" << __FUNCTION__ << "," << __LINE__
268  << "trying to book plots without the right constructor being called!" << std::endl;
269  return;
270  }
271 
272  std::string dilep = (m_flav ? "e^{+}e^{-}" : "#mu^{+}#mu^{-}");
273  std::string lep = (m_flav ? "e^{+}" : "#mu^{+}");
274  std::string lem = (m_flav ? "e^{-}" : "#mu^{-}");
275 
276  static constexpr float maxMuEta = 2.4;
277  static constexpr float maxMuMuEta = 3.5;
278  TH1F::SetDefaultSumw2(kTRUE);
279 
280  // clang-format off
281  m_h2_map[xAxis::Z_ETA] = fs.make<TH2F>(fmt::sprintf("%sVsMuMuEta", m_name).c_str(),
282  fmt::sprintf("%s vs %s pair #eta;%s #eta;%s", m_title, dilep, dilep, m_ytitle).c_str(),
283  nxbins, -M_PI, M_PI,
284  nybins, valmin, valmax);
285 
286  m_h2_map[xAxis::Z_PHI] = fs.make<TH2F>(fmt::sprintf("%sVsMuMuPhi", m_name).c_str(),
287  fmt::sprintf("%s vs %s pair #phi;%s #phi [rad];%s", m_title, dilep, dilep, m_ytitle).c_str(),
288  nxbins, -maxMuMuEta, maxMuMuEta,
289  nybins, valmin, valmax);
290 
291  m_h2_map[xAxis::LP_ETA] = fs.make<TH2F>(fmt::sprintf("%sVsMuPlusEta", m_name).c_str(),
292  fmt::sprintf("%s vs %s #eta;%s #eta;%s", m_title, lep, lep, m_ytitle).c_str(),
293  nxbins, -maxMuEta, maxMuEta,
294  nybins, valmin, valmax);
295 
296  m_h2_map[xAxis::LP_PHI] = fs.make<TH2F>(fmt::sprintf("%sVsMuPlusPhi", m_name).c_str(),
297  fmt::sprintf("%s vs %s #phi;%s #phi [rad];%s", m_title, lep, lep, m_ytitle).c_str(),
298  nxbins, -M_PI, M_PI,
299  nybins, valmin, valmax);
300 
301  m_h2_map[xAxis::LM_ETA] = fs.make<TH2F>(fmt::sprintf("%sVsMuMinusEta", m_name).c_str(),
302  fmt::sprintf("%s vs %s #eta;%s #eta;%s", m_title, lem, lem, m_ytitle).c_str(),
303  nxbins, -maxMuEta, maxMuEta,
304  nybins, valmin, valmax);
305 
306  m_h2_map[xAxis::LM_PHI] = fs.make<TH2F>(fmt::sprintf("%sVsMuMinusPhi", m_name).c_str(),
307  fmt::sprintf("%s vs %s #phi;%s #phi [rad];%s", m_title, lem, lem, m_ytitle).c_str(),
308  nxbins, -M_PI, M_PI,
309  nybins, valmin, valmax);
310  // clang-format on
311 
312  // flip the is booked bit
313  m_isBooked = true;
314  }
Log< level::Error, false > LogError
std::map< xAxis, TH2F * > m_h2_map
#define M_PI

◆ fillPlots()

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

Definition at line 317 of file DiLeptonVertexHelpers.h.

References m_h2_map, m_isBooked, and heppy_batch::val.

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

317  {
318  if (!m_isBooked) {
319  edm::LogError("PlotsVsKinematics")
320  << "In" << __FUNCTION__ << "," << __LINE__ << "trying to fill a plot not booked!" << std::endl;
321  return;
322  }
323 
324  m_h2_map[xAxis::Z_ETA]->Fill((momenta.first + momenta.second).Eta(), val);
325  m_h2_map[xAxis::Z_PHI]->Fill((momenta.first + momenta.second).Phi(), val);
326  m_h2_map[xAxis::LP_ETA]->Fill((momenta.first).Eta(), val);
327  m_h2_map[xAxis::LP_PHI]->Fill((momenta.first).Phi(), val);
328  m_h2_map[xAxis::LM_ETA]->Fill((momenta.second).Eta(), val);
329  m_h2_map[xAxis::LM_PHI]->Fill((momenta.second).Phi(), val);
330  }
Log< level::Error, false > LogError
std::map< xAxis, TH2F * > m_h2_map

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 334 of file DiLeptonVertexHelpers.h.

Referenced by bookFromPSet().

◆ m_flav

flavour DiLeptonHelp::PlotsVsKinematics::m_flav
private

Definition at line 342 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 344 of file DiLeptonVertexHelpers.h.

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

◆ m_isBooked

bool DiLeptonHelp::PlotsVsKinematics::m_isBooked
private

Definition at line 341 of file DiLeptonVertexHelpers.h.

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

◆ m_name

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

Definition at line 337 of file DiLeptonVertexHelpers.h.

Referenced by bookPlots().

◆ m_title

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

Definition at line 338 of file DiLeptonVertexHelpers.h.

Referenced by bookPlots().

◆ m_ytitle

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

Definition at line 339 of file DiLeptonVertexHelpers.h.

Referenced by bookPlots().