CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
RooUtil::CutTree Class Reference

#include <cutflowutil.h>

Public Member Functions

void addCut (TString n)
 
void addEventList (int run, int lumi, unsigned long long evt)
 
void addHist1D (TH1D *h, std::function< float()> var, TString syst)
 
void addHist1DVec (TH1D *h, std::function< std::vector< float >()> var, std::function< std::vector< float >()> wgt, TString syst)
 
void addHist2D (TH2F *h, std::function< float()> varx, std::function< float()> vary, TString syst)
 
void addHist2DVec (TH2F *h, std::function< std::vector< float >()> varx, std::function< std::vector< float >()> vary, std::function< std::vector< float >()> elemwgt, TString syst)
 
void addSyst (TString syst)
 
void addSyst (TString syst, std::vector< TString > patterns, std::vector< TString > vetopatterns=std::vector< TString >())
 
void clear ()
 
void clear_passbits ()
 
void clearEventList ()
 
 CutTree (TString n)
 
void evaluate (RooUtil::TTreeX &tx, TString cutsystname="", bool doeventlist=false, bool aggregated_pass=true, float aggregated_weight=1)
 
void evaluate_use_internal_variable (RooUtil::TTreeX &tx, TString cutsystname="", bool doeventlist=false, bool aggregated_pass=true, float aggregated_weight=1)
 
void evaluate_use_lambda (RooUtil::TTreeX &tx, TString cutsystname="", bool doeventlist=false, bool aggregated_pass=true, float aggregated_weight=1)
 
void evaluate_use_ttreex (RooUtil::TTreeX &tx, TString cutsystname="", bool doeventlist=false, bool aggregated_pass=true, float aggregated_weight=1)
 
void fillHistograms (TString syst, float extrawgt)
 
CutTreegetCut (TString n)
 
std::vector< TString > getCutList (TString n, std::vector< TString > cut_list=std::vector< TString >())
 
std::vector< TString > getCutListBelow (TString n, std::vector< TString > cut_list=std::vector< TString >())
 
CutTreegetCutPointer (TString n)
 
std::vector< TString > getEndCuts (std::vector< TString > endcuts=std::vector< TString >())
 
void printCuts (int indent=0, std::vector< int > multichild=std::vector< int >())
 
void printEventList ()
 
void sortEventList ()
 
void writeEventList (TString ofilename)
 
 ~CutTree ()
 

Public Attributes

std::vector< CutTree * > children
 
std::vector< std::tuple< int, int, unsigned long long > > eventlist
 
std::map< TString, std::vector< std::tuple< TH1D *, std::function< float()> > > > hists1d
 
std::map< TString, std::vector< std::tuple< TH1D *, std::function< std::vector< float >)>, std::function< std::vector< float >)> > > > hists1dvec
 
std::map< TString, std::vector< std::tuple< TH2F *, std::function< float()>, std::function< float()> > > > hists2d
 
std::map< TString, std::vector< std::tuple< TH2F *, std::function< std::vector< float >)>, std::function< std::vector< float >)>, std::function< std::vector< float >)> > > > hists2dvec
 
TString name
 
CutTreeparent
 
std::vector< CutTree * > parents
 
int pass
 
bool pass_this_cut
 
std::function< bool()> pass_this_cut_func
 
std::vector< TString > systcutnames
 
std::vector< CutTree * > systcuts
 
std::vector< int > systpasses
 
std::map< TString, CutTree * > systs
 
std::vector< float > systweights
 
float weight
 
float weight_this_cut
 
std::function< float()> weight_this_cut_func
 

Detailed Description

Definition at line 76 of file cutflowutil.h.

Constructor & Destructor Documentation

◆ CutTree()

RooUtil::CutTree::CutTree ( TString  n)
inline

Definition at line 112 of file cutflowutil.h.

Referenced by addCut(), and addSyst().

112 : name(n), parent(0), pass(false), weight(0) {}
CutTree * parent
Definition: cutflowutil.h:79

◆ ~CutTree()

RooUtil::CutTree::~CutTree ( )
inline

Definition at line 113 of file cutflowutil.h.

References submitPVValidationJobs::child, and children.

113  {
114  for (auto& child : children) {
115  if (child)
116  delete child;
117  }
118  }
std::vector< CutTree * > children
Definition: cutflowutil.h:81

Member Function Documentation

◆ addCut()

void RooUtil::CutTree::addCut ( TString  n)
inline

Definition at line 181 of file cutflowutil.h.

References children, CutTree(), create_idmaps::n, and getGTfromDQMFile::obj.

181  {
182  CutTree* obj = new CutTree(n);
183  obj->parent = this;
184  obj->parents.push_back(this);
185  children.push_back(obj);
186  }
CutTree(TString n)
Definition: cutflowutil.h:112
std::vector< CutTree * > children
Definition: cutflowutil.h:81

