ROOT  6.06/09
Reference Guide
RooSimultaneous.cxx
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * @(#)root/roofitcore:$Id$
5  * Authors: *
6  * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7  * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8  * *
9  * Copyright (c) 2000-2005, Regents of the University of California *
10  * and Stanford University. All rights reserved. *
11  * *
12  * Redistribution and use in source and binary forms, *
13  * with or without modification, are permitted according to the terms *
14  * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15  *****************************************************************************/
16 
17 //////////////////////////////////////////////////////////////////////////////
18 //
19 // BEGIN_HTML
20 // RooSimultaneous facilitates simultaneous fitting of multiple PDFs
21 // to subsets of a given dataset.
22 // <p>
23 // The class takes an index category, which is interpreted as
24 // the data subset indicator, and a list of PDFs, each associated
25 // with a state of the index category. RooSimultaneous always returns
26 // the value of the PDF that is associated with the current value
27 // of the index category
28 // <p>
29 // Extended likelihood fitting is supported if all components support
30 // extended likelihood mode. The expected number of events by a RooSimultaneous
31 // is that of the component p.d.f. selected by the index category
32 // END_HTML
33 //
34 
35 #include "RooFit.h"
36 #include "Riostream.h"
37 
38 #include "TObjString.h"
39 #include "RooSimultaneous.h"
40 #include "RooAbsCategoryLValue.h"
41 #include "RooPlot.h"
42 #include "RooCurve.h"
43 #include "RooRealVar.h"
44 #include "RooAddPdf.h"
45 #include "RooAbsData.h"
46 #include "Roo1DTable.h"
47 #include "RooSimGenContext.h"
48 #include "RooSimSplitGenContext.h"
49 #include "RooDataSet.h"
50 #include "RooCmdConfig.h"
51 #include "RooNameReg.h"
52 #include "RooGlobalFunc.h"
53 #include "RooNameReg.h"
54 #include "RooMsgService.h"
55 #include "RooCategory.h"
56 #include "RooSuperCategory.h"
57 #include "RooDataHist.h"
58 #include "RooRandom.h"
59 #include "RooArgSet.h"
60 
61 using namespace std ;
62 
64 ;
65 
66 
67 
68 
69 ////////////////////////////////////////////////////////////////////////////////
70 /// Constructor with index category. PDFs associated with indexCat
71 /// states can be added after construction with the addPdf() function.
72 ///
73 /// RooSimultaneous can function without having a PDF associated
74 /// with every single state. The normalization in such cases is taken
75 /// from the number of registered PDFs, but getVal() will assert if
76 /// when called for an unregistered index state.
77 
78 RooSimultaneous::RooSimultaneous(const char *name, const char *title,
79  RooAbsCategoryLValue& inIndexCat) :
80  RooAbsPdf(name,title),
81  _plotCoefNormSet("!plotCoefNormSet","plotCoefNormSet",this,kFALSE,kFALSE),
82  _plotCoefNormRange(0),
83  _partIntMgr(this,10),
84  _indexCat("indexCat","Index category",this,inIndexCat),
85  _numPdf(0)
86 {
87 }
88 
89 
90 
91 ////////////////////////////////////////////////////////////////////////////////
92 /// Constructor from index category and full list of PDFs.
93 /// In this constructor form, a PDF must be supplied for each indexCat state
94 /// to avoid ambiguities. The PDFS are associated in order with the state of the
95 /// index category as listed by the index categories type iterator.
96 ///
97 /// PDFs may not overlap (i.e. share any variables) with the index category (function)
98 
99 RooSimultaneous::RooSimultaneous(const char *name, const char *title,
100  const RooArgList& inPdfList, RooAbsCategoryLValue& inIndexCat) :
101  RooAbsPdf(name,title),
102  _plotCoefNormSet("!plotCoefNormSet","plotCoefNormSet",this,kFALSE,kFALSE),
103  _plotCoefNormRange(0),
104  _partIntMgr(this,10),
105  _indexCat("indexCat","Index category",this,inIndexCat),
106  _numPdf(0)
107 {
108  if (inPdfList.getSize() != inIndexCat.numTypes()) {
109  coutE(InputArguments) << "RooSimultaneous::ctor(" << GetName()
110  << " ERROR: Number PDF list entries must match number of index category states, no PDFs added" << endl ;
111  return ;
112  }
113 
114  map<string,RooAbsPdf*> pdfMap ;
115  // Iterator over PDFs and index cat states and add each pair
116  TIterator* pIter = inPdfList.createIterator() ;
117  TIterator* cIter = inIndexCat.typeIterator() ;
118  RooAbsPdf* pdf ;
119  RooCatType* type(0) ;
120  while ((pdf=(RooAbsPdf*)pIter->Next())) {
121  type = (RooCatType*) cIter->Next() ;
122  pdfMap[string(type->GetName())] = pdf ;
123  }
124  delete pIter ;
125  delete cIter ;
126 
127  initialize(inIndexCat,pdfMap) ;
128 }
129 
130 
131 ////////////////////////////////////////////////////////////////////////////////
132 
133 RooSimultaneous::RooSimultaneous(const char *name, const char *title,
134  map<string,RooAbsPdf*> pdfMap, RooAbsCategoryLValue& inIndexCat) :
135  RooAbsPdf(name,title),
136  _plotCoefNormSet("!plotCoefNormSet","plotCoefNormSet",this,kFALSE,kFALSE),
137  _plotCoefNormRange(0),
138  _partIntMgr(this,10),
139  _indexCat("indexCat","Index category",this,inIndexCat),
140  _numPdf(0)
141 {
142  initialize(inIndexCat,pdfMap) ;
143 }
144 
145 
146 
147 
148 // This class cannot be locally defined in initialize as it cannot be
149 // used as a template argument in that case
151  struct CompInfo {
152  RooAbsPdf* pdf ;
153  RooSimultaneous* simPdf ;
154  const RooAbsCategoryLValue* subIndex ;
155  RooArgSet* subIndexComps ;
156  } ;
157 }
158 
159 void RooSimultaneous::initialize(RooAbsCategoryLValue& inIndexCat, std::map<std::string,RooAbsPdf*> pdfMap)
160 {
161  // First see if there are any RooSimultaneous input components
162  Bool_t simComps(kFALSE) ;
163  for (map<string,RooAbsPdf*>::iterator iter=pdfMap.begin() ; iter!=pdfMap.end() ; iter++) {
164  if (dynamic_cast<RooSimultaneous*>(iter->second)) {
165  simComps = kTRUE ;
166  break ;
167  }
168  }
169 
170  // If there are no simultaneous component p.d.f. do simple processing through addPdf()
171  if (!simComps) {
172  for (map<string,RooAbsPdf*>::iterator iter=pdfMap.begin() ; iter!=pdfMap.end() ; iter++) {
173  addPdf(*iter->second,iter->first.c_str()) ;
174  }
175  return ;
176  }
177 
178  // Issue info message that we are about to do some rearraning
179  coutI(InputArguments) << "RooSimultaneous::initialize(" << GetName() << ") INFO: one or more input component of simultaneous p.d.f.s are"
180  << " simultaneous p.d.f.s themselves, rewriting composite expressions as one-level simultaneous p.d.f. in terms of"
181  << " final constituents and extended index category" << endl ;
182 
183 
184  RooArgSet allAuxCats ;
185  map<string,RooSimultaneousAux::CompInfo> compMap ;
186  for (map<string,RooAbsPdf*>::iterator iter=pdfMap.begin() ; iter!=pdfMap.end() ; iter++) {
187  RooSimultaneousAux::CompInfo ci ;
188  ci.pdf = iter->second ;
189  RooSimultaneous* simComp = dynamic_cast<RooSimultaneous*>(iter->second) ;
190  if (simComp) {
191  ci.simPdf = simComp ;
192  ci.subIndex = &simComp->indexCat() ;
193  ci.subIndexComps = simComp->indexCat().isFundamental() ? new RooArgSet(simComp->indexCat()) : simComp->indexCat().getVariables() ;
194  allAuxCats.add(*(ci.subIndexComps),kTRUE) ;
195  } else {
196  ci.simPdf = 0 ;
197  ci.subIndex = 0 ;
198  ci.subIndexComps = 0 ;
199  }
200  compMap[iter->first] = ci ;
201  }
202 
203  // Construct the 'superIndex' from the nominal index category and all auxiliary components
204  RooArgSet allCats(inIndexCat) ;
205  allCats.add(allAuxCats) ;
206  string siname = Form("%s_index",GetName()) ;
207  RooSuperCategory* superIndex = new RooSuperCategory(siname.c_str(),siname.c_str(),allCats) ;
208 
209  // Now process each of original pdf/state map entries
210  for (map<string,RooSimultaneousAux::CompInfo>::iterator citer = compMap.begin() ; citer != compMap.end() ; citer++) {
211 
212  RooArgSet repliCats(allAuxCats) ;
213  if (citer->second.subIndexComps) {
214  repliCats.remove(*citer->second.subIndexComps) ;
215  delete citer->second.subIndexComps ;
216  }
217  inIndexCat.setLabel(citer->first.c_str()) ;
218 
219 
220  if (!citer->second.simPdf) {
221 
222  // Entry is a plain p.d.f. assign it to every state permutation of the repliCats set
223  RooSuperCategory repliSuperCat("tmp","tmp",repliCats) ;
224 
225  // Iterator over all states of repliSuperCat
226  TIterator* titer = repliSuperCat.typeIterator() ;
227  RooCatType* type ;
228  while ((type=(RooCatType*)titer->Next())) {
229  // Set value
230  repliSuperCat.setLabel(type->GetName()) ;
231  // Retrieve corresponding label of superIndex
232  string superLabel = superIndex->getLabel() ;
233  addPdf(*citer->second.pdf,superLabel.c_str()) ;
234  cxcoutD(InputArguments) << "RooSimultaneous::initialize(" << GetName()
235  << ") assigning pdf " << citer->second.pdf->GetName() << " to super label " << superLabel << endl ;
236  }
237  } else {
238 
239  // Entry is a simultaneous p.d.f
240 
241  if (repliCats.getSize()==0) {
242 
243  // Case 1 -- No replication of components of RooSim component are required
244 
245  TIterator* titer = citer->second.subIndex->typeIterator() ;
246  RooCatType* type ;
247  while ((type=(RooCatType*)titer->Next())) {
248  const_cast<RooAbsCategoryLValue*>(citer->second.subIndex)->setLabel(type->GetName()) ;
249  string superLabel = superIndex->getLabel() ;
250  RooAbsPdf* compPdf = citer->second.simPdf->getPdf(type->GetName()) ;
251  if (compPdf) {
252  addPdf(*compPdf,superLabel.c_str()) ;
253  cxcoutD(InputArguments) << "RooSimultaneous::initialize(" << GetName()
254  << ") assigning pdf " << compPdf->GetName() << "(member of " << citer->second.pdf->GetName()
255  << ") to super label " << superLabel << endl ;
256  } else {
257  coutW(InputArguments) << "RooSimultaneous::initialize(" << GetName() << ") WARNING: No p.d.f. associated with label "
258  << type->GetName() << " for component RooSimultaneous p.d.f " << citer->second.pdf->GetName()
259  << "which is associated with master index label " << citer->first << endl ;
260  }
261  }
262  delete titer ;
263 
264  } else {
265 
266  // Case 2 -- Replication of components of RooSim component are required
267 
268  // Make replication supercat
269  RooSuperCategory repliSuperCat("tmp","tmp",repliCats) ;
270  TIterator* triter = repliSuperCat.typeIterator() ;
271 
272  TIterator* tsiter = citer->second.subIndex->typeIterator() ;
273  RooCatType* stype, *rtype ;
274  while ((stype=(RooCatType*)tsiter->Next())) {
275  const_cast<RooAbsCategoryLValue*>(citer->second.subIndex)->setLabel(stype->GetName()) ;
276  triter->Reset() ;
277  while ((rtype=(RooCatType*)triter->Next())) {
278  repliSuperCat.setLabel(rtype->GetName()) ;
279  string superLabel = superIndex->getLabel() ;
280  RooAbsPdf* compPdf = citer->second.simPdf->getPdf(stype->GetName()) ;
281  if (compPdf) {
282  addPdf(*compPdf,superLabel.c_str()) ;
283  cxcoutD(InputArguments) << "RooSimultaneous::initialize(" << GetName()
284  << ") assigning pdf " << compPdf->GetName() << "(member of " << citer->second.pdf->GetName()
285  << ") to super label " << superLabel << endl ;
286  } else {
287  coutW(InputArguments) << "RooSimultaneous::initialize(" << GetName() << ") WARNING: No p.d.f. associated with label "
288  << stype->GetName() << " for component RooSimultaneous p.d.f " << citer->second.pdf->GetName()
289  << "which is associated with master index label " << citer->first << endl ;
290  }
291  }
292  }
293 
294  delete tsiter ;
295  delete triter ;
296 
297  }
298  }
299  }
300 
301  // Change original master index to super index and take ownership of it
302  _indexCat.setArg(*superIndex) ;
303  addOwnedComponents(*superIndex) ;
304 
305 }
306 
307 
308 
309 ////////////////////////////////////////////////////////////////////////////////
310 /// Copy constructor
311 
313  RooAbsPdf(other,name),
314  _plotCoefNormSet("!plotCoefNormSet",this,other._plotCoefNormSet),
315  _plotCoefNormRange(other._plotCoefNormRange),
316  _partIntMgr(other._partIntMgr,this),
317  _indexCat("indexCat",this,other._indexCat),
318  _numPdf(other._numPdf)
319 {
320  // Copy proxy list
321  TIterator* pIter = other._pdfProxyList.MakeIterator() ;
322  RooRealProxy* proxy ;
323  while ((proxy=(RooRealProxy*)pIter->Next())) {
324  _pdfProxyList.Add(new RooRealProxy(proxy->GetName(),this,*proxy)) ;
325  }
326  delete pIter ;
327 }
328 
329 
330 
331 ////////////////////////////////////////////////////////////////////////////////
332 /// Destructor
333 
335 {
337 }
338 
339 
340 
341 ////////////////////////////////////////////////////////////////////////////////
342 /// Return the p.d.f associated with the given index category name
343 
344 RooAbsPdf* RooSimultaneous::getPdf(const char* catName) const
345 {
346  RooRealProxy* proxy = (RooRealProxy*) _pdfProxyList.FindObject(catName) ;
347  return proxy ? ((RooAbsPdf*)proxy->absArg()) : 0 ;
348 }
349 
350 
351 
352 ////////////////////////////////////////////////////////////////////////////////
353 /// Associate given PDF with index category state label 'catLabel'.
354 /// The names state must be already defined in the index category
355 ///
356 /// RooSimultaneous can function without having a PDF associated
357 /// with every single state. The normalization in such cases is taken
358 /// from the number of registered PDFs, but getVal() will assert if
359 /// when called for an unregistered index state.
360 ///
361 /// PDFs may not overlap (i.e. share any variables) with the index category (function)
362 
363 Bool_t RooSimultaneous::addPdf(const RooAbsPdf& pdf, const char* catLabel)
364 {
365  // PDFs cannot overlap with the index category
366  if (pdf.dependsOn(_indexCat.arg())) {
367  coutE(InputArguments) << "RooSimultaneous::addPdf(" << GetName() << "): ERROR, PDF " << pdf.GetName()
368  << " overlaps with index category " << _indexCat.arg().GetName() << endl ;
369  return kTRUE ;
370  }
371 
372  // Each index state can only have one PDF associated with it
373  if (_pdfProxyList.FindObject(catLabel)) {
374  coutE(InputArguments) << "RooSimultaneous::addPdf(" << GetName() << "): ERROR, index state "
375  << catLabel << " has already an associated PDF" << endl ;
376  return kTRUE ;
377  }
378 
379  const RooSimultaneous* simPdf = dynamic_cast<const RooSimultaneous*>(&pdf) ;
380  if (simPdf) {
381 
382  coutE(InputArguments) << "RooSimultaneous::addPdf(" << GetName()
383  << ") ERROR: you cannot add a RooSimultaneous component to a RooSimultaneous using addPdf()."
384  << " Use the constructor with RooArgList if input p.d.f.s or the map<string,RooAbsPdf&> instead." << endl ;
385  return kTRUE ;
386 
387  } else {
388 
389  // Create a proxy named after the associated index state
390  TObject* proxy = new RooRealProxy(catLabel,catLabel,this,(RooAbsPdf&)pdf) ;
391  _pdfProxyList.Add(proxy) ;
392  _numPdf += 1 ;
393  }
394 
395  return kFALSE ;
396 }
397 
398 
399 
400 
401 
402 ////////////////////////////////////////////////////////////////////////////////
403 /// WVE NEEDS FIX
404 
406 {
407  Bool_t allCanExtend(kTRUE) ;
408  Bool_t anyMustExtend(kFALSE) ;
409 
410  for (Int_t i=0 ; i<_numPdf ; i++) {
412  if (proxy) {
413 // cout << " now processing pdf " << pdf->GetName() << endl ;
414  RooAbsPdf* pdf = (RooAbsPdf*) proxy->absArg() ;
415  if (!pdf->canBeExtended()) {
416 // cout << "RooSim::extendedMode(" << GetName() << ") component " << pdf->GetName() << " cannot be extended" << endl ;
417  allCanExtend=kFALSE ;
418  }
419  if (pdf->mustBeExtended()) {
420  anyMustExtend=kTRUE;
421  }
422  }
423  }
424  if (anyMustExtend) {
425 // cout << "RooSim::extendedMode(" << GetName() << ") returning MustBeExtended" << endl ;
426  return MustBeExtended ;
427  }
428  if (allCanExtend) {
429 // cout << "RooSim::extendedMode(" << GetName() << ") returning CanBeExtended" << endl ;
430  return CanBeExtended ;
431  }
432 // cout << "RooSim::extendedMode(" << GetName() << ") returning CanNotBeExtended" << endl ;
433  return CanNotBeExtended ;
434 }
435 
436 
437 
438 
439 ////////////////////////////////////////////////////////////////////////////////
440 /// Return the current value:
441 /// the value of the PDF associated with the current index category state
442 
444 {
445  // Retrieve the proxy by index name
447 
448  //assert(proxy!=0) ;
449  if (proxy==0) return 0 ;
450 
451  // Calculate relative weighting factor for sim-pdfs of all extendable components
452  Double_t catFrac(1) ;
453  if (canBeExtended()) {
454  Double_t nEvtCat = ((RooAbsPdf*)(proxy->absArg()))->expectedEvents(_normSet) ;
455 
456  Double_t nEvtTot(0) ;
458  RooRealProxy* proxy2 ;
459  while((proxy2=(RooRealProxy*)iter->Next())) {
460  nEvtTot += ((RooAbsPdf*)(proxy2->absArg()))->expectedEvents(_normSet) ;
461  }
462  delete iter ;
463  catFrac=nEvtCat/nEvtTot ;
464  }
465 
466  // Return the selected PDF value, normalized by the number of index states
467  return ((RooAbsPdf*)(proxy->absArg()))->getVal(_normSet)*catFrac ;
468 }
469 
470 
471 
472 ////////////////////////////////////////////////////////////////////////////////
473 /// Return the number of expected events: If the index is in nset,
474 /// then return the sum of the expected events of all components,
475 /// otherwise return the number of expected events of the PDF
476 /// associated with the current index category state
477 
479 {
480  if (nset->contains(_indexCat.arg())) {
481 
482  Double_t sum(0) ;
483 
485  RooRealProxy* proxy ;
486  while((proxy=(RooRealProxy*)iter->Next())) {
487  sum += ((RooAbsPdf*)(proxy->absArg()))->expectedEvents(nset) ;
488  }
489  delete iter ;
490 
491  return sum ;
492 
493  } else {
494 
495  // Retrieve the proxy by index name
497 
498  //assert(proxy!=0) ;
499  if (proxy==0) return 0 ;
500 
501  // Return the selected PDF value, normalized by the number of index states
502  return ((RooAbsPdf*)(proxy->absArg()))->expectedEvents(nset);
503  }
504 }
505 
506 
507 
508 ////////////////////////////////////////////////////////////////////////////////
509 /// Forward determination of analytical integration capabilities to component p.d.f.s
510 /// A unique code is assigned to the combined integration capabilities of all associated
511 /// p.d.f.s
512 
514  const RooArgSet* normSet, const char* rangeName) const
515 {
516  // Declare that we can analytically integrate all requested observables
517  analVars.add(allVars) ;
518 
519  // Retrieve (or create) the required partial integral list
520  Int_t code ;
521 
522  // Check if this configuration was created before
523  CacheElem* cache = (CacheElem*) _partIntMgr.getObj(normSet,&analVars,0,RooNameReg::ptr(rangeName)) ;
524  if (cache) {
525  code = _partIntMgr.lastIndex() ;
526  return code+1 ;
527  }
528  cache = new CacheElem ;
529 
530  // Create the partial integral set for this request
532  RooRealProxy* proxy ;
533  while((proxy=(RooRealProxy*)iter->Next())) {
534  RooAbsReal* pdfInt = proxy->arg().createIntegral(analVars,normSet,0,rangeName) ;
535  cache->_partIntList.addOwned(*pdfInt) ;
536  }
537  delete iter ;
538 
539  // Store the partial integral list and return the assigned code ;
540  code = _partIntMgr.setObj(normSet,&analVars,cache,RooNameReg::ptr(rangeName)) ;
541 
542  return code+1 ;
543 }
544 
545 
546 
547 ////////////////////////////////////////////////////////////////////////////////
548 /// Return analytical integration defined by given code
549 
550 Double_t RooSimultaneous::analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* /*rangeName*/) const
551 {
552  // No integration scenario
553  if (code==0) {
554  return getVal(normSet) ;
555  }
556 
557  // Partial integration scenarios, rangeName already encoded in 'code'
558  CacheElem* cache = (CacheElem*) _partIntMgr.getObjByIndex(code-1) ;
559 
561  Int_t idx = _pdfProxyList.IndexOf(proxy) ;
562  return ((RooAbsReal*)cache->_partIntList.at(idx))->getVal(normSet) ;
563 }
564 
565 
566 
567 
568 
569 
570 ////////////////////////////////////////////////////////////////////////////////
571 /// Back-end for plotOn() implementation on RooSimultaneous which
572 /// needs special handling because a RooSimultaneous PDF cannot
573 /// project out its index category via integration, plotOn() will
574 /// abort if this is requested without providing a projection dataset
575 
577 {
578  // Sanity checks
579  if (plotSanityChecks(frame)) return frame ;
580 
581  // Extract projection configuration from command list
582  RooCmdConfig pc(Form("RooSimultaneous::plotOn(%s)",GetName())) ;
583  pc.defineString("sliceCatState","SliceCat",0,"",kTRUE) ;
584  pc.defineDouble("scaleFactor","Normalization",0,1.0) ;
585  pc.defineInt("scaleType","Normalization",0,RooAbsPdf::Relative) ;
586  pc.defineObject("sliceCatList","SliceCat",0,0,kTRUE) ;
587  pc.defineObject("projSet","Project",0) ;
588  pc.defineObject("sliceSet","SliceVars",0) ;
589  pc.defineObject("projDataSet","ProjData",0) ;
590  pc.defineObject("projData","ProjData",1) ;
591  pc.defineMutex("Project","SliceVars") ;
592  pc.allowUndefined() ; // there may be commands we don't handle here
593 
594  // Process and check varargs
595  pc.process(cmdList) ;
596  if (!pc.ok(kTRUE)) {
597  return frame ;
598  }
599 
600  const RooAbsData* projData = (const RooAbsData*) pc.getObject("projData") ;
601  const RooArgSet* projDataSet = (const RooArgSet*) pc.getObject("projDataSet") ;
602  const RooArgSet* sliceSetTmp = (const RooArgSet*) pc.getObject("sliceSet") ;
603  RooArgSet* sliceSet = sliceSetTmp ? ((RooArgSet*) sliceSetTmp->Clone()) : 0 ;
604  const RooArgSet* projSet = (const RooArgSet*) pc.getObject("projSet") ;
605  Double_t scaleFactor = pc.getDouble("scaleFactor") ;
606  ScaleType stype = (ScaleType) pc.getInt("scaleType") ;
607 
608 
609  // Look for category slice arguments and add them to the master slice list if found
610  const char* sliceCatState = pc.getString("sliceCatState",0,kTRUE) ;
611  const RooLinkedList& sliceCatList = pc.getObjectList("sliceCatList") ;
612  if (sliceCatState) {
613 
614  // Make the master slice set if it doesnt exist
615  if (!sliceSet) {
616  sliceSet = new RooArgSet ;
617  }
618 
619  // Prepare comma separated label list for parsing
620  char buf[1024] ;
621  strlcpy(buf,sliceCatState,1024) ;
622  const char* slabel = strtok(buf,",") ;
623 
624  // Loop over all categories provided by (multiple) Slice() arguments
625  TIterator* iter = sliceCatList.MakeIterator() ;
626  RooCategory* scat ;
627  while((scat=(RooCategory*)iter->Next())) {
628  if (slabel) {
629  // Set the slice position to the value indicate by slabel
630  scat->setLabel(slabel) ;
631  // Add the slice category to the master slice set
632  sliceSet->add(*scat,kFALSE) ;
633  }
634  slabel = strtok(0,",") ;
635  }
636  delete iter ;
637  }
638 
639  // Check if we have a projection dataset
640  if (!projData) {
641  coutE(InputArguments) << "RooSimultaneous::plotOn(" << GetName() << ") ERROR: must have a projection dataset for index category" << endl ;
642  return frame ;
643  }
644 
645  // Make list of variables to be projected
646  RooArgSet projectedVars ;
647  if (sliceSet) {
648  //cout << "frame->getNormVars() = " ; frame->getNormVars()->Print("1") ;
649 
650  makeProjectionSet(frame->getPlotVar(),frame->getNormVars(),projectedVars,kTRUE) ;
651 
652  // Take out the sliced variables
653  TIterator* iter = sliceSet->createIterator() ;
654  RooAbsArg* sliceArg ;
655  while((sliceArg=(RooAbsArg*)iter->Next())) {
656  RooAbsArg* arg = projectedVars.find(sliceArg->GetName()) ;
657  if (arg) {
658  projectedVars.remove(*arg) ;
659  } else {
660  coutI(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") slice variable "
661  << sliceArg->GetName() << " was not projected anyway" << endl ;
662  }
663  }
664  delete iter ;
665  } else if (projSet) {
666  makeProjectionSet(frame->getPlotVar(),projSet,projectedVars,kFALSE) ;
667  } else {
668  makeProjectionSet(frame->getPlotVar(),frame->getNormVars(),projectedVars,kTRUE) ;
669  }
670 
671  Bool_t projIndex(kFALSE) ;
672 
673  if (!_indexCat.arg().isDerived()) {
674  // *** Error checking for a fundamental index category ***
675  //cout << "RooSim::plotOn: index is fundamental" << endl ;
676 
677  // Check that the provided projection dataset contains our index variable
678  if (!projData->get()->find(_indexCat.arg().GetName())) {
679  coutE(Plotting) << "RooSimultaneous::plotOn(" << GetName() << ") ERROR: Projection over index category "
680  << "requested, but projection data set doesn't contain index category" << endl ;
681  return frame ;
682  }
683 
684  if (projectedVars.find(_indexCat.arg().GetName())) {
685  projIndex=kTRUE ;
686  }
687 
688  } else {
689  // *** Error checking for a composite index category ***
690 
691  // Determine if any servers of the index category are in the projectedVars
692  TIterator* sIter = _indexCat.arg().serverIterator() ;
693  RooAbsArg* server ;
694  RooArgSet projIdxServers ;
695  Bool_t anyServers(kFALSE) ;
696  while((server=(RooAbsArg*)sIter->Next())) {
697  if (projectedVars.find(server->GetName())) {
698  anyServers=kTRUE ;
699  projIdxServers.add(*server) ;
700  }
701  }
702  delete sIter ;
703 
704  // Check that the projection dataset contains all the
705  // index category components we're projecting over
706 
707  // Determine if all projected servers of the index category are in the projection dataset
708  sIter = projIdxServers.createIterator() ;
709  Bool_t allServers(kTRUE) ;
710  while((server=(RooAbsArg*)sIter->Next())) {
711  if (!projData->get()->find(server->GetName())) {
712  allServers=kFALSE ;
713  }
714  }
715  delete sIter ;
716 
717  if (!allServers) {
718  coutE(Plotting) << "RooSimultaneous::plotOn(" << GetName()
719  << ") ERROR: Projection dataset doesn't contain complete set of index category dependents" << endl ;
720  return frame ;
721  }
722 
723  if (anyServers) {
724  projIndex = kTRUE ;
725  }
726  }
727 
728  // Calculate relative weight fractions of components
729  Roo1DTable* wTable = projData->table(_indexCat.arg()) ;
730 
731  // If we don't project over the index, just do the regular plotOn
732  if (!projIndex) {
733 
734  coutI(Plotting) << "RooSimultaneous::plotOn(" << GetName() << ") plot on " << frame->getPlotVar()->GetName()
735  << " represents a slice in the index category (" << _indexCat.arg().GetName() << ")" << endl ;
736 
737  // Reduce projData: take out fitCat (component) columns and entries that don't match selected slice
738  // Construct cut string to only select projection data event that match the current slice
739 
740  const RooAbsData* projDataTmp(projData) ;
741  if (projData) {
742  // Make list of categories columns to exclude from projection data
743  RooArgSet* indexCatComps = _indexCat.arg().getObservables(frame->getNormVars());
744 
745  // Make cut string to exclude rows from projection data
746  TString cutString ;
747  TIterator* compIter = indexCatComps->createIterator() ;
748  RooAbsCategory* idxComp ;
749  Bool_t first(kTRUE) ;
750  while((idxComp=(RooAbsCategory*)compIter->Next())) {
751  if (!first) {
752  cutString.Append("&&") ;
753  } else {
754  first=kFALSE ;
755  }
756  cutString.Append(Form("%s==%d",idxComp->GetName(),idxComp->getIndex())) ;
757  }
758  delete compIter ;
759 
760  // Make temporary projData without RooSim index category components
761  RooArgSet projDataVars(*projData->get()) ;
762  projDataVars.remove(*indexCatComps,kTRUE,kTRUE) ;
763 
764  projDataTmp = ((RooAbsData*)projData)->reduce(projDataVars,cutString) ;
765  delete indexCatComps ;
766  }
767 
768  // Multiply scale factor with fraction of events in current state of index
769 
770 // RooPlot* retFrame = getPdf(_indexCat.arg().getLabel())->plotOn(frame,drawOptions,
771 // scaleFactor*wTable->getFrac(_indexCat.arg().getLabel()),
772 // stype,projDataTmp,projSet) ;
773 
774  // Override normalization and projection dataset
775  RooCmdArg tmp1 = RooFit::Normalization(scaleFactor*wTable->getFrac(_indexCat.arg().getLabel()),stype) ;
776  RooCmdArg tmp2 = RooFit::ProjWData(*projDataSet,*projDataTmp) ;
777 
778  // WVE -- do not adjust normalization for asymmetry plots
779  RooLinkedList cmdList2(cmdList) ;
780  if (!cmdList.find("Asymmetry")) {
781  cmdList2.Add(&tmp1) ;
782  }
783  cmdList2.Add(&tmp2) ;
784 
785  // Plot single component
786  RooPlot* retFrame = getPdf(_indexCat.arg().getLabel())->plotOn(frame,cmdList2) ;
787 
788  // Delete temporary dataset
789  if (projDataTmp) {
790  delete projDataTmp ;
791  }
792 
793  delete wTable ;
794  delete sliceSet ;
795  return retFrame ;
796  }
797 
798  // If we project over the index, plot using a temporary RooAddPdf
799  // using the weights from the data as coefficients
800 
801  // Make a deep clone of our index category
802  RooArgSet* idxCloneSet = (RooArgSet*) RooArgSet(_indexCat.arg()).snapshot(kTRUE) ;
803  RooAbsCategoryLValue* idxCatClone = (RooAbsCategoryLValue*) idxCloneSet->find(_indexCat.arg().GetName()) ;
804 
805  // Build the list of indexCat components that are sliced
806  RooArgSet* idxCompSliceSet = _indexCat.arg().getObservables(frame->getNormVars()) ;
807  idxCompSliceSet->remove(projectedVars,kTRUE,kTRUE) ;
808  TIterator* idxCompSliceIter = idxCompSliceSet->createIterator() ;
809 
810  // Make a new expression that is the weighted sum of requested components
811  RooArgList pdfCompList ;
812  RooArgList wgtCompList ;
813 //RooAbsPdf* pdf ;
814  RooRealProxy* proxy ;
816  Double_t sumWeight(0) ;
817  while((proxy=(RooRealProxy*)pIter->Next())) {
818 
819  idxCatClone->setLabel(proxy->name()) ;
820 
821  // Determine if this component is the current slice (if we slice)
822  Bool_t skip(kFALSE) ;
823  idxCompSliceIter->Reset() ;
824  RooAbsCategory* idxSliceComp ;
825  while((idxSliceComp=(RooAbsCategory*)idxCompSliceIter->Next())) {
826  RooAbsCategory* idxComp = (RooAbsCategory*) idxCloneSet->find(idxSliceComp->GetName()) ;
827  if (idxComp->getIndex()!=idxSliceComp->getIndex()) {
828  skip=kTRUE ;
829  break ;
830  }
831  }
832  if (skip) continue ;
833 
834  // Instantiate a RRV holding this pdfs weight fraction
835  RooRealVar *wgtVar = new RooRealVar(proxy->name(),"coef",wTable->getFrac(proxy->name())) ;
836  wgtCompList.addOwned(*wgtVar) ;
837  sumWeight += wTable->getFrac(proxy->name()) ;
838 
839  // Add the PDF to list list
840  pdfCompList.add(proxy->arg()) ;
841  }
842 
843  TString plotVarName(GetName()) ;
844  RooAddPdf *plotVar = new RooAddPdf(plotVarName,"weighted sum of RS components",pdfCompList,wgtCompList) ;
845 
846  // Fix appropriate coefficient normalization in plot function
847  if (_plotCoefNormSet.getSize()>0) {
849  }
850 
851  RooAbsData* projDataTmp(0) ;
852  RooArgSet projSetTmp ;
853  if (projData) {
854 
855  // Construct cut string to only select projection data event that match the current slice
856  TString cutString ;
857  if (idxCompSliceSet->getSize()>0) {
858  idxCompSliceIter->Reset() ;
859  RooAbsCategory* idxSliceComp ;
860  Bool_t first(kTRUE) ;
861  while((idxSliceComp=(RooAbsCategory*)idxCompSliceIter->Next())) {
862  if (!first) {
863  cutString.Append("&&") ;
864  } else {
865  first=kFALSE ;
866  }
867  cutString.Append(Form("%s==%d",idxSliceComp->GetName(),idxSliceComp->getIndex())) ;
868  }
869  }
870 
871  // Make temporary projData without RooSim index category components
872  RooArgSet projDataVars(*projData->get()) ;
873  RooArgSet* idxCatServers = _indexCat.arg().getObservables(frame->getNormVars()) ;
874 
875  projDataVars.remove(*idxCatServers,kTRUE,kTRUE) ;
876 
877  if (idxCompSliceSet->getSize()>0) {
878  projDataTmp = ((RooAbsData*)projData)->reduce(projDataVars,cutString) ;
879  } else {
880  projDataTmp = ((RooAbsData*)projData)->reduce(projDataVars) ;
881  }
882 
883 
884 
885  if (projSet) {
886  projSetTmp.add(*projSet) ;
887  projSetTmp.remove(*idxCatServers,kTRUE,kTRUE);
888  }
889 
890 
891  delete idxCatServers ;
892  }
893 
894 
895  if (_indexCat.arg().isDerived() && idxCompSliceSet->getSize()>0) {
896  coutI(Plotting) << "RooSimultaneous::plotOn(" << GetName() << ") plot on " << frame->getPlotVar()->GetName()
897  << " represents a slice in index category components " << *idxCompSliceSet << endl ;
898 
899  RooArgSet* idxCompProjSet = _indexCat.arg().getObservables(frame->getNormVars()) ;
900  idxCompProjSet->remove(*idxCompSliceSet,kTRUE,kTRUE) ;
901  if (idxCompProjSet->getSize()>0) {
902  coutI(Plotting) << "RooSimultaneous::plotOn(" << GetName() << ") plot on " << frame->getPlotVar()->GetName()
903  << " averages with data index category components " << *idxCompProjSet << endl ;
904  }
905  delete idxCompProjSet ;
906  } else {
907  coutI(Plotting) << "RooSimultaneous::plotOn(" << GetName() << ") plot on " << frame->getPlotVar()->GetName()
908  << " averages with data index category (" << _indexCat.arg().GetName() << ")" << endl ;
909  }
910 
911 
912  // Override normalization and projection dataset
913  RooLinkedList cmdList2(cmdList) ;
914 
915  RooCmdArg tmp1 = RooFit::Normalization(scaleFactor*sumWeight,stype) ;
916  RooCmdArg tmp2 = RooFit::ProjWData(*projDataSet,*projDataTmp) ;
917  // WVE -- do not adjust normalization for asymmetry plots
918  if (!cmdList.find("Asymmetry")) {
919  cmdList2.Add(&tmp1) ;
920  }
921  cmdList2.Add(&tmp2) ;
922 
923  RooPlot* frame2 ;
924  if (projSetTmp.getSize()>0) {
925  // Plot temporary function
926  RooCmdArg tmp3 = RooFit::Project(projSetTmp) ;
927  cmdList2.Add(&tmp3) ;
928  frame2 = plotVar->plotOn(frame,cmdList2) ;
929  } else {
930  // Plot temporary function
931  frame2 = plotVar->plotOn(frame,cmdList2) ;
932  }
933 
934  // Cleanup
935  delete sliceSet ;
936  delete pIter ;
937  delete wTable ;
938  delete idxCloneSet ;
939  delete idxCompSliceIter ;
940  delete idxCompSliceSet ;
941  delete plotVar ;
942 
943  if (projDataTmp) delete projDataTmp ;
944 
945  return frame2 ;
946 }
947 
948 
949 
950 ////////////////////////////////////////////////////////////////////////////////
951 /// OBSOLETE -- Retained for backward compatibility
952 
953 RooPlot* RooSimultaneous::plotOn(RooPlot *frame, Option_t* drawOptions, Double_t scaleFactor,
954  ScaleType stype, const RooAbsData* projData, const RooArgSet* projSet,
955  Double_t /*precision*/, Bool_t /*shiftToZero*/, const RooArgSet* /*projDataSet*/,
956  Double_t /*rangeLo*/, Double_t /*rangeHi*/, RooCurve::WingMode /*wmode*/) const
957 {
958  // Make command list
959  RooLinkedList cmdList ;
960  cmdList.Add(new RooCmdArg(RooFit::DrawOption(drawOptions))) ;
961  cmdList.Add(new RooCmdArg(RooFit::Normalization(scaleFactor,stype))) ;
962  if (projData) cmdList.Add(new RooCmdArg(RooFit::ProjWData(*projData))) ;
963  if (projSet) cmdList.Add(new RooCmdArg(RooFit::Project(*projSet))) ;
964 
965  // Call new method
966  RooPlot* ret = plotOn(frame,cmdList) ;
967 
968  // Cleanup
969  cmdList.Delete() ;
970  return ret ;
971 }
972 
973 
974 
975 ////////////////////////////////////////////////////////////////////////////////
976 /// Interface function used by test statistics to freeze choice of observables
977 /// for interpretation of fraction coefficients. Needed here because a RooSimultaneous
978 /// works like a RooAddPdf when plotted
979 
980 void RooSimultaneous::selectNormalization(const RooArgSet* normSet, Bool_t /*force*/)
981 {
983  if (normSet) _plotCoefNormSet.add(*normSet) ;
984 }
985 
986 
987 ////////////////////////////////////////////////////////////////////////////////
988 /// Interface function used by test statistics to freeze choice of range
989 /// for interpretation of fraction coefficients. Needed here because a RooSimultaneous
990 /// works like a RooAddPdf when plotted
991 
992 void RooSimultaneous::selectNormalizationRange(const char* normRange2, Bool_t /*force*/)
993 {
994  _plotCoefNormRange = RooNameReg::ptr(normRange2) ;
995 }
996 
997 
998 
999 
1000 ////////////////////////////////////////////////////////////////////////////////
1001 
1003  const RooArgSet* auxProto, Bool_t verbose, Bool_t autoBinned, const char* binnedTag) const
1004 {
1005  const char* idxCatName = _indexCat.arg().GetName() ;
1006 
1007  if (vars.find(idxCatName) && prototype==0 && (auxProto==0 || auxProto->getSize()==0) && (autoBinned || (binnedTag && strlen(binnedTag)))) {
1008 
1009  // Return special generator config that can also do binned generation for selected states
1010  return new RooSimSplitGenContext(*this,vars,verbose,autoBinned,binnedTag) ;
1011 
1012  } else {
1013 
1014  // Return regular generator config ;
1015  return genContext(vars,prototype,auxProto,verbose) ;
1016  }
1017 }
1018 
1019 
1020 
1021 ////////////////////////////////////////////////////////////////////////////////
1022 /// Return specialized generator contenxt for simultaneous p.d.f.s
1023 
1025  const RooArgSet* auxProto, Bool_t verbose) const
1026 {
1027  const char* idxCatName = _indexCat.arg().GetName() ;
1028  const RooArgSet* protoVars = prototype ? prototype->get() : 0 ;
1029 
1030  if (vars.find(idxCatName) || (protoVars && protoVars->find(idxCatName))) {
1031 
1032  // Generating index category: return special sim-context
1033  return new RooSimGenContext(*this,vars,prototype,auxProto,verbose) ;
1034 
1035  } else if (_indexCat.arg().isDerived()) {
1036  // Generating dependents of a derived index category
1037 
1038  // Determine if we none,any or all servers
1039  Bool_t anyServer(kFALSE), allServers(kTRUE) ;
1040  if (prototype) {
1041  TIterator* sIter = _indexCat.arg().serverIterator() ;
1042  RooAbsArg* server ;
1043  while((server=(RooAbsArg*)sIter->Next())) {
1044  if (prototype->get()->find(server->GetName())) {
1045  anyServer=kTRUE ;
1046  } else {
1047  allServers=kFALSE ;
1048  }
1049  }
1050  delete sIter ;
1051  } else {
1052  allServers=kTRUE ;
1053  }
1054 
1055  if (allServers) {
1056  // Use simcontext if we have all servers
1057 
1058  return new RooSimGenContext(*this,vars,prototype,auxProto,verbose) ;
1059  } else if (!allServers && anyServer) {
1060  // Abort if we have only part of the servers
1061  coutE(Plotting) << "RooSimultaneous::genContext: ERROR: prototype must include either all "
1062  << " components of the RooSimultaneous index category or none " << endl ;
1063  return 0 ;
1064  }
1065  // Otherwise make single gencontext for current state
1066  }
1067 
1068  // Not generating index cat: return context for pdf associated with present index state
1070  if (!proxy) {
1071  coutE(InputArguments) << "RooSimultaneous::genContext(" << GetName()
1072  << ") ERROR: no PDF associated with current state ("
1073  << _indexCat.arg().GetName() << "=" << _indexCat.arg().getLabel() << ")" << endl ;
1074  return 0 ;
1075  }
1076  return ((RooAbsPdf*)proxy->absArg())->genContext(vars,prototype,auxProto,verbose) ;
1077 }
1078 
1079 
1080 
1081 
1082 ////////////////////////////////////////////////////////////////////////////////
1083 
1085  const RooArgSet* nset,
1086  Double_t scaleFactor,
1087  Bool_t correctForBinVolume,
1088  Bool_t showProgress) const
1089 {
1090  if (RooAbsReal::fillDataHist (hist, nset, scaleFactor,
1091  correctForBinVolume, showProgress) == 0)
1092  return 0;
1093 
1094  Double_t sum = 0;
1095  for (int i=0 ; i<hist->numEntries() ; i++) {
1096  hist->get(i) ;
1097  sum += hist->weight();
1098  }
1099  if (sum != 0) {
1100  for (int i=0 ; i<hist->numEntries() ; i++) {
1101  hist->get(i) ;
1102  hist->set (hist->weight() / sum);
1103  }
1104  }
1105 
1106  return hist;
1107 }
1108 
1109 
1110 
1111 
1112 ////////////////////////////////////////////////////////////////////////////////
1113 /// Special generator interface for generation of 'global observables' -- for RooStats tools
1114 
1116 {
1117  // Make set with clone of variables (placeholder for output)
1118  RooArgSet* globClone = (RooArgSet*) whatVars.snapshot() ;
1119 
1120  RooDataSet* data = new RooDataSet("gensimglobal","gensimglobal",whatVars) ;
1121 
1122  // Construct iterator over index types
1124 
1125  for (Int_t i=0 ; i<nEvents ; i++) {
1126  iter->Reset() ;
1127  RooCatType* tt ;
1128  while((tt=(RooCatType*) iter->Next())) {
1129 
1130  // Get pdf associated with state from simpdf
1131  RooAbsPdf* pdftmp = getPdf(tt->GetName()) ;
1132 
1133  // Generate only global variables defined by the pdf associated with this state
1134  RooArgSet* globtmp = pdftmp->getObservables(whatVars) ;
1135  RooDataSet* tmp = pdftmp->generate(*globtmp,1) ;
1136 
1137  // Transfer values to output placeholder
1138  *globClone = *tmp->get(0) ;
1139 
1140  // Cleanup
1141  delete globtmp ;
1142  delete tmp ;
1143  }
1144  data->add(*globClone) ;
1145  }
1146 
1147 
1148  delete iter ;
1149  delete globClone ;
1150  return data ;
1151 }
1152 
1153 
1154 
1155 
1156 
1157 
1158 
1159 
1160 
virtual void selectNormalizationRange(const char *rangeName=0, Bool_t force=kFALSE)
Interface function used by test statistics to freeze choice of range for interpretation of fraction c...
RooSetProxy _plotCoefNormSet
#define coutE(a)
Definition: RooMsgService.h:35
virtual void selectNormalization(const RooArgSet *depSet=0, Bool_t force=kFALSE)
Interface function used by test statistics to freeze choice of observables for interpretation of frac...
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:404
RooCmdArg DrawOption(const char *opt)
RooAbsCollection * snapshot(Bool_t deepCopy=kTRUE) const
Take a snap shot of current collection contents: An owning collection is returned containing clones o...
RooCategoryProxy _indexCat
virtual Bool_t isDerived() const
Definition: RooAbsArg.h:81
TIterator * serverIterator() const
Definition: RooAbsArg.h:112
virtual Double_t expectedEvents(const RooArgSet *nset) const
Return the number of expected events: If the index is in nset, then return the sum of the expected ev...
virtual void Reset()=0
Bool_t defineDouble(const char *name, const char *argName, Int_t doubleNum, Double_t defValue=0.)
Define Double_t property name 'name' mapped to Double_t in slot 'doubleNum' in RooCmdArg with name ar...
virtual Roo1DTable * table(const RooArgSet &catSet, const char *cuts="", const char *opts="") const
Construct table for product of categories in catSet.
Definition: RooAbsData.cxx:833
const char Option_t
Definition: RtypesCore.h:62
virtual Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
#define coutI(a)
Definition: RooMsgService.h:32
const char * getString(const char *name, const char *defaultValue="", Bool_t convEmptyToNull=kFALSE)
Return string property registered with name 'name'.
virtual void removeAll()
Remove all argument inset using remove(const RooAbsArg&).
#define cxcoutD(a)
Definition: RooMsgService.h:80
virtual Int_t getIndex() const
Return index number of current state.
RooArgSet * getObservables(const RooArgSet &set, Bool_t valueOnly=kTRUE) const
Definition: RooAbsArg.h:194
virtual ExtendMode extendMode() const
WVE NEEDS FIX.
virtual Bool_t isFundamental() const
Definition: RooAbsArg.h:157
const RooAbsCategoryLValue & indexCat() const
Bool_t contains(const RooAbsArg &var) const
void set(Double_t weight, Double_t wgtErr=-1)
Increment the weight of the bin enclosing the coordinates given by 'row' by the specified amount...
virtual Bool_t setLabel(const char *label, Bool_t printError=kTRUE)=0
virtual const char * name() const
Definition: RooArgProxy.h:42
virtual RooAbsGenContext * autoGenContext(const RooArgSet &vars, const RooDataSet *prototype=0, const RooArgSet *auxProto=0, Bool_t verbose=kFALSE, Bool_t autoBinned=kTRUE, const char *binnedTag="") const
Int_t lastIndex() const
Basic string class.
Definition: TString.h:137
const TNamed * _plotCoefNormRange
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
RooCmdArg Project(const RooArgSet &projSet)
RooAbsData * reduce(const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg())
Create a reduced copy of this dataset.
Definition: RooAbsData.cxx:397
const Bool_t kFALSE
Definition: Rtypes.h:92
RooCmdArg ProjWData(const RooAbsData &projData, Bool_t binData=kFALSE)
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:496
void allowUndefined(Bool_t flag=kTRUE)
Definition: RooCmdConfig.h:39
Bool_t addOwnedComponents(const RooArgSet &comps)
Take ownership of the contents of 'comps'.
Definition: RooAbsArg.cxx:2281
STL namespace.
#define coutW(a)
Definition: RooMsgService.h:34
virtual RooPlot * plotOn(RooPlot *frame, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg(), const RooCmdArg &arg10=RooCmdArg()) const
Plot (project) PDF on specified frame.
RooAbsPdf * getPdf(const char *catName) const
Return the p.d.f associated with the given index category name.
TObject * getObject(const char *name, TObject *obj=0)
Return TObject property registered with name 'name'.
virtual Double_t evaluate() const
Return the current value: the value of the PDF associated with the current index category state...
Iterator abstract base class.
Definition: TIterator.h:32
const RooAbsReal & arg() const
Definition: RooRealProxy.h:43
virtual Bool_t setLabel(const char *label, Bool_t printError=kTRUE)
Set value by specifying the name of the desired state If printError is set, a message will be printed...
virtual const RooArgSet * get() const
Definition: RooDataHist.h:77
RooObjCacheManager _partIntMgr
Bool_t process(const RooCmdArg &arg)
Process given RooCmdArg.
friend class CacheElem
Definition: RooAbsPdf.h:314
Double_t analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=0) const
Return analytical integration defined by given code.
const char Int_t const char TProof Int_t stype
Definition: TXSlave.cxx:46
TText * tt
Definition: textangle.C:16
Bool_t addPdf(const RooAbsPdf &pdf, const char *catLabel)
Associate given PDF with index category state label 'catLabel'.
RooArgSet * getVariables(Bool_t stripDisconnected=kTRUE) const
Return RooArgSet with all variables (tree leaf nodes of expresssion tree)
Definition: RooAbsArg.cxx:2081
T * getObj(const RooArgSet *nset, Int_t *sterileIndex=0, const TNamed *isetRangeName=0)
Int_t numTypes(const char *=0) const
std::map< std::string, std::string >::const_iterator iter
Definition: TAlienJob.cxx:54
TIterator * createIterator(Bool_t dir=kIterForward) const
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
if on multiple lines(like in C++).**The" * configuration fragment. * * The "import myobject continue
Parses the configuration file.
Definition: HLFactory.cxx:368
Bool_t defineString(const char *name, const char *argName, Int_t stringNum, const char *defValue="", Bool_t appendMode=kFALSE)
Define Double_t property name 'name' mapped to Double_t in slot 'stringNum' in RooCmdArg with name ar...
TString & Append(const char *cs)
Definition: TString.h:492
TIterator * MakeIterator(Bool_t dir=kTRUE) const
Return an iterator over this list.
friend class RooArgSet
Definition: RooAbsArg.h:469
Double_t getVal(const RooArgSet *set=0) const
Definition: RooAbsReal.h:64
Bool_t defineInt(const char *name, const char *argName, Int_t intNum, Int_t defValue=0)
Define integer property name 'name' mapped to integer in slot 'intNum' in RooCmdArg with name argName...
virtual const RooArgSet * get() const
Definition: RooAbsData.h:77
virtual Bool_t setArg(RooAbsCategory &newRef)
Change object held in proxy into newRef.
virtual void Add(TObject *arg)
Definition: RooLinkedList.h:62
const int nEvents
Definition: testRooFit.cxx:42
void defineMutex(const char *argName1, const char *argName2)
Define arguments named argName1 and argName2 mutually exclusive.
Int_t getInt(const char *name, Int_t defaultValue=0)
Return integer property registered with name 'name'.
RooAbsArg * find(const char *name) const
Find object with given name in list.
virtual RooPlot * plotOn(RooPlot *frame, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none(), const RooCmdArg &arg9=RooCmdArg::none(), const RooCmdArg &arg10=RooCmdArg::none()) const
Plot (project) PDF on specified frame.
Definition: RooAbsPdf.h:105
return
Definition: TBase64.cxx:62
virtual Double_t weight() const
Definition: RooDataHist.h:96
friend class RooSimSplitGenContext
static const TNamed * ptr(const char *stringPtr)
Return a unique TNamed pointer for given C++ string.
Definition: RooNameReg.cxx:124
virtual RooAbsGenContext * genContext(const RooArgSet &vars, const RooDataSet *prototype=0, const RooArgSet *auxProto=0, Bool_t verbose=kFALSE) const
Return specialized generator contenxt for simultaneous p.d.f.s.
bool verbose
char * Form(const char *fmt,...)
RooAbsArg * absArg() const
Definition: RooArgProxy.h:37
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
Bool_t ok(Bool_t verbose) const
Return true of parsing was successful.
RooAbsRealLValue * getPlotVar() const
Definition: RooPlot.h:132
Bool_t plotSanityChecks(RooPlot *frame) const
Utility function for plotOn(), perform general sanity check on frame to ensure safe plotting operatio...
virtual void add(const RooArgSet &row, Double_t weight=1.0, Double_t weightError=0)
Add a data point, with its coordinates specified in the 'data' argset, to the data set...
void initialize(RooAbsCategoryLValue &inIndexCat, std::map< std::string, RooAbsPdf * > pdfMap)
Double_t getFrac(const char *label, Bool_t silent=kFALSE) const
Return the fraction of entries in the table contained in the slot named 'label'.
Definition: Roo1DTable.cxx:300
void Delete(Option_t *o=0)
Remove all elements in collection and delete all elements NB: Collection does not own elements...
friend class RooAddPdf
Definition: RooAbsReal.h:471
RooAbsArg * at(Int_t idx) const
Definition: RooArgList.h:84
double Double_t
Definition: RtypesCore.h:55
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
friend class RooDataSet
Definition: RooAbsArg.h:534
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &numVars, const RooArgSet *normSet, const char *rangeName=0) const
Forward determination of analytical integration capabilities to component p.d.f.s A unique code is as...
Bool_t canBeExtended() const
Definition: RooAbsPdf.h:216
Double_t getDouble(const char *name, Double_t defaultValue=0)
Return Double_t property registered with name 'name'.
int type
Definition: TGX11.cxx:120
RooCmdArg Normalization(Double_t scaleFactor)
RooDataHist * fillDataHist(RooDataHist *hist, const RooArgSet *nset, Double_t scaleFactor, Bool_t correctForBinVolume=kFALSE, Bool_t showProgress=kFALSE) const
Fill a RooDataHist with values sampled from this function at the bin centers.
TObject * find(const char *name) const
Return pointer to object with given name in collection.
virtual Int_t numEntries() const
Return the number of bins.
const RooLinkedList & getObjectList(const char *name)
Return list of objects registered with name 'name'.
#define name(a, b)
Definition: linkTestLib0.cpp:5
Mother of all ROOT objects.
Definition: TObject.h:58
virtual RooDataSet * generateSimGlobal(const RooArgSet &whatVars, Int_t nEvents)
Special generator interface for generation of 'global observables' – for RooStats tools...
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
virtual ~RooSimultaneous()
Destructor.
void makeProjectionSet(const RooAbsArg *plotVar, const RooArgSet *allVars, RooArgSet &projectedVars, Bool_t silent) const
Utility function for plotOn() that constructs the set of observables to project when plotting ourselv...
const RooArgSet * getNormVars() const
Definition: RooPlot.h:139
friend class RooRealProxy
Definition: RooAbsReal.h:403
T * getObjByIndex(Int_t index) const
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
Definition: RooAbsPdf.h:41
virtual void Add(TObject *obj)
Definition: TList.h:81
RooDataSet * generate(const RooArgSet &whatVars, Int_t nEvents, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none())
Generate a new dataset containing the specified variables with events sampled from our distribution...
Definition: RooAbsPdf.cxx:1702
virtual TObject * Next()=0
Bool_t dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0, Bool_t valueOnly=kFALSE) const
Test whether we depend on (ie, are served by) any object in the specified collection.
Definition: RooAbsArg.cxx:743
virtual const char * getLabel() const
Return label string of current state.
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const
Return a list iterator.
Definition: TList.cxx:603
const RooAbsCategory & arg() const
Bool_t mustBeExtended() const
Definition: RooAbsPdf.h:220
Bool_t defineObject(const char *name, const char *argName, Int_t setNum, const TObject *obj=0, Bool_t isArray=kFALSE)
Define TObject property name 'name' mapped to object in slot 'setNum' in RooCmdArg with name argName ...
RooArgSet * _normSet
Normalization integral (owned by _normMgr)
Definition: RooAbsPdf.h:302
Int_t setObj(const RooArgSet *nset, T *obj, const TNamed *isetRangeName=0)
virtual void fixAddCoefNormalization(const RooArgSet &addNormSet=RooArgSet(), Bool_t force=kTRUE)
Fix the interpretation of the coefficient of any RooAddPdf component in the expression tree headed by...
Int_t getSize() const
virtual Int_t IndexOf(const TObject *obj) const
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66
const char * label() const
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual Bool_t setLabel(const char *label, Bool_t printError=kTRUE)
Set the value of the super category by specifying the state name by setting the state names of the co...
ClassImp(RooSimultaneous)
friend class RooSimGenContext
static char * skip(char **buf, const char *delimiters)
Definition: civetweb.c:1014
virtual const RooArgSet * get(Int_t index) const
Return RooArgSet with coordinates of event 'index'.
virtual const Text_t * GetName() const
Returns name of object.
Definition: RooCatType.h:45
TIterator * typeIterator() const
Return iterator over all defined states.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add element to non-owning set.
Definition: RooArgSet.cxx:448
RooAbsReal * createIntegral(const RooArgSet &iset, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
Create an object that represents the integral of the function over one or more observables listed in ...
Definition: RooAbsReal.cxx:503
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Overloaded RooArgSet::add() method inserts 'var' into set and registers 'var' as server to owner with...
virtual RooDataHist * fillDataHist(RooDataHist *hist, const RooArgSet *nset, Double_t scaleFactor, Bool_t correctForBinVolume=kFALSE, Bool_t showProgress=kFALSE) const