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 144 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 149 of file JetResolution_PayloadInspector.cc.

References svgfig::canvas(), f, mps_fire::i, heavyIonCSV_trainingSettings::idx, 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.

149  {
150  TH1D* resol_eta = new TH1D("Jet Resolution vs #eta", "", NBIN_ETA, MIN_ETA, MAX_ETA);
151  TH1D* resol_pt = new TH1D("Jet Resolution vs p_T", "", NBIN_PT, MIN_PT, MAX_PT);
152  TLegend* leg_eta = new TLegend(0.26, 0.73, 0.935, 0.90);
153  TLegend* leg_pt = new TLegend(0.26, 0.73, 0.935, 0.90);
154 
155  leg_eta->SetBorderSize(0);
156  leg_eta->SetLineStyle(0);
157  leg_eta->SetFillStyle(0);
158 
159  leg_eta->SetTextFont(42);
160  leg_pt->SetBorderSize(0);
161  leg_pt->SetLineStyle(0);
162  leg_pt->SetFillStyle(0);
163 
164  auto tag = PlotBase::getTag<0>();
165  auto iov = tag.iovs.front();
166  std::shared_ptr<JetResolutionObject> payload = fetchPayload(std::get<1>(iov));
167  unsigned int run = std::get<0>(iov);
168  std::string tagname = tag.name;
169  std::stringstream ss_tagname(tag.name);
170  std::string stmp;
171 
172  std::string tag_ver;
173  std::string tag_res;
174  std::string tag_jet;
175 
176  getline(ss_tagname, stmp, '_'); // drop first
177  getline(ss_tagname, stmp, '_'); // year
178  tag_ver = stmp;
179  getline(ss_tagname, stmp, '_'); // ver
180  tag_ver += '_' + stmp;
181  getline(ss_tagname, stmp, '_'); // cmssw
182  tag_ver += '_' + stmp;
183  getline(ss_tagname, stmp, '_'); // data/mc
184  tag_ver += '_' + stmp;
185  getline(ss_tagname, stmp, '_'); // bin
186  tag_res = stmp;
187  getline(ss_tagname, stmp, '_'); // jet algorithm
188  tag_jet = stmp;
189 
190  if (payload.get()) {
191  if (!payload->getRecords().empty() && // No formula for SF
192  payload->getDefinition().getFormulaString().compare("") == 0)
193  return false;
194 
195  for (const auto& record : payload->getRecords()) {
196  // Check Pt & Rho
197  if (!record.getVariablesRange().empty() && payload->getDefinition().getVariableName(0) == "JetPt" &&
198  record.getVariablesRange()[0].is_inside(100.)) {
199  if (record.getBinsRange().size() > 1 && payload->getDefinition().getBinName(1) == "Rho" &&
200  record.getBinsRange()[1].is_inside(20.)) {
201  if (!record.getBinsRange().empty() && payload->getDefinition().getBinName(0) == "JetEta") {
202  reco::FormulaEvaluator f(payload->getDefinition().getFormulaString());
203 
204  for (size_t idx = 0; idx <= NBIN_ETA; idx++) {
205  double x_axis = (idx + 0.5) * (MAX_ETA - MIN_ETA) / NBIN_ETA + MIN_ETA;
206  if (record.getBinsRange()[0].is_inside(x_axis)) {
207  std::vector<double> var = {100.};
208  std::vector<double> param;
209  for (size_t i = 0; i < record.getParametersValues().size(); i++) {
210  double par = record.getParametersValues()[i];
211  param.push_back(par);
212  }
213  float res = f.evaluate(var, param);
214  resol_eta->SetBinContent(idx + 1, res);
215  }
216  }
217  }
218  }
219  }
220 
221  if (!record.getBinsRange().empty() && payload->getDefinition().getBinName(0) == "JetEta" &&
222  record.getBinsRange()[0].is_inside(2.30)) {
223  if (record.getBinsRange().size() > 1 && payload->getDefinition().getBinName(1) == "Rho" &&
224  record.getBinsRange()[1].is_inside(15.)) {
225  if (!record.getVariablesRange().empty() && payload->getDefinition().getVariableName(0) == "JetPt") {
226  reco::FormulaEvaluator f(payload->getDefinition().getFormulaString());
227 
228  for (size_t idx = 0; idx <= NBIN_PT + 2; idx++) {
229  double x_axis = (idx + 0.5) * (MAX_PT - MIN_PT) / NBIN_PT + MIN_PT;
230  if (record.getVariablesRange()[0].is_inside(x_axis)) {
231  std::vector<double> var = {x_axis};
232  std::vector<double> param;
233  for (size_t i = 0; i < record.getParametersValues().size(); i++) {
234  double par = record.getParametersValues()[i];
235  param.push_back(par);
236  }
237  float res = f.evaluate(var, param);
238  resol_pt->SetBinContent(idx + 1, res);
239  }
240  }
241  }
242  }
243  }
244  } // records
245 
246  gStyle->SetOptStat(0);
247  gStyle->SetLabelFont(42, "XYZ");
248  gStyle->SetLabelSize(0.05, "XYZ");
249  gStyle->SetFrameLineWidth(3);
250 
251  std::string title = Form("Summary Run %i", run);
252  TCanvas canvas("Jet Resolution Summary", title.c_str(), 800, 1200);
253  canvas.Divide(1, 2);
254 
255  canvas.cd(1);
256  resol_eta->SetTitle(tag_res.c_str());
257  resol_eta->SetXTitle("#eta");
258  resol_eta->SetYTitle("Resolution");
259  resol_eta->SetLineWidth(3);
260  resol_eta->SetMaximum(resol_eta->GetMaximum() * 1.25);
261  resol_eta->Draw("");
262 
263  leg_eta->AddEntry(resol_eta, (tag_ver + '_' + tag_jet).c_str(), "l");
264  leg_eta->AddEntry((TObject*)nullptr, "JetPt=100, Rho=20", "");
265  leg_eta->Draw();
266 
267  canvas.cd(2);
268  resol_pt->SetXTitle("p_{T} [GeV]");
269  resol_pt->SetYTitle("Resolution");
270  resol_pt->SetLineWidth(3);
271  resol_pt->Draw("][");
272 
273  leg_pt->AddEntry(resol_pt, (tag_ver + '_' + tag_jet).c_str(), "l");
274  leg_pt->AddEntry((TObject*)nullptr, "JetEta=2.3, Rho=15", "");
275  leg_pt->Draw();
276 
277  canvas.SaveAs(m_imageFileName.c_str());
278 
279  return true;
280  } else // no payload.get()
281  return false;
282  } // fill
Definition: Electron.h:6
double f[11][100]
def canvas(sub, attr)
Definition: svgfig.py:482
std::shared_ptr< JetResolutionObject > fetchPayload(const cond::Hash &payloadHash)