CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions | Variables
utils Namespace Reference

Classes

class  BinToBin
 
class  BinToBin1percent
 
struct  CheapValueSnapshot
 
class  Chi2
 
class  KS
 
class  StatisticalTest
 
class  unpickler
 

Functions

def ask_ok
 
bool checkModel (const RooStats::ModelConfig &model, bool throwOnFail=false)
 
void copyAttributes (const RooAbsArg &from, RooAbsArg &to)
 
void factorizeFunc (const RooArgSet &observables, RooAbsReal &pdf, RooArgList &obsTerms, RooArgList &otherTerms, bool debug=false)
 factorize a RooAbsReal More...
 
RooAbsPdf * factorizePdf (const RooArgSet &observables, RooAbsPdf &pdf, RooArgList &constraints)
 
void factorizePdf (RooStats::ModelConfig &model, RooAbsPdf &pdf, RooArgList &obsTerms, RooArgList &constraints, bool debug=false)
 collect factors depending on observables in obsTerms, and all others in constraints More...
 
void factorizePdf (const RooArgSet &observables, RooAbsPdf &pdf, RooArgList &obsTerms, RooArgList &constraints, bool debug=false)
 
RooAbsReal * fullCloneFunc (const RooAbsReal *pdf, RooArgSet &holder, bool cloneLeafNodes=false)
 
RooAbsPdf * fullClonePdf (const RooAbsPdf *pdf, RooArgSet &holder, bool cloneLeafNodes=false)
 
def get_relval_cmssw_version
 
def get_relval_id
 
def get_relval_max_version
 
def get_relval_version
 -------------—— Make files pairs: RelVal utils ---------------—— More...
 
def get_relvaldata_cmssw_version
 
def get_relvaldata_id
 -----------—— Make files pairs: RelValData utils --------------—— More...
 
def get_relvaldata_max_version
 
def get_relvaldata_version
 
void getClients (const RooAbsCollection &values, const RooAbsCollection &allObjects, RooAbsCollection &clients)
 add to 'clients' all object within allObjects that directly depend on values More...
 
def getNbins
 
void guessChannelMode (RooSimultaneous &simPdf, RooAbsData &simData, bool verbose=false)
 
def is_empty
 
def is_relvaldata
 ----------------------— Make files pairs -----------------------— More...
 
def is_sparse
 
def literal2root
 
def logger
 
def make_files_pairs
 
RooAbsPdf * makeNuisancePdf (RooStats::ModelConfig &model, const char *name="nuisancePdf")
 
RooAbsPdf * makeNuisancePdf (RooAbsPdf &pdf, const RooArgSet &observables, const char *name="nuisancePdf")
 
RooAbsPdf * makeObsOnlyPdf (RooStats::ModelConfig &model, const char *name="obsPdf")
 Note: doesn't recompose Simultaneous pdfs properly, for that use factorizePdf method. More...
 
std::vector< RooPlot * > makePlots (const RooAbsPdf &pdf, const RooAbsData &data, const char *signalSel=0, const char *backgroundSel=0, float rebinFactor=1.0)
 make plots, if possible More...
 
void printPdf (RooAbsPdf *pdf)
 
void printPdf (RooStats::ModelConfig &model)
 
void printPdf (RooWorkspace *w, const char *pdfName)
 
void printRAD (const RooAbsData *d)
 
void printRDH (RooAbsData *data)
 
def profile2histo
 
RooSimultaneous * rebuildSimPdf (const RooArgSet &observables, RooSimultaneous *pdf)
 
bool setAllConstant (const RooAbsCollection &coll, bool constant=true)
 set all RooRealVars to constants. return true if at least one changed status More...
 
def setTDRStyle
 
void tdrStyle ()
 set style for plots More...
 
def wget
 

Variables

int _log_level = 10
 
 theargv = sys.argv
 

Function Documentation

def utils.ask_ok (   prompt,
  retries = 4,
  complaint = 'yes or no' 
)

Definition at line 423 of file utils.py.

424 def ask_ok(prompt, retries=4, complaint='yes or no'):
425  while True:
426  ok = raw_input(prompt)
427  if ok in ('y', 'ye', 'yes'):
428  return True
429  if ok in ('n', 'no'):
430  return False
431  retries = retries - 1
432  if retries < 0:
433  raise IOError('refusenik user')
434  print complaint
435 
436 #-------------------------------------------------------------------------------
def ask_ok
Definition: utils.py:423
bool utils::checkModel ( const RooStats::ModelConfig &  model,
bool  throwOnFail = false 
)

Performs the following checks:

Definition at line 261 of file utils.cc.

References a, gather_cfg::cout, benchmark_cfg::errors, convertSQLiteXML::ok, and v.

Referenced by Combine::run().