◆ addEventList()

void RooUtil::CutTree::addEventList ( int  run,
int  lumi,
unsigned long long  evt 
)
inline

Definition at line 516 of file cutflowutil.h.

References eventlist, and writedatasetfile::run.

516  {
517  eventlist.push_back(std::make_tuple(run, lumi, evt));
518  }
std::vector< std::tuple< int, int, unsigned long long > > eventlist
Definition: cutflowutil.h:111

◆ addHist1D()

void RooUtil::CutTree::addHist1D ( TH1D *  h,
std::function< float()>  var,
TString  syst 
)
inline

Definition at line 203 of file cutflowutil.h.

References h, hists1d, push_back(), and ALCARECOEcalPhiSym_cff::var.

203  {
204  if (syst.IsNull())
205  hists1d["Nominal"].push_back(std::make_tuple(h, var));
206  else
207  hists1d[syst].push_back(std::make_tuple(h, var));
208  }
std::map< TString, std::vector< std::tuple< TH1D *, std::function< float()> > > > hists1d
Definition: cutflowutil.h:96
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ addHist1DVec()

void RooUtil::CutTree::addHist1DVec ( TH1D *  h,
std::function< std::vector< float >()>  var,
std::function< std::vector< float >()>  wgt,
TString  syst 
)
inline

Definition at line 209 of file cutflowutil.h.

References h, hists1dvec, push_back(), and ALCARECOEcalPhiSym_cff::var.

212  {
213  if (syst.IsNull())
214  hists1dvec["Nominal"].push_back(std::make_tuple(h, var, wgt));
215  else
216  hists1dvec[syst].push_back(std::make_tuple(h, var, wgt));
217  }
std::map< TString, std::vector< std::tuple< TH1D *, std::function< std::vector< float >)>, std::function< std::vector< float >)> > > > hists1dvec
Definition: cutflowutil.h:99
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ addHist2D()

void RooUtil::CutTree::addHist2D ( TH2F *  h,
std::function< float()>  varx,
std::function< float()>  vary,
TString  syst 
)
inline

Definition at line 218 of file cutflowutil.h.

References h, hists2d, and push_back().

218  {
219  if (syst.IsNull())
220  hists2d["Nominal"].push_back(std::make_tuple(h, varx, vary));
221  else
222  hists2d[syst].push_back(std::make_tuple(h, varx, vary));
223  }
std::map< TString, std::vector< std::tuple< TH2F *, std::function< float()>, std::function< float()> > > > hists2d
Definition: cutflowutil.h:100
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ addHist2DVec()

void RooUtil::CutTree::addHist2DVec ( TH2F *  h,
std::function< std::vector< float >()>  varx,
std::function< std::vector< float >()>  vary,
std::function< std::vector< float >()>  elemwgt,
TString  syst 
)
inline

Definition at line 224 of file cutflowutil.h.

References h, hists2dvec, and push_back().

228  {
229  if (syst.IsNull())
230  hists2dvec["Nominal"].push_back(std::make_tuple(h, varx, vary, elemwgt));
231  else
232  hists2dvec[syst].push_back(std::make_tuple(h, varx, vary, elemwgt));
233  }
std::map< TString, std::vector< std::tuple< TH2F *, std::function< std::vector< float >)>, std::function< std::vector< float >)>, std::function< std::vector< float >)> > > > hists2dvec
Definition: cutflowutil.h:106
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ addSyst() [1/2]

void RooUtil::CutTree::addSyst ( TString  syst)
inline

Definition at line 187 of file cutflowutil.h.

References children, CutTree(), getGTfromDQMFile::obj, parent, parents, systcutnames, systcuts, systpasses, systs, and systweights.

Referenced by addSyst().

187  {
188  // If already added ignore
189  if (systs.find(syst) != systs.end())
190  return;
191  // Syst CutTree object knows the parents, and children, however, the children does not know the syst-counter-part parent, nor the parent knows the syste-counter-part children.
192  CutTree* obj = new CutTree(this->name + syst);
193  systs[syst] = obj;
194  systcutnames.push_back(syst);
195  systcuts.push_back(obj);
196  systpasses.push_back(1);
197  systweights.push_back(1);
198  obj->children = this->children;
199  obj->parents = this->parents;
200  obj->parent = this->parent;
201  }
std::vector< int > systpasses
Definition: cutflowutil.h:87
CutTree(TString n)
Definition: cutflowutil.h:112
std::vector< TString > systcutnames
Definition: cutflowutil.h:82
std::vector< float > systweights
Definition: cutflowutil.h:88
std::vector< CutTree * > parents
Definition: cutflowutil.h:80
std::vector< CutTree * > children
Definition: cutflowutil.h:81
std::map< TString, CutTree * > systs
Definition: cutflowutil.h:84
CutTree * parent
Definition: cutflowutil.h:79
std::vector< CutTree * > systcuts
Definition: cutflowutil.h:83

