CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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

Constructor & Destructor Documentation

DiLeptonHelp::PlotsVsKinematics::PlotsVsKinematics ( flavour  FLAV)
inline
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.

References m_flav.

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  }
Log< level::Error, false > LogError
DiLeptonHelp::PlotsVsKinematics::~PlotsVsKinematics ( )
default

Member Function Documentation

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

Definition at line 67 of file DiLeptonVertexHelpers.h.

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

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

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  }
std::map< xAxis, TH2F * > m_h2_map
const std::vector< xAxis > axisChoices
T * make(const Args &...args) const
make new ROOT object
#define M_PI
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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.

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

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  }
Log< level::Error, false > LogError
std::map< xAxis, TH2F * > m_h2_map
T * make(const Args &...args) const
make new ROOT object
#define M_PI
void DiLeptonHelp::PlotsVsKinematics::fillPlots ( const float  val,
const std::pair< TLorentzVector, TLorentzVector > &  momenta 
)
inline

Definition at line 192 of file DiLeptonVertexHelpers.h.

References m_h2_map, m_isBooked, and hgcalPerformanceValidation::val.

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

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  }
Log< level::Error, false > LogError
std::map< xAxis, TH2F * > m_h2_map

Member Data Documentation

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().

flavour DiLeptonHelp::PlotsVsKinematics::m_flav
private

Definition at line 217 of file DiLeptonVertexHelpers.h.

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

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

Definition at line 219 of file DiLeptonVertexHelpers.h.

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

bool DiLeptonHelp::PlotsVsKinematics::m_isBooked
private

Definition at line 216 of file DiLeptonVertexHelpers.h.

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

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

Definition at line 212 of file DiLeptonVertexHelpers.h.

Referenced by bookPlots().

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

Definition at line 213 of file DiLeptonVertexHelpers.h.

Referenced by bookPlots().

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

Definition at line 214 of file DiLeptonVertexHelpers.h.

Referenced by bookPlots().