261  {
262  bool ok = true; std::ostringstream errors;
263  std::auto_ptr<TIterator> iter;
264  RooAbsPdf *pdf = model.GetPdf(); if (pdf == 0) throw std::invalid_argument("Model without Pdf");
265  RooArgSet allowedToFloat;
266  if (model.GetObservables() == 0) {
267  ok = false; errors << "ERROR: model does not define observables.\n";
268  std::cout << errors.str() << std::endl;
269  if (throwOnFail) throw std::invalid_argument(errors.str()); else return false;
270  } else {
271  allowedToFloat.add(*model.GetObservables());
272  }
273  if (model.GetParametersOfInterest() == 0) {
274  ok = false; errors << "ERROR: model does not define parameters of interest.\n";
275  } else {
276  iter.reset(model.GetParametersOfInterest()->createIterator());
277  for (RooAbsArg *a = (RooAbsArg *) iter->Next(); a != 0; a = (RooAbsArg *) iter->Next()) {
278  RooRealVar *v = dynamic_cast<RooRealVar *>(a);
279  if (!v) { ok = false; errors << "ERROR: parameter of interest " << a->GetName() << " is a " << a->ClassName() << " and not a RooRealVar\n"; continue; }
280  if (v->isConstant()) { ok = false; errors << "ERROR: parameter of interest " << a->GetName() << " is constant\n"; continue; }
281  if (!pdf->dependsOn(*v)) { ok = false; errors << "ERROR: pdf does not depend on parameter of interest " << a->GetName() << "\n"; continue; }
282  allowedToFloat.add(*v);
283  }
284  }
285  if (model.GetNuisanceParameters() != 0) {
286  iter.reset(model.GetNuisanceParameters()->createIterator());
287  for (RooAbsArg *a = (RooAbsArg *) iter->Next(); a != 0; a = (RooAbsArg *) iter->Next()) {
288  RooRealVar *v = dynamic_cast<RooRealVar *>(a);
289  if (!v) { ok = false; errors << "ERROR: nuisance parameter " << a->GetName() << " is a " << a->ClassName() << " and not a RooRealVar\n"; continue; }
290  if (v->isConstant()) { ok = false; errors << "ERROR: nuisance parameter " << a->GetName() << " is constant\n"; continue; }
291  if (!pdf->dependsOn(*v)) { errors << "WARNING: pdf does not depend on nuisance parameter " << a->GetName() << "\n"; continue; }
292  allowedToFloat.add(*v);
293  }
294  }
295  if (model.GetGlobalObservables() != 0) {
296  iter.reset(model.GetGlobalObservables()->createIterator());
297  for (RooAbsArg *a = (RooAbsArg *) iter->Next(); a != 0; a = (RooAbsArg *) iter->Next()) {
298  RooRealVar *v = dynamic_cast<RooRealVar *>(a);
299  if (!v) { ok = false; errors << "ERROR: global observable " << a->GetName() << " is a " << a->ClassName() << " and not a RooRealVar\n"; continue; }
300  if (!v->isConstant()) { ok = false; errors << "ERROR: global observable " << a->GetName() << " is not constant\n"; continue; }
301  if (!pdf->dependsOn(*v)) { errors << "WARNING: pdf does not depend on global observable " << a->GetName() << "\n"; continue; }
302  }
303  }
304  std::auto_ptr<RooArgSet> params(pdf->getParameters(*model.GetObservables()));
305  iter.reset(params->createIterator());
306  for (RooAbsArg *a = (RooAbsArg *) iter->Next(); a != 0; a = (RooAbsArg *) iter->Next()) {
307  if (a->getAttribute("flatParam") && a->isConstant()) {
308  ok = false; errors << "ERROR: parameter " << a->GetName() << " is declared as flatParam but is constant.\n";
309  }
310  if (a->isConstant() || allowedToFloat.contains(*a)) continue;
311  if (a->getAttribute("flatParam")) {
312  RooRealVar *rrv = dynamic_cast<RooRealVar *>(a);
313  if (rrv->getVal() > rrv->getMax() || rrv->getVal() < rrv->getMin()) {
314  ok = false; errors << "ERROR: flatParam " << rrv->GetName() << " has a value " << rrv->getVal() <<
315  " outside of the defined range [" << rrv->getMin() << ", " << rrv->getMax() << "]\n";
316  }
317  } else {
318  errors << "WARNING: pdf parameter " << a->GetName() << " (type " << a->ClassName() << ") is not allowed to float (it's not nuisance, poi, observable or global observable\n";
319  }
320  }
321  iter.reset();
322  std::cout << errors.str() << std::endl;
323  if (!ok && throwOnFail) throw std::invalid_argument(errors.str());
324  return ok;
325 }
double a
Definition: hdecay.h:121
tuple cout
Definition: gather_cfg.py:121
mathSSE::Vec4< T > v
void utils::copyAttributes ( const RooAbsArg &  from,
RooAbsArg &  to 
)

Definition at line 364 of file utils.cc.

Referenced by factorizePdf(), and rebuildSimPdf().

364  {
365  if (&from == &to) return;
366  const std::set<std::string> attribs = from.attributes();
367  if (!attribs.empty()) {
368  for (std::set<std::string>::const_iterator it = attribs.begin(), ed = attribs.end(); it != ed; ++it) to.setAttribute(it->c_str());
369  }
370  const std::map<std::string, std::string> strattribs = from.stringAttributes();
371  if (!strattribs.empty()) {
372  for (std::map<std::string,std::string>::const_iterator it = strattribs.begin(), ed = strattribs.end(); it != ed; ++it) to.setStringAttribute(it->first.c_str(), it->second.c_str());
373  }
374 }
static std::string from(" from ")
void utils::factorizeFunc ( const RooArgSet &  observables,
RooAbsReal &  pdf,
RooArgList &  obsTerms,
RooArgList &  otherTerms,
bool  debug = false 
)

factorize a RooAbsReal

Definition at line 177 of file utils.cc.

References makeMuonMisalignmentScenario::components, factorizePdf(), and parseEventContent::prod.

Referenced by cacheutils::CachingAddNLL::setup_().

177  {
178  RooAbsPdf *pdf = dynamic_cast<RooAbsPdf *>(&func);
179  if (pdf != 0) {
180  factorizePdf(observables, *pdf, obsTerms, constraints, debug);
181  return;
182  }
183  const std::type_info & id = typeid(func);
184  if (id == typeid(RooProduct)) {
185  RooProduct *prod = dynamic_cast<RooProduct *>(&func);
186  RooArgSet components(prod->components());
187  //std::cout << "Function " << func.GetName() << " is a RooProduct with " << components.getSize() << " components." << std::endl;
188  std::auto_ptr<TIterator> iter(components.createIterator());
189  for (RooAbsReal *funci = (RooAbsReal *) iter->Next(); funci != 0; funci = (RooAbsReal *) iter->Next()) {
190  //std::cout << " component " << funci->GetName() << " of type " << funci->ClassName() << std::endl;
191  factorizeFunc(observables, *funci, obsTerms, constraints);
192  }
193  } else if (func.dependsOn(observables)) {
194  if (!obsTerms.contains(func)) obsTerms.add(func);
195  } else {
196  if (!constraints.contains(func)) constraints.add(func);
197  }
198 }
void factorizeFunc(const RooArgSet &observables, RooAbsReal &pdf, RooArgList &obsTerms, RooArgList &otherTerms, bool debug=false)
factorize a RooAbsReal
Definition: utils.cc:177
RooAbsPdf * factorizePdf(const RooArgSet &observables, RooAbsPdf &pdf, RooArgList &constraints)
Definition: utils.cc:80
#define debug
Definition: MEtoEDMFormat.h:34
RooAbsPdf * utils::factorizePdf ( const RooArgSet &  observables,
RooAbsPdf &  pdf,
RooArgList &  constraints 
)

Create a pdf which depends only on observables, and collect the other constraint terms Will return 0 if it's all constraints, &pdf if it's all observables, or a new pdf if it's something mixed In the last case, you're the owner of the returned pdf.

Definition at line 80 of file utils.cc.

References copyAttributes(), i, list(), n, pileupCalc::nbins, parseEventContent::prod, and run_regression::ret.

Referenced by HybridNew::create(), factorizeFunc(), factorizePdf(), makeNuisancePdf(), makeObsOnlyPdf(), makePlots(), rebuildSimPdf(), GoodnessOfFit::runSaturatedModel(), cacheutils::CachingSimNLL::setup_(), toymcoptutils::SimPdfGenInfo::SimPdfGenInfo(), and SimplerLikelihoodRatioTestStatOpt::SimplerLikelihoodRatioTestStatOpt().