◆ addSyst() [2/2]

void RooUtil::CutTree::addSyst ( TString  syst,
std::vector< TString >  patterns,
std::vector< TString >  vetopatterns = std::vector<TString>() 
)
inline

Definition at line 328 of file cutflowutil.h.

References addSyst(), children, name, topSingleLeptonDQM_PU_cfi::pattern, and relval_cleanedupgrade::veto.

330  {
331  for (auto& pattern : patterns)
332  if (name.Contains(pattern)) {
333  bool veto = false;
334  for (auto& vetopattern : vetopatterns) {
335  if (name.Contains(vetopattern))
336  veto = true;
337  }
338  if (not veto)
339  addSyst(syst);
340  }
341  for (auto& child : children)
342  child->addSyst(syst, patterns, vetopatterns);
343  }
std::vector< CutTree * > children
Definition: cutflowutil.h:81
void addSyst(TString syst)
Definition: cutflowutil.h:187

◆ clear()

void RooUtil::CutTree::clear ( void  )
inline

Definition at line 322 of file cutflowutil.h.

References children, and pass.

322  {
323  pass = false;
324  weight = 0;
325  for (auto& child : children)
326  child->clear();
327  }
Definition: weight.py:1
std::vector< CutTree * > children
Definition: cutflowutil.h:81

◆ clear_passbits()

void RooUtil::CutTree::clear_passbits ( )
inline

Definition at line 344 of file cutflowutil.h.

References children, and pass.

Referenced by evaluate_use_internal_variable(), and evaluate_use_lambda().

344  {
345  pass = 0;
346  weight = 0;
347  for (auto& child : children)
348  child->clear_passbits();
349  }
Definition: weight.py:1
std::vector< CutTree * > children
Definition: cutflowutil.h:81

◆ clearEventList()

void RooUtil::CutTree::clearEventList ( )
inline

Definition at line 515 of file cutflowutil.h.

References eventlist.

515 { eventlist.clear(); }
std::vector< std::tuple< int, int, unsigned long long > > eventlist
Definition: cutflowutil.h:111

◆ evaluate()

void RooUtil::CutTree::evaluate ( RooUtil::TTreeX tx,
TString  cutsystname = "",
bool  doeventlist = false,
bool  aggregated_pass = true,
float  aggregated_weight = 1 
)
inline

Definition at line 350 of file cutflowutil.h.

References evaluate_use_internal_variable(), evaluate_use_lambda(), and evaluate_use_ttreex().

354  {
355 #ifdef USE_TTREEX
356  evaluate_use_ttreex(tx, cutsystname, doeventlist, aggregated_pass, aggregated_weight);
357 #else
358 #ifdef USE_CUTLAMBDA
359  evaluate_use_lambda(tx, cutsystname, doeventlist, aggregated_pass, aggregated_weight);
360 #else
361  evaluate_use_internal_variable(tx, cutsystname, doeventlist, aggregated_pass, aggregated_weight);
362 #endif
363 #endif
364  }
void evaluate_use_lambda(RooUtil::TTreeX &tx, TString cutsystname="", bool doeventlist=false, bool aggregated_pass=true, float aggregated_weight=1)
Definition: cutflowutil.h:365
void evaluate_use_ttreex(RooUtil::TTreeX &tx, TString cutsystname="", bool doeventlist=false, bool aggregated_pass=true, float aggregated_weight=1)
Definition: cutflowutil.h:463
void evaluate_use_internal_variable(RooUtil::TTreeX &tx, TString cutsystname="", bool doeventlist=false, bool aggregated_pass=true, float aggregated_weight=1)
Definition: cutflowutil.h:425

◆ evaluate_use_internal_variable()

void RooUtil::CutTree::evaluate_use_internal_variable ( RooUtil::TTreeX tx,
TString  cutsystname = "",
bool  doeventlist = false,
bool  aggregated_pass = true,
float  aggregated_weight = 1 
)
inline

Definition at line 425 of file cutflowutil.h.

References children, clear_passbits(), eventlist, RooUtil::TTreeX::getBranch(), RooUtil::TTreeX::hasBranch(), parent, pass, pass_this_cut, systs, and weight_this_cut.

Referenced by evaluate().

