CMS 3D CMS Logo

List of all members | Public Member Functions
JME::JetResolutionCompare Class Reference
Inheritance diagram for JME::JetResolutionCompare:
cond::payloadInspector::PlotImage< JetResolutionObject, SINGLE_IOV, 2 > cond::payloadInspector::PlotImpl< IOV_M, NTAGS > cond::payloadInspector::PlotBase

Public Member Functions

bool fill () override
 
 JetResolutionCompare ()
 
- Public Member Functions inherited from cond::payloadInspector::PlotImage< JetResolutionObject, SINGLE_IOV, 2 >
std::shared_ptr< JetResolutionObject > fetchPayload (const cond::Hash &payloadHash)
 
 PlotImage (const std::string &title)
 
std::string serializeData () override
 
- Public Member Functions inherited from cond::payloadInspector::PlotImpl< IOV_M, NTAGS >
 PlotImpl (const std::string &type, const std::string &title)
 
std::string processData () override
 
 ~PlotImpl () override=default
 
- Public Member Functions inherited from cond::payloadInspector::PlotBase
void addInputParam (const std::string &paramName)
 
cond::persistency::Session dbSession ()
 
template<typename PayloadType >
std::shared_ptr< PayloadType > fetchPayload (const cond::Hash &payloadHash)
 
template<int index>
TagReference getTag ()
 
cond::Tag_t getTagInfo (const std::string &tag)
 
virtual void init ()
 
const std::map< std::string, std::string > & inputParamValues () const
 
bool isSingleIov () const
 
bool isTwoTags () const
 
unsigned int ntags () const
 
std::string payloadType () const
 
 PlotBase ()
 
std::string title () const
 
std::string type () const
 
virtual ~PlotBase ()=default
 

Additional Inherited Members

- Public Types inherited from cond::payloadInspector::PlotImage< JetResolutionObject, SINGLE_IOV, 2 >
typedef PlotImpl< IOV_M, NTAGS > Base
 
- Protected Attributes inherited from cond::payloadInspector::PlotImage< JetResolutionObject, SINGLE_IOV, 2 >
std::string m_imageFileName
 
- Protected Attributes inherited from cond::payloadInspector::PlotBase
std::set< std::string > m_inputParams
 
std::map< std::string, std::string > m_inputParamValues
 
PlotAnnotations m_plotAnnotations
 
std::vector< std::pair< cond::Time_t, cond::Time_t > > m_tagBoundaries
 
std::vector< std::vector< std::tuple< cond::Time_t, cond::Hash > > > m_tagIovs
 
std::vector< std::string > m_tagNames
 

Detailed Description

Definition at line 311 of file JetResolution_PayloadInspector.cc.

Constructor & Destructor Documentation

◆ JetResolutionCompare()

JME::JetResolutionCompare::JetResolutionCompare ( )
inline

Member Function Documentation

◆ fill()

bool JME::JetResolutionCompare::fill ( )
inlineoverridevirtual

Implements cond::payloadInspector::PlotImpl< IOV_M, NTAGS >.

Definition at line 320 of file JetResolution_PayloadInspector.cc.

References svgfig::canvas(), heavyIonCSV_trainingSettings::idx, cond::payloadInspector::PlotBase::inputParamValues(), MAX_ETA, MAX_PT, MIN_ETA, MIN_PT, NBIN_ETA, NBIN_PT, JME::JetParameters::setJetEta(), JME::JetParameters::setJetPt(), JME::JetParameters::setRho(), AlCaHLTBitMon_QueryRunRegistry::string, and runGCPTkAlMap::title.

