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 697 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 705 of file JetResolution_PayloadInspector.cc.

References svgfig::canvas(), cond::payloadInspector::PlotBase::inputParamValues(), MAX_ETA, MAX_PT, MIN_ETA, MIN_PT, NBIN_ETA, NBIN_PT, jetsAK4_Puppi_cff::payload, AlCaHarvesting_cff::record, writedatasetfile::run, AlCaHLTBitMon_QueryRunRegistry::string, makeGlobalPositionRcd_cfg::tag, createPayload::tagname, and runGCPTkAlMap::title.

705  {
706  double par_Pt = 100.;
707  double par_Eta = 1.;
708 
710  auto ip = paramValues.find("Jet_Pt");
711  if (ip != paramValues.end()) {
712  par_Pt = std::stod(ip->second);
713  }
714  ip = paramValues.find("Jet_Eta");
715  if (ip != paramValues.end()) {
716  par_Eta = std::stod(ip->second);
717  }
718 
719  TH1D* sf_eta_norm = new TH1D("Jet SF vs #eta NORM", "", NBIN_ETA, MIN_ETA, MAX_ETA);
720  TH1D* sf_eta_down = new TH1D("Jet SF vs #eta DOWN", "", NBIN_ETA, MIN_ETA, MAX_ETA);
721  TH1D* sf_eta_up = new TH1D("Jet SF vs #eta UP", "", NBIN_ETA, MIN_ETA, MAX_ETA);
722  TH1D* sf_pt_norm = new TH1D("Jet SF vs p_T NORM", "", NBIN_PT, MIN_PT, MAX_PT);
723  TH1D* sf_pt_down = new TH1D("Jet SF vs p_T DOWN", "", NBIN_PT, MIN_PT, MAX_PT);
724  TH1D* sf_pt_up = new TH1D("Jet SF vs p_T UP", "", NBIN_PT, MIN_PT, MAX_PT);
725 
726  TLegend* leg_eta = new TLegend(0.26, 0.73, 0.935, 0.90);
727  TLegend* leg_pt = new TLegend(0.26, 0.73, 0.935, 0.90);
728 
729  leg_eta->SetBorderSize(0);
730  leg_eta->SetLineStyle(0);
731  leg_eta->SetFillStyle(0);
732 
733  leg_eta->SetTextFont(42);
734  leg_pt->SetBorderSize(0);
735  leg_pt->SetLineStyle(0);
736  leg_pt->SetFillStyle(0);
737 
738  auto tag = PlotBase::getTag<0>();
739  auto iov = tag.iovs.front();
740  std::shared_ptr<JetResolutionObject> payload = fetchPayload(std::get<1>(iov));
741  unsigned int run = std::get<0>(iov);
742  std::string tagname = tag.name;
743  std::stringstream ss_tagname(tag.name);
744  std::string stmp;
745 
746  std::string tag_ver;
747  std::string tag_res;
748  std::string tag_jet;
749 
750  getline(ss_tagname, stmp, '_'); // drop first
751  getline(ss_tagname, stmp, '_'); // year
752  tag_ver = stmp;
753  getline(ss_tagname, stmp, '_'); // ver
754  tag_ver += '_' + stmp;
755  getline(ss_tagname, stmp, '_'); // cmssw
756  tag_ver += '_' + stmp;
757  getline(ss_tagname, stmp, '_'); // data/mc
758  tag_ver += '_' + stmp;
759  getline(ss_tagname, stmp, '_'); // bin
760  tag_res = stmp;
761  getline(ss_tagname, stmp, '_'); // jet algorithm
762  tag_jet = stmp;
763 
764  bool is_2bin = false;
765 
766  if (payload.get()) {
767  if (!payload->getRecords().empty() && // No formula for SF
768  payload->getDefinition().getFormulaString().compare("") != 0)
769  return false;
770 
771  is_2bin = false;
772  for (const auto& record : payload->getRecords()) {
773  if (record.getBinsRange().size() > 1)
774  is_2bin = true;
775 
776  if (!record.getBinsRange().empty() && payload->getDefinition().getBinName(0) == "JetEta" &&
777  record.getParametersValues().size() == 3) { // norm, down, up
778 
779  for (size_t it = 0; it <= NBIN_ETA; it++) {
780  double x_axis = (it + 0.5) * (MAX_ETA - MIN_ETA) / NBIN_ETA + MIN_ETA;
781  if (((is_2bin == false) || (is_2bin == true && record.getBinsRange()[1].is_inside(par_Pt))) &&
782  record.getBinsRange()[0].is_inside(x_axis)) {
783  sf_eta_norm->SetBinContent(it + 1, record.getParametersValues()[0]);
784  sf_eta_down->SetBinContent(it + 1, record.getParametersValues()[1]);
785  sf_eta_up->SetBinContent(it + 1, record.getParametersValues()[2]);
786  }
787  }
788  }
789 
790  if (record.getBinsRange().size() > 1 && payload->getDefinition().getBinName(0) == "JetEta" &&
791  record.getBinsRange()[0].is_inside(par_Eta) && // take jeteta=2.5
792  payload->getDefinition().getBinName(1) == "JetPt" &&
793  record.getParametersValues().size() == 3) { // norm, down, up
794 
795  is_2bin = true;
796 
797  for (size_t it = 0; it <= NBIN_PT; it++) {
798  double x_axis = (it + 0.5) * (MAX_PT - MIN_PT) / NBIN_PT + MIN_PT;
799  if (record.getBinsRange()[1].is_inside(x_axis)) {
800  sf_pt_norm->SetBinContent(it + 1, record.getParametersValues()[0]);
801  sf_pt_down->SetBinContent(it + 1, record.getParametersValues()[1]);
802  sf_pt_up->SetBinContent(it + 1, record.getParametersValues()[2]);
803  }
804  }
805  } // 2-bin
806  } // records
807 
808  gStyle->SetOptStat(0);
809  gStyle->SetLabelFont(42, "XYZ");
810  gStyle->SetLabelSize(0.05, "XYZ");
811  gStyle->SetFrameLineWidth(3);
812 
813  std::string title = Form("Summary Run %i", run);
814  TCanvas canvas("Jet ScaleFactor Summary", title.c_str(), 800, 1200);
815  canvas.Divide(1, 2);
816 
817  canvas.cd(1);
818  sf_eta_up->SetTitle("ScaleFactor vs. #eta");
819  sf_eta_up->SetXTitle("#eta");
820  sf_eta_up->SetYTitle("Scale Factor");
821  sf_eta_up->SetLineStyle(7);
822  sf_eta_up->SetLineWidth(3);
823  sf_eta_up->SetFillColorAlpha(kGray, 0.5);
824  sf_eta_up->SetMaximum(sf_eta_up->GetMaximum() * 1.25);
825  sf_eta_up->SetMinimum(0.);
826  sf_eta_up->Draw("][");
827 
828  sf_eta_down->SetLineStyle(7);
829  sf_eta_down->SetLineWidth(3);
830  sf_eta_down->SetFillColorAlpha(kWhite, 1);
831  sf_eta_down->Draw("][ same");
832 
833  sf_eta_norm->SetLineStyle(1);
834  sf_eta_norm->SetLineWidth(5);
835  sf_eta_norm->SetFillColor(0);
836  sf_eta_norm->Draw("][ same");
837  sf_eta_norm->Draw("axis same");
838 
839  leg_eta->AddEntry(sf_eta_norm, (tag_ver + '_' + tag_jet).c_str(), "l");
840  leg_eta->AddEntry((TObject*)nullptr, Form("JetPt=%.2f", par_Pt), "");
841  leg_eta->Draw();
842 
843  if (is_2bin == true) {
844  canvas.cd(2);
845  sf_pt_up->SetTitle("ScaleFactor vs. p_{T}");
846  sf_pt_up->SetXTitle("p_{T} [GeV]");
847  sf_pt_up->SetYTitle("Scale Factor");
848  sf_pt_up->SetLineStyle(7);
849  sf_pt_up->SetLineWidth(3);
850  sf_pt_up->SetFillColorAlpha(kGray, 0.5);
851  sf_pt_up->SetMaximum(sf_pt_up->GetMaximum() * 1.25);
852  sf_pt_up->SetMinimum(0.);
853  sf_pt_up->Draw("][");
854 
855  sf_pt_down->SetLineStyle(7);
856  sf_pt_down->SetLineWidth(3);
857  sf_pt_down->SetFillColorAlpha(kWhite, 1);
858  sf_pt_down->Draw("][ same");
859 
860  sf_pt_norm->SetLineStyle(1);
861  sf_pt_norm->SetLineWidth(5);
862  sf_pt_norm->SetFillColor(0);
863  sf_pt_norm->Draw("][ same");
864  sf_pt_norm->Draw("axis same");
865 
866  leg_pt->AddEntry(sf_pt_norm, (tag_ver + '_' + tag_jet).c_str(), "l");
867  leg_pt->AddEntry((TObject*)nullptr, Form("JetEta=%.2f", par_Eta), "");
868  leg_pt->Draw();
869  }
870 
871  canvas.SaveAs(m_imageFileName.c_str());
872 
873  return true;
874  } else // no payload.get()
875  return false;
876  } // 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)