429  {
430  if (!parent) {
431  clear_passbits();
432  pass = 1;
433  weight = 1;
434  } else {
435  if (cutsystname.IsNull()) {
436  pass = pass_this_cut && aggregated_pass;
437  weight = weight_this_cut * aggregated_weight;
438  if (!pass)
439  return;
440  } else {
441  if (systs.find(cutsystname) == systs.end()) {
442  pass = pass_this_cut && aggregated_pass;
443  weight = weight_this_cut * aggregated_weight;
444  if (!pass)
445  return;
446  } else {
447  pass = systs[cutsystname]->pass_this_cut && aggregated_pass;
448  weight = systs[cutsystname]->weight_this_cut * aggregated_weight;
449  if (!pass)
450  return;
451  }
452  }
453  }
454  if (doeventlist and pass and cutsystname.IsNull()) {
455  if (tx.hasBranch<int>("run") && tx.hasBranch<int>("lumi") && tx.hasBranch<unsigned long long>("evt")) {
456  eventlist.push_back(std::make_tuple(
457  tx.getBranch<int>("run"), tx.getBranch<int>("lumi"), tx.getBranch<unsigned long long>("evt")));
458  }
459  }
460  for (auto& child : children)
461  child->evaluate_use_internal_variable(tx, cutsystname, doeventlist, pass, weight);
462  }
const T & getBranch(TString, bool=true)
Definition: weight.py:1
float weight_this_cut
Definition: cutflowutil.h:90
std::vector< std::tuple< int, int, unsigned long long > > eventlist
Definition: cutflowutil.h:111
std::vector< CutTree * > children
Definition: cutflowutil.h:81
bool hasBranch(TString)
std::map< TString, CutTree * > systs
Definition: cutflowutil.h:84
CutTree * parent
Definition: cutflowutil.h:79
void clear_passbits()
Definition: cutflowutil.h:344

◆ evaluate_use_lambda()

void RooUtil::CutTree::evaluate_use_lambda ( RooUtil::TTreeX tx,
TString  cutsystname = "",
bool  doeventlist = false,
bool  aggregated_pass = true,
float  aggregated_weight = 1 
)
inline

Definition at line 365 of file cutflowutil.h.

References children, clear_passbits(), eventlist, RooUtil::TTreeX::getBranch(), RooUtil::TTreeX::hasBranch(), mps_check::msg, name, parent, pass, pass_this_cut_func, systs, RooUtil::warning(), and weight_this_cut_func.

Referenced by evaluate().

369  {
370  if (!parent) {
371  clear_passbits();
372  pass = 1;
373  weight = 1;
374  } else {
375  if (cutsystname.IsNull()) {
376  if (pass_this_cut_func) {
377  pass = pass_this_cut_func() && aggregated_pass;
378  weight = weight_this_cut_func() * aggregated_weight;
379  if (!pass)
380  return;
381  } else {
382  TString msg = "cowardly passing the event because cut and weight func not set! cut name = " + name;
383  warning(msg);
384  pass = aggregated_pass;
385  weight = aggregated_weight;
386  }
387  } else {
388  if (systs.find(cutsystname) == systs.end()) {
389  if (pass_this_cut_func) {
390  pass = pass_this_cut_func() && aggregated_pass;
391  weight = weight_this_cut_func() * aggregated_weight;
392  if (!pass)
393  return;
394  } else {
395  TString msg = "cowardly passing the event because cut and weight func not set! cut name = " + name;
396  warning(msg);
397  pass = aggregated_pass;
398  weight = aggregated_weight;
399  }
400  } else {
401  if (systs[cutsystname]->pass_this_cut_func) {
402  pass = systs[cutsystname]->pass_this_cut_func() && aggregated_pass;
403  weight = systs[cutsystname]->weight_this_cut_func() * aggregated_weight;
404  if (!pass)
405  return;
406  } else {
407  TString msg = "cowardly passing the event because cut and weight func not set! cut name = " + name +
408  " syst name = " + cutsystname;
409  warning(msg);
410  pass = aggregated_pass;
411  weight = aggregated_weight;
412  }
413  }
414  }
415  }
416  if (doeventlist and pass and cutsystname.IsNull()) {
417  if (tx.hasBranch<int>("run") && tx.hasBranch<int>("lumi") && tx.hasBranch<unsigned long long>("evt")) {
418  eventlist.push_back(std::make_tuple(
419  tx.getBranch<int>("run"), tx.getBranch<int>("lumi"), tx.getBranch<unsigned long long>("evt")));
420  }
421  }
422  for (auto& child : children)
423  child->evaluate_use_lambda(tx, cutsystname, doeventlist, pass, weight);
424  }
void warning(TString msg, const char *fname="")
Definition: printutil.cc:38
const T & getBranch(TString, bool=true)
Definition: weight.py:1
std::function< float()> weight_this_cut_func
Definition: cutflowutil.h:92
std::vector< std::tuple< int, int, unsigned long long > > eventlist
Definition: cutflowutil.h:111
std::vector< CutTree * > children
Definition: cutflowutil.h:81
bool hasBranch(TString)
std::function< bool()> pass_this_cut_func
Definition: cutflowutil.h:91
std::map< TString, CutTree * > systs
Definition: cutflowutil.h:84
tuple msg
Definition: mps_check.py:286
CutTree * parent
Definition: cutflowutil.h:79
void clear_passbits()
Definition: cutflowutil.h:344