320  {
321  double par_Pt = 100.;
322  double par_Eta = 1.;
323  double par_Rho = 20.;
324 
326  auto ip = paramValues.find("Jet_Pt");
327  if (ip != paramValues.end()) {
328  par_Pt = std::stod(ip->second);
329  }
330  ip = paramValues.find("Jet_Eta");
331  if (ip != paramValues.end()) {
332  par_Eta = std::stod(ip->second);
333  }
334  ip = paramValues.find("Jet_Rho");
335  if (ip != paramValues.end()) {
336  par_Rho = std::stod(ip->second);
337  }
338 
339  TH1D* resol_eta1 = new TH1D("Jet Resolution vs #eta one", "", NBIN_ETA, MIN_ETA, MAX_ETA);
340  TH1D* resol_eta2 = new TH1D("Jet Resolution vs #eta two", "", NBIN_ETA, MIN_ETA, MAX_ETA);
341  TH1D* resol_pt1 = new TH1D("Jet Resolution vs p_T one", "", NBIN_PT, MIN_PT, MAX_PT);
342  TH1D* resol_pt2 = new TH1D("Jet Resolution vs p_T two", "", NBIN_PT, MIN_PT, MAX_PT);
343  TLegend* leg_eta = new TLegend(0.26, 0.73, 0.935, 0.90);
344  TLegend* leg_pt = new TLegend(0.26, 0.73, 0.935, 0.90);
345 
346  leg_eta->SetBorderSize(0);
347  leg_eta->SetLineStyle(0);
348  leg_eta->SetFillStyle(0);
349 
350  leg_eta->SetTextFont(42);
351  leg_pt->SetBorderSize(0);
352  leg_pt->SetLineStyle(0);
353  leg_pt->SetFillStyle(0);
354 
355  auto tag1 = PlotBase::getTag<0>();
356  auto iov1 = tag1.iovs.front();
357  std::shared_ptr<JetResolutionObject> payload1 = fetchPayload(std::get<1>(iov1));
358  auto tag2 = PlotBase::getTag<1>();
359  auto iov2 = tag2.iovs.front();
360  std::shared_ptr<JetResolutionObject> payload2 = fetchPayload(std::get<1>(iov2));
361 
362  std::stringstream ss_tagname1(tag1.name);
363  std::stringstream ss_tagname2(tag2.name);
364  std::string stmp;
365 
366  std::string tag_ver1;
367  std::string tag_ver2;
368 
369  getline(ss_tagname1, stmp, '_'); // drop first
370  getline(ss_tagname1, stmp); // year
371  tag_ver1 = stmp;
372 
373  getline(ss_tagname2, stmp, '_'); // drop first
374  getline(ss_tagname2, stmp); // year
375  tag_ver2 = stmp;
376 
377  if (payload1.get() && payload2.get()) {
378  if (!payload1->getRecords().empty() && // No formula for SF
379  payload1->getDefinition().getFormulaString().compare("") == 0)
380  return false;
381 
382  for (size_t idx = 0; idx <= NBIN_ETA; idx++) {
383  double x_axis = (idx + 0.5) * (MAX_ETA - MIN_ETA) / NBIN_ETA + MIN_ETA;
384 
385  JetParameters j_param;
386  j_param.setJetPt(par_Pt);
387  j_param.setRho(par_Rho);
388  j_param.setJetEta(x_axis);
389 
390  if (payload1->getRecord(j_param) == nullptr || payload2->getRecord(j_param) == nullptr) {
391  continue;
392  }
393 
394  const JetResolutionObject::Record record1 = *(payload1->getRecord(j_param));
395  const JetResolutionObject::Record record2 = *(payload2->getRecord(j_param));
396  float res1 = payload1->evaluateFormula(record1, j_param);
397  resol_eta1->SetBinContent(idx + 1, res1);
398  float res2 = payload2->evaluateFormula(record2, j_param);
399  resol_eta2->SetBinContent(idx + 1, res2);
400  } // x-axis
401 
402  for (size_t idx = 0; idx <= NBIN_PT; idx++) {
403  double x_axis = (idx + 0.5) * (MAX_PT - MIN_PT) / NBIN_PT + MIN_PT;
404 
405  JetParameters j_param;
406  j_param.setJetEta(par_Eta);
407  j_param.setRho(par_Rho);
408  j_param.setJetPt(x_axis);
409 
410  if (payload1->getRecord(j_param) == nullptr || payload2->getRecord(j_param) == nullptr) {
411  continue;
412  }
413 
414  const JetResolutionObject::Record record1 = *(payload1->getRecord(j_param));
415  const JetResolutionObject::Record record2 = *(payload2->getRecord(j_param));
416  float res1 = payload1->evaluateFormula(record1, j_param);
417  resol_pt1->SetBinContent(idx + 1, res1);
418  float res2 = payload2->evaluateFormula(record2, j_param);
419  resol_pt2->SetBinContent(idx + 1, res2);
420  } // x-axis
421 
422  gStyle->SetOptStat(0);
423  gStyle->SetLabelFont(42, "XYZ");
424  gStyle->SetLabelSize(0.05, "XYZ");
425  gStyle->SetFrameLineWidth(3);
426 
427  std::string title = Form("Comparison between %s and %s", tag1.name.c_str(), tag2.name.c_str());
428  TCanvas canvas("Jet Resolution Comparison", title.c_str(), 800, 1200);
429  canvas.Divide(1, 2);
430 
431  canvas.cd(1);
432  resol_eta1->SetTitle("Jet Resolution Comparison vs. #eta");
433  resol_eta1->SetXTitle("#eta");
434  resol_eta1->SetYTitle("Resolution");
435  resol_eta1->SetLineWidth(3);
436  resol_eta1->SetMaximum(resol_eta1->GetMaximum() * 1.25);
437  resol_eta1->Draw("][");
438 
439  resol_eta2->SetLineColor(2);
440  resol_eta2->SetLineWidth(3);
441  resol_eta2->SetLineStyle(2);
442  resol_eta2->Draw("][same");
443 
444  leg_eta->AddEntry(resol_eta1, tag_ver1.c_str(), "l");
445  leg_eta->AddEntry(resol_eta2, tag_ver2.c_str(), "l");
446  leg_eta->AddEntry((TObject*)nullptr, Form("JetPt=%.2f; JetRho=%.2f", par_Pt, par_Rho), "");
447  leg_eta->Draw();
448 
449  canvas.cd(2);
450  resol_pt1->SetTitle("Jet Resolution Comparison vs. p_{T}");
451  resol_pt1->SetXTitle("p_{T} [GeV]");
452  resol_pt1->SetYTitle("Resolution");
453  resol_pt1->SetLineWidth(3);
454  resol_pt1->Draw("][");
455 
456  resol_pt2->SetLineColor(2);
457  resol_pt2->SetLineWidth(3);
458  resol_pt2->SetLineStyle(2);
459  resol_pt2->Draw("][same");
460 
461  leg_pt->AddEntry(resol_pt1, tag_ver1.c_str(), "l");
462  leg_pt->AddEntry(resol_pt2, tag_ver2.c_str(), "l");
463  leg_pt->AddEntry((TObject*)nullptr, Form("JetEta=%.2f; JetRho=%.2f", par_Eta, par_Rho), "");
464  leg_pt->Draw();
465 
466  canvas.SaveAs(m_imageFileName.c_str());
467 
468  return true;
469  } else // no payload.get()
470  return false;
471  } // fill
const std::map< std::string, std::string > & inputParamValues() const
def canvas(sub, attr)
Definition: svgfig.py:482
std::shared_ptr< JetResolutionObject > fetchPayload(const cond::Hash &payloadHash)