80  {
81  assert(&pdf);
82  const std::type_info & id = typeid(pdf);
83  if (id == typeid(RooProdPdf)) {
84  //std::cout << " pdf is product pdf " << pdf.GetName() << std::endl;
85  RooProdPdf *prod = dynamic_cast<RooProdPdf *>(&pdf);
86  RooArgList newFactors; RooArgSet newOwned;
87  RooArgList list(prod->pdfList());
88  bool needNew = false;
89  for (int i = 0, n = list.getSize(); i < n; ++i) {
90  RooAbsPdf *pdfi = (RooAbsPdf *) list.at(i);
91  RooAbsPdf *newpdf = factorizePdf(observables, *pdfi, constraints);
92  //std::cout << " for " << pdfi->GetName() << " newpdf " << (newpdf == 0 ? "null" : (newpdf == pdfi ? "old" : "new")) << std::endl;
93  if (newpdf == 0) { needNew = true; continue; }
94  if (newpdf != pdfi) { needNew = true; newOwned.add(*newpdf); }
95  newFactors.add(*newpdf);
96  }
97  if (!needNew) { copyAttributes(pdf, *prod); return prod; }
98  else if (newFactors.getSize() == 0) return 0;
99  else if (newFactors.getSize() == 1) {
100  RooAbsPdf *ret = (RooAbsPdf *) newFactors.first()->Clone(TString::Format("%s_obsOnly", pdf.GetName()));
101  copyAttributes(pdf, *ret);
102  return ret;
103  }
104  RooProdPdf *ret = new RooProdPdf(TString::Format("%s_obsOnly", pdf.GetName()), "", newFactors);
105  ret->addOwnedComponents(newOwned);
106  copyAttributes(pdf, *ret);
107  return ret;
108  } else if (id == typeid(RooSimultaneous) || id == typeid(RooSimultaneousOpt)) {
109  RooSimultaneous *sim = dynamic_cast<RooSimultaneous *>(&pdf);
110  RooAbsCategoryLValue *cat = (RooAbsCategoryLValue *) sim->indexCat().Clone();
111  int nbins = cat->numBins((const char *)0);
112  TObjArray factorizedPdfs(nbins); RooArgSet newOwned;
113  bool needNew = false;
114  for (int ic = 0, nc = nbins; ic < nc; ++ic) {
115  cat->setBin(ic);
116  RooAbsPdf *pdfi = sim->getPdf(cat->getLabel());
117  RooAbsPdf *newpdf = factorizePdf(observables, *pdfi, constraints);
118  factorizedPdfs[ic] = newpdf;
119  if (newpdf == 0) { throw std::runtime_error(std::string("ERROR: channel ") + cat->getLabel() + " factorized to zero."); }
120  if (newpdf != pdfi) { needNew = true; newOwned.add(*newpdf); }
121  }
122  RooSimultaneous *ret = sim;
123  if (needNew) {
124  ret = new RooSimultaneous(TString::Format("%s_obsOnly", pdf.GetName()), "", (RooAbsCategoryLValue&) sim->indexCat());
125  for (int ic = 0, nc = nbins; ic < nc; ++ic) {
126  cat->setBin(ic);
127  RooAbsPdf *newpdf = (RooAbsPdf *) factorizedPdfs[ic];
128  if (newpdf) ret->addPdf(*newpdf, cat->getLabel());
129  }
130  ret->addOwnedComponents(newOwned);
131  }
132  delete cat;
133  if (id == typeid(RooSimultaneousOpt)) {
134  RooSimultaneousOpt *newret = new RooSimultaneousOpt(*ret);
135  newret->addOwnedComponents(RooArgSet(*ret));
136  ret = newret;
137  }
138  copyAttributes(pdf, *ret);
139  return ret;
140  } else if (pdf.dependsOn(observables)) {
141  return &pdf;
142  } else {
143  if (!constraints.contains(pdf)) constraints.add(pdf);
144  return 0;
145  }
146 
147 }
int i
Definition: DBlmapReader.cc:9
Definition: sim.h:19
RooAbsPdf * factorizePdf(const RooArgSet &observables, RooAbsPdf &pdf, RooArgList &constraints)
Definition: utils.cc:80
void copyAttributes(const RooAbsArg &from, RooAbsArg &to)
Definition: utils.cc:364
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
void utils::factorizePdf ( RooStats::ModelConfig &  model,
RooAbsPdf &  pdf,
RooArgList &  obsTerms,
RooArgList &  constraints,
bool  debug = false 
)

collect factors depending on observables in obsTerms, and all others in constraints

Definition at line 149 of file utils.cc.

References createBeamHaloJobs::constraints, debug, and factorizePdf().

149  {
150  return factorizePdf(*model.GetObservables(), pdf, obsTerms, constraints, debug);
151 }
RooAbsPdf * factorizePdf(const RooArgSet &observables, RooAbsPdf &pdf, RooArgList &constraints)
Definition: utils.cc:80
#define debug
Definition: MEtoEDMFormat.h:34
void utils::factorizePdf ( const RooArgSet &  observables,
RooAbsPdf &  pdf,
RooArgList &  obsTerms,
RooArgList &  constraints,
bool  debug = false 
)

Definition at line 152 of file utils.cc.

References factorizePdf(), i, list(), n, and parseEventContent::prod.

152  {
153  assert(&pdf);
154  const std::type_info & id = typeid(pdf);
155  if (id == typeid(RooProdPdf)) {
156  RooProdPdf *prod = dynamic_cast<RooProdPdf *>(&pdf);
157  RooArgList list(prod->pdfList());
158  for (int i = 0, n = list.getSize(); i < n; ++i) {
159  RooAbsPdf *pdfi = (RooAbsPdf *) list.at(i);
160  factorizePdf(observables, *pdfi, obsTerms, constraints);
161  }
162  } else if (id == typeid(RooSimultaneous) || id == typeid(RooSimultaneousOpt)) {
163  RooSimultaneous *sim = dynamic_cast<RooSimultaneous *>(&pdf);
164  RooAbsCategoryLValue *cat = (RooAbsCategoryLValue *) sim->indexCat().Clone();
165  for (int ic = 0, nc = cat->numBins((const char *)0); ic < nc; ++ic) {
166  cat->setBin(ic);
167  RooAbsPdf *pdfi = sim->getPdf(cat->getLabel());
168  if (pdfi != 0) factorizePdf(observables, *pdfi, obsTerms, constraints);
169  }
170  delete cat;
171  } else if (pdf.dependsOn(observables)) {
172  if (!obsTerms.contains(pdf)) obsTerms.add(pdf);
173  } else {
174  if (!constraints.contains(pdf)) constraints.add(pdf);
175  }
176 }
int i
Definition: DBlmapReader.cc:9
Definition: sim.h:19
RooAbsPdf * factorizePdf(const RooArgSet &observables, RooAbsPdf &pdf, RooArgList &constraints)
Definition: utils.cc:80
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
RooAbsReal * utils::fullCloneFunc ( const RooAbsReal *  pdf,
RooArgSet &  holder,
bool  cloneLeafNodes = false 
)

Definition at line 226 of file utils.cc.

References tmp.

226  {
227  // Clone all FUNC compents by copying all branch nodes
228  RooArgSet tmp("RealBranchNodeList") ;
229  pdf->branchNodeServerList(&tmp);
230  tmp.snapshot(holder, cloneLeafNodes);
231  // Find the top level FUNC in the snapshot list
232  return (RooAbsReal*) holder.find(pdf->GetName());
233 }
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
RooAbsPdf * utils::fullClonePdf ( const RooAbsPdf *  pdf,
RooArgSet &  holder,
bool  cloneLeafNodes = false 
)

