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 787 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 795 of file JetResolution_PayloadInspector.cc.

References svgfig::canvas(), JME::JetResolutionObject::Record::getBinsRange(), JME::JetResolutionObject::Record::getParametersValues(), 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(), AlCaHLTBitMon_QueryRunRegistry::string, and runGCPTkAlMap::title.

795  {
796  double par_Pt = 100.;
797  double par_Eta = 1.;
798 
800  auto ip = paramValues.find("Jet_Pt");
801  if (ip != paramValues.end()) {
802  par_Pt = std::stod(ip->second);
803  }
804  ip = paramValues.find("Jet_Eta");
805  if (ip != paramValues.end()) {
806  par_Eta = std::stod(ip->second);
807  }
808 
809  TH1D* sf_eta_one = new TH1D("Jet SF vs #eta one", "", NBIN_ETA, MIN_ETA, MAX_ETA);
810  TH1D* sf_eta_two = new TH1D("Jet SF vs #eta two", "", NBIN_ETA, MIN_ETA, MAX_ETA);
811  TH1D* sf_pt_one = new TH1D("Jet SF vs p_T one", "", NBIN_PT, MIN_PT, MAX_PT);
812  TH1D* sf_pt_two = new TH1D("Jet SF vs p_T two", "", NBIN_PT, MIN_PT, MAX_PT);
813 
814  TLegend* leg_eta = new TLegend(0.26, 0.73, 0.935, 0.90);
815  TLegend* leg_pt = new TLegend(0.26, 0.73, 0.935, 0.90);
816 
817  leg_eta->SetBorderSize(0);
818  leg_eta->SetLineStyle(0);
819  leg_eta->SetFillStyle(0);
820 
821  leg_eta->SetTextFont(42);
822  leg_pt->SetBorderSize(0);
823  leg_pt->SetLineStyle(0);
824  leg_pt->SetFillStyle(0);
825 
826  auto tag1 = PlotBase::getTag<0>();
827  auto iov1 = tag1.iovs.front();
828  std::shared_ptr<JetResolutionObject> payload1 = fetchPayload(std::get<1>(iov1));
829 
830  auto tag2 = PlotBase::getTag<1>();
831  auto iov2 = tag2.iovs.front();
832  std::shared_ptr<JetResolutionObject> payload2 = fetchPayload(std::get<1>(iov2));
833 
834  std::stringstream ss_tagname1(tag1.name);
835  std::stringstream ss_tagname2(tag2.name);
836  std::string stmp;
837 
838  std::string tag_ver1;
839  std::string tag_ver2;
840 
841  getline(ss_tagname1, stmp, '_'); // drop first
842  getline(ss_tagname1, stmp); // year
843  tag_ver1 = stmp;
844 
845  getline(ss_tagname2, stmp, '_'); // drop first
846  getline(ss_tagname2, stmp); // year
847  tag_ver2 = stmp;
848 
849  bool is_2bin = false;
850 
851  if (payload1.get() && payload2.get()) {
852  if (!payload1->getRecords().empty() && // No formula for SF
853  payload1->getDefinition().getFormulaString().compare("") != 0)
854  return false;
855 
856  is_2bin = false;
857  for (size_t idx = 0; idx <= NBIN_ETA; idx++) {
858  double x_axis = (idx + 0.5) * (MAX_ETA - MIN_ETA) / NBIN_ETA + MIN_ETA;
859 
860  JetParameters j_param;
861  j_param.setJetPt(par_Pt);
862  j_param.setJetEta(x_axis);
863 
864  const JetResolutionObject::Record* rcd_p1 = payload1->getRecord(j_param);
865  const JetResolutionObject::Record* rcd_p2 = payload2->getRecord(j_param);
866  if (rcd_p1 == nullptr || rcd_p2 == nullptr) {
867  continue;
868  }
869 
870  const JetResolutionObject::Record record1 = *(rcd_p1);
871  const JetResolutionObject::Record record2 = *(rcd_p2);
872 
873  if (record1.getBinsRange().size() > 1 && record2.getBinsRange().size() > 1)
874  is_2bin = true;
875 
876  if (record1.getParametersValues().size() == 3) { // norm, down, up
877  sf_eta_one->SetBinContent(idx + 1, record1.getParametersValues()[0]);
878  }
879  if (record2.getParametersValues().size() == 3) { // norm, down, up
880  sf_eta_two->SetBinContent(idx + 1, record2.getParametersValues()[0]);
881  }
882  } // x-axis
883 
884  for (size_t idx = 0; idx <= NBIN_PT; idx++) {
885  double x_axis = (idx + 0.5) * (MAX_PT - MIN_PT) / NBIN_PT + MIN_PT;
886 
887  JetParameters j_param;
888  j_param.setJetEta(par_Eta);
889  j_param.setJetPt(x_axis);
890 
891  const JetResolutionObject::Record* rcd_p1 = payload1->getRecord(j_param);
892  const JetResolutionObject::Record* rcd_p2 = payload2->getRecord(j_param);
893  if (rcd_p1 == nullptr || rcd_p2 == nullptr) {
894  continue;
895  }
896 
897  const JetResolutionObject::Record record1 = *(rcd_p1);
898  const JetResolutionObject::Record record2 = *(rcd_p2);
899 
900  if (record1.getParametersValues().size() == 3) { // norm, down, up
901  sf_pt_one->SetBinContent(idx + 1, record1.getParametersValues()[0]);
902  }
903  if (record2.getParametersValues().size() == 3) { // norm, down, up
904  sf_pt_two->SetBinContent(idx + 1, record2.getParametersValues()[0]);
905  }
906  } // x-axis
907 
908  gStyle->SetOptStat(0);
909  gStyle->SetLabelFont(42, "XYZ");
910  gStyle->SetLabelSize(0.05, "XYZ");
911  gStyle->SetFrameLineWidth(3);
912 
913  std::string title = Form("Comparison");
914  TCanvas canvas("Jet ScaleFactor", title.c_str(), 800, 1200);
915  canvas.Divide(1, 2);
916 
917  canvas.cd(1);
918  sf_eta_one->SetTitle("Jet ScaleFactor Comparison vs. #eta");
919  sf_eta_one->SetXTitle("#eta");
920  sf_eta_one->SetYTitle("Scale Factor");
921  sf_eta_one->SetLineWidth(3);
922  sf_eta_one->SetMaximum(sf_eta_one->GetMaximum() * 1.25);
923  sf_eta_one->SetMinimum(0.);
924  sf_eta_one->Draw("][");
925 
926  sf_eta_two->SetLineColor(2);
927  sf_eta_two->SetLineWidth(3);
928  sf_eta_two->SetLineStyle(2);
929  sf_eta_two->Draw("][ same");
930 
931  leg_eta->AddEntry(sf_eta_one, tag_ver1.c_str(), "l");
932  leg_eta->AddEntry(sf_eta_two, tag_ver2.c_str(), "l");
933  leg_eta->AddEntry((TObject*)nullptr, Form("JetPt=%.2f", par_Pt), "");
934  leg_eta->Draw();
935 
936  if (is_2bin == true) {
937  canvas.cd(2);
938  sf_pt_one->SetTitle("Jet ScaleFactor Comparison vs. p_{T}");
939  sf_pt_one->SetXTitle("p_{T} [GeV]");
940  sf_pt_one->SetYTitle("Scale Factor");
941  sf_pt_one->SetLineWidth(3);
942  sf_pt_one->SetMaximum(sf_pt_one->GetMaximum() * 1.25);
943  sf_pt_one->SetMinimum(0.);
944  sf_pt_one->Draw("][");
945 
946  sf_pt_two->SetLineColor(2);
947  sf_pt_two->SetLineWidth(3);
948  sf_pt_two->SetLineStyle(2);
949  sf_pt_two->Draw("][ same");
950 
951  leg_pt->AddEntry(sf_pt_one, tag_ver1.c_str(), "l");
952  leg_pt->AddEntry(sf_pt_two, tag_ver2.c_str(), "l");
953  leg_pt->AddEntry((TObject*)nullptr, Form("JetEta=%.2f", par_Eta), "");
954  leg_pt->Draw();
955  }
956 
957  canvas.SaveAs(m_imageFileName.c_str());
958 
959  return true;
960  } else // no payload.get()
961  return false;
962  } // 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)