◆ evaluate_use_ttreex()

void RooUtil::CutTree::evaluate_use_ttreex ( RooUtil::TTreeX tx,
TString  cutsystname = "",
bool  doeventlist = false,
bool  aggregated_pass = true,
float  aggregated_weight = 1 
)
inline

Definition at line 463 of file cutflowutil.h.

References children, eventlist, RooUtil::TTreeX::getBranch(), RooUtil::TTreeX::hasBranch(), name, parent, pass, and systs.

Referenced by evaluate().

467  {
468  if (!parent) {
469  pass = tx.getBranch<bool>(name);
470  weight = tx.getBranch<float>(name + "_weight");
471  } else {
472  if (cutsystname.IsNull()) {
473  if (!tx.hasBranch<bool>(name))
474  return;
475  pass = tx.getBranch<bool>(name) && aggregated_pass;
476  weight = tx.getBranch<float>(name + "_weight") * aggregated_weight;
477  } else {
478  if (systs.find(cutsystname) == systs.end()) {
479  if (!tx.hasBranch<bool>(name))
480  return;
481  pass = tx.getBranch<bool>(name) && aggregated_pass;
482  weight = tx.getBranch<float>(name + "_weight") * aggregated_weight;
483  } else {
484  if (!tx.hasBranch<bool>(name + cutsystname))
485  return;
486  pass = tx.getBranch<bool>(name + cutsystname) && aggregated_pass;
487  weight = tx.getBranch<float>(name + cutsystname + "_weight") * aggregated_weight;
488  }
489  }
490  }
491  if (doeventlist and pass and cutsystname.IsNull()) {
492  if (tx.hasBranch<int>("run") && tx.hasBranch<int>("lumi") && tx.hasBranch<unsigned long long>("evt")) {
493  eventlist.push_back(std::make_tuple(
494  tx.getBranch<int>("run"), tx.getBranch<int>("lumi"), tx.getBranch<unsigned long long>("evt")));
495  }
496  }
497  for (auto& child : children)
498  child->evaluate_use_ttreex(tx, cutsystname, doeventlist, pass, weight);
499  }
const T & getBranch(TString, bool=true)
Definition: weight.py:1
std::vector< std::tuple< int, int, unsigned long long > > eventlist
Definition: cutflowutil.h:111
std::vector< CutTree * > children
Definition: cutflowutil.h:81
bool hasBranch(TString)
std::map< TString, CutTree * > systs
Definition: cutflowutil.h:84
CutTree * parent
Definition: cutflowutil.h:79

◆ fillHistograms()

void RooUtil::CutTree::fillHistograms ( TString  syst,
float  extrawgt 
)
inline

Definition at line 520 of file cutflowutil.h.

References children, h, hists1d, hists1dvec, hists2d, hists2dvec, mps_fire::i, mps_check::msg, or, pass, THist, mkLumiAveragedPlots::tuple, and RooUtil::warning().

520  {
521  // If the cut didn't pass then stop
522  if (!pass)
523  return;
524 
525  if (hists1d.size() != 0 or hists2d.size() != 0 or hists2dvec.size() != 0 or hists1dvec.size() != 0) {
526  TString systkey = syst.IsNull() ? "Nominal" : syst;
527  for (auto& tuple : hists1d[systkey]) {
528  THist* h = std::get<0>(tuple);
529  std::function<float()> vardef = std::get<1>(tuple);
530  h->Fill(vardef(), weight * extrawgt);
531  }
532  for (auto& tuple : hists2d[systkey]) {
533  TH2F* h = std::get<0>(tuple);
534  std::function<float()> varxdef = std::get<1>(tuple);
535  std::function<float()> varydef = std::get<2>(tuple);
536  h->Fill(varxdef(), varydef(), weight * extrawgt);
537  }
538  for (auto& tuple : hists1dvec[systkey]) {
539  THist* h = std::get<0>(tuple);
540  std::function<std::vector<float>()> vardef = std::get<1>(tuple);
541  std::function<std::vector<float>()> wgtdef = std::get<2>(tuple);
542  std::vector<float> varx = vardef();
543  std::vector<float> elemwgts;
544  if (wgtdef)
545  elemwgts = wgtdef();
546  for (unsigned int i = 0; i < varx.size(); ++i) {
547  if (wgtdef)
548  h->Fill(varx[i], weight * extrawgt * elemwgts[i]);
549  else
550  h->Fill(varx[i], weight * extrawgt);
551  }
552  }
553  for (auto& tuple : hists2dvec[systkey]) {
554  TH2F* h = std::get<0>(tuple);
555  std::function<std::vector<float>()> varxdef = std::get<1>(tuple);
556  std::function<std::vector<float>()> varydef = std::get<2>(tuple);
557  std::function<std::vector<float>()> wgtdef = std::get<3>(tuple);
558  std::vector<float> varx = varxdef();
559  std::vector<float> vary = varydef();
560  if (varx.size() != vary.size()) {
561  TString msg =
562  "the vector input to be looped over do not have same length for x and y! check the variable definition "
563  "for histogram ";
564  msg += h->GetName();
565  warning(msg);
566  }
567  std::vector<float> elemwgts;
568  if (wgtdef)
569  elemwgts = wgtdef();
570  for (unsigned int i = 0; i < varx.size(); ++i) {
571  if (wgtdef)
572  h->Fill(varx[i], vary[i], weight * extrawgt * elemwgts[i]);
573  else
574  h->Fill(varx[i], vary[i], weight * extrawgt);
575  }
576  }
577  }
578  for (auto& child : children)
579  child->fillHistograms(syst, extrawgt);
580  }
std::map< TString, std::vector< std::tuple< TH1D *, std::function< float()> > > > hists1d
Definition: cutflowutil.h:96
void warning(TString msg, const char *fname="")
Definition: printutil.cc:38
std::map< TString, std::vector< std::tuple< TH2F *, std::function< float()>, std::function< float()> > > > hists2d
Definition: cutflowutil.h:100
Definition: weight.py:1
std::map< TString, std::vector< std::tuple< TH2F *, std::function< std::vector< float >)>, std::function< std::vector< float >)>, std::function< std::vector< float >)> > > > hists2dvec
Definition: cutflowutil.h:106
std::map< TString, std::vector< std::tuple< TH1D *, std::function< std::vector< float >)>, std::function< std::vector< float >)> > > > hists1dvec
Definition: cutflowutil.h:99
std::vector< CutTree * > children
Definition: cutflowutil.h:81
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
#define THist
Definition: cutflowutil.h:21
tuple msg
Definition: mps_check.py:286
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ getCut()