Definition at line 218 of file utils.cc.

References tmp.

Referenced by SimplerLikelihoodRatioTestStatOpt::SimplerLikelihoodRatioTestStatOpt().

218  {
219  // Clone all FUNC compents by copying all branch nodes
220  RooArgSet tmp("RealBranchNodeList") ;
221  pdf->branchNodeServerList(&tmp);
222  tmp.snapshot(holder, cloneLeafNodes);
223  // Find the top level FUNC in the snapshot list
224  return (RooAbsPdf*) holder.find(pdf->GetName());
225 }
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
def utils.get_relval_cmssw_version (   file)

Definition at line 536 of file utils.py.

537 def get_relval_cmssw_version(file):
538  cmssw_release = re.findall('(CMSSW_\d*_\d*_\d*(?:_[\w\d]*)?)-', file)
539  gr_r_version = re.findall('CMSSW_\d*_\d*_\d*(?:_[\w\d]*)?-([\w\d]*)_V\d*\w?(_[\w\d]*)?-v', file)
540  if cmssw_release and gr_r_version:
541  return (cmssw_release[0], gr_r_version[0])
def get_relval_cmssw_version
Definition: utils.py:536
def utils.get_relval_id (   file)
Returns unique relval ID (dataset name) for a given file.

Definition at line 542 of file utils.py.

543 def get_relval_id(file):
544  """Returns unique relval ID (dataset name) for a given file."""
545  dataset_name = re.findall('R\d{9}__([\w\d]*)__CMSSW_', file)
546  return dataset_name[0]
def get_relval_id
Definition: utils.py:542
def utils.get_relval_max_version (   files)
Returns file with maximum version at a) beggining of the file,
e.g. DQM_V000M b) at the end of run, e.g. _run2012-vM. M has to be max.

Definition at line 524 of file utils.py.

References get_relval_version().

525 def get_relval_max_version(files):
526  """Returns file with maximum version at a) beggining of the file,
527  e.g. DQM_V000M b) at the end of run, e.g. _run2012-vM. M has to be max."""
528  max_file = files[0]
529  max_v = get_relval_version(files[0])
530  for file in files:
531  file_v = get_relval_version(file)
532  if file_v[1] > max_v[1] or ((file_v[1] == max_v[1]) and (file_v[0] > max_v[0])):
533  max_file = file
534  max_v = file_v
535  return max_file
def get_relval_version
-------------—— Make files pairs: RelVal utils ---------------——
Definition: utils.py:517
def get_relval_max_version
Definition: utils.py:524
def utils.get_relval_version (   file)

-------------—— Make files pairs: RelVal utils ---------------——

Returns tuple (CMSSW version, run version) for specified file.

Definition at line 517 of file utils.py.

Referenced by get_relval_max_version().

518 def get_relval_version(file):
519  """Returns tuple (CMSSW version, run version) for specified file."""
520  cmssw_version = re.findall('DQM_V(\d*)_', file)
521  run_version = re.findall('CMSSW_\d*_\d*_\d*(?:_[\w\d]*)?-[\w\d]*_V\d*\w?(?:_[\w\d]*)?-v(\d*)__', file)
522  if cmssw_version and run_version:
523  return (int(cmssw_version[0]), int(run_version[0]))
def get_relval_version
-------------—— Make files pairs: RelVal utils ---------------——
Definition: utils.py:517
def utils.get_relvaldata_cmssw_version (   file)
Returns tuple (CMSSW release, GR_R version) for specified RelValData file.

Definition at line 486 of file utils.py.

488  """Returns tuple (CMSSW release, GR_R version) for specified RelValData file."""
489  cmssw_release = re.findall('(CMSSW_\d*_\d*_\d*(?:_[\w\d]*)?)-', file)
490  gr_r_version = re.findall('-(GR_R_\d*_V\d*\w?)(?:_RelVal)?_', file)
491  if not gr_r_version:
492  gr_r_version = re.findall('CMSSW_\d*_\d*_\d*(?:_[\w\d]*)?-(\w*)_RelVal_', file)
493  if cmssw_release and gr_r_version:
494  return (cmssw_release[0], gr_r_version[0])
def get_relvaldata_cmssw_version
Definition: utils.py:486
def utils.get_relvaldata_id (   file)

-----------—— Make files pairs: RelValData utils --------------——

Returns unique relvaldata ID for a given file.

Definition at line 476 of file utils.py.

477 def get_relvaldata_id(file):
478  """Returns unique relvaldata ID for a given file."""
479  run_id = re.search('R\d{9}', file)
480  run = re.search('_RelVal_([\w\d]*)-v\d__', file)
481  if not run:
482  run = re.search('GR_R_\d*_V\d*C?_([\w\d]*)-v\d__', file)
483  if run_id and run:
484  return (run_id.group(), run.group(1))
485  return None
def get_relvaldata_id
-----------—— Make files pairs: RelValData utils --------------——
Definition: utils.py:476
def utils.get_relvaldata_max_version (   files)
Returns file with maximum version at a) beggining of the file,
e.g. DQM_V000M b) at the end of run, e.g. _run2012-vM. M has to be max.

Definition at line 504 of file utils.py.

References get_relvaldata_version().

505 def get_relvaldata_max_version(files):
506  """Returns file with maximum version at a) beggining of the file,
507  e.g. DQM_V000M b) at the end of run, e.g. _run2012-vM. M has to be max."""
508  max_file = files[0]
509  max_v = get_relvaldata_version(files[0])
510  for file in files:
511  file_v = get_relvaldata_version(file)
512  if file_v[1] > max_v[1] or ((file_v[1] == max_v[1]) and (file_v[0] > max_v[0])):
513  max_file = file
514  max_v = file_v
515  return max_file
def get_relvaldata_version
Definition: utils.py:495
def get_relvaldata_max_version
Definition: utils.py:504
def utils.get_relvaldata_version (   file)
Returns tuple (CMSSW version, run version) for specified file.

Definition at line 495 of file utils.py.

Referenced by get_relvaldata_max_version().

496 def get_relvaldata_version(file):
497  """Returns tuple (CMSSW version, run version) for specified file."""
498  cmssw_version = re.findall('DQM_V(\d*)_', file)
499  run_version = re.findall('_RelVal_[\w\d]*-v(\d)__', file)
500  if not run_version:
501  run_version = re.findall('GR_R_\d*_V\d*C?_[\w\d]*-v(\d)__', file)
502  if cmssw_version and run_version:
503  return (int(cmssw_version[0]), int(run_version[0]))
def get_relvaldata_version
Definition: utils.py:495
void utils::getClients ( const RooAbsCollection &  values,
const RooAbsCollection &  allObjects,
RooAbsCollection &  clients 
)

add to 'clients' all object within allObjects that directly depend on values

Definition at line 236 of file utils.cc.

References a, and v.

