CMS 3D CMS Logo

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

#include <DiLeptonPlotHelpers.h>

Public Member Functions

void bookFromPSet (dqm::reco::DQMStore::IBooker &iBooker, const edm::ParameterSet &hpar)
 
void bookPlots (dqm::reco::DQMStore::IBooker &iBooker, 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, DELTA_ETA, COSTHETACS
}
 

Private Attributes

const std::vector< xAxisaxisChoices
 
flavour m_flav
 
std::map< xAxis, dqm::reco::MonitorElement * > 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 20 of file DiLeptonPlotHelpers.h.

Member Enumeration Documentation

◆ xAxis

Constructor & Destructor Documentation

◆ PlotsVsKinematics() [1/2]

DiLepPlotHelp::PlotsVsKinematics::PlotsVsKinematics ( flavour  FLAV)
inline

◆ PlotsVsKinematics() [2/2]

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

Definition at line 26 of file DiLeptonPlotHelpers.h.

References m_flav.

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

◆ ~PlotsVsKinematics()

DiLepPlotHelp::PlotsVsKinematics::~PlotsVsKinematics ( )
default

Member Function Documentation

◆ bookFromPSet()

void DiLepPlotHelp::PlotsVsKinematics::bookFromPSet ( dqm::reco::DQMStore::IBooker iBooker,
const edm::ParameterSet hpar 
)
inline

Definition at line 36 of file DiLeptonPlotHelpers.h.

References axisChoices, dqm::implementation::IBooker::book2D(), Exception, 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 DiMuonVertexMonitor::bookHistograms(), and DiMuonMassBiasMonitor::bookHistograms().

36  {
37  std::string namePostfix;
38  std::string titlePostfix;
39  float xmin, xmax;
40 
41  std::string sed = (m_flav ? "e" : "#mu");
42 
43  for (const auto& xAx : axisChoices) {
44  switch (xAx) {
45  case xAxis::Z_PHI:
46  xmin = -M_PI;
47  xmax = M_PI;
48  namePostfix = m_flav ? "EEPhi" : "MuMuPhi";
49  titlePostfix = fmt::sprintf("%s%s pair #phi;%s^{+}%s^{-} #phi", sed, sed, sed, sed);
50  break;
51  case xAxis::Z_ETA:
52  xmin = -3.5;
53  xmax = 3.5;
54  namePostfix = m_flav ? "EEEta" : "MuMuEta";
55  titlePostfix = fmt::sprintf("%s%s pair #eta;%s^{+}%s^{-} #eta", sed, sed, sed, sed);
56  break;
57  case xAxis::LP_PHI:
58  xmin = -M_PI;
59  xmax = M_PI;
60  namePostfix = m_flav ? "EPlusPhi" : "MuPlusPhi";
61  titlePostfix = fmt::sprintf("%s^{+} #phi;%s^{+} #phi [rad]", sed, sed);
62  break;
63  case xAxis::LP_ETA:
64  xmin = -2.4;
65  xmax = 2.4;
66  namePostfix = m_flav ? "EPlusEta" : "MuPlusEta";
67  titlePostfix = fmt::sprintf("%s^{+} #eta;%s^{+} #eta", sed, sed);
68  break;
69  case xAxis::LM_PHI:
70  xmin = -M_PI;
71  xmax = M_PI;
72  namePostfix = m_flav ? "EMinusPhi" : "MuMinusPhi";
73  titlePostfix = fmt::sprintf("%s^{-} #phi;%s^{-} #phi [rad]", sed, sed);
74  break;
75  case xAxis::LM_ETA:
76  xmin = -2.4;
77  xmax = 2.4;
78  namePostfix = m_flav ? "EMinusEta" : "MuMinusEta";
79  titlePostfix = fmt::sprintf("%s^{-} #eta;%s^{+} #eta", sed, sed);
80  break;
81  case xAxis::DELTA_ETA:
82  xmin = -hpar.getParameter<double>("maxDeltaEta");
83  xmax = hpar.getParameter<double>("maxDeltaEta");
84  namePostfix = m_flav ? "EEDeltEta" : "MuMuDeltaEta";
85  titlePostfix = fmt::sprintf("%s^{-}%s^{+} #Delta#eta;%s^{+}%s^{-} #Delta#eta", sed, sed, sed, sed);
86  break;
87  case xAxis::COSTHETACS:
88  xmin = -1.;
89  xmax = 1.;
90  namePostfix = "CosThetaCS";
91  titlePostfix =
92  fmt::sprintf("%s^{+}%s^{-} cos(#theta_{CS});%s^{+}%s^{-} cos(#theta_{CS})", sed, sed, sed, sed);
93  break;
94  default:
95  throw cms::Exception("LogicalError") << " there is not such Axis choice as " << xAx;
96  }
97 
98  const auto& h2name = fmt::sprintf("%sVs%s", hpar.getParameter<std::string>("name"), namePostfix);
99  const auto& h2title = fmt::sprintf("%s vs %s;%s% s",
100  hpar.getParameter<std::string>("title"),
101  titlePostfix,
102  hpar.getParameter<std::string>("title"),
103  hpar.getParameter<std::string>("yUnits"));
104 
105  m_h2_map[xAx] = iBooker.book2D(h2name.c_str(),
106  h2title.c_str(),
107  hpar.getParameter<int32_t>("NxBins"),
108  xmin,
109  xmax,
110  hpar.getParameter<int32_t>("NyBins"),
111  hpar.getParameter<double>("ymin"),
112  hpar.getParameter<double>("ymax"));
113  }
114 
115  // flip the is booked bit
116  m_isBooked = true;
117  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::map< xAxis, dqm::reco::MonitorElement * > m_h2_map
const std::vector< xAxis > axisChoices
#define M_PI
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:221

◆ bookPlots()

void DiLepPlotHelp::PlotsVsKinematics::bookPlots ( dqm::reco::DQMStore::IBooker iBooker,
const float  valmin,
const float  valmax,
const int  nxbins,
const int  nybins 
)
inline

Definition at line 120 of file DiLeptonPlotHelpers.h.

References dqm::implementation::IBooker::book2D(), ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), m_flav, m_h2_map, m_isBooked, m_name, M_PI, m_title, m_ytitle, and AlCaHLTBitMon_QueryRunRegistry::string.