CutTree& RooUtil::CutTree::getCut ( TString  n)
inline

Definition at line 263 of file cutflowutil.h.

References DummyCfis::c, RooUtil::error(), getCutPointer(), and create_idmaps::n.

Referenced by getCutList(), and getCutListBelow().

263  {
264  CutTree* c = getCutPointer(n);
265  if (c) {
266  return *c;
267  } else {
268  RooUtil::error(TString::Format("Asked for %s cut, but did not find the cut", n.Data()));
269  return *this;
270  }
271  }
CutTree(TString n)
Definition: cutflowutil.h:112
void error(TString msg, const char *fname="", int is_error=1)
Definition: printutil.cc:44
CutTree * getCutPointer(TString n)
Definition: cutflowutil.h:248

◆ getCutList()

std::vector<TString> RooUtil::CutTree::getCutList ( TString  n,
std::vector< TString >  cut_list = std::vector<TString>() 
)
inline

Definition at line 272 of file cutflowutil.h.

References DummyCfis::c, getCut(), create_idmaps::n, and groupFilesInBlocks::reverse.

272  {
273  // Main idea: start from the end node provided by the first argument "n", and work your way up to the root node.
274  //
275  // The algorithm will first determine whether I am starting from a specific cut requested by the user or within in recursion.
276  // If the cut_list.size() == 0, the function is called by the user (since no list is aggregated so far)
277  // In that case, first find the pointer to the object we want and set it to "c"
278  // If cut_list.size() is non-zero then take this as the cut that I am starting and I go up the chain to aggregate all the cuts prior to the requested cut
279  CutTree* c = 0;
280  if (cut_list.size() == 0) {
281  c = &getCut(n);
282  cut_list.push_back(c->name);
283  } else {
284  c = this;
285  cut_list.push_back(n);
286  }
287  if (c->parent) {
288  return (c->parent)->getCutList((c->parent)->name, cut_list);
289  } else {
290  std::reverse(cut_list.begin(), cut_list.end());
291  return cut_list;
292  }
293  }
CutTree & getCut(TString n)
Definition: cutflowutil.h:263
CutTree(TString n)
Definition: cutflowutil.h:112

◆ getCutListBelow()

std::vector<TString> RooUtil::CutTree::getCutListBelow ( TString  n,
std::vector< TString >  cut_list = std::vector<TString>() 
)
inline

Definition at line 303 of file cutflowutil.h.

References DummyCfis::c, children, getCut(), and create_idmaps::n.

303  {
304  // Main idea: start from the node provided by the first argument "n", and work your way down to the ends.
305  CutTree* c = 0;
306  if (cut_list.size() == 0) {
307  c = &getCut(n);
308  cut_list.push_back(c->name);
309  } else {
310  c = this;
311  cut_list.push_back(n);
312  }
313  if (children.size() > 0) {
314  for (auto& child : c->children) {
315  cut_list = child->getCutListBelow(child->name, cut_list);
316  }
317  return cut_list;
318  } else {
319  return cut_list;
320  }
321  }
CutTree & getCut(TString n)
Definition: cutflowutil.h:263
CutTree(TString n)
Definition: cutflowutil.h:112
std::vector< CutTree * > children
Definition: cutflowutil.h:81