Referenced by SimplerLikelihoodRatioTestStatOpt::SimplerLikelihoodRatioTestStatOpt().

236  {
237  std::auto_ptr<TIterator> iterAll(allObjects.createIterator());
238  std::auto_ptr<TIterator> iterVal(values.createIterator());
239  for (RooAbsArg *v = (RooAbsArg *) iterVal->Next(); v != 0; v = (RooAbsArg *) iterVal->Next()) {
240  if (typeid(*v) != typeid(RooRealVar)) continue;
241  std::auto_ptr<TIterator> clientIter(v->clientIterator());
242  for (RooAbsArg *a = (RooAbsArg *) clientIter->Next(); a != 0; a = (RooAbsArg *) clientIter->Next()) {
243  if (allObjects.containsInstance(*a) && !clients.containsInstance(*a)) clients.add(*a);
244  }
245  }
246 }
double a
Definition: hdecay.h:121
mathSSE::Vec4< T > v
def utils.getNbins (   h)

Definition at line 92 of file utils.py.

Referenced by utils.Chi2.absval(), utils.BinToBin.do_test(), utils.BinToBin1percent.do_test(), and utils.StatisticalTest.get_rank().

92 
93 def getNbins(h):
94  biny=h.GetNbinsY()
95  if biny>1:biny+=1
96  binz=h.GetNbinsZ()
97  if binz>1:binz+=1
98  return (h.GetNbinsX()+1)*(biny)*(binz)
99 
100 #-------------------------------------------------------------------------------
101 
def getNbins
Definition: utils.py:92
void utils::guessChannelMode ( RooSimultaneous &  simPdf,
RooAbsData &  simData,
bool  verbose = false 
)

Definition at line 376 of file utils.cc.

References gather_cfg::cout, i, n, and split.

Referenced by Combine::run().

377 {
378  RooAbsCategoryLValue &cat = const_cast<RooAbsCategoryLValue &>(simPdf.indexCat());
379  TList *split = simData.split(cat, kTRUE);
380  for (int i = 0, n = cat.numBins((const char *)0); i < n; ++i) {
381  cat.setBin(i);
382  RooAbsPdf *pdf = simPdf.getPdf(cat.getLabel());
383  if (pdf->getAttribute("forceGenBinned") || pdf->getAttribute("forceGenUnbinned")) {
384  if (verbose) std::cout << " - " << cat.getLabel() << " has generation mode already set" << std::endl;
385  continue;
386  }
387  RooAbsData *spl = (RooAbsData *) split->FindObject(cat.getLabel());
388  if (spl == 0) {
389  if (verbose) std::cout << " - " << cat.getLabel() << " has no dataset, cannot guess" << std::endl;
390  continue;
391  }
392  if (spl->numEntries() != spl->sumEntries()) {
393  if (verbose) std::cout << " - " << cat.getLabel() << " has " << spl->numEntries() << " num entries of sum " << spl->sumEntries() << ", mark as binned" << std::endl;
394  pdf->setAttribute("forceGenBinned");
395  } else {
396  if (verbose) std::cout << " - " << cat.getLabel() << " has " << spl->numEntries() << " num entries of sum " << spl->sumEntries() << ", mark as unbinned" << std::endl;
397  pdf->setAttribute("forceGenUnbinned");
398  }
399  }
400 }
int i
Definition: DBlmapReader.cc:9
tuple cout
Definition: gather_cfg.py:121
double split
Definition: MVATrainer.cc:139
def utils.is_empty (   h)

Definition at line 171 of file utils.py.

Referenced by DTSectColl.addTSTheta(), DEcompare< T >.get_ncand(), utils.StatisticalTest.get_rank(), and DEcompare< T >.SortCollections().

172 def is_empty(h):
173  for i in xrange(1,getNbins(h)):
174  if h.GetBinContent(i)!=0: return False
175  return True
176  #return h.GetSumOfWeights()==0
177 
178 #-------------------------------------------------------------------------------
def is_empty
Definition: utils.py:171
def getNbins
Definition: utils.py:92
def utils.is_relvaldata (   files)

----------------------— Make files pairs -----------------------—

Definition at line 548 of file utils.py.

References any.

Referenced by make_files_pairs().

549 def is_relvaldata(files):
550  is_relvaldata_re = re.compile('_RelVal_')
551  return any([is_relvaldata_re.search(filename) for filename in files])
def is_relvaldata
----------------------— Make files pairs -----------------------—
Definition: utils.py:548
def utils.is_sparse (   h)

Definition at line 179 of file utils.py.

180 def is_sparse(h):
181  filled_bins=0.
182  nbins=h.GetNbinsX()
183  for ibin in xrange(nbins):
184  if h.GetBinContent(ibin)>0:
185  filled_bins+=1
186  #print "%s %s --> %s" %(filled_bins,nbins,filled_bins/nbins)
187  if filled_bins/nbins < .5:
188  return True
189  else:
190  return False
191 
192 #-------------------------------------------------------------------------------
def is_sparse
Definition: utils.py:179
def utils.literal2root (   literal,
  rootType 
)

Definition at line 69 of file utils.py.

69 
70 def literal2root (literal,rootType):
71  bitsarray = array.array('B')
72  bitsarray.fromstring(literal.decode('hex'))
73 
74  tbuffer=0
75  try:
76  tbuffer = TBufferFile(TBufferFile.kRead, len(bitsarray), bitsarray, False,0)
77  except:
78  print "could not transform to object array:"
79  print [ i for i in bitsarray ]
80 
81  # replace a couple of shortcuts with the real root class name
82  if rootType == 'TPROF':
83  rootType = 'TProfile'
84  if rootType == 'TPROF2D':
85  rootType = 'TProfile2D'
86 
87  root_class=eval(rootType+'.Class()')
88 
89  return tbuffer.ReadObject(root_class)
90 
91 #-------------------------------------------------------------------------------
def literal2root
Definition: utils.py:69
def utils.logger (   msg_level,
  message 
)

Definition at line 47 of file utils.py.

Referenced by utils.StatisticalTest.get_rank(), and utils.StatisticalTest.get_status().

47 
48 def logger(msg_level,message):
49  if msg_level>=_log_level:
50  print "[%s] %s" %(asctime(),message)
51 
#-------------------------------------------------------------------------------
def logger
Definition: utils.py:47
def utils.make_files_pairs (   files,
  verbose = True 
)

Definition at line 552 of file utils.py.

References python.multivaluedict.append(), python.multivaluedict.dict, cmsRelvalreport.exit, is_relvaldata(), max(), and runtimedef.set().

Referenced by ValidationMatrix.get_filenames_from_pool().