124  {
125  if (m_name.empty() && m_title.empty() && m_ytitle.empty()) {
126  edm::LogError("PlotsVsKinematics")
127  << "In" << __FUNCTION__ << "," << __LINE__
128  << "trying to book plots without the right constructor being called!" << std::endl;
129  return;
130  }
131 
132  std::string dilep = (m_flav ? "e^{+}e^{-}" : "#mu^{+}#mu^{-}");
133  std::string lep = (m_flav ? "e^{+}" : "#mu^{+}");
134  std::string lem = (m_flav ? "e^{-}" : "#mu^{-}");
135 
136  static constexpr float maxMuEta = 2.4;
137  static constexpr float maxMuMuEta = 3.5;
138  TH1F::SetDefaultSumw2(kTRUE);
139 
140  // clang-format off
141  m_h2_map[xAxis::Z_ETA] = iBooker.book2D(fmt::sprintf("%sVsMuMuEta", m_name).c_str(),
142  fmt::sprintf("%s vs %s pair #eta;%s #eta;%s", m_title, dilep, dilep, m_ytitle).c_str(),
143  nxbins, -M_PI, M_PI,
144  nybins, valmin, valmax);
145 
146  m_h2_map[xAxis::Z_PHI] = iBooker.book2D(fmt::sprintf("%sVsMuMuPhi", m_name).c_str(),
147  fmt::sprintf("%s vs %s pair #phi;%s #phi [rad];%s", m_title, dilep, dilep, m_ytitle).c_str(),
148  nxbins, -maxMuMuEta, maxMuMuEta,
149  nybins, valmin, valmax);
150 
151  m_h2_map[xAxis::LP_ETA] = iBooker.book2D(fmt::sprintf("%sVsMuPlusEta", m_name).c_str(),
152  fmt::sprintf("%s vs %s #eta;%s #eta;%s", m_title, lep, lep, m_ytitle).c_str(),
153  nxbins, -maxMuEta, maxMuEta,
154  nybins, valmin, valmax);
155 
156  m_h2_map[xAxis::LP_PHI] = iBooker.book2D(fmt::sprintf("%sVsMuPlusPhi", m_name).c_str(),
157  fmt::sprintf("%s vs %s #phi;%s #phi [rad];%s", m_title, lep, lep, m_ytitle).c_str(),
158  nxbins, -M_PI, M_PI,
159  nybins, valmin, valmax);
160 
161  m_h2_map[xAxis::LM_ETA] = iBooker.book2D(fmt::sprintf("%sVsMuMinusEta", m_name).c_str(),
162  fmt::sprintf("%s vs %s #eta;%s #eta;%s", m_title, lem, lem, m_ytitle).c_str(),
163  nxbins, -maxMuEta, maxMuEta,
164  nybins, valmin, valmax);
165 
166  m_h2_map[xAxis::LM_PHI] = iBooker.book2D(fmt::sprintf("%sVsMuMinusPhi", m_name).c_str(),
167  fmt::sprintf("%s vs %s #phi;%s #phi [rad];%s", m_title, lem, lem, m_ytitle).c_str(),
168  nxbins, -M_PI, M_PI,
169  nybins, valmin, valmax);
170 
171  m_h2_map[xAxis::DELTA_ETA] = iBooker.book2D(fmt::sprintf("%sVsMuMuDeltaEta", m_name).c_str(),
172  fmt::sprintf("%s vs %s #Delta#eta;%s #Delta#eta;%s", m_title, dilep, dilep, m_ytitle).c_str(),
173  nxbins, -4., 4.,
174  nybins, valmin, valmax);
175 
176  m_h2_map[xAxis::COSTHETACS] = iBooker.book2D(fmt::sprintf("%sVsCosThetaCS", m_name).c_str(),
177  fmt::sprintf("%s vs %s cos(#theta_{CS});%s cos(#theta_{CS});%s", m_title, dilep, dilep, m_ytitle).c_str(),
178  nxbins, -1., 1.,
179  nybins, valmin, valmax);
180  // clang-format on
181 
182  // flip the is booked bit
183  m_isBooked = true;
184  }
std::map< xAxis, dqm::reco::MonitorElement * > m_h2_map
Log< level::Error, false > LogError
#define M_PI
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:221

