CMS 3D CMS Logo

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

Public Member Functions

bool fill () override
 
 JetScaleFactorCompare ()
 
- 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 880 of file JetResolution_PayloadInspector.cc.

Constructor & Destructor Documentation

◆ JetScaleFactorCompare()

JME::JetScaleFactorCompare::JetScaleFactorCompare ( )
inline

Member Function Documentation

◆ fill()

bool JME::JetScaleFactorCompare::fill ( )
inlineoverridevirtual

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

Definition at line 888 of file JetResolution_PayloadInspector.cc.

References svgfig::canvas(), cond::payloadInspector::PlotBase::inputParamValues(), MAX_ETA, MAX_PT, MIN_ETA, MIN_PT, NBIN_ETA, NBIN_PT, AlCaHarvesting_cff::record, AlCaHLTBitMon_QueryRunRegistry::string, and runGCPTkAlMap::title.

888  {
889  double par_Pt = 100.;
890  double par_Eta = 1.;
891 
893  auto ip = paramValues.find("Jet_Pt");
894  if (ip != paramValues.end()) {
895  par_Pt = std::stod(ip->second);
896  }
897  ip = paramValues.find("Jet_Eta");
898  if (ip != paramValues.end()) {
899  par_Eta = std::stod(ip->second);
900  }
901 
902  TH1D* sf_eta_one = new TH1D("Jet SF vs #eta one", "", NBIN_ETA, MIN_ETA, MAX_ETA);
903  TH1D* sf_eta_two = new TH1D("Jet SF vs #eta two", "", NBIN_ETA, MIN_ETA, MAX_ETA);
904  TH1D* sf_pt_one = new TH1D("Jet SF vs p_T one", "", NBIN_PT, MIN_PT, MAX_PT);
905  TH1D* sf_pt_two = new TH1D("Jet SF vs p_T two", "", NBIN_PT, MIN_PT, MAX_PT);
906 
907  TLegend* leg_eta = new TLegend(0.26, 0.73, 0.935, 0.90);
908  TLegend* leg_pt = new TLegend(0.26, 0.73, 0.935, 0.90);
909 
910  leg_eta->SetBorderSize(0);
911  leg_eta->SetLineStyle(0);
912  leg_eta->SetFillStyle(0);
913 
914  leg_eta->SetTextFont(42);
915  leg_pt->SetBorderSize(0);
916  leg_pt->SetLineStyle(0);
917  leg_pt->SetFillStyle(0);
918 
919  auto tag1 = PlotBase::getTag<0>();
920  auto iov1 = tag1.iovs.front();
921  std::shared_ptr<JetResolutionObject> payload1 = fetchPayload(std::get<1>(iov1));
922 
923  auto tag2 = PlotBase::getTag<1>();
924  auto iov2 = tag2.iovs.front();
925  std::shared_ptr<JetResolutionObject> payload2 = fetchPayload(std::get<1>(iov2));
926 
927  std::stringstream ss_tagname1(tag1.name);
928  std::stringstream ss_tagname2(tag2.name);
929  std::string stmp;
930 
931  std::string tag_ver1;
932  std::string tag_ver2;
933 
934  getline(ss_tagname1, stmp, '_'); // drop first
935  getline(ss_tagname1, stmp); // year
936  tag_ver1 = stmp;
937 
938  getline(ss_tagname2, stmp, '_'); // drop first
939  getline(ss_tagname2, stmp); // year
940  tag_ver2 = stmp;
941 
942  bool is_2bin = false;
943 
944  if (payload1.get() && payload2.get()) {
945  if (!payload1->getRecords().empty() && // No formula for SF
946  payload1->getDefinition().getFormulaString().compare("") != 0)
947  return false;
948 
949  is_2bin = false;
950  for (const auto& record : payload1->getRecords()) {
951  if (record.getBinsRange().size() > 1)
952  is_2bin = true;
953 
954  if (!record.getBinsRange().empty() && payload1->getDefinition().getBinName(0) == "JetEta" &&
955  record.getParametersValues().size() == 3) { // norm, down, up
956 
957  for (size_t it = 0; it <= NBIN_ETA; it++) {
958  double x_axis = (it + 0.5) * (MAX_ETA - MIN_ETA) / NBIN_ETA + MIN_ETA;
959  if (((is_2bin == false) || (is_2bin == true && record.getBinsRange()[1].is_inside(par_Pt))) &&
960  record.getBinsRange()[0].is_inside(x_axis)) {
961  sf_eta_one->SetBinContent(it + 1, record.getParametersValues()[0]);
962  }
963  }
964  }
965 
966  if (record.getBinsRange().size() > 1 && payload1->getDefinition().getBinName(0) == "JetEta" &&
967  record.getBinsRange()[0].is_inside(par_Eta) && // take jeteta=2.5
968  payload1->getDefinition().getBinName(1) == "JetPt" &&
969  record.getParametersValues().size() == 3) { // norm, down, up
970 
971  is_2bin = true;
972 
973  for (size_t it = 0; it <= NBIN_PT; it++) {
974  double x_axis = (it + 0.5) * (MAX_PT - MIN_PT) / NBIN_PT + MIN_PT;
975  if (record.getBinsRange()[1].is_inside(x_axis)) {
976  sf_pt_one->SetBinContent(it + 1, record.getParametersValues()[0]);
977  }
978  }
979  } // 2-bin
980  } // records
981 
982  is_2bin = false;
983  for (const auto& record : payload2->getRecords()) {
984  if (record.getBinsRange().size() > 1)
985  is_2bin = true;
986 
987  if (!record.getBinsRange().empty() && payload2->getDefinition().getBinName(0) == "JetEta" &&
988  record.getParametersValues().size() == 3) { // norm, down, up
989 
990  for (size_t it = 0; it <= NBIN_ETA; it++) {
991  double x_axis = (it + 0.5) * (MAX_ETA - MIN_ETA) / NBIN_ETA + MIN_ETA;
992  if (((is_2bin == false) || (is_2bin == true && record.getBinsRange()[1].is_inside(par_Pt))) &&
993  record.getBinsRange()[0].is_inside(x_axis)) {
994  sf_eta_two->SetBinContent(it + 1, record.getParametersValues()[0]);
995  }
996  }
997  }
998 
999  if (record.getBinsRange().size() > 1 && payload2->getDefinition().getBinName(0) == "JetEta" &&
1000  record.getBinsRange()[0].is_inside(par_Eta) && // take jeteta=2.5
1001  payload2->getDefinition().getBinName(1) == "JetPt" &&
1002  record.getParametersValues().size() == 3) { // norm, down, up
1003 
1004  is_2bin = true;
1005 
1006  for (size_t it = 0; it <= NBIN_PT; it++) {
1007  double x_axis = (it + 0.5) * (MAX_PT - MIN_PT) / NBIN_PT + MIN_PT;
1008  if (record.getBinsRange()[1].is_inside(x_axis)) {
1009  sf_pt_two->SetBinContent(it + 1, record.getParametersValues()[0]);
1010  }
1011  }
1012  } // 2-bin
1013  } // records
1014 
1015  gStyle->SetOptStat(0);
1016  gStyle->SetLabelFont(42, "XYZ");
1017  gStyle->SetLabelSize(0.05, "XYZ");
1018  gStyle->SetFrameLineWidth(3);
1019 
1020  std::string title = Form("Comparison");
1021  TCanvas canvas("Jet ScaleFactor", title.c_str(), 800, 1200);
1022  canvas.Divide(1, 2);
1023 
1024  canvas.cd(1);
1025  sf_eta_one->SetTitle("Jet ScaleFactor vs. #eta");
1026  sf_eta_one->SetXTitle("#eta");
1027  sf_eta_one->SetYTitle("Scale Factor");
1028  sf_eta_one->SetLineWidth(3);
1029  sf_eta_one->SetMaximum(sf_eta_one->GetMaximum() * 1.25);
1030  sf_eta_one->SetMinimum(0.);
1031  sf_eta_one->Draw("][");
1032 
1033  sf_eta_two->SetLineColor(2);
1034  sf_eta_two->SetLineWidth(3);
1035  sf_eta_two->SetLineStyle(2);
1036  sf_eta_two->Draw("][ same");
1037 
1038  leg_eta->AddEntry(sf_eta_one, tag_ver1.c_str(), "l");
1039  leg_eta->AddEntry(sf_eta_two, tag_ver2.c_str(), "l");
1040  leg_eta->AddEntry((TObject*)nullptr, Form("JetPt=%.2f", par_Pt), "");
1041  leg_eta->Draw();
1042 
1043  if (is_2bin == true) {
1044  canvas.cd(2);
1045  sf_pt_one->SetTitle("Jet ScaleFactor vs. p_{T}");
1046  sf_pt_one->SetXTitle("p_{T} [GeV]");
1047  sf_pt_one->SetYTitle("Scale Factor");
1048  sf_pt_one->SetLineWidth(3);
1049  sf_pt_one->SetMaximum(sf_pt_one->GetMaximum() * 1.25);
1050  sf_pt_one->SetMinimum(0.);
1051  sf_pt_one->Draw("][");
1052 
1053  sf_pt_two->SetLineColor(2);
1054  sf_pt_two->SetLineWidth(3);
1055  sf_pt_two->SetLineStyle(2);
1056  sf_pt_two->Draw("][ same");
1057 
1058  leg_pt->AddEntry(sf_pt_one, tag_ver1.c_str(), "l");
1059  leg_pt->AddEntry(sf_pt_two, tag_ver2.c_str(), "l");
1060  leg_pt->AddEntry((TObject*)nullptr, Form("JetEta=%.2f", par_Eta), "");
1061  leg_pt->Draw();
1062  }
1063 
1064  canvas.SaveAs(m_imageFileName.c_str());
1065 
1066  return true;
1067  } else // no payload.get()
1068  return false;
1069  } // 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)