553 def make_files_pairs(files, verbose=True):
554  ## Select functions to use
555  if is_relvaldata(files):
556  is_relval_data = True
557  get_cmssw_version = get_relvaldata_cmssw_version
558  get_id = get_relvaldata_id
559  get_max_version = get_relvaldata_max_version
560  # print 'Pairing Data RelVal files.'
561  else:
562  is_relval_data = False
563  get_cmssw_version = get_relval_cmssw_version
564  get_id = get_relval_id
565  get_max_version = get_relval_max_version
566  # print 'Pairing Monte Carlo RelVal files.'
567 
568  ## Divide files into groups
569  versions_files = dict()
570  for file in files:
571  version = get_cmssw_version(file)
572  if versions_files.has_key(version):
573  versions_files[version].append(file)
574  else:
575  versions_files[version] = [file]
576 
577  ## Print the division into groups
578  if verbose:
579  print '\nFound versions:'
580  for version in versions_files:
581  print '%s: %d files' % (str(version), len(versions_files[version]))
582 
583  if len(versions_files.keys()) <= 1:
584  print '\nFound too little versions, there is nothing to pair. Exiting...\n'
585  exit()
586 
587  ## Select two biggest groups.
588  versions = versions_files.keys()
589  sizes = [len(value) for value in versions_files.values()]
590  v1 = versions[sizes.index(max(sizes))]
591  versions.remove(v1)
592  sizes.remove(max(sizes))
593  v2 = versions[sizes.index(max(sizes))]
594 
595  ## Print two biggest groups.
596  if verbose:
597  print '\nPairing %s (%d files) and %s (%d files)' % (str(v1),
598  len(versions_files[v1]), str(v2), len(versions_files[v2]))
599 
600  ## Pairing two versions
601  print '\nGot pairs:'
602  pairs = []
603  for unique_id in set([get_id(file) for file in versions_files[v1]]):
604  if is_relval_data:
605  dataset_re = re.compile(unique_id[0]+'_')
606  run_re = re.compile(unique_id[1])
607  c1_files = [file for file in versions_files[v1] if dataset_re.search(file) and run_re.search(file)]
608  c2_files = [file for file in versions_files[v2] if dataset_re.search(file) and run_re.search(file)]
609  else:
610  dataset_re = re.compile(unique_id+'_')
611  c1_files = [file for file in versions_files[v1] if dataset_re.search(file)]
612  c2_files = [file for file in versions_files[v2] if dataset_re.search(file)]
613 
614  if len(c1_files) > 0 and len(c2_files) > 0:
615  first_file = get_max_version(c1_files)
616  second_file = get_max_version(c2_files)
617  print '%s\n%s\n' % (first_file, second_file)
618  pairs.extend((first_file, second_file))
619  if verbose:
620  print "Paired and got %d files.\n" % len(pairs)
621  return pairs
const T & max(const T &a, const T &b)
def is_relvaldata
----------------------— Make files pairs -----------------------—
Definition: utils.py:548
def make_files_pairs
Definition: utils.py:552
void set(const std::string &name, int value)
set the flag, with a run-time name
RooAbsPdf * utils::makeNuisancePdf ( RooStats::ModelConfig &  model,
const char *  name = "nuisancePdf" 
)

Definition at line 200 of file utils.cc.

References mergeVDriftHistosByStation::name.

Referenced by asimovutils::asimovDatasetWithFit(), HybridNew::create(), BayesianToyMC::run(), ProfileLikelihood::run(), Combine::run(), and MaxLikelihoodFit::runSpecific().

200  {
201  return utils::makeNuisancePdf(*model.GetPdf(), *model.GetObservables(), name);
202 }
RooAbsPdf * makeNuisancePdf(RooStats::ModelConfig &model, const char *name="nuisancePdf")
Definition: utils.cc:200
RooAbsPdf * utils::makeNuisancePdf ( RooAbsPdf &  pdf,
const RooArgSet &  observables,
const char *  name = "nuisancePdf" 
)

Definition at line 204 of file utils.cc.

References createBeamHaloJobs::constraints, and factorizePdf().

204  {
205  assert(&pdf);
206  RooArgList obsTerms, constraints;
207  factorizePdf(observables, pdf, obsTerms, constraints);
208  if (constraints.getSize() == 0) return 0;
209  return new RooProdPdf(name,"", constraints);
210 }
RooAbsPdf * factorizePdf(const RooArgSet &observables, RooAbsPdf &pdf, RooArgList &constraints)
Definition: utils.cc:80
RooAbsPdf * utils::makeObsOnlyPdf ( RooStats::ModelConfig &  model,
const char *  name = "obsPdf" 
)

Note: doesn't recompose Simultaneous pdfs properly, for that use factorizePdf method.

Definition at line 212 of file utils.cc.

References createBeamHaloJobs::constraints, and factorizePdf().

212  {
213  RooArgList obsTerms, constraints;
214  factorizePdf(model, *model.GetPdf(), obsTerms, constraints);
215  return new RooProdPdf(name,"", obsTerms);
216 }
RooAbsPdf * factorizePdf(const RooArgSet &observables, RooAbsPdf &pdf, RooArgList &constraints)
Definition: utils.cc:80
std::vector< RooPlot * > utils::makePlots ( const RooAbsPdf &  pdf,
const RooAbsData &  data,
const char *  signalSel = 0,
const char *  backgroundSel = 0,
float  rebinFactor = 1.0 
)

make plots, if possible

Definition at line 403 of file utils.cc.

References createBeamHaloJobs::constraints, RecoTau_DiTaus_pt_20-420_cfg::datasets, factorizePdf(), pileupCalc::nbins, GetRecoTauVFromDQM_MC_cff::next, run_regression::ret, and x.

Referenced by MaxLikelihoodFit::runSpecific().

403  {
404  std::vector<RooPlot *> ret;
405  RooArgList constraints;
406  RooAbsPdf *facpdf = factorizePdf(*data.get(0), const_cast<RooAbsPdf &>(pdf), constraints);
407 
408  const std::type_info & id = typeid(*facpdf);
409  if (id == typeid(RooSimultaneous) || id == typeid(RooSimultaneousOpt)) {
410  const RooSimultaneous *sim = dynamic_cast<const RooSimultaneous *>(&pdf);
411  const RooAbsCategoryLValue &cat = (RooAbsCategoryLValue &) sim->indexCat();
412  TList *datasets = data.split(cat, true);
413  TIter next(datasets);
414  for (RooAbsData *ds = (RooAbsData *) next(); ds != 0; ds = (RooAbsData *) next()) {
415  RooAbsPdf *pdfi = sim->getPdf(ds->GetName());
416  std::auto_ptr<RooArgSet> obs(pdfi->getObservables(ds));
417  if (obs->getSize() == 0) break;
418  RooRealVar *x = dynamic_cast<RooRealVar *>(obs->first());
419  if (x == 0) continue;
420  int nbins = x->numBins(); if (nbins == 0) nbins = 100;
421  if (nbins/rebinFactor > 6) nbins = ceil(nbins/rebinFactor);
422  ret.push_back(x->frame(RooFit::Title(ds->GetName()), RooFit::Bins(nbins)));
423  ret.back()->SetName(ds->GetName());
424  ds->plotOn(ret.back());
425  if (signalSel && strlen(signalSel)) pdfi->plotOn(ret.back(), RooFit::LineColor(209), RooFit::Components(signalSel));
426  if (backgroundSel && strlen(backgroundSel)) pdfi->plotOn(ret.back(), RooFit::LineColor(206), RooFit::Components(backgroundSel));
427  pdfi->plotOn(ret.back());
428  delete ds;
429  }
430  delete datasets;
431  } else if (pdf.canBeExtended()) {
432  std::auto_ptr<RooArgSet> obs(pdf.getObservables(&data));
433  RooRealVar *x = dynamic_cast<RooRealVar *>(obs->first());
434  if (x != 0) {
435  ret.push_back(x->frame());
436  ret.back()->SetName("data");
437  data.plotOn(ret.back());
438  if (signalSel && strlen(signalSel)) pdf.plotOn(ret.back(), RooFit::LineColor(209), RooFit::Components(signalSel));
439  if (backgroundSel && strlen(backgroundSel)) pdf.plotOn(ret.back(), RooFit::LineColor(206), RooFit::Components(backgroundSel));
440  pdf.plotOn(ret.back());
441  }
442  }
443  if (facpdf != &pdf) { delete facpdf; }
444  return ret;
445 
446 }
Definition: sim.h:19
RooAbsPdf * factorizePdf(const RooArgSet &observables, RooAbsPdf &pdf, RooArgList &constraints)
Definition: utils.cc:80
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
Definition: DDAxes.h:10
void utils::printPdf ( RooAbsPdf *  pdf)

