CMS 3D CMS Logo

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

Public Member Functions

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

Constructor & Destructor Documentation

◆ JetResolutionSummary()

JME::JetResolutionSummary::JetResolutionSummary ( )
inline

Member Function Documentation

◆ fill()

bool JME::JetResolutionSummary::fill ( )
inlineoverridevirtual

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

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

172  {
173  double par_Pt = 100.;
174  double par_Eta = 1.;
175  double par_Rho = 20.;
176 
178  auto ip = paramValues.find("Jet_Pt");
179  if (ip != paramValues.end()) {
180  par_Pt = std::stod(ip->second);
181  }
182  ip = paramValues.find("Jet_Eta");
183  if (ip != paramValues.end()) {
184  par_Eta = std::stod(ip->second);
185  }
186  ip = paramValues.find("Jet_Rho");
187  if (ip != paramValues.end()) {
188  par_Rho = std::stod(ip->second);
189  }
190 
191  TH1D* resol_eta = new TH1D("Jet Resolution vs #eta", "", NBIN_ETA, MIN_ETA, MAX_ETA);
192  TH1D* resol_pt = new TH1D("Jet Resolution vs p_T", "", NBIN_PT, MIN_PT, MAX_PT);
193  TLegend* leg_eta = new TLegend(0.26, 0.73, 0.935, 0.90);
194  TLegend* leg_pt = new TLegend(0.26, 0.73, 0.935, 0.90);
195 
196  leg_eta->SetBorderSize(0);
197  leg_eta->SetLineStyle(0);
198  leg_eta->SetFillStyle(0);
199 
200  leg_eta->SetTextFont(42);
201  leg_pt->SetBorderSize(0);
202  leg_pt->SetLineStyle(0);
203  leg_pt->SetFillStyle(0);
204 
205  auto tag = PlotBase::getTag<0>();
206  auto iov = tag.iovs.front();
207  std::shared_ptr<JetResolutionObject> payload = fetchPayload(std::get<1>(iov));
208  unsigned int run = std::get<0>(iov);
209  std::string tagname = tag.name;
210  std::stringstream ss_tagname(tag.name);
211  std::string stmp;
212 
213  std::string tag_ver;
214  std::string tag_res;
215  std::string tag_jet;
216 
217  getline(ss_tagname, stmp, '_'); // drop first
218  getline(ss_tagname, stmp, '_'); // year
219  tag_ver = stmp;
220  getline(ss_tagname, stmp, '_'); // ver
221  tag_ver += '_' + stmp;
222  getline(ss_tagname, stmp, '_'); // cmssw
223  tag_ver += '_' + stmp;
224  getline(ss_tagname, stmp, '_'); // data/mc
225  tag_ver += '_' + stmp;
226  getline(ss_tagname, stmp, '_'); // bin
227  tag_res = stmp;
228  getline(ss_tagname, stmp, '_'); // jet algorithm
229  tag_jet = stmp;
230 
231  if (payload.get()) {
232  if (!payload->getRecords().empty() && // No formula for SF
233  payload->getDefinition().getFormulaString().compare("") == 0)
234  return false;
235 
236  for (size_t idx = 0; idx <= NBIN_ETA; idx++) {
237  double x_axis = (idx + 0.5) * (MAX_ETA - MIN_ETA) / NBIN_ETA + MIN_ETA;
238 
239  JetParameters j_param;
240  j_param.setJetPt(par_Pt);
241  j_param.setRho(par_Rho);
242  j_param.setJetEta(x_axis);
243 
244  if (payload->getRecord(j_param) == nullptr) {
245  continue;
246  }
247 
248  const JetResolutionObject::Record record = *(payload->getRecord(j_param));
249  float res = payload->evaluateFormula(record, j_param);
250  resol_eta->SetBinContent(idx + 1, res);
251  } // x-axis
252 
253  for (size_t idx = 0; idx <= NBIN_PT; idx++) {
254  double x_axis = (idx + 0.5) * (MAX_PT - MIN_PT) / NBIN_PT + MIN_PT;
255 
256  JetParameters j_param;
257  j_param.setJetEta(par_Eta);
258  j_param.setRho(par_Rho);
259  j_param.setJetPt(x_axis);
260 
261  if (payload->getRecord(j_param) == nullptr) {
262  continue;
263  }
264 
265  const JetResolutionObject::Record record = *(payload->getRecord(j_param));
266  float res = payload->evaluateFormula(record, j_param);
267  resol_pt->SetBinContent(idx + 1, res);
268  } // x-axis
269 
270  gStyle->SetOptStat(0);
271  gStyle->SetLabelFont(42, "XYZ");
272  gStyle->SetLabelSize(0.05, "XYZ");
273  gStyle->SetFrameLineWidth(3);
274 
275  std::string title = Form("Summary Run %i", run);
276  TCanvas canvas("Jet Resolution Summary", title.c_str(), 800, 1200);
277  canvas.Divide(1, 2);
278 
279  canvas.cd(1);
280  resol_eta->SetTitle("Jet Resolution vs. #eta");
281  resol_eta->SetXTitle("#eta");
282  resol_eta->SetYTitle("Resolution");
283  resol_eta->SetLineWidth(3);
284  resol_eta->SetMaximum(resol_eta->GetMaximum() * 1.25);
285  resol_eta->Draw("");
286 
287  leg_eta->AddEntry(resol_eta, (tag_ver + '_' + tag_jet).c_str(), "l");
288  leg_eta->AddEntry((TObject*)nullptr, Form("JetPt=%.2f; JetRho=%.2f", par_Pt, par_Rho), "");
289  leg_eta->Draw();
290 
291  canvas.cd(2);
292  resol_pt->SetTitle("Jet Resolution vs. p_{T}");
293  resol_pt->SetXTitle("p_{T} [GeV]");
294  resol_pt->SetYTitle("Resolution");
295  resol_pt->SetLineWidth(3);
296  resol_pt->Draw("][");
297 
298  leg_pt->AddEntry(resol_pt, (tag_ver + '_' + tag_jet).c_str(), "l");
299  leg_pt->AddEntry((TObject*)nullptr, Form("JetEta=%.2f; JetRho=%.2f", par_Eta, par_Rho), "");
300  leg_pt->Draw();
301 
302  canvas.SaveAs(m_imageFileName.c_str());
303 
304  return true;
305  } else // no payload.get()
306  return false;
307  } // fill
Definition: Electron.h:6
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)