◆ getCutPointer()

CutTree* RooUtil::CutTree::getCutPointer ( TString  n)
inline

Definition at line 248 of file cutflowutil.h.

References DummyCfis::c, children, create_idmaps::n, and name.

Referenced by getCut().

248  {
249  // If the name match then return itself
250  if (name.EqualTo(n)) {
251  return this;
252  } else {
253  // Otherwise, loop over the children an if a children has the correct one return the found CutTree
254  for (auto& child : children) {
255  CutTree* c = child->getCutPointer(n);
256  if (c)
257  return c;
258  }
259  return 0;
260  }
261  }
CutTree(TString n)
Definition: cutflowutil.h:112
std::vector< CutTree * > children
Definition: cutflowutil.h:81

◆ getEndCuts()

std::vector<TString> RooUtil::CutTree::getEndCuts ( std::vector< TString >  endcuts = std::vector<TString>())
inline

Definition at line 294 of file cutflowutil.h.

References children, and name.

294  {
295  if (children.size() == 0) {
296  endcuts.push_back(name);
297  return endcuts;
298  }
299  for (auto& child : children)
300  endcuts = child->getEndCuts(endcuts);
301  return endcuts;
302  }
std::vector< CutTree * > children
Definition: cutflowutil.h:81

◆ printCuts()

void RooUtil::CutTree::printCuts ( int  indent = 0,
std::vector< int >  multichild = std::vector<int>() 
)
inline

Definition at line 119 of file cutflowutil.h.

References children, makeHLTPrescaleTable::delimiter, spr::find(), RecoTauValidation_cfi::header, mps_fire::i, validateAlignments::indent, submitPVResolutionJobs::key, SiStripPI::min, mps_check::msg, name, pass, RooUtil::print(), systs, and w().

119  {
120  struct winsize w;
121  ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
122  int colsize = std::min(w.ws_col - 100, 600);
123  if (indent == 0) {
124  TString header = "Cut name";
125  int extra = colsize - header.Length();
126  for (int i = 0; i < extra; ++i)
127  header += " ";
128  header += "|pass|weight|systs";
129  print(header);
130  TString delimiter = "";
131  for (int i = 0; i < w.ws_col - 10; ++i)
132  delimiter += "=";
133  print(delimiter);
134  }
135  TString msg = "";
136  for (int i = 0; i < indent; ++i) {
137  if (std::find(multichild.begin(), multichild.end(), i + 1) != multichild.end()) {
138  if (indent == i + 1)
139  msg += " +";
140  else
141  msg += " |";
142  } else
143  msg += " ";
144  }
145  msg += name;
146  int extrapad = colsize - msg.Length() > 0 ? colsize - msg.Length() : 0;
147  for (int i = 0; i < extrapad; ++i)
148  msg += " ";
149  //msg += TString::Format("| %d | %.5f|", pass, weight);
150  msg += TString::Format("| %d | %f|", pass, weight);
151  for (auto& key : systs) {
152  msg += key.first + " ";
153  }
154  print(msg);
155  if (children.size() > 1)
156  multichild.push_back(indent + 1);
157  for (auto& child : children) {
158  (*child).printCuts(indent + 1, multichild);
159  }
160  }
T w() const
void print(TString msg="", const char *fname="", int flush_before=0, int flush_after=0)
Definition: printutil.cc:23
Definition: weight.py:1
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::vector< CutTree * > children
Definition: cutflowutil.h:81
key
prepare the HTCondor submission files and eventually submit them
std::map< TString, CutTree * > systs
Definition: cutflowutil.h:84
tuple msg
Definition: mps_check.py:286

◆ printEventList()

void RooUtil::CutTree::printEventList ( )
inline

Definition at line 161 of file cutflowutil.h.

References gather_cfg::cout, eventlist, mps_check::msg, name, RooUtil::print(), and writedatasetfile::run.

161  {
162  print(TString::Format("Print event list for the cut = %s", name.Data()));
163  for (auto& eventid : eventlist) {
164  int run = std::get<0>(eventid);
165  int lumi = std::get<1>(eventid);
166  unsigned long long evt = std::get<2>(eventid);
167  TString msg = TString::Format("%d:%d:%llu", run, lumi, evt);
168  std::cout << msg << std::endl;
169  }
170  }
void print(TString msg="", const char *fname="", int flush_before=0, int flush_after=0)
Definition: printutil.cc:23
std::vector< std::tuple< int, int, unsigned long long > > eventlist
Definition: cutflowutil.h:111
tuple msg
Definition: mps_check.py:286

◆ sortEventList()

void RooUtil::CutTree::sortEventList ( )
inline

Definition at line 500 of file cutflowutil.h.