Definition at line 61 of file utils.cc.

References gather_cfg::cout.

Referenced by Combine::run().

61  {
62  std::cout << "Pdf " << pdf->GetName() << " parameters." << std::endl;
63  std::auto_ptr<RooArgSet> params(pdf->getVariables());
64  params->Print("V");
65 }
tuple cout
Definition: gather_cfg.py:121
void utils::printPdf ( RooStats::ModelConfig &  model)

Definition at line 68 of file utils.cc.

References gather_cfg::cout.

68  {
69  std::cout << "ModelConfig " << mc.GetName() << " (" << mc.GetTitle() << "): pdf parameters." << std::endl;
70  std::auto_ptr<RooArgSet> params(mc.GetPdf()->getVariables());
71  params->Print("V");
72 }
tuple cout
Definition: gather_cfg.py:121
void utils::printPdf ( RooWorkspace *  w,
const char *  pdfName 
)

Definition at line 74 of file utils.cc.

References gather_cfg::cout.

74  {
75  std::cout << "PDF " << pdfName << " parameters." << std::endl;
76  std::auto_ptr<RooArgSet> params(w->pdf(pdfName)->getVariables());
77  params->Print("V");
78 }
tuple cout
Definition: gather_cfg.py:121
T w() const
void utils::printRAD ( const RooAbsData *  d)

Definition at line 56 of file utils.cc.

References printRDH().

Referenced by Combine::run().

56  {
57  if (d->InheritsFrom("RooDataHist") || d->numEntries() != 1) printRDH(const_cast<RooAbsData*>(d));
58  else d->get(0)->Print("V");
59 }
void printRDH(RooAbsData *data)
Definition: utils.cc:30
void utils::printRDH ( RooAbsData *  data)

Definition at line 30 of file utils.cc.

References a, newFWLiteAna::bin, i, and j.

Referenced by GoodnessOfFit::makeSaturatedPdf(), and printRAD().

