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 183 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 192 of file JetResolution_PayloadInspector.cc.

References svgfig::canvas(), f, mps_fire::i, 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, AlCaHLTBitMon_QueryRunRegistry::string, makeGlobalPositionRcd_cfg::tag, createPayload::tagname, runGCPTkAlMap::title, and trigObjTnPSource_cfi::var.

192  {
193  double par_Pt = 100.;
194  double par_Eta = 1.;
195  double par_Rho = 20.;
196 
198  auto ip = paramValues.find("Jet_Pt");
199  if (ip != paramValues.end()) {
200  par_Pt = std::stod(ip->second);
201  }
202  ip = paramValues.find("Jet_Eta");
203  if (ip != paramValues.end()) {
204  par_Eta = std::stod(ip->second);
205  }
206  ip = paramValues.find("Jet_Rho");
207  if (ip != paramValues.end()) {
208  par_Rho = std::stod(ip->second);
209  }
210 
211  TH1D* resol_eta = new TH1D("Jet Resolution vs #eta", "", NBIN_ETA, MIN_ETA, MAX_ETA);
212  TH1D* resol_pt = new TH1D("Jet Resolution vs p_T", "", NBIN_PT, MIN_PT, MAX_PT);
213  TLegend* leg_eta = new TLegend(0.26, 0.73, 0.935, 0.90);
214  TLegend* leg_pt = new TLegend(0.26, 0.73, 0.935, 0.90);
215 
216  leg_eta->SetBorderSize(0);
217  leg_eta->SetLineStyle(0);
218  leg_eta->SetFillStyle(0);
219 
220  leg_eta->SetTextFont(42);
221  leg_pt->SetBorderSize(0);
222  leg_pt->SetLineStyle(0);
223  leg_pt->SetFillStyle(0);
224 
225  auto tag = PlotBase::getTag<0>();
226  auto iov = tag.iovs.front();
227  std::shared_ptr<JetResolutionObject> payload = fetchPayload(std::get<1>(iov));
228  unsigned int run = std::get<0>(iov);
229  std::string tagname = tag.name;
230  std::stringstream ss_tagname(tag.name);
231  std::string stmp;
232 
233  std::string tag_ver;
234  std::string tag_res;
235  std::string tag_jet;
236 
237  getline(ss_tagname, stmp, '_'); // drop first
238  getline(ss_tagname, stmp, '_'); // year
239  tag_ver = stmp;
240  getline(ss_tagname, stmp, '_'); // ver
241  tag_ver += '_' + stmp;
242  getline(ss_tagname, stmp, '_'); // cmssw
243  tag_ver += '_' + stmp;
244  getline(ss_tagname, stmp, '_'); // data/mc
245  tag_ver += '_' + stmp;
246  getline(ss_tagname, stmp, '_'); // bin
247  tag_res = stmp;
248  getline(ss_tagname, stmp, '_'); // jet algorithm
249  tag_jet = stmp;
250 
251  if (payload.get()) {
252  if (!payload->getRecords().empty() && // No formula for SF
253  payload->getDefinition().getFormulaString().compare("") == 0)
254  return false;
255 
256  for (const auto& record : payload->getRecords()) {
257  // Check Pt & Rho
258  if (!record.getVariablesRange().empty() && payload->getDefinition().getVariableName(0) == "JetPt" &&
259  record.getVariablesRange()[0].is_inside(par_Pt)) {
260  if (record.getBinsRange().size() > 1 && payload->getDefinition().getBinName(1) == "Rho" &&
261  record.getBinsRange()[1].is_inside(par_Rho)) {
262  if (!record.getBinsRange().empty() && payload->getDefinition().getBinName(0) == "JetEta") {
263  reco::FormulaEvaluator f(payload->getDefinition().getFormulaString());
264 
265  for (size_t idx = 0; idx <= NBIN_ETA; idx++) {
266  double x_axis = (idx + 0.5) * (MAX_ETA - MIN_ETA) / NBIN_ETA + MIN_ETA;
267  if (record.getBinsRange()[0].is_inside(x_axis)) {
268  std::vector<double> var = {par_Pt};
269  std::vector<double> param;
270  for (size_t i = 0; i < record.getParametersValues().size(); i++) {
271  double par = record.getParametersValues()[i];
272  param.push_back(par);
273  }
274  float res = f.evaluate(var, param);
275  resol_eta->SetBinContent(idx + 1, res);
276  }
277  }
278  }
279  }
280  }
281 
282  if (!record.getBinsRange().empty() && payload->getDefinition().getBinName(0) == "JetEta" &&
283  record.getBinsRange()[0].is_inside(par_Eta)) {
284  if (record.getBinsRange().size() > 1 && payload->getDefinition().getBinName(1) == "Rho" &&
285  record.getBinsRange()[1].is_inside(par_Rho)) {
286  if (!record.getVariablesRange().empty() && payload->getDefinition().getVariableName(0) == "JetPt") {
287  reco::FormulaEvaluator f(payload->getDefinition().getFormulaString());
288 
289  for (size_t idx = 0; idx <= NBIN_PT + 2; idx++) {
290  double x_axis = (idx + 0.5) * (MAX_PT - MIN_PT) / NBIN_PT + MIN_PT;
291  if (record.getVariablesRange()[0].is_inside(x_axis)) {
292  std::vector<double> var = {x_axis};
293  std::vector<double> param;
294  for (size_t i = 0; i < record.getParametersValues().size(); i++) {
295  double par = record.getParametersValues()[i];
296  param.push_back(par);
297  }
298  float res = f.evaluate(var, param);
299  resol_pt->SetBinContent(idx + 1, res);
300  }
301  }
302  }
303  }
304  }
305  } // records
306 
307  gStyle->SetOptStat(0);
308  gStyle->SetLabelFont(42, "XYZ");
309  gStyle->SetLabelSize(0.05, "XYZ");
310  gStyle->SetFrameLineWidth(3);
311 
312  std::string title = Form("Summary Run %i", run);
313  TCanvas canvas("Jet Resolution Summary", title.c_str(), 800, 1200);
314  canvas.Divide(1, 2);
315 
316  canvas.cd(1);
317  resol_eta->SetTitle(tag_res.c_str());
318  resol_eta->SetXTitle("#eta");
319  resol_eta->SetYTitle("Resolution");
320  resol_eta->SetLineWidth(3);
321  resol_eta->SetMaximum(resol_eta->GetMaximum() * 1.25);
322  resol_eta->Draw("");
323 
324  leg_eta->AddEntry(resol_eta, (tag_ver + '_' + tag_jet).c_str(), "l");
325  leg_eta->AddEntry((TObject*)nullptr, Form("JetPt=%.2f; JetRho=%.2f", par_Pt, par_Rho), "");
326  leg_eta->Draw();
327 
328  canvas.cd(2);
329  resol_pt->SetXTitle("p_{T} [GeV]");
330  resol_pt->SetYTitle("Resolution");
331  resol_pt->SetLineWidth(3);
332  resol_pt->Draw("][");
333 
334  leg_pt->AddEntry(resol_pt, (tag_ver + '_' + tag_jet).c_str(), "l");
335  leg_pt->AddEntry((TObject*)nullptr, Form("JetEta=%.2f; JetRho=%.2f", par_Eta, par_Rho), "");
336  leg_pt->Draw();
337 
338  canvas.SaveAs(m_imageFileName.c_str());
339 
340  return true;
341  } else // no payload.get()
342  return false;
343  } // fill
Definition: Electron.h:6
double f[11][100]
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)