CMS 3D CMS Logo

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

Public Member Functions

bool fill () override
 
 JetScaleFactorSummary ()
 
- Public Member Functions inherited from cond::payloadInspector::PlotImage< JetResolutionObject, SINGLE_IOV >
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, 0 >
 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 >
typedef PlotImpl< IOV_M, 0 > Base
 
- Protected Attributes inherited from cond::payloadInspector::PlotImage< JetResolutionObject, SINGLE_IOV >
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 599 of file JetResolution_PayloadInspector.cc.

Constructor & Destructor Documentation

◆ JetScaleFactorSummary()

JME::JetScaleFactorSummary::JetScaleFactorSummary ( )
inline

Member Function Documentation

◆ fill()

bool JME::JetScaleFactorSummary::fill ( )
inlineoverridevirtual

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

Definition at line 607 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, jetsAK4_Puppi_cff::payload, Hcal_FrontierConditions_cff::record, writedatasetfile::run, JME::JetParameters::setJetEta(), JME::JetParameters::setJetPt(), AlCaHLTBitMon_QueryRunRegistry::string, makeGlobalPositionRcd_cfg::tag, createPayload::tagname, and runGCPTkAlMap::title.

607  {
608  double par_Pt = 100.;
609  double par_Eta = 1.;
610 
612  auto ip = paramValues.find("Jet_Pt");
613  if (ip != paramValues.end()) {
614  par_Pt = std::stod(ip->second);
615  }
616  ip = paramValues.find("Jet_Eta");
617  if (ip != paramValues.end()) {
618  par_Eta = std::stod(ip->second);
619  }
620 
621  TH1D* sf_eta_norm = new TH1D("Jet SF vs #eta NORM", "", NBIN_ETA, MIN_ETA, MAX_ETA);
622  TH1D* sf_eta_down = new TH1D("Jet SF vs #eta DOWN", "", NBIN_ETA, MIN_ETA, MAX_ETA);
623  TH1D* sf_eta_up = new TH1D("Jet SF vs #eta UP", "", NBIN_ETA, MIN_ETA, MAX_ETA);
624  TH1D* sf_pt_norm = new TH1D("Jet SF vs p_T NORM", "", NBIN_PT, MIN_PT, MAX_PT);
625  TH1D* sf_pt_down = new TH1D("Jet SF vs p_T DOWN", "", NBIN_PT, MIN_PT, MAX_PT);
626  TH1D* sf_pt_up = new TH1D("Jet SF vs p_T UP", "", NBIN_PT, MIN_PT, MAX_PT);
627 
628  TLegend* leg_eta = new TLegend(0.26, 0.73, 0.935, 0.90);
629  TLegend* leg_pt = new TLegend(0.26, 0.73, 0.935, 0.90);
630 
631  leg_eta->SetBorderSize(0);
632  leg_eta->SetLineStyle(0);
633  leg_eta->SetFillStyle(0);
634 
635  leg_eta->SetTextFont(42);
636  leg_pt->SetBorderSize(0);
637  leg_pt->SetLineStyle(0);
638  leg_pt->SetFillStyle(0);
639 
640  auto tag = PlotBase::getTag<0>();
641  auto iov = tag.iovs.front();
642  std::shared_ptr<JetResolutionObject> payload = fetchPayload(std::get<1>(iov));
643  unsigned int run = std::get<0>(iov);
644  std::string tagname = tag.name;
645  std::stringstream ss_tagname(tag.name);
646  std::string stmp;
647 
648  std::string tag_ver;
649  std::string tag_res;
650  std::string tag_jet;
651 
652  getline(ss_tagname, stmp, '_'); // drop first
653  getline(ss_tagname, stmp, '_'); // year
654  tag_ver = stmp;
655  getline(ss_tagname, stmp, '_'); // ver
656  tag_ver += '_' + stmp;
657  getline(ss_tagname, stmp, '_'); // cmssw
658  tag_ver += '_' + stmp;
659  getline(ss_tagname, stmp, '_'); // data/mc
660  tag_ver += '_' + stmp;
661  getline(ss_tagname, stmp, '_'); // bin
662  tag_res = stmp;
663  getline(ss_tagname, stmp, '_'); // jet algorithm
664  tag_jet = stmp;
665 
666  bool is_2bin = false;
667 
668  if (payload.get()) {
669  if (!payload->getRecords().empty() && // No formula for SF
670  payload->getDefinition().getFormulaString().compare("") != 0)
671  return false;
672 
673  is_2bin = false;
674  for (size_t idx = 0; idx <= NBIN_ETA; idx++) {
675  double x_axis = (idx + 0.5) * (MAX_ETA - MIN_ETA) / NBIN_ETA + MIN_ETA;
676 
677  JetParameters j_param;
678  j_param.setJetPt(par_Pt);
679  j_param.setJetEta(x_axis);
680 
681  if (payload->getRecord(j_param) == nullptr) {
682  continue;
683  }
684 
685  const JetResolutionObject::Record record = *(payload->getRecord(j_param));
686  if (record.getBinsRange().size() > 1)
687  is_2bin = true;
688 
689  if (record.getParametersValues().size() == 3) { // norm, down, up
690  sf_eta_norm->SetBinContent(idx + 1, record.getParametersValues()[0]);
691  sf_eta_down->SetBinContent(idx + 1, record.getParametersValues()[1]);
692  sf_eta_up->SetBinContent(idx + 1, record.getParametersValues()[2]);
693  }
694  } // x-axis
695 
696  for (size_t idx = 0; idx <= NBIN_PT; idx++) {
697  double x_axis = (idx + 0.5) * (MAX_PT - MIN_PT) / NBIN_PT + MIN_PT;
698 
699  JetParameters j_param;
700  j_param.setJetEta(par_Eta);
701  j_param.setJetPt(x_axis);
702 
703  if (payload->getRecord(j_param) == nullptr) {
704  continue;
705  }
706 
707  const JetResolutionObject::Record record = *(payload->getRecord(j_param));
708  if (record.getParametersValues().size() == 3) { // norm, down, up
709  sf_pt_norm->SetBinContent(idx + 1, record.getParametersValues()[0]);
710  sf_pt_down->SetBinContent(idx + 1, record.getParametersValues()[1]);
711  sf_pt_up->SetBinContent(idx + 1, record.getParametersValues()[2]);
712  }
713  } // x-axis
714 
715  gStyle->SetOptStat(0);
716  gStyle->SetLabelFont(42, "XYZ");
717  gStyle->SetLabelSize(0.05, "XYZ");
718  gStyle->SetFrameLineWidth(3);
719 
720  std::string title = Form("Summary Run %i", run);
721  TCanvas canvas("Jet ScaleFactor Summary", title.c_str(), 800, 1200);
722  canvas.Divide(1, 2);
723 
724  canvas.cd(1);
725  sf_eta_up->SetTitle("ScaleFactor vs. #eta");
726  sf_eta_up->SetXTitle("#eta");
727  sf_eta_up->SetYTitle("Scale Factor");
728  sf_eta_up->SetLineStyle(7);
729  sf_eta_up->SetLineWidth(3);
730  sf_eta_up->SetFillColorAlpha(kGray, 0.5);
731  sf_eta_up->SetMaximum(sf_eta_up->GetMaximum() * 1.25);
732  sf_eta_up->SetMinimum(0.);
733  sf_eta_up->Draw("][");
734 
735  sf_eta_down->SetLineStyle(7);
736  sf_eta_down->SetLineWidth(3);
737  sf_eta_down->SetFillColorAlpha(kWhite, 1);
738  sf_eta_down->Draw("][ same");
739 
740  sf_eta_norm->SetLineStyle(1);
741  sf_eta_norm->SetLineWidth(5);
742  sf_eta_norm->SetFillColor(0);
743  sf_eta_norm->Draw("][ same");
744  sf_eta_norm->Draw("axis same");
745 
746  leg_eta->AddEntry(sf_eta_norm, (tag_ver + '_' + tag_jet).c_str(), "l");
747  leg_eta->AddEntry((TObject*)nullptr, Form("JetPt=%.2f", par_Pt), "");
748  leg_eta->Draw();
749 
750  if (is_2bin == true) {
751  canvas.cd(2);
752  sf_pt_up->SetTitle("ScaleFactor vs. p_{T}");
753  sf_pt_up->SetXTitle("p_{T} [GeV]");
754  sf_pt_up->SetYTitle("Scale Factor");
755  sf_pt_up->SetLineStyle(7);
756  sf_pt_up->SetLineWidth(3);
757  sf_pt_up->SetFillColorAlpha(kGray, 0.5);
758  sf_pt_up->SetMaximum(sf_pt_up->GetMaximum() * 1.25);
759  sf_pt_up->SetMinimum(0.);
760  sf_pt_up->Draw("][");
761 
762  sf_pt_down->SetLineStyle(7);
763  sf_pt_down->SetLineWidth(3);
764  sf_pt_down->SetFillColorAlpha(kWhite, 1);
765  sf_pt_down->Draw("][ same");
766 
767  sf_pt_norm->SetLineStyle(1);
768  sf_pt_norm->SetLineWidth(5);
769  sf_pt_norm->SetFillColor(0);
770  sf_pt_norm->Draw("][ same");
771  sf_pt_norm->Draw("axis same");
772 
773  leg_pt->AddEntry(sf_pt_norm, (tag_ver + '_' + tag_jet).c_str(), "l");
774  leg_pt->AddEntry((TObject*)nullptr, Form("JetEta=%.2f", par_Eta), "");
775  leg_pt->Draw();
776  }
777 
778  canvas.SaveAs(m_imageFileName.c_str());
779 
780  return true;
781  } else // no payload.get()
782  return false;
783  } // 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)