30  {
31  std::vector<std::string> varnames, catnames;
32  const RooArgSet *b0 = data->get();
33  TIterator *iter = b0->createIterator();
34  for (RooAbsArg *a = 0; (a = (RooAbsArg *)iter->Next()) != 0; ) {
35  if (a->InheritsFrom("RooRealVar")) {
36  varnames.push_back(a->GetName());
37  } else if (a->InheritsFrom("RooCategory")) {
38  catnames.push_back(a->GetName());
39  }
40  }
41  delete iter;
42  size_t nv = varnames.size(), nc = catnames.size();
43  printf(" bin ");
44  for (size_t j = 0; j < nv; ++j) { printf("%16.16s ", varnames[j].c_str()); }
45  for (size_t j = 0; j < nc; ++j) { printf("%16.16s ", catnames[j].c_str()); }
46  printf(" weight\n");
47  for (int i = 0, nb = data->numEntries(); i < nb; ++i) {
48  const RooArgSet *bin = data->get(i);
49  printf("%4d ",i);
50  for (size_t j = 0; j < nv; ++j) { printf("%16g ", bin->getRealValue(varnames[j].c_str())); }
51  for (size_t j = 0; j < nc; ++j) { printf("%16.16s ", bin->getCatLabel(catnames[j].c_str())); }
52  printf("%8.3f\n", data->weight());
53  }
54 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
double a
Definition: hdecay.h:121
def utils.profile2histo (   profile)

Definition at line 220 of file utils.py.

221 def profile2histo(profile):
222  if not profile.InheritsFrom("TH1"):
223  return profile
224 
225  bin_low_edges=[]
226  n_bins=profile.GetNbinsX()
227 
228  for ibin in xrange(1,n_bins+2):
229  bin_low_edges.append(profile.GetBinLowEdge(ibin))
230  bin_low_edges=array.array('f',bin_low_edges)
231  histo=TH1F(profile.GetName(),profile.GetTitle(),n_bins,bin_low_edges)
232  for ibin in xrange(0,n_bins+1):
233  histo.SetBinContent(ibin,profile.GetBinContent(ibin))
234  histo.SetBinError(ibin,profile.GetBinError(ibin))
235 
236  return histo
237 #-------------------------------------------------------------------------------
def profile2histo
Definition: utils.py:220
RooSimultaneous * utils::rebuildSimPdf ( const RooArgSet &  observables,
RooSimultaneous *  pdf 
)

Definition at line 327 of file utils.cc.

References createBeamHaloJobs::constraints, copyAttributes(), factorizePdf(), pileupCalc::nbins, and run_regression::ret.

Referenced by Combine::run().

327  {
328  RooArgList constraints;
329  RooAbsCategoryLValue *cat = (RooAbsCategoryLValue *) sim->indexCat().Clone();
330  int nbins = cat->numBins((const char *)0);
331  TObjArray factorizedPdfs(nbins);
332  RooArgSet newOwned;
333  for (int ic = 0, nc = nbins; ic < nc; ++ic) {
334  cat->setBin(ic);
335  RooAbsPdf *pdfi = sim->getPdf(cat->getLabel());
336  if (pdfi == 0) { factorizedPdfs[ic] = 0; continue; }
337  RooAbsPdf *newpdf = factorizePdf(observables, *pdfi, constraints);
338  factorizedPdfs[ic] = newpdf;
339  if (newpdf == 0) { continue; }
340  if (newpdf != pdfi) { newOwned.add(*newpdf); }
341  }
342  RooSimultaneous *ret = new RooSimultaneous(TString::Format("%s_reloaded", sim->GetName()), "", (RooAbsCategoryLValue&) sim->indexCat());
343  for (int ic = 0, nc = nbins; ic < nc; ++ic) {
344  cat->setBin(ic);
345  RooAbsPdf *newpdf = (RooAbsPdf *) factorizedPdfs[ic];
346  if (newpdf) {
347  if (constraints.getSize() > 0) {
348  RooArgList allfactors(constraints); allfactors.add(*newpdf);
349  RooProdPdf *newerpdf = new RooProdPdf(TString::Format("%s_plus_constr", newpdf->GetName()), "", allfactors);
350  ret->addPdf(*newerpdf, cat->getLabel());
351  copyAttributes(*newpdf, *newerpdf);
352  newOwned.add(*newerpdf);
353  } else {
354  ret->addPdf(*newpdf, cat->getLabel());
355  }
356  }
357  }
358  ret->addOwnedComponents(newOwned);
359  copyAttributes(*sim, *ret);
360  delete cat;
361  return ret;
362 }
Definition: sim.h:19
RooAbsPdf * factorizePdf(const RooArgSet &observables, RooAbsPdf &pdf, RooArgList &constraints)
Definition: utils.cc:80
void copyAttributes(const RooAbsArg &from, RooAbsArg &to)
Definition: utils.cc:364
bool utils::setAllConstant ( const RooAbsCollection &  coll,
bool  constant = true 
)

set all RooRealVars to constants. return true if at least one changed status

Definition at line 248 of file utils.cc.

References a, and v.

Referenced by Asymptotic::asimovDataset(), asimovutils::asimovDatasetWithFit(), HybridNew::create(), ProfiledLikelihoodTestStatOpt::Evaluate(), and Combine::run().

248  {
249  bool changed = false;
250  std::auto_ptr<TIterator> iter(coll.createIterator());
251  for (RooAbsArg *a = (RooAbsArg *) iter->Next(); a != 0; a = (RooAbsArg *) iter->Next()) {
252  RooRealVar *v = dynamic_cast<RooRealVar *>(a);
253  if (v && (v->isConstant() != constant)) {
254  changed = true;
255  v->setConstant(constant);
256  }
257  }
258  return changed;
259 }
JetCorrectorParametersCollection coll
Definition: classes.h:14
double a
Definition: hdecay.h:121
mathSSE::Vec4< T > v
def utils.setTDRStyle ( )

Definition at line 52 of file utils.py.

References combineCards.dirname, and plotscripts.tdrStyle.

Referenced by FlavourHistograms< T >.plot(), and TrackIPTagPlotter.psPlot().

52 
53 def setTDRStyle():
54  this_dir=dirname(this_module_name)
55  this_dir_one_up=this_dir[:this_dir.rfind("/")+1]
56  #this_dir_two_up=this_dir_one_up[:this_dir_one_up.rfind("/")+1]
57  style_file=''
58  if os.environ.has_key("RELMON_SA"):
59  style_file=this_dir_one_up+"data/tdrstyle_mod.C"
60  else:
61  style_file="%s/src/Utilities/RelMon/data/tdrstyle_mod.C"%(os.environ["CMSSW_BASE"])
62  try:
63  gROOT.ProcessLine(".L %s" %style_file)
64  gROOT.ProcessLine("setTDRStyle()")
65  except:
66  "Print could not set the TDR style. File %s not found?" %style_file
67 
68 
#-------------------------------------------------------------------------------
def setTDRStyle
Definition: utils.py:52
void utils::tdrStyle ( )

set style for plots

—> gStyle->SetStatFontSize(0.025);

Definition at line 4 of file tdrstyle.cc.

Referenced by MaxLikelihoodFit::runSpecific().

4  {
5  gStyle->SetPadTopMargin(0.05);
6  gStyle->SetPadBottomMargin(0.13);
7  gStyle->SetPadLeftMargin(0.16);
8  gStyle->SetPadRightMargin(0.04);
9  gStyle->SetPalette(1);
10  gStyle->SetHistMinimumZero(1);
11  gStyle->SetCanvasBorderMode(0);
12  gStyle->SetCanvasColor(kWhite);
13  gStyle->SetPadBorderMode(0);
14  gStyle->SetPadColor(kWhite);
15  gStyle->SetFrameBorderMode(0);
16  gStyle->SetFrameBorderSize(1);
17  gStyle->SetFrameFillColor(0);
18  gStyle->SetStatColor(kWhite);
19  gStyle->SetTitleColor(1);
20  gStyle->SetTitleFillColor(10);
21 
22  gStyle->SetOptTitle(0);
23 
24  gStyle->SetStatFont(42);
25  gStyle->SetStatFontSize(0.04);
26  gStyle->SetTitleColor(1, "XYZ");
27  gStyle->SetTitleFont(42, "XYZ");
28  gStyle->SetTitleSize(0.06, "XYZ");
29  // gStyle->SetTitleXSize(Float_t size = 0.02); // Another way to set the size?
30  // gStyle->SetTitleYSize(Float_t size = 0.02);
31  gStyle->SetTitleXOffset(0.9);
32  gStyle->SetTitleYOffset(1.25);
33  // gStyle->SetTitleOffset(1.1, "Y"); // Another way to set the Offset
34 
35  // For the axis labels:
36 
37  gStyle->SetLabelColor(1, "XYZ");
38  gStyle->SetLabelFont(42, "XYZ");
39  gStyle->SetLabelOffset(0.007, "XYZ");
40  gStyle->SetLabelSize(0.05, "XYZ");
41 
42  // For the axis:
43  gStyle->SetAxisColor(1, "XYZ");
44  gStyle->SetStripDecimals(kTRUE);
45  gStyle->SetTickLength(0.03, "XYZ");
46  gStyle->SetNdivisions(510, "XYZ");
47  gStyle->SetPadTickX(1); // To get tick marks on the opposite side of the frame
48  gStyle->SetPadTickY(1);
49 }
def utils.wget (   url)
Fetch the WHOLE file, not in bunches... To be optimised.

Definition at line 451 of file utils.py.

References SiPixelLorentzAngle_cfi.read.

452 def wget(url):
453  """ Fetch the WHOLE file, not in bunches... To be optimised.
454  """
455  opener=build_opener(X509CertOpen())
456  datareq = Request(url)
457  datareq.add_header('authenticated_wget', "The ultimate wgetter")
458  bin_content=None
459  try:
460  filename=basename(url)
461  print "Checking existence of file %s on disk..."%filename
462  if not isfile("./%s"%filename):
463  bin_content=opener.open(datareq).read()
464  else:
465  print "File %s exists, skipping.." %filename
466  except ValueError:
467  print "Error: Unknown url %s" %url
468 
469  if bin_content!=None:
470  ofile = open(filename, 'wb')
471  ofile.write(bin_content)
472  ofile.close()
473 
#-------------------------------------------------------------------------------
def wget
Definition: utils.py:451

Variable Documentation

int utils._log_level = 10

Definition at line 46 of file utils.py.

utils.theargv = sys.argv

Definition at line 24 of file utils.py.