◆ fillPlots()

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

Definition at line 187 of file DiLeptonPlotHelpers.h.

References spr::deltaEta, m_h2_map, m_isBooked, BPhysicsValidation_cfi::muminus, BPhysicsValidation_cfi::muplus, funct::pow(), mathSSE::sqrt(), and heppy_batch::val.

Referenced by DiMuonVertexMonitor::analyze(), and DiMuonMassBiasMonitor::analyze().

187  {
188  if (!m_isBooked) {
189  edm::LogError("PlotsVsKinematics")
190  << "In" << __FUNCTION__ << "," << __LINE__ << "trying to fill a plot not booked!" << std::endl;
191  return;
192  }
193 
194  m_h2_map[xAxis::Z_ETA]->Fill((momenta.first + momenta.second).Eta(), val);
195  m_h2_map[xAxis::Z_PHI]->Fill((momenta.first + momenta.second).Phi(), val);
196  m_h2_map[xAxis::LP_ETA]->Fill((momenta.first).Eta(), val);
197  m_h2_map[xAxis::LP_PHI]->Fill((momenta.first).Phi(), val);
198  m_h2_map[xAxis::LM_ETA]->Fill((momenta.second).Eta(), val);
199  m_h2_map[xAxis::LM_PHI]->Fill((momenta.second).Phi(), val);
200 
201  // follows here kinematics
202  double deltaEta = (momenta.first).Eta() - (momenta.second).Eta();
203 
204  double muplus = 1. / sqrt(2.) * (momenta.first.E() + momenta.first.Z());
205  double muminus = 1. / sqrt(2.) * (momenta.first.E() - momenta.first.Z());
206  double mubarplus = 1. / sqrt(2.) * (momenta.second.E() + momenta.second.Z());
207  double mubarminus = 1. / sqrt(2.) * (momenta.second.E() - momenta.second.Z());
208 
209  const auto& mother = momenta.first + momenta.second;
210  double cosThetaCS = 2. / mother.Mag() / sqrt(pow(mother.Mag(), 2) + pow(mother.Pt(), 2)) *
211  (muplus * mubarminus - muminus * mubarplus);
212 
213  m_h2_map[xAxis::DELTA_ETA]->Fill(deltaEta, val);
214  m_h2_map[xAxis::COSTHETACS]->Fill(cosThetaCS, val);
215  }
std::map< xAxis, dqm::reco::MonitorElement * > m_h2_map
Log< level::Error, false > LogError
static const double deltaEta
Definition: CaloConstants.h:8
T sqrt(T t)
Definition: SSEVec.h:23
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

Member Data Documentation

◆ axisChoices

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

Definition at line 219 of file DiLeptonPlotHelpers.h.

Referenced by bookFromPSet().

◆ m_flav

flavour DiLepPlotHelp::PlotsVsKinematics::m_flav
private

Definition at line 233 of file DiLeptonPlotHelpers.h.

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

◆ m_h2_map

std::map<xAxis, dqm::reco::MonitorElement*> DiLepPlotHelp::PlotsVsKinematics::m_h2_map
private

Definition at line 235 of file DiLeptonPlotHelpers.h.

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

◆ m_isBooked

bool DiLepPlotHelp::PlotsVsKinematics::m_isBooked
private

Definition at line 232 of file DiLeptonPlotHelpers.h.

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

◆ m_name

const std::string DiLepPlotHelp::PlotsVsKinematics::m_name
private

Definition at line 228 of file DiLeptonPlotHelpers.h.

Referenced by bookPlots().

◆ m_title

const std::string DiLepPlotHelp::PlotsVsKinematics::m_title
private

Definition at line 229 of file DiLeptonPlotHelpers.h.

Referenced by bookPlots().

◆ m_ytitle

const std::string DiLepPlotHelp::PlotsVsKinematics::m_ytitle
private

Definition at line 230 of file DiLeptonPlotHelpers.h.

Referenced by bookPlots().