References a, b, eventlist, and jetUpdater_cfi::sort.

500  {
501  std::sort(
502  eventlist.begin(),
503  eventlist.end(),
504  [](const std::tuple<int, int, unsigned long long>& a, const std::tuple<int, int, unsigned long long>& b) {
505  if (std::get<0>(a) != std::get<0>(b))
506  return std::get<0>(a) < std::get<0>(b);
507  else if (std::get<1>(a) != std::get<1>(b))
508  return std::get<1>(a) < std::get<1>(b);
509  else if (std::get<2>(a) != std::get<2>(b))
510  return std::get<2>(a) < std::get<2>(b);
511  else
512  return true;
513  });
514  }
std::vector< std::tuple< int, int, unsigned long long > > eventlist
Definition: cutflowutil.h:111
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121

◆ writeEventList()

void RooUtil::CutTree::writeEventList ( TString  ofilename)
inline

Definition at line 171 of file cutflowutil.h.

References eventlist, produceTPGParameters_beamv6_transparency_spikekill_2016_script::outFile, writedatasetfile::run, and mkLumiAveragedPlots::tuple.

171  {
172  std::ofstream outFile(ofilename);
173  for (auto& tuple : eventlist) {
174  int run = std::get<0>(tuple);
175  int lumi = std::get<1>(tuple);
176  unsigned long long evt = std::get<2>(tuple);
177  outFile << run << ":" << lumi << ":" << evt << std::endl;
178  }
179  outFile.close();
180  }
std::vector< std::tuple< int, int, unsigned long long > > eventlist
Definition: cutflowutil.h:111

Member Data Documentation

◆ children

std::vector<CutTree*> RooUtil::CutTree::children

◆ eventlist

std::vector<std::tuple<int, int, unsigned long long> > RooUtil::CutTree::eventlist

◆ hists1d

std::map<TString, std::vector<std::tuple< TH1D *, std::function<float()> > > > RooUtil::CutTree::hists1d

Definition at line 96 of file cutflowutil.h.

Referenced by addHist1D(), and fillHistograms().

◆ hists1dvec

std::map<TString, std::vector<std::tuple< TH1D *, std::function<std::vector<float>)>, std::function<std::vector<float>)> > > > RooUtil::CutTree::hists1dvec

Definition at line 99 of file cutflowutil.h.

Referenced by addHist1DVec(), and fillHistograms().

◆ hists2d

std::map<TString, std::vector<std::tuple<TH2F*, std::function<float()>, std::function<float()> > > > RooUtil::CutTree::hists2d

Definition at line 100 of file cutflowutil.h.

Referenced by addHist2D(), and fillHistograms().

◆ hists2dvec

std::map<TString, std::vector<std::tuple<TH2F*, std::function<std::vector<float>)>, std::function<std::vector<float>)>, std::function<std::vector<float>)> > > > RooUtil::CutTree::hists2dvec

Definition at line 106 of file cutflowutil.h.

Referenced by addHist2DVec(), and fillHistograms().

◆ name

TString RooUtil::CutTree::name

◆ parent

CutTree* RooUtil::CutTree::parent

◆ parents

std::vector<CutTree*> RooUtil::CutTree::parents

Definition at line 80 of file cutflowutil.h.

Referenced by addSyst().

◆ pass

int RooUtil::CutTree::pass

◆ pass_this_cut

bool RooUtil::CutTree::pass_this_cut

Definition at line 89 of file cutflowutil.h.

Referenced by evaluate_use_internal_variable().

◆ pass_this_cut_func

std::function<bool()> RooUtil::CutTree::pass_this_cut_func

Definition at line 91 of file cutflowutil.h.

Referenced by evaluate_use_lambda().

◆ systcutnames

std::vector<TString> RooUtil::CutTree::systcutnames

Definition at line 82 of file cutflowutil.h.

Referenced by addSyst().

◆ systcuts

std::vector<CutTree*> RooUtil::CutTree::systcuts

Definition at line 83 of file cutflowutil.h.

Referenced by addSyst().

◆ systpasses

std::vector<int> RooUtil::CutTree::systpasses

Definition at line 87 of file cutflowutil.h.

Referenced by addSyst().

◆ systs

std::map<TString, CutTree*> RooUtil::CutTree::systs

◆ systweights

std::vector<float> RooUtil::CutTree::systweights

Definition at line 88 of file cutflowutil.h.

Referenced by addSyst().

◆ weight

float RooUtil::CutTree::weight

◆ weight_this_cut

float RooUtil::CutTree::weight_this_cut

Definition at line 90 of file cutflowutil.h.

Referenced by evaluate_use_internal_variable().

◆ weight_this_cut_func

std::function<float()> RooUtil::CutTree::weight_this_cut_func

Definition at line 92 of file cutflowutil.h.

Referenced by evaluate_use_lambda().