Loading [MathJax]/extensions/tex2jax.js
Logo ROOT   6.18/05
Reference Guide
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
RooDataSet.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\file RooDataSet.cxx
19\class RooDataSet
20\ingroup Roofitcore
21
22RooDataSet is a container class to hold unbinned data. Each data point
23in N-dimensional space is represented by a RooArgSet of RooRealVar, RooCategory
24or RooStringVar objects.
25
26There are two storage backends:
27- RooVectorDataStore (default): std::vectors in memory. They are fast, but they
28cannot be serialised if the dataset exceeds a size of 1 Gb
29- RooTreeDataStore: Uses a TTree, which can be file backed if a file is opened
30before creating the dataset. This significantly reduces the memory pressure, as the
31baskets of the tree can be written to a file, and only the basket that's currently
32being read stays in RAM.
33Enable tree-backed storage similar to this:
34```
35TFile outputFile("filename.root", "RECREATE");
36RooAbsData::setDefaultStorageType(RooAbsData::Tree);
37RooDataSet mydata(...);
38```
39or convert an existing memory-backed data storage:
40```
41RooDataSet mydata(...);
42
43TFile outputFile("filename.root", "RECREATE");
44mydata.convertToTreeStore();
45```
46
47Tree-backed storage can be converted like this:
48`RooAbsData::convertToTreeStore()`.
49
50**/
51
52#include "RooFit.h"
53
54#include "Riostream.h"
55#include "Riostream.h"
56#include <fstream>
57#include "TTree.h"
58#include "TH2.h"
59#include "TDirectory.h"
60#include "RooDataSet.h"
61#include "RooPlot.h"
62#include "RooAbsReal.h"
63#include "Roo1DTable.h"
64#include "RooCategory.h"
65#include "RooFormulaVar.h"
66#include "RooArgList.h"
67#include "RooAbsRealLValue.h"
68#include "RooRealVar.h"
69#include "RooDataHist.h"
70#include "RooMsgService.h"
71#include "RooCmdConfig.h"
72#include "RooHist.h"
73#include "TROOT.h"
74#include "TFile.h"
75#include "RooTreeDataStore.h"
76#include "RooVectorDataStore.h"
78#include "RooTreeData.h"
79#include "RooSentinel.h"
80#include "RooTrace.h"
81
82#if (__GNUC__==3&&__GNUC_MINOR__==2&&__GNUC_PATCHLEVEL__==3)
83char* operator+( streampos&, char* );
84#endif
85
86using namespace std;
87
89
90#ifndef USEMEMPOOLFORDATASET
92#else
93
94#include "MemPoolForRooSets.h"
95
98 static auto * memPool = new RooDataSet::MemPool();
99 return memPool;
100}
101
102void RooDataSet::cleanup() {
103 auto pool = memPool();
104 pool->teardown();
105
106 //The pool will have to leak if it's not empty at this point.
107 if (pool->empty())
108 delete pool;
109}
110
111
112////////////////////////////////////////////////////////////////////////////////
113/// Overloaded new operator guarantees that all RooDataSets allocated with new
114/// have a unique address, a property that is exploited in several places
115/// in roofit to quickly index contents on normalization set pointers.
116/// The memory pool only allocates space for the class itself. The elements
117/// stored in the set are stored outside the pool.
118
119void* RooDataSet::operator new (size_t bytes)
120{
121 //This will fail if a derived class uses this operator
122 assert(sizeof(RooDataSet) == bytes);
123
124 return memPool()->allocate(bytes);
125}
126
127
128
129////////////////////////////////////////////////////////////////////////////////
130/// Memory is owned by pool, we need to do nothing to release it
131
132void RooDataSet::operator delete (void* ptr)
133{
134 // Decrease use count in pool that ptr is on
135 if (memPool()->deallocate(ptr))
136 return;
137
138 std::cerr << __func__ << " " << ptr << " is not in any of the pools." << std::endl;
139
140 // Not part of any pool; use global op delete:
141 ::operator delete(ptr);
142}
143
144#endif
145
146
147////////////////////////////////////////////////////////////////////////////////
148/// Default constructor for persistence
149
151{
153}
154
155
156
157
158
159////////////////////////////////////////////////////////////////////////////////
160/// Construct an unbinned dataset from a RooArgSet defining the dimensions of the data space. Optionally, data
161/// can be imported at the time of construction.
162///
163/// <table>
164/// <tr><th> %RooCmdArg <th> Effect
165/// <tr><td> Import(TTree*) <td> Import contents of given TTree. Only braches of the TTree that have names
166/// corresponding to those of the RooAbsArgs that define the RooDataSet are
167/// imported.
168/// <tr><td> ImportFromFile(const char* fileName, const char* treeName) <td> Import tree with given name from file with given name.
169/// <tr><td> Import(RooDataSet&)
170/// <td> Import contents of given RooDataSet. Only observables that are common with the definition of this dataset will be imported
171/// <tr><td> Index(RooCategory&) <td> Prepare import of datasets into a N+1 dimensional RooDataSet
172/// where the extra discrete dimension labels the source of the imported histogram.
173/// <tr><td> Import(const char*, RooDataSet&)
174/// <td> Import a dataset to be associated with the given state name of the index category
175/// specified in Index(). If the given state name is not yet defined in the index
176/// category it will be added on the fly. The import command can be specified multiple times.
177/// <tr><td> Link(const char*, RooDataSet&) <td> Link contents of supplied RooDataSet to this dataset for given index category state name.
178/// In this mode, no data is copied and the linked dataset must be remain live for the duration
179/// of this dataset. Note that link is active for both reading and writing, so modifications
180/// to the aggregate dataset will also modify its components. Link() and Import() are mutually exclusive.
181/// <tr><td> OwnLinked() <td> Take ownership of all linked datasets
182/// <tr><td> Import(map<string,RooDataSet*>&) <td> As above, but allows specification of many imports in a single operation
183/// <tr><td> Link(map<string,RooDataSet*>&) <td> As above, but allows specification of many links in a single operation
184/// <tr><td> Cut(const char*) <br>
185/// Cut(RooFormulaVar&)
186/// <td> Apply the given cut specification when importing data
187/// <tr><td> CutRange(const char*) <td> Only accept events in the observable range with the given name
188/// <tr><td> WeightVar(const char*) <br>
189/// WeightVar(const RooAbsArg&)
190/// <td> Interpret the given variable as event weight rather than as observable
191/// <tr><td> StoreError(const RooArgSet&) <td> Store symmetric error along with value for given subset of observables
192/// <tr><td> StoreAsymError(const RooArgSet&) <td> Store asymmetric error along with value for given subset of observables
193/// </table>
194///
195
196RooDataSet::RooDataSet(const char* name, const char* title, const RooArgSet& vars, const RooCmdArg& arg1, const RooCmdArg& arg2, const RooCmdArg& arg3,
197 const RooCmdArg& arg4,const RooCmdArg& arg5,const RooCmdArg& arg6,const RooCmdArg& arg7,const RooCmdArg& arg8) :
198 RooAbsData(name,title,RooArgSet(vars,(RooAbsArg*)RooCmdConfig::decodeObjOnTheFly("RooDataSet::RooDataSet", "IndexCat",0,0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)))
199{
200 // Define configuration for this method
201 RooCmdConfig pc(Form("RooDataSet::ctor(%s)",GetName())) ;
202 pc.defineInt("ownLinked","OwnLinked",0) ;
203 pc.defineObject("impTree","ImportTree",0) ;
204 pc.defineObject("impData","ImportData",0) ;
205 pc.defineObject("indexCat","IndexCat",0) ;
206 pc.defineObject("impSliceData","ImportDataSlice",0,0,kTRUE) ; // array
207 pc.defineString("impSliceState","ImportDataSlice",0,"",kTRUE) ; // array
208 pc.defineObject("lnkSliceData","LinkDataSlice",0,0,kTRUE) ; // array
209 pc.defineString("lnkSliceState","LinkDataSlice",0,"",kTRUE) ; // array
210 pc.defineString("cutSpec","CutSpec",0,"") ;
211 pc.defineObject("cutVar","CutVar",0) ;
212 pc.defineString("cutRange","CutRange",0,"") ;
213 pc.defineString("wgtVarName","WeightVarName",0,"") ;
214 pc.defineInt("newWeight1","WeightVarName",0,0) ;
215 pc.defineString("fname","ImportFromFile",0,"") ;
216 pc.defineString("tname","ImportFromFile",1,"") ;
217 pc.defineObject("wgtVar","WeightVar",0) ;
218 pc.defineInt("newWeight2","WeightVar",0,0) ;
219 pc.defineObject("dummy1","ImportDataSliceMany",0) ;
220 pc.defineObject("dummy2","LinkDataSliceMany",0) ;
221 pc.defineSet("errorSet","StoreError",0) ;
222 pc.defineSet("asymErrSet","StoreAsymError",0) ;
223 pc.defineMutex("ImportTree","ImportData","ImportDataSlice","LinkDataSlice","ImportFromFile") ;
224 pc.defineMutex("CutSpec","CutVar") ;
225 pc.defineMutex("WeightVarName","WeightVar") ;
226 pc.defineDependency("ImportDataSlice","IndexCat") ;
227 pc.defineDependency("LinkDataSlice","IndexCat") ;
228 pc.defineDependency("OwnLinked","LinkDataSlice") ;
229
230
232 l.Add((TObject*)&arg1) ; l.Add((TObject*)&arg2) ;
233 l.Add((TObject*)&arg3) ; l.Add((TObject*)&arg4) ;
234 l.Add((TObject*)&arg5) ; l.Add((TObject*)&arg6) ;
235 l.Add((TObject*)&arg7) ; l.Add((TObject*)&arg8) ;
236
237 // Process & check varargs
238 pc.process(l) ;
239 if (!pc.ok(kTRUE)) {
240 assert(0) ;
241 return ;
242 }
243
244 // Extract relevant objects
245 TTree* impTree = static_cast<TTree*>(pc.getObject("impTree")) ;
246 RooDataSet* impData = static_cast<RooDataSet*>(pc.getObject("impData")) ;
247 RooFormulaVar* cutVar = static_cast<RooFormulaVar*>(pc.getObject("cutVar")) ;
248 const char* cutSpec = pc.getString("cutSpec","",kTRUE) ;
249 const char* cutRange = pc.getString("cutRange","",kTRUE) ;
250 const char* wgtVarName = pc.getString("wgtVarName","",kTRUE) ;
251 RooRealVar* wgtVar = static_cast<RooRealVar*>(pc.getObject("wgtVar")) ;
252 const char* impSliceNames = pc.getString("impSliceState","",kTRUE) ;
253 const RooLinkedList& impSliceData = pc.getObjectList("impSliceData") ;
254 const char* lnkSliceNames = pc.getString("lnkSliceState","",kTRUE) ;
255 const RooLinkedList& lnkSliceData = pc.getObjectList("lnkSliceData") ;
256 RooCategory* indexCat = static_cast<RooCategory*>(pc.getObject("indexCat")) ;
257 RooArgSet* errorSet = pc.getSet("errorSet") ;
258 RooArgSet* asymErrorSet = pc.getSet("asymErrSet") ;
259 const char* fname = pc.getString("fname") ;
260 const char* tname = pc.getString("tname") ;
261 Int_t ownLinked = pc.getInt("ownLinked") ;
262 Int_t newWeight = pc.getInt("newWeight1") + pc.getInt("newWeight2") ;
263
264 // Case 1 --- Link multiple dataset as slices
265 if (lnkSliceNames) {
266
267 // Make import mapping if index category is specified
268 map<string,RooAbsData*> hmap ;
269 if (indexCat) {
270 char tmp[64000];
271 strlcpy(tmp, lnkSliceNames, 64000);
272 char *token = strtok(tmp, ",");
273 TIterator *hiter = lnkSliceData.MakeIterator();
274 while (token) {
275 hmap[token] = (RooAbsData *)hiter->Next();
276 token = strtok(0, ",");
277 }
278 delete hiter ;
279 }
280
281 // Lookup name of weight variable if it was specified by object reference
282 if (wgtVar) {
283 // coverity[UNUSED_VALUE]
284 wgtVarName = wgtVar->GetName() ;
285 }
286
287 appendToDir(this,kTRUE) ;
288
289 // Initialize RooDataSet with optional weight variable
290 initialize(0) ;
291
292 map<string,RooAbsDataStore*> storeMap ;
293 RooCategory* icat = (RooCategory*) (indexCat ? _vars.find(indexCat->GetName()) : 0 ) ;
294 if (!icat) {
295 throw std::string("RooDataSet::RooDataSet() ERROR in constructor, cannot find index category") ;
296 }
297 for (map<string,RooAbsData*>::iterator hiter = hmap.begin() ; hiter!=hmap.end() ; ++hiter) {
298 // Define state labels in index category (both in provided indexCat and in internal copy in dataset)
299 if (indexCat && !indexCat->lookupType(hiter->first.c_str())) {
300 indexCat->defineType(hiter->first.c_str()) ;
301 coutI(InputArguments) << "RooDataSet::ctor(" << GetName() << ") defining state \"" << hiter->first << "\" in index category " << indexCat->GetName() << endl ;
302 }
303 if (icat && !icat->lookupType(hiter->first.c_str())) {
304 icat->defineType(hiter->first.c_str()) ;
305 }
306 icat->setLabel(hiter->first.c_str()) ;
307 storeMap[icat->getLabel()]=hiter->second->store() ;
308
309 // Take ownership of slice if requested
310 if (ownLinked) {
311 addOwnedComponent(hiter->first.c_str(),*hiter->second) ;
312 }
313 }
314
315 // Create composite datastore
316 _dstore = new RooCompositeDataStore(name,title,_vars,*icat,storeMap) ;
317
318 } else {
319
320 if (wgtVar) {
321 wgtVarName = wgtVar->GetName() ;
322 }
323
324 // Clone weight variable of imported dataset if we are not weighted
325 if (!wgtVar && !wgtVarName && impData && impData->_wgtVar) {
328 wgtVarName = _wgtVar->GetName() ;
329 }
330
331 // Create empty datastore
332 RooTreeDataStore* tstore(0) ;
333 RooVectorDataStore* vstore(0) ;
334
336 tstore = new RooTreeDataStore(name,title,_vars,wgtVarName) ;
337 _dstore = tstore ;
338 } else if (defaultStorageType==Vector) {
339 if (wgtVarName && newWeight) {
340 RooAbsArg* wgttmp = _vars.find(wgtVarName) ;
341 if (wgttmp) {
342 wgttmp->setAttribute("NewWeight") ;
343 }
344 }
345 vstore = new RooVectorDataStore(name,title,_vars,wgtVarName) ;
346 _dstore = vstore ;
347 } else {
348 _dstore = 0 ;
349 }
350
351
352 // Make import mapping if index category is specified
353 map<string,RooDataSet*> hmap ;
354 if (indexCat) {
355 char tmp[100000] ;
356 strlcpy(tmp,impSliceNames,100000) ;
357 char* token = strtok(tmp,",") ;
358 TIterator* hiter = impSliceData.MakeIterator() ;
359 while(token) {
360 hmap[token] = (RooDataSet*) hiter->Next() ;
361 token = strtok(0,",") ;
362 }
363 delete hiter ;
364 }
365
366 // process StoreError requests
367 if (errorSet) {
368 RooArgSet* intErrorSet = (RooArgSet*) _vars.selectCommon(*errorSet) ;
369 intErrorSet->setAttribAll("StoreError") ;
370 TIterator* iter = intErrorSet->createIterator() ;
371 RooAbsArg* arg ;
372 while((arg=(RooAbsArg*)iter->Next())) {
373 arg->attachToStore(*_dstore) ;
374 }
375 delete iter ;
376 delete intErrorSet ;
377 }
378 if (asymErrorSet) {
379 RooArgSet* intAsymErrorSet = (RooArgSet*) _vars.selectCommon(*asymErrorSet) ;
380 intAsymErrorSet->setAttribAll("StoreAsymError") ;
381 TIterator* iter = intAsymErrorSet->createIterator() ;
382 RooAbsArg* arg ;
383 while((arg=(RooAbsArg*)iter->Next())) {
384 arg->attachToStore(*_dstore) ;
385 }
386 delete iter ;
387 delete intAsymErrorSet ;
388 }
389
390 // Lookup name of weight variable if it was specified by object reference
391 if (wgtVar) {
392 wgtVarName = wgtVar->GetName() ;
393 }
394
395
396 appendToDir(this,kTRUE) ;
397
398 // Initialize RooDataSet with optional weight variable
399 if (wgtVarName && *wgtVarName) {
400 // Use the supplied weight column
401 initialize(wgtVarName) ;
402
403 } else {
404 if (impData && impData->_wgtVar && vars.find(impData->_wgtVar->GetName())) {
405
406 // Use the weight column of the source data set
407 initialize(impData->_wgtVar->GetName()) ;
408
409 } else if (indexCat) {
410
411 RooDataSet* firstDS = hmap.begin()->second ;
412 if (firstDS->_wgtVar && vars.find(firstDS->_wgtVar->GetName())) {
413 initialize(firstDS->_wgtVar->GetName()) ;
414 } else {
415 initialize(0) ;
416 }
417 } else {
418 initialize(0) ;
419 }
420 }
421
422 // Import one or more datasets with a cut specification
423 if (cutSpec && *cutSpec) {
424
425 // Create a RooFormulaVar cut from given cut expression
426 if (indexCat) {
427
428 // Case 2a --- Import multiple RooDataSets as slices with cutspec
429 RooCategory* icat = (RooCategory*) _vars.find(indexCat->GetName()) ;
430 for (map<string,RooDataSet*>::iterator hiter = hmap.begin() ; hiter!=hmap.end() ; ++hiter) {
431 // Define state labels in index category (both in provided indexCat and in internal copy in dataset)
432 if (!indexCat->lookupType(hiter->first.c_str())) {
433 indexCat->defineType(hiter->first.c_str()) ;
434 coutI(InputArguments) << "RooDataSet::ctor(" << GetName() << ") defining state \"" << hiter->first << "\" in index category " << indexCat->GetName() << endl ;
435 }
436 if (!icat->lookupType(hiter->first.c_str())) {
437 icat->defineType(hiter->first.c_str()) ;
438 }
439 icat->setLabel(hiter->first.c_str()) ;
440
441 RooFormulaVar cutVarTmp(cutSpec,cutSpec,hiter->second->_vars) ;
442 _dstore->loadValues(hiter->second->store(),&cutVarTmp,cutRange) ;
443 }
444
445 } else if (impData) {
446
447 // Case 3a --- Import RooDataSet with cutspec
448 RooFormulaVar cutVarTmp(cutSpec,cutSpec,impData->_vars) ;
449 _dstore->loadValues(impData->store(),&cutVarTmp,cutRange);
450 } else if (impTree) {
451
452 // Case 4a --- Import TTree from memory with cutspec
453 RooFormulaVar cutVarTmp(cutSpec,cutSpec,_vars) ;
454 if (tstore) {
455 tstore->loadValues(impTree,&cutVarTmp,cutRange);
456 } else {
457 RooTreeDataStore tmpstore(name,title,_vars,wgtVarName) ;
458 tmpstore.loadValues(impTree,&cutVarTmp,cutRange) ;
459 _dstore->append(tmpstore) ;
460 }
461 } else if (fname && strlen(fname)) {
462
463 // Case 5a --- Import TTree from file with cutspec
464 TFile *f = TFile::Open(fname) ;
465 if (!f) {
466 coutE(InputArguments) << "RooDataSet::ctor(" << GetName() << ") ERROR file '" << fname << "' cannot be opened or does not exist" << endl ;
467 throw string(Form("RooDataSet::ctor(%s) ERROR file %s cannot be opened or does not exist",GetName(),fname)) ;
468 }
469 TTree* t = dynamic_cast<TTree*>(f->Get(tname)) ;
470 if (!t) {
471 coutE(InputArguments) << "RooDataSet::ctor(" << GetName() << ") ERROR file '" << fname << "' does not contain a TTree named '" << tname << "'" << endl ;
472 throw string(Form("RooDataSet::ctor(%s) ERROR file %s does not contain a TTree named %s",GetName(),fname,tname)) ;
473 }
474 RooFormulaVar cutVarTmp(cutSpec,cutSpec,_vars) ;
475 if (tstore) {
476 tstore->loadValues(t,&cutVarTmp,cutRange);
477 } else {
478 RooTreeDataStore tmpstore(name,title,_vars,wgtVarName) ;
479 tmpstore.loadValues(t,&cutVarTmp,cutRange) ;
480 _dstore->append(tmpstore) ;
481 }
482 f->Close() ;
483
484 }
485
486 // Import one or more datasets with a cut formula
487 } else if (cutVar) {
488
489 if (indexCat) {
490
491 // Case 2b --- Import multiple RooDataSets as slices with cutvar
492
493 RooCategory* icat = (RooCategory*) _vars.find(indexCat->GetName()) ;
494 for (map<string,RooDataSet*>::iterator hiter = hmap.begin() ; hiter!=hmap.end() ; ++hiter) {
495 // Define state labels in index category (both in provided indexCat and in internal copy in dataset)
496 if (!indexCat->lookupType(hiter->first.c_str())) {
497 indexCat->defineType(hiter->first.c_str()) ;
498 coutI(InputArguments) << "RooDataSet::ctor(" << GetName() << ") defining state \"" << hiter->first << "\" in index category " << indexCat->GetName() << endl ;
499 }
500 if (!icat->lookupType(hiter->first.c_str())) {
501 icat->defineType(hiter->first.c_str()) ;
502 }
503 icat->setLabel(hiter->first.c_str()) ;
504 _dstore->loadValues(hiter->second->store(),cutVar,cutRange) ;
505 }
506
507
508 } else if (impData) {
509 // Case 3b --- Import RooDataSet with cutvar
510 _dstore->loadValues(impData->store(),cutVar,cutRange);
511 } else if (impTree) {
512 // Case 4b --- Import TTree from memory with cutvar
513 if (tstore) {
514 tstore->loadValues(impTree,cutVar,cutRange);
515 } else {
516 RooTreeDataStore tmpstore(name,title,_vars,wgtVarName) ;
517 tmpstore.loadValues(impTree,cutVar,cutRange) ;
518 _dstore->append(tmpstore) ;
519 }
520 } else if (fname && strlen(fname)) {
521 // Case 5b --- Import TTree from file with cutvar
522 TFile *f = TFile::Open(fname) ;
523 if (!f) {
524 coutE(InputArguments) << "RooDataSet::ctor(" << GetName() << ") ERROR file '" << fname << "' cannot be opened or does not exist" << endl ;
525 throw string(Form("RooDataSet::ctor(%s) ERROR file %s cannot be opened or does not exist",GetName(),fname)) ;
526 }
527 TTree* t = dynamic_cast<TTree*>(f->Get(tname)) ;
528 if (!t) {
529 coutE(InputArguments) << "RooDataSet::ctor(" << GetName() << ") ERROR file '" << fname << "' does not contain a TTree named '" << tname << "'" << endl ;
530 throw string(Form("RooDataSet::ctor(%s) ERROR file %s does not contain a TTree named %s",GetName(),fname,tname)) ;
531 }
532 if (tstore) {
533 tstore->loadValues(t,cutVar,cutRange);
534 } else {
535 RooTreeDataStore tmpstore(name,title,_vars,wgtVarName) ;
536 tmpstore.loadValues(t,cutVar,cutRange) ;
537 _dstore->append(tmpstore) ;
538 }
539
540 f->Close() ;
541 }
542
543 // Import one or more datasets without cuts
544 } else {
545
546 if (indexCat) {
547
548 RooCategory* icat = (RooCategory*) _vars.find(indexCat->GetName()) ;
549 for (map<string,RooDataSet*>::iterator hiter = hmap.begin() ; hiter!=hmap.end() ; ++hiter) {
550 // Define state labels in index category (both in provided indexCat and in internal copy in dataset)
551 if (!indexCat->lookupType(hiter->first.c_str())) {
552 indexCat->defineType(hiter->first.c_str()) ;
553 coutI(InputArguments) << "RooDataSet::ctor(" << GetName() << ") defining state \"" << hiter->first << "\" in index category " << indexCat->GetName() << endl ;
554 }
555 if (!icat->lookupType(hiter->first.c_str())) {
556 icat->defineType(hiter->first.c_str()) ;
557 }
558 icat->setLabel(hiter->first.c_str()) ;
559 // Case 2c --- Import multiple RooDataSets as slices
560 _dstore->loadValues(hiter->second->store(),0,cutRange) ;
561 }
562
563
564 } else if (impData) {
565 // Case 3c --- Import RooDataSet
566 _dstore->loadValues(impData->store(),0,cutRange);
567 } else if (impTree) {
568 // Case 4c --- Import TTree from memort
569 if (tstore) {
570 tstore->loadValues(impTree,0,cutRange);
571 } else {
572 RooTreeDataStore tmpstore(name,title,_vars,wgtVarName) ;
573 tmpstore.loadValues(impTree,0,cutRange) ;
574 _dstore->append(tmpstore) ;
575 }
576 } else if (fname && strlen(fname)) {
577 // Case 5c --- Import TTree from file
578 TFile *f = TFile::Open(fname) ;
579 if (!f) {
580 coutE(InputArguments) << "RooDataSet::ctor(" << GetName() << ") ERROR file '" << fname << "' cannot be opened or does not exist" << endl ;
581 throw string(Form("RooDataSet::ctor(%s) ERROR file %s cannot be opened or does not exist",GetName(),fname)) ;
582 }
583 TTree* t = dynamic_cast<TTree*>(f->Get(tname)) ;
584 if (!t) {
585 coutE(InputArguments) << "RooDataSet::ctor(" << GetName() << ") ERROR file '" << fname << "' does not contain a TTree named '" << tname << "'" << endl ;
586 throw string(Form("RooDataSet::ctor(%s) ERROR file %s does not contain a TTree named %s",GetName(),fname,tname)) ;
587 }
588 if (tstore) {
589 tstore->loadValues(t,0,cutRange);
590 } else {
591 RooTreeDataStore tmpstore(name,title,_vars,wgtVarName) ;
592 tmpstore.loadValues(t,0,cutRange) ;
593 _dstore->append(tmpstore) ;
594 }
595 f->Close() ;
596 }
597 }
598
599 }
601}
602
603
604
605////////////////////////////////////////////////////////////////////////////////
606/// Constructor of an empty data set from a RooArgSet defining the dimensions
607/// of the data space.
608
609RooDataSet::RooDataSet(const char *name, const char *title, const RooArgSet& vars, const char* wgtVarName) :
610 RooAbsData(name,title,vars)
611{
612// cout << "RooDataSet::ctor(" << this << ") storageType = " << ((defaultStorageType==Tree)?"Tree":"Vector") << endl ;
613 _dstore = (defaultStorageType==Tree) ? ((RooAbsDataStore*) new RooTreeDataStore(name,title,_vars,wgtVarName)) :
614 ((RooAbsDataStore*) new RooVectorDataStore(name,title,_vars,wgtVarName)) ;
615
616 appendToDir(this,kTRUE) ;
617 initialize(wgtVarName) ;
619}
620
621
622////////////////////////////////////////////////////////////////////////////////
623/// Constructor of a data set from (part of) an existing data
624/// set. The dimensions of the data set are defined by the 'vars'
625/// RooArgSet, which can be identical to 'dset' dimensions, or a
626/// subset thereof. The 'cuts' string is an optional RooFormula
627/// expression and can be used to select the subset of the data
628/// points in 'dset' to be copied. The cut expression can refer to
629/// any variable in the source dataset. For cuts involving variables
630/// other than those contained in the source data set, such as
631/// intermediate formula objects, use the equivalent constructor
632/// accepting RooFormulaVar reference as cut specification.
633///
634/// This constructor will internally store the data in a TTree.
635///
636/// For most uses the RooAbsData::reduce() wrapper function, which
637/// uses this constructor, is the most convenient way to create a
638/// subset of an existing data
639///
640
641RooDataSet::RooDataSet(const char *name, const char *title, RooDataSet *dset,
642 const RooArgSet& vars, const char *cuts, const char* wgtVarName) :
643 RooAbsData(name,title,vars)
644{
645 // Initialize datastore
646 _dstore = new RooTreeDataStore(name,title,_vars,*dset->_dstore,cuts,wgtVarName) ;
647
648 appendToDir(this,kTRUE) ;
649
650 if (wgtVarName) {
651 // Use the supplied weight column
652 initialize(wgtVarName) ;
653 } else {
654 if (dset->_wgtVar && vars.find(dset->_wgtVar->GetName())) {
655 // Use the weight column of the source data set
656 initialize(dset->_wgtVar->GetName()) ;
657 } else {
658 initialize(0) ;
659 }
660 }
662}
663
664
665////////////////////////////////////////////////////////////////////////////////
666/// Constructor of a data set from (part of) an existing data
667/// set. The dimensions of the data set are defined by the 'vars'
668/// RooArgSet, which can be identical to 'dset' dimensions, or a
669/// subset thereof. The 'cutVar' formula variable is used to select
670/// the subset of data points to be copied. For subsets without
671/// selection on the data points, or involving cuts operating
672/// exclusively and directly on the data set dimensions, the
673/// equivalent constructor with a string based cut expression is
674/// recommended.
675///
676/// This constructor will internally store the data in a TTree.
677///
678/// For most uses the RooAbsData::reduce() wrapper function, which
679/// uses this constructor, is the most convenient way to create a
680/// subset of an existing data
681
682RooDataSet::RooDataSet(const char *name, const char *title, RooDataSet *dset,
683 const RooArgSet& vars, const RooFormulaVar& cutVar, const char* wgtVarName) :
684 RooAbsData(name,title,vars)
685{
686 // Initialize datastore
687 _dstore = new RooTreeDataStore(name,title,_vars,*dset->_dstore,cutVar,wgtVarName) ;
688
689 appendToDir(this,kTRUE) ;
690
691 if (wgtVarName) {
692 // Use the supplied weight column
693 initialize(wgtVarName) ;
694 } else {
695 if (dset->_wgtVar && vars.find(dset->_wgtVar->GetName())) {
696 // Use the weight column of the source data set
697 initialize(dset->_wgtVar->GetName()) ;
698 } else {
699 initialize(0) ;
700 }
701 }
703}
704
705
706
707
708////////////////////////////////////////////////////////////////////////////////
709/// Constructor of a data set from (part of) an ROOT TTRee. The dimensions
710/// of the data set are defined by the 'vars' RooArgSet. For each dimension
711/// specified, the TTree must have a branch with the same name. For category
712/// branches, this branch should contain the numeric index value. Real dimensions
713/// can be constructed from either 'Double_t' or 'Float_t' tree branches. In the
714/// latter case, an automatic conversion is applied.
715///
716/// The 'cutVar' formula variable
717/// is used to select the subset of data points to be copied.
718/// For subsets without selection on the data points, or involving cuts
719/// operating exclusively and directly on the data set dimensions, the equivalent
720/// constructor with a string based cut expression is recommended.
721
722RooDataSet::RooDataSet(const char *name, const char *title, TTree *intree,
723 const RooArgSet& vars, const RooFormulaVar& cutVar, const char* wgtVarName) :
724 RooAbsData(name,title,vars)
725{
726 // Create tree version of datastore
727 RooTreeDataStore* tstore = new RooTreeDataStore(name,title,_vars,*intree,cutVar,wgtVarName) ;
728
729 // Convert to vector datastore if needed
731 _dstore = tstore ;
732 } else if (defaultStorageType==Vector) {
733 RooVectorDataStore* vstore = new RooVectorDataStore(name,title,_vars,wgtVarName) ;
734 _dstore = vstore ;
735 _dstore->append(*tstore) ;
736 delete tstore ;
737 } else {
738 _dstore = 0 ;
739 }
740
741 appendToDir(this,kTRUE) ;
742 initialize(wgtVarName) ;
744}
745
746
747
748////////////////////////////////////////////////////////////////////////////////
749/// Constructor of a data set from (part of) an ROOT TTRee. The dimensions
750/// of the data set are defined by the 'vars' RooArgSet. For each dimension
751/// specified, the TTree must have a branch with the same name. For category
752/// branches, this branch should contain the numeric index value. Real dimensions
753/// can be constructed from either 'Double_t' or 'Float_t' tree branches. In the
754/// latter case, an automatic conversion is applied.
755///
756/// The 'cuts' string is an optional
757/// RooFormula expression and can be used to select the subset of the data points
758/// in 'dset' to be copied. The cut expression can refer to any variable in the
759/// vars argset. For cuts involving variables other than those contained in
760/// the vars argset, such as intermediate formula objects, use the
761/// equivalent constructor accepting RooFormulaVar reference as cut specification
762///
763
764RooDataSet::RooDataSet(const char *name, const char *title, TTree *intree,
765 const RooArgSet& vars, const char *selExpr, const char* wgtVarName) :
766 RooAbsData(name,title,vars)
767{
768 // Create tree version of datastore
769 RooTreeDataStore* tstore = new RooTreeDataStore(name,title,_vars,*intree,selExpr,wgtVarName) ;
770
771 // Convert to vector datastore if needed
773 _dstore = tstore ;
774 } else if (defaultStorageType==Vector) {
775 RooVectorDataStore* vstore = new RooVectorDataStore(name,title,_vars,wgtVarName) ;
776 _dstore = vstore ;
777 _dstore->append(*tstore) ;
778 delete tstore ;
779 } else {
780 _dstore = 0 ;
781 }
782
783 appendToDir(this,kTRUE) ;
784
785 initialize(wgtVarName) ;
787}
788
789
790
791////////////////////////////////////////////////////////////////////////////////
792/// Copy constructor
793
794RooDataSet::RooDataSet(RooDataSet const & other, const char* newname) :
795 RooAbsData(other,newname), RooDirItem()
796{
797 appendToDir(this,kTRUE) ;
798 initialize(other._wgtVar?other._wgtVar->GetName():0) ;
800}
801
802////////////////////////////////////////////////////////////////////////////////
803/// Protected constructor for internal use only
804
805RooDataSet::RooDataSet(const char *name, const char *title, RooDataSet *dset,
806 const RooArgSet& vars, const RooFormulaVar* cutVar, const char* cutRange,
807 Int_t nStart, Int_t nStop, Bool_t copyCache, const char* wgtVarName) :
808 RooAbsData(name,title,vars)
809{
810 _dstore =
812 ? ((RooAbsDataStore *)new RooTreeDataStore(name, title, *dset->_dstore, _vars, cutVar, cutRange, nStart, nStop,
813 copyCache, wgtVarName))
814 : (
815 // ( dset->_dstore->IsA()==RooCompositeDataStore::Class() )?
816 // ((RooAbsDataStore*) new
817 // RooCompositeDataStore(name,title,(RooCompositeDataStore&)(*dset->_dstore),_vars,cutVar,cutRange,nStart,nStop,copyCache,wgtVarName))
818 // :
819 ((RooAbsDataStore *)new RooVectorDataStore(name, title, *dset->_dstore, _vars, cutVar, cutRange, nStart,
820 nStop, copyCache, wgtVarName)));
821
823
824 appendToDir(this, kTRUE);
825 initialize(dset->_wgtVar ? dset->_wgtVar->GetName() : 0);
827}
828
829
830////////////////////////////////////////////////////////////////////////////////
831/// Helper function for constructor that adds optional weight variable to construct
832/// total set of observables
833
834RooArgSet RooDataSet::addWgtVar(const RooArgSet& origVars, const RooAbsArg* wgtVar)
835{
836 RooArgSet tmp(origVars) ;
837 if (wgtVar) tmp.add(*wgtVar) ;
838 return tmp ;
839}
840
841
842
843////////////////////////////////////////////////////////////////////////////////
844/// Return a clone of this dataset containing only the cached variables
845
846RooAbsData* RooDataSet::cacheClone(const RooAbsArg* newCacheOwner, const RooArgSet* newCacheVars, const char* newName)
847{
848 RooDataSet* dset = new RooDataSet(newName?newName:GetName(),GetTitle(),this,_vars,(RooFormulaVar*)0,0,0,2000000000,kTRUE,_wgtVar?_wgtVar->GetName():0) ;
849 //if (_wgtVar) dset->setWeightVar(_wgtVar->GetName()) ;
850
851 RooArgSet* selCacheVars = (RooArgSet*) newCacheVars->selectCommon(dset->_cachedVars) ;
852 dset->attachCache(newCacheOwner, *selCacheVars) ;
853 delete selCacheVars ;
854
855 return dset ;
856}
857
858
859
860////////////////////////////////////////////////////////////////////////////////
861/// Return an empty clone of this dataset. If vars is not null, only the variables in vars
862/// are added to the definition of the empty clone
863
864RooAbsData* RooDataSet::emptyClone(const char* newName, const char* newTitle, const RooArgSet* vars, const char* wgtVarName) const
865{
866 // If variables are given, be sure to include weight variable if it exists and is not included
867 RooArgSet vars2 ;
868 RooRealVar* tmpWgtVar = _wgtVar ;
869 if (wgtVarName && vars && !_wgtVar) {
870 tmpWgtVar = (RooRealVar*) vars->find(wgtVarName) ;
871 }
872
873 if (vars) {
874 vars2.add(*vars) ;
875 if (_wgtVar && !vars2.find(_wgtVar->GetName())) {
876 vars2.add(*_wgtVar) ;
877 }
878 } else {
879 vars2.add(_vars) ;
880 }
881
882 RooDataSet* dset = new RooDataSet(newName?newName:GetName(),newTitle?newTitle:GetTitle(),vars2,tmpWgtVar?tmpWgtVar->GetName():0) ;
883 //if (_wgtVar) dset->setWeightVar(_wgtVar->GetName()) ;
884 return dset ;
885}
886
887
888
889////////////////////////////////////////////////////////////////////////////////
890/// Initialize the dataset. If wgtVarName is not null, interpret the observable
891/// with that name as event weight
892
893void RooDataSet::initialize(const char* wgtVarName)
894{
897 _wgtVar = 0 ;
898 if (wgtVarName) {
899 RooAbsArg* wgt = _varsNoWgt.find(wgtVarName) ;
900 if (!wgt) {
901 coutW(DataHandling) << "RooDataSet::RooDataSet(" << GetName() << ") WARNING: designated weight variable "
902 << wgtVarName << " not found in set of variables, no weighting will be assigned" << endl ;
903 } else if (!dynamic_cast<RooRealVar*>(wgt)) {
904 coutW(DataHandling) << "RooDataSet::RooDataSet(" << GetName() << ") WARNING: designated weight variable "
905 << wgtVarName << " is not of type RooRealVar, no weighting will be assigned" << endl ;
906 } else {
907 _varsNoWgt.remove(*wgt) ;
908 _wgtVar = (RooRealVar*) wgt ;
909 }
910 }
911}
912
913
914
915////////////////////////////////////////////////////////////////////////////////
916/// Implementation of RooAbsData virtual method that drives the RooAbsData::reduce() methods
917
918RooAbsData* RooDataSet::reduceEng(const RooArgSet& varSubset, const RooFormulaVar* cutVar, const char* cutRange,
919 Int_t nStart, Int_t nStop, Bool_t copyCache)
920{
921 checkInit() ;
922
923 //cout << "reduceEng varSubset = " << varSubset << " _wgtVar = " << (_wgtVar ? _wgtVar->GetName() : "") << endl;
924
925 RooArgSet tmp(varSubset) ;
926 if (_wgtVar) {
927 tmp.add(*_wgtVar) ;
928 }
929 RooDataSet* ret = new RooDataSet(GetName(), GetTitle(), this, tmp, cutVar, cutRange, nStart, nStop, copyCache,_wgtVar?_wgtVar->GetName():0) ;
930
931 // WVE - propagate optional weight variable
932 // check behaviour in plotting.
933 // if (_wgtVar) {
934 // ret->setWeightVar(_wgtVar->GetName()) ;
935 // }
936 return ret ;
937}
938
939
940
941////////////////////////////////////////////////////////////////////////////////
942/// Destructor
943
945{
946 removeFromDir(this) ;
948}
949
950
951
952////////////////////////////////////////////////////////////////////////////////
953/// Return binned clone of this dataset
954
955RooDataHist* RooDataSet::binnedClone(const char* newName, const char* newTitle) const
956{
957 TString title, name ;
958 if (newName) {
959 name = newName ;
960 } else {
961 name = Form("%s_binned",GetName()) ;
962 }
963 if (newTitle) {
964 title = newTitle ;
965 } else {
966 title = Form("%s_binned",GetTitle()) ;
967 }
968
969 return new RooDataHist(name,title,*get(),*this) ;
970}
971
972
973
974////////////////////////////////////////////////////////////////////////////////
975/// Return event weight of current event
976
978{
979 return store()->weight() ;
980}
981
982
983
984
985////////////////////////////////////////////////////////////////////////////////
986/// Return event weight of current event
987
989{
990 return store()->weight()*store()->weight() ;
991}
992
993
994
995
996////////////////////////////////////////////////////////////////////////////////
997
999{
1000 store()->weightError(lo,hi,etype) ;
1001}
1002
1003
1004
1005////////////////////////////////////////////////////////////////////////////////
1006
1008{
1009 return store()->weightError(etype) ;
1010}
1011
1012
1013
1014////////////////////////////////////////////////////////////////////////////////
1015/// Return RooArgSet with coordinates of event 'index'
1016
1018{
1019 const RooArgSet* ret = RooAbsData::get(index) ;
1020 return ret ? &_varsNoWgt : 0 ;
1021}
1022
1023
1024////////////////////////////////////////////////////////////////////////////////
1025
1027{
1028 return store()->sumEntries() ;
1029
1030 //---------
1031
1032 // Shortcut for unweighted unselected datasets
1033 if (!isWeighted()) {
1034 return numEntries() ;
1035 }
1036
1037 // Otherwise sum the weights in the event
1038 Double_t sumw(0), carry(0);
1039 Int_t i ;
1040 for (i=0 ; i<numEntries() ; i++) {
1041 get(i) ;
1042 Double_t y = weight() - carry;
1043 Double_t t = sumw + y;
1044 carry = (t - sumw) - y;
1045 sumw = t;
1046 }
1047
1048 return sumw ;
1049}
1050
1051
1052////////////////////////////////////////////////////////////////////////////////
1053/// Return the sum of weights in all entries matching cutSpec (if specified)
1054/// and in named range cutRange (if specified)
1055
1056Double_t RooDataSet::sumEntries(const char* cutSpec, const char* cutRange) const
1057{
1058 // Setup RooFormulaVar for cutSpec if it is present
1059 RooFormula* select = 0 ;
1060 if (cutSpec && strlen(cutSpec) > 0) {
1061 select = new RooFormula("select",cutSpec,*get()) ;
1062 }
1063
1064 // Shortcut for unweighted unselected datasets
1065 if (!select && !cutRange && !isWeighted()) {
1066 return numEntries() ;
1067 }
1068
1069 // Otherwise sum the weights in the event
1070 Double_t sumw(0), carry(0);
1071 Int_t i ;
1072 for (i=0 ; i<numEntries() ; i++) {
1073 get(i) ;
1074 if (select && select->eval()==0.) continue ;
1075 if (cutRange && !_vars.allInRange(cutRange)) continue ;
1076 Double_t y = weight() - carry;
1077 Double_t t = sumw + y;
1078 carry = (t - sumw) - y;
1079 sumw = t;
1080 }
1081
1082 if (select) delete select ;
1083
1084 return sumw ;
1085}
1086
1087
1088
1089
1090////////////////////////////////////////////////////////////////////////////////
1091/// Return true if dataset contains weighted events
1092
1094{
1095 return store()->isWeighted() ;
1096}
1097
1098
1099
1100////////////////////////////////////////////////////////////////////////////////
1101/// Returns true if histogram contains bins with entries with a non-integer weight
1102
1104{
1105 // Return false if we have no weights
1106 if (!_wgtVar) return kFALSE ;
1107
1108 // Now examine individual weights
1109 for (int i=0 ; i<numEntries() ; i++) {
1110 get(i) ;
1111 if (fabs(weight()-Int_t(weight()))>1e-10) return kTRUE ;
1112 }
1113 // If sum of weights is less than number of events there are negative (integer) weights
1114 if (sumEntries()<numEntries()) return kTRUE ;
1115
1116 return kFALSE ;
1117}
1118
1119
1120
1121
1122////////////////////////////////////////////////////////////////////////////////
1123/// Return a RooArgSet with the coordinates of the current event
1124
1126{
1127 return &_varsNoWgt ;
1128}
1129
1130
1131
1132////////////////////////////////////////////////////////////////////////////////
1133/// Add a data point, with its coordinates specified in the 'data' argset, to the data set.
1134/// Any variables present in 'data' but not in the dataset will be silently ignored.
1135/// \param[in] data Data point.
1136/// \param[in] wgt Event weight. Defaults to 1. The current value of the weight variable is
1137/// ignored.
1138/// \note To obtain weighted events, a variable must be designated `WeightVar` in the constructor.
1139/// \param[in] wgtError Optional weight error.
1140/// \note This requires including the weight variable in the set of `StoreError` variables when constructing
1141/// the dataset.
1142
1143void RooDataSet::add(const RooArgSet& data, Double_t wgt, Double_t wgtError)
1144{
1145 checkInit() ;
1146
1147 const double oldW = _wgtVar ? _wgtVar->getVal() : 0.;
1148
1149 _varsNoWgt = data;
1150
1151 if (_wgtVar) {
1152 _wgtVar->setVal(wgt) ;
1153 if (wgtError!=0.) {
1154 _wgtVar->setError(wgtError) ;
1155 }
1156 } else if ((wgt != 1. || wgtError != 0.) && _errorMsgCount < 5) {
1157 ccoutE(DataHandling) << "An event weight/error was passed but no weight variable was defined"
1158 << " in the dataset '" << GetName() << "'. The weight will be ignored." << std::endl;
1160 }
1161
1163 && wgtError != 0.
1164 && fabs(wgt*wgt - wgtError)/wgtError > 1.E-15 //Exception for standard wgt^2 errors, which need not be stored.
1165 && _errorMsgCount < 5 && !_wgtVar->getAttribute("StoreError")) {
1166 coutE(DataHandling) << "An event weight error was passed to the RooDataSet '" << GetName()
1167 << "', but the weight variable '" << _wgtVar->GetName()
1168 << "' does not store errors. Check `StoreError` in the RooDataSet constructor." << std::endl;
1170 }
1171
1172 fill();
1173
1174 // Restore weight state
1175 if (_wgtVar) {
1176 _wgtVar->setVal(oldW);
1178 }
1179}
1180
1181
1182
1183
1184////////////////////////////////////////////////////////////////////////////////
1185/// Add a data point, with its coordinates specified in the 'data' argset, to the data set.
1186/// Any variables present in 'data' but not in the dataset will be silently ignored.
1187/// \param[in] data Data point.
1188/// \param[in] wgt Event weight. The current value of the weight variable is ignored.
1189/// \note To obtain weighted events, a variable must be designated `WeightVar` in the constructor.
1190/// \param[in] wgtErrorLo Asymmetric weight error.
1191/// \param[in] wgtErrorHi Asymmetric weight error.
1192/// \note This requires including the weight variable in the set of `StoreAsymError` variables when constructing
1193/// the dataset.
1194
1195void RooDataSet::add(const RooArgSet& indata, Double_t inweight, Double_t weightErrorLo, Double_t weightErrorHi)
1196{
1197 checkInit() ;
1198
1199 const double oldW = _wgtVar ? _wgtVar->getVal() : 0.;
1200
1201 _varsNoWgt = indata;
1202 if (_wgtVar) {
1203 _wgtVar->setVal(inweight) ;
1204 _wgtVar->setAsymError(weightErrorLo,weightErrorHi) ;
1205 } else if (inweight != 1. && _errorMsgCount < 5) {
1206 ccoutE(DataHandling) << "An event weight was given but no weight variable was defined"
1207 << " in the dataset '" << GetName() << "'. The weight will be ignored." << std::endl;
1209 }
1210
1212 && _errorMsgCount < 5 && !_wgtVar->getAttribute("StoreAsymError")) {
1213 coutE(DataHandling) << "An event weight error was passed to the RooDataSet '" << GetName()
1214 << "', but the weight variable '" << _wgtVar->GetName()
1215 << "' does not store errors. Check `StoreAsymError` in the RooDataSet constructor." << std::endl;
1217 }
1218
1219 fill();
1220
1221 // Restore weight state
1222 if (_wgtVar) {
1223 _wgtVar->setVal(oldW);
1225 }
1226}
1227
1228
1229
1230
1231
1232////////////////////////////////////////////////////////////////////////////////
1233/// Add a data point, with its coordinates specified in the 'data' argset, to the data set.
1234/// \attention The order and type of the input variables are **assumed** to be the same as
1235/// for the RooArgSet returned by RooDataSet::get(). Input values will just be written
1236/// into the internal data columns by ordinal position.
1237/// \param[in] data Data point.
1238/// \param[in] wgt Event weight. Defaults to 1. The current value of the weight variable is
1239/// ignored.
1240/// \note To obtain weighted events, a variable must be designated `WeightVar` in the constructor.
1241/// \param[in] wgtError Optional weight error.
1242/// \note This requires including the weight variable in the set of `StoreError` variables when constructing
1243/// the dataset.
1244
1245void RooDataSet::addFast(const RooArgSet& data, Double_t wgt, Double_t wgtError)
1246{
1247 checkInit() ;
1248
1249 const double oldW = _wgtVar ? _wgtVar->getVal() : 0.;
1250
1252 if (_wgtVar) {
1253 _wgtVar->setVal(wgt) ;
1254 if (wgtError!=0.) {
1255 _wgtVar->setError(wgtError) ;
1256 }
1257 } else if (wgt != 1. && _errorMsgCount < 5) {
1258 ccoutE(DataHandling) << "An event weight was given but no weight variable was defined"
1259 << " in the dataset '" << GetName() << "'. The weight will be ignored." << std::endl;
1261 }
1262
1263 fill();
1264
1266 && wgtError != 0. && wgtError != wgt*wgt //Exception for standard weight error, which need not be stored
1267 && _errorMsgCount < 5 && !_wgtVar->getAttribute("StoreError")) {
1268 coutE(DataHandling) << "An event weight error was passed to the RooDataSet '" << GetName()
1269 << "', but the weight variable '" << _wgtVar->GetName()
1270 << "' does not store errors. Check `StoreError` in the RooDataSet constructor." << std::endl;
1272 }
1274 _doWeightErrorCheck = false;
1275 }
1276
1277 if (_wgtVar) {
1278 _wgtVar->setVal(oldW);
1280 }
1281}
1282
1283
1284
1285////////////////////////////////////////////////////////////////////////////////
1286
1288 RooDataSet* data4, RooDataSet* data5, RooDataSet* data6)
1289{
1290 checkInit() ;
1291 list<RooDataSet*> dsetList ;
1292 if (data1) dsetList.push_back(data1) ;
1293 if (data2) dsetList.push_back(data2) ;
1294 if (data3) dsetList.push_back(data3) ;
1295 if (data4) dsetList.push_back(data4) ;
1296 if (data5) dsetList.push_back(data5) ;
1297 if (data6) dsetList.push_back(data6) ;
1298 return merge(dsetList) ;
1299}
1300
1301
1302
1303////////////////////////////////////////////////////////////////////////////////
1304/// Merge columns of supplied data set(s) with this data set. All
1305/// data sets must have equal number of entries. In case of
1306/// duplicate columns the column of the last dataset in the list
1307/// prevails
1308
1309Bool_t RooDataSet::merge(list<RooDataSet*>dsetList)
1310{
1311
1312 checkInit() ;
1313 // Sanity checks: data sets must have the same size
1314 for (list<RooDataSet*>::iterator iter = dsetList.begin() ; iter != dsetList.end() ; ++iter) {
1315 if (numEntries()!=(*iter)->numEntries()) {
1316 coutE(InputArguments) << "RooDataSet::merge(" << GetName() << ") ERROR: datasets have different size" << endl ;
1317 return kTRUE ;
1318 }
1319 }
1320
1321 // Extend vars with elements of other dataset
1322 list<RooAbsDataStore*> dstoreList ;
1323 for (list<RooDataSet*>::iterator iter = dsetList.begin() ; iter != dsetList.end() ; ++iter) {
1324 _vars.addClone((*iter)->_vars,kTRUE) ;
1325 dstoreList.push_back((*iter)->store()) ;
1326 }
1327
1328 // Merge data stores
1329 RooAbsDataStore* mergedStore = _dstore->merge(_vars,dstoreList) ;
1330 mergedStore->SetName(_dstore->GetName()) ;
1331 mergedStore->SetTitle(_dstore->GetTitle()) ;
1332
1333 // Replace current data store with merged store
1334 delete _dstore ;
1335 _dstore = mergedStore ;
1336
1338 return kFALSE ;
1339}
1340
1341
1342////////////////////////////////////////////////////////////////////////////////
1343/// Add all data points of given data set to this data set.
1344/// Observable in 'data' that are not in this dataset
1345/// with not be transferred
1346
1348{
1349 checkInit() ;
1350 _dstore->append(*data._dstore) ;
1351}
1352
1353
1354
1355////////////////////////////////////////////////////////////////////////////////
1356/// Add a column with the values of the given (function) argument
1357/// to this dataset. The function value is calculated for each
1358/// event using the observable values of each event in case the
1359/// function depends on variables with names that are identical
1360/// to the observable names in the dataset
1361
1363{
1364 checkInit() ;
1365 RooAbsArg* ret = _dstore->addColumn(var,adjustRange) ;
1366 _vars.addOwned(*ret) ;
1368 return ret ;
1369}
1370
1371
1372////////////////////////////////////////////////////////////////////////////////
1373/// Add a column with the values of the given list of (function)
1374/// argument to this dataset. Each function value is calculated for
1375/// each event using the observable values of the event in case the
1376/// function depends on variables with names that are identical to
1377/// the observable names in the dataset
1378
1380{
1381 checkInit() ;
1382 RooArgSet* ret = _dstore->addColumns(varList) ;
1383 _vars.addOwned(*ret) ;
1385 return ret ;
1386}
1387
1388
1389
1390////////////////////////////////////////////////////////////////////////////////
1391/// Create a TH2F histogram of the distribution of the specified variable
1392/// using this dataset. Apply any cuts to select which events are used.
1393/// The variable being plotted can either be contained directly in this
1394/// dataset, or else be a function of the variables in this dataset.
1395/// The histogram will be created using RooAbsReal::createHistogram() with
1396/// the name provided (with our dataset name prepended).
1397
1398TH2F* RooDataSet::createHistogram(const RooAbsRealLValue& var1, const RooAbsRealLValue& var2, const char* cuts, const char *name) const
1399{
1400 checkInit() ;
1401 return createHistogram(var1, var2, var1.getBins(), var2.getBins(), cuts, name);
1402}
1403
1404
1405
1406////////////////////////////////////////////////////////////////////////////////
1407/// Create a TH2F histogram of the distribution of the specified variable
1408/// using this dataset. Apply any cuts to select which events are used.
1409/// The variable being plotted can either be contained directly in this
1410/// dataset, or else be a function of the variables in this dataset.
1411/// The histogram will be created using RooAbsReal::createHistogram() with
1412/// the name provided (with our dataset name prepended).
1413
1415 Int_t nx, Int_t ny, const char* cuts, const char *name) const
1416{
1417 checkInit() ;
1418 static Int_t counter(0) ;
1419
1420 Bool_t ownPlotVarX(kFALSE) ;
1421 // Is this variable in our dataset?
1422 RooAbsReal* plotVarX= (RooAbsReal*)_vars.find(var1.GetName());
1423 if(0 == plotVarX) {
1424 // Is this variable a client of our dataset?
1425 if (!var1.dependsOn(_vars)) {
1426 coutE(InputArguments) << GetName() << "::createHistogram: Argument " << var1.GetName()
1427 << " is not in dataset and is also not dependent on data set" << endl ;
1428 return 0 ;
1429 }
1430
1431 // Clone derived variable
1432 plotVarX = (RooAbsReal*) var1.Clone() ;
1433 ownPlotVarX = kTRUE ;
1434
1435 //Redirect servers of derived clone to internal ArgSet representing the data in this set
1436 plotVarX->redirectServers(const_cast<RooArgSet&>(_vars)) ;
1437 }
1438
1439 Bool_t ownPlotVarY(kFALSE) ;
1440 // Is this variable in our dataset?
1441 RooAbsReal* plotVarY= (RooAbsReal*)_vars.find(var2.GetName());
1442 if(0 == plotVarY) {
1443 // Is this variable a client of our dataset?
1444 if (!var2.dependsOn(_vars)) {
1445 coutE(InputArguments) << GetName() << "::createHistogram: Argument " << var2.GetName()
1446 << " is not in dataset and is also not dependent on data set" << endl ;
1447 return 0 ;
1448 }
1449
1450 // Clone derived variable
1451 plotVarY = (RooAbsReal*) var2.Clone() ;
1452 ownPlotVarY = kTRUE ;
1453
1454 //Redirect servers of derived clone to internal ArgSet representing the data in this set
1455 plotVarY->redirectServers(const_cast<RooArgSet&>(_vars)) ;
1456 }
1457
1458 // Create selection formula if selection cuts are specified
1459 RooFormula* select = 0;
1460 if(0 != cuts && strlen(cuts)) {
1461 select=new RooFormula(cuts,cuts,_vars);
1462 if (!select || !select->ok()) {
1463 delete select;
1464 return 0 ;
1465 }
1466 }
1467
1468 TString histName(name);
1469 histName.Prepend("_");
1470 histName.Prepend(fName);
1471 histName.Append("_") ;
1472 histName.Append(Form("%08x",counter++)) ;
1473
1474 // create the histogram
1475 TH2F* histogram=new TH2F(histName.Data(), "Events", nx, var1.getMin(), var1.getMax(),
1476 ny, var2.getMin(), var2.getMax());
1477 if(!histogram) {
1478 coutE(DataHandling) << fName << "::createHistogram: unable to create a new histogram" << endl;
1479 return 0;
1480 }
1481
1482 // Dump contents
1483 Int_t nevent= numEntries() ;
1484 for(Int_t i=0; i < nevent; ++i)
1485 {
1486 get(i);
1487
1488 if (select && select->eval()==0) continue ;
1489 histogram->Fill(plotVarX->getVal(), plotVarY->getVal(),weight()) ;
1490 }
1491
1492 if (ownPlotVarX) delete plotVarX ;
1493 if (ownPlotVarY) delete plotVarY ;
1494 if (select) delete select ;
1495
1496 return histogram ;
1497}
1498
1499
1500
1501
1502
1503////////////////////////////////////////////////////////////////////////////////
1504/// Special plot method for 'X-Y' datasets used in \f$ \chi^2 \f$ fitting. These datasets
1505/// have one observable (X) and have weights (Y) and associated errors.
1506/// <table>
1507/// <tr><th> Contents options <th> Effect
1508/// <tr><td> YVar(RooRealVar& var) <td> Designate specified observable as 'y' variable
1509/// If not specified, the event weight will be the y variable
1510/// <tr><th> Histogram drawing options <th> Effect
1511/// <tr><td> DrawOption(const char* opt) <td> Select ROOT draw option for resulting TGraph object
1512/// <tr><td> LineStyle(Int_t style) <td> Select line style by ROOT line style code, default is solid
1513/// <tr><td> LineColor(Int_t color) <td> Select line color by ROOT color code, default is black
1514/// <tr><td> LineWidth(Int_t width) <td> Select line with in pixels, default is 3
1515/// <tr><td> MarkerStyle(Int_t style) <td> Select the ROOT marker style, default is 21
1516/// <tr><td> MarkerColor(Int_t color) <td> Select the ROOT marker color, default is black
1517/// <tr><td> MarkerSize(Double_t size) <td> Select the ROOT marker size
1518/// <tr><td> Rescale(Double_t factor) <td> Apply global rescaling factor to histogram
1519/// <tr><th> Misc. other options <th> Effect
1520/// <tr><td> Name(const chat* name) <td> Give curve specified name in frame. Useful if curve is to be referenced later
1521/// <tr><td> Invisible(Bool_t flag) <td> Add curve to frame, but do not display. Useful in combination AddTo()
1522/// </table>
1523
1524RooPlot* RooDataSet::plotOnXY(RooPlot* frame, const RooCmdArg& arg1, const RooCmdArg& arg2,
1525 const RooCmdArg& arg3, const RooCmdArg& arg4,
1526 const RooCmdArg& arg5, const RooCmdArg& arg6,
1527 const RooCmdArg& arg7, const RooCmdArg& arg8) const
1528{
1529 checkInit() ;
1530
1531 RooLinkedList argList ;
1532 argList.Add((TObject*)&arg1) ; argList.Add((TObject*)&arg2) ;
1533 argList.Add((TObject*)&arg3) ; argList.Add((TObject*)&arg4) ;
1534 argList.Add((TObject*)&arg5) ; argList.Add((TObject*)&arg6) ;
1535 argList.Add((TObject*)&arg7) ; argList.Add((TObject*)&arg8) ;
1536
1537 // Process named arguments
1538 RooCmdConfig pc(Form("RooDataSet::plotOnXY(%s)",GetName())) ;
1539 pc.defineString("drawOption","DrawOption",0,"P") ;
1540 pc.defineString("histName","Name",0,"") ;
1541 pc.defineInt("lineColor","LineColor",0,-999) ;
1542 pc.defineInt("lineStyle","LineStyle",0,-999) ;
1543 pc.defineInt("lineWidth","LineWidth",0,-999) ;
1544 pc.defineInt("markerColor","MarkerColor",0,-999) ;
1545 pc.defineInt("markerStyle","MarkerStyle",0,8) ;
1546 pc.defineDouble("markerSize","MarkerSize",0,-999) ;
1547 pc.defineInt("fillColor","FillColor",0,-999) ;
1548 pc.defineInt("fillStyle","FillStyle",0,-999) ;
1549 pc.defineInt("histInvisible","Invisible",0,0) ;
1550 pc.defineDouble("scaleFactor","Rescale",0,1.) ;
1551 pc.defineObject("xvar","XVar",0,0) ;
1552 pc.defineObject("yvar","YVar",0,0) ;
1553
1554
1555 // Process & check varargs
1556 pc.process(argList) ;
1557 if (!pc.ok(kTRUE)) {
1558 return frame ;
1559 }
1560
1561 // Extract values from named arguments
1562 const char* drawOptions = pc.getString("drawOption") ;
1563 Int_t histInvisible = pc.getInt("histInvisible") ;
1564 const char* histName = pc.getString("histName",0,kTRUE) ;
1565 Double_t scaleFactor = pc.getDouble("scaleFactor") ;
1566
1567 RooRealVar* xvar = (RooRealVar*) _vars.find(frame->getPlotVar()->GetName()) ;
1568
1569 // Determine Y variable (default is weight, if present)
1570 RooRealVar* yvar = (RooRealVar*)(pc.getObject("yvar")) ;
1571
1572 // Sanity check. XY plotting only applies to weighted datasets if no YVar is specified
1573 if (!_wgtVar && !yvar) {
1574 coutE(InputArguments) << "RooDataSet::plotOnXY(" << GetName() << ") ERROR: no YVar() argument specified and dataset is not weighted" << endl ;
1575 return 0 ;
1576 }
1577
1578 RooRealVar* dataY = yvar ? (RooRealVar*) _vars.find(yvar->GetName()) : 0 ;
1579 if (yvar && !dataY) {
1580 coutE(InputArguments) << "RooDataSet::plotOnXY(" << GetName() << ") ERROR on YVar() argument, dataset does not contain a variable named " << yvar->GetName() << endl ;
1581 return 0 ;
1582 }
1583
1584
1585 // Make RooHist representing XY contents of data
1586 RooHist* graph = new RooHist ;
1587 if (histName) {
1588 graph->SetName(histName) ;
1589 } else {
1590 graph->SetName(Form("hxy_%s",GetName())) ;
1591 }
1592
1593 for (int i=0 ; i<numEntries() ; i++) {
1594 get(i) ;
1595 Double_t x = xvar->getVal() ;
1596 Double_t exlo = xvar->getErrorLo() ;
1597 Double_t exhi = xvar->getErrorHi() ;
1598 Double_t y,eylo,eyhi ;
1599 if (!dataY) {
1600 y = weight() ;
1601 weightError(eylo,eyhi) ;
1602 } else {
1603 y = dataY->getVal() ;
1604 eylo = dataY->getErrorLo() ;
1605 eyhi = dataY->getErrorHi() ;
1606 }
1607 graph->addBinWithXYError(x,y,-1*exlo,exhi,-1*eylo,eyhi,scaleFactor) ;
1608 }
1609
1610 // Adjust style options according to named arguments
1611 Int_t lineColor = pc.getInt("lineColor") ;
1612 Int_t lineStyle = pc.getInt("lineStyle") ;
1613 Int_t lineWidth = pc.getInt("lineWidth") ;
1614 Int_t markerColor = pc.getInt("markerColor") ;
1615 Int_t markerStyle = pc.getInt("markerStyle") ;
1616 Size_t markerSize = pc.getDouble("markerSize") ;
1617 Int_t fillColor = pc.getInt("fillColor") ;
1618 Int_t fillStyle = pc.getInt("fillStyle") ;
1619
1620 if (lineColor!=-999) graph->SetLineColor(lineColor) ;
1621 if (lineStyle!=-999) graph->SetLineStyle(lineStyle) ;
1622 if (lineWidth!=-999) graph->SetLineWidth(lineWidth) ;
1623 if (markerColor!=-999) graph->SetMarkerColor(markerColor) ;
1624 if (markerStyle!=-999) graph->SetMarkerStyle(markerStyle) ;
1625 if (markerSize!=-999) graph->SetMarkerSize(markerSize) ;
1626 if (fillColor!=-999) graph->SetFillColor(fillColor) ;
1627 if (fillStyle!=-999) graph->SetFillStyle(fillStyle) ;
1628
1629 // Add graph to frame
1630 frame->addPlotable(graph,drawOptions,histInvisible) ;
1631
1632 return frame ;
1633}
1634
1635
1636
1637
1638////////////////////////////////////////////////////////////////////////////////
1639/// Read given list of ascii files, and construct a data set, using the given
1640/// ArgList as structure definition.
1641/// \param fileList Multiple file names, comma separated. Each
1642/// file is optionally prefixed with 'commonPath' if such a path is
1643/// provided
1644///
1645/// \param varList Specify the dimensions of the dataset to be built.
1646/// This list describes the order in which these dimensions appear in the
1647/// ascii files to be read.
1648/// Each line in the ascii file should contain N white-space separated
1649/// tokens, with N the number of args in `varList`. Any text beyond
1650/// N tokens will be ignored with a warning message.
1651/// (NB: This is the default output of RooArgList::writeToStream())
1652///
1653/// \param verbOpt `Q` be quiet, `D` debug mode (verbose)
1654///
1655/// \param commonPath All filenames in `fileList` will be prefixed with this optional path.
1656///
1657/// \param indexCatName Interpret the data as belonging to category `indexCatName`.
1658/// When multiple files are read, a RooCategory arg in `varList` can
1659/// optionally be designated to hold information about the source file
1660/// of each data point. This feature is enabled by giving the name
1661/// of the (already existing) category variable in `indexCatName`.
1662///
1663/// \attention If the value of any of the variables on a given line exceeds the
1664/// fit range associated with that dimension, the entire line will be
1665/// ignored. A warning message is printed in each case, unless the
1666/// `Q` verbose option is given. The number of events read and skipped
1667/// is always summarized at the end.
1668///
1669/// If no further information is given a label name 'fileNNN' will
1670/// be assigned to each event, where NNN is the sequential number of
1671/// the source file in `fileList`.
1672///
1673/// Alternatively, it is possible to override the default label names
1674/// of the index category by specifying them in the fileList string:
1675/// When instead of `file1.txt,file2.txt` the string
1676/// `file1.txt:FOO,file2.txt:BAR` is specified, a state named "FOO"
1677/// is assigned to the index category for each event originating from
1678/// file1.txt. The labels FOO,BAR may be predefined in the index
1679/// category via defineType(), but don't have to be.
1680///
1681/// Finally, one can also assign the same label to multiple files,
1682/// either by specifying `file1.txt:FOO,file2,txt:FOO,file3.txt:BAR`
1683/// or `file1.txt,file2.txt:FOO,file3.txt:BAR`.
1684///
1685
1686RooDataSet *RooDataSet::read(const char *fileList, const RooArgList &varList,
1687 const char *verbOpt, const char* commonPath,
1688 const char* indexCatName) {
1689 // Make working copy of variables list
1690 RooArgList variables(varList) ;
1691
1692 // Append blinding state category to variable list if not already there
1693 Bool_t ownIsBlind(kTRUE) ;
1694 RooAbsArg* blindState = variables.find("blindState") ;
1695 if (!blindState) {
1696 blindState = new RooCategory("blindState","Blinding State") ;
1697 variables.add(*blindState) ;
1698 } else {
1699 ownIsBlind = kFALSE ;
1700 if (blindState->IsA()!=RooCategory::Class()) {
1701 oocoutE((TObject*)0,DataHandling) << "RooDataSet::read: ERROR: variable list already contains"
1702 << "a non-RooCategory blindState member" << endl ;
1703 return 0 ;
1704 }
1705 oocoutW((TObject*)0,DataHandling) << "RooDataSet::read: WARNING: recycling existing "
1706 << "blindState category in variable list" << endl ;
1707 }
1708 RooCategory* blindCat = (RooCategory*) blindState ;
1709
1710 // Configure blinding state category
1711 blindCat->setAttribute("Dynamic") ;
1712 blindCat->defineType("Normal",0) ;
1713 blindCat->defineType("Blind",1) ;
1714
1715 // parse the option string
1716 TString opts= verbOpt;
1717 opts.ToLower();
1718 Bool_t verbose= !opts.Contains("q");
1719 Bool_t debug= opts.Contains("d");
1720
1721 RooDataSet *data= new RooDataSet("dataset", fileList, variables);
1722 if (ownIsBlind) { variables.remove(*blindState) ; delete blindState ; }
1723 if(!data) {
1724 oocoutE((TObject*)0,DataHandling) << "RooDataSet::read: unable to create a new dataset"
1725 << endl;
1726 return 0;
1727 }
1728
1729 // Redirect blindCat to point to the copy stored in the data set
1730 blindCat = (RooCategory*) data->_vars.find("blindState") ;
1731
1732 // Find index category, if requested
1733 RooCategory *indexCat = 0;
1734 //RooCategory *indexCatOrig = 0;
1735 if (indexCatName) {
1736 RooAbsArg* tmp = 0;
1737 tmp = data->_vars.find(indexCatName) ;
1738 if (!tmp) {
1739 oocoutE((TObject*)0,DataHandling) << "RooDataSet::read: no index category named "
1740 << indexCatName << " in supplied variable list" << endl ;
1741 return 0 ;
1742 }
1743 if (tmp->IsA()!=RooCategory::Class()) {
1744 oocoutE((TObject*)0,DataHandling) << "RooDataSet::read: variable " << indexCatName
1745 << " is not a RooCategory" << endl ;
1746 return 0 ;
1747 }
1748 indexCat = (RooCategory*)tmp ;
1749
1750 // Prevent RooArgSet from attempting to read in indexCat
1751 indexCat->setAttribute("Dynamic") ;
1752 }
1753
1754
1755 Int_t outOfRange(0) ;
1756
1757 // Make local copy of file list for tokenizing
1758 char fileList2[64000];
1759 strlcpy(fileList2, fileList, 64000);
1760
1761 // Loop over all names in comma separated list
1762 char *filename = strtok(fileList2,", ") ;
1763 Int_t fileSeqNum(0) ;
1764 while (filename) {
1765 // Determine index category number, if this option is active
1766 if (indexCat) {
1767
1768 // Find and detach optional file category name
1769 char *catname = strchr(filename,':') ;
1770
1771 if (catname) {
1772 // Use user category name if provided
1773 *catname=0 ;
1774 catname++ ;
1775
1776 const RooCatType* type = indexCat->lookupType(catname,kFALSE) ;
1777 if (type) {
1778 // Use existing category index
1779 indexCat->setIndex(type->getVal()) ;
1780 } else {
1781 // Register cat name
1782 indexCat->defineType(catname,fileSeqNum) ;
1783 indexCat->setIndex(fileSeqNum) ;
1784 }
1785 } else {
1786 // Assign autogenerated name
1787 char newLabel[128] ;
1788 snprintf(newLabel,128,"file%03d",fileSeqNum) ;
1789 if (indexCat->defineType(newLabel,fileSeqNum)) {
1790 oocoutE((TObject*)0,DataHandling) << "RooDataSet::read: Error, cannot register automatic type name " << newLabel
1791 << " in index category " << indexCat->GetName() << endl ;
1792 return 0 ;
1793 }
1794 // Assign new category number
1795 indexCat->setIndex(fileSeqNum) ;
1796 }
1797 }
1798
1799 oocoutI((TObject*)0,DataHandling) << "RooDataSet::read: reading file " << filename << endl ;
1800
1801 // Prefix common path
1802 TString fullName(commonPath) ;
1803 fullName.Append(filename) ;
1804 ifstream file(fullName) ;
1805
1806 if(!file.good()) {
1807 oocoutW((TObject*)0,DataHandling) << "RooDataSet::read: unable to open '"
1808 << filename << "', skipping" << endl;
1809 }
1810
1811// Double_t value;
1812 Int_t line(0) ;
1813 Bool_t haveBlindString(false) ;
1814
1815 while(file.good() && !file.eof()) {
1816 line++;
1817 if(debug) oocxcoutD((TObject*)0,DataHandling) << "reading line " << line << endl;
1818
1819 // process comment lines
1820 if (file.peek() == '#')
1821 {
1822 if(debug) oocxcoutD((TObject*)0,DataHandling) << "skipping comment on line " << line << endl;
1823 }
1824 else {
1825
1826 // Skip empty lines
1827 // if(file.peek() == '\n') { file.get(); }
1828
1829 // Read single line
1830 Bool_t readError = variables.readFromStream(file,kTRUE,verbose) ;
1831 data->_vars = variables ;
1832// Bool_t readError = data->_vars.readFromStream(file,kTRUE,verbose) ;
1833
1834 // Stop at end of file or on read error
1835 if(file.eof()) break ;
1836 if(!file.good()) {
1837 oocoutE((TObject*)0,DataHandling) << "RooDataSet::read(static): read error at line " << line << endl ;
1838 break;
1839 }
1840
1841 if (readError) {
1842 outOfRange++ ;
1843 continue ;
1844 }
1845 blindCat->setIndex(haveBlindString) ;
1846 data->fill(); // store this event
1847 }
1848 }
1849
1850 file.close();
1851
1852 // get next file name
1853 filename = strtok(0," ,") ;
1854 fileSeqNum++ ;
1855 }
1856
1857 if (indexCat) {
1858 // Copy dynamically defined types from new data set to indexCat in original list
1859 RooCategory* origIndexCat = (RooCategory*) variables.find(indexCatName) ;
1860 TIterator* tIter = indexCat->typeIterator() ;
1861 RooCatType* type = 0;
1862 while ((type=(RooCatType*)tIter->Next())) {
1863 origIndexCat->defineType(type->GetName(),type->getVal()) ;
1864 }
1865 }
1866 oocoutI((TObject*)0,DataHandling) << "RooDataSet::read: read " << data->numEntries()
1867 << " events (ignored " << outOfRange << " out of range events)" << endl;
1868 return data;
1869}
1870
1871
1872
1873
1874////////////////////////////////////////////////////////////////////////////////
1875/// Write the contents of this dataset to an ASCII file with the specified name.
1876/// Each event will be written as a single line containing the written values
1877/// of each observable in the order they were declared in the dataset and
1878/// separated by whitespaces
1879
1880Bool_t RooDataSet::write(const char* filename) const
1881{
1882 // Open file for writing
1883 ofstream ofs(filename) ;
1884 if (ofs.fail()) {
1885 coutE(DataHandling) << "RooDataSet::write(" << GetName() << ") cannot create file " << filename << endl ;
1886 return kTRUE ;
1887 }
1888
1889 // Write all lines as arglist in compact mode
1890 coutI(DataHandling) << "RooDataSet::write(" << GetName() << ") writing ASCII file " << filename << endl ;
1891 return write(ofs);
1892}
1893
1894////////////////////////////////////////////////////////////////////////////////
1895/// Write the contents of this dataset to the stream.
1896/// Each event will be written as a single line containing the written values
1897/// of each observable in the order they were declared in the dataset and
1898/// separated by whitespaces
1899
1900Bool_t RooDataSet::write(ostream & ofs) const {
1901 checkInit();
1902
1903 for (Int_t i=0; i<numEntries(); ++i) {
1904 get(i)->writeToStream(ofs,kTRUE);
1905 }
1906
1907 if (ofs.fail()) {
1908 coutW(DataHandling) << "RooDataSet::write(" << GetName() << "): WARNING error(s) have occured in writing" << endl ;
1909 }
1910
1911 return ofs.fail() ;
1912}
1913
1914
1915////////////////////////////////////////////////////////////////////////////////
1916/// Print info about this dataset to the specified output stream.
1917///
1918/// Standard: number of entries
1919/// Shape: list of variables we define & were generated with
1920
1921void RooDataSet::printMultiline(ostream& os, Int_t contents, Bool_t verbose, TString indent) const
1922{
1923 checkInit() ;
1925 if (_wgtVar) {
1926 os << indent << " Dataset variable \"" << _wgtVar->GetName() << "\" is interpreted as the event weight" << endl ;
1927 }
1928}
1929
1930
1931////////////////////////////////////////////////////////////////////////////////
1932/// Print value of the dataset, i.e. the sum of weights contained in the dataset
1933
1934void RooDataSet::printValue(ostream& os) const
1935{
1936 os << numEntries() << " entries" ;
1937 if (isWeighted()) {
1938 os << " (" << sumEntries() << " weighted)" ;
1939 }
1940}
1941
1942
1943
1944////////////////////////////////////////////////////////////////////////////////
1945/// Print argument of dataset, i.e. the observable names
1946
1947void RooDataSet::printArgs(ostream& os) const
1948{
1949 os << "[" ;
1951 RooAbsArg* arg ;
1952 Bool_t first(kTRUE) ;
1953 while((arg=(RooAbsArg*)iter->Next())) {
1954 if (first) {
1955 first=kFALSE ;
1956 } else {
1957 os << "," ;
1958 }
1959 os << arg->GetName() ;
1960 }
1961 if (_wgtVar) {
1962 os << ",weight:" << _wgtVar->GetName() ;
1963 }
1964 os << "]" ;
1965 delete iter ;
1966}
1967
1968
1969
1970////////////////////////////////////////////////////////////////////////////////
1971/// Change the name of this dataset into the given name
1972
1973void RooDataSet::SetName(const char *name)
1974{
1975 if (_dir) _dir->GetList()->Remove(this);
1977 if (_dir) _dir->GetList()->Add(this);
1978}
1979
1980
1981////////////////////////////////////////////////////////////////////////////////
1982/// Change the title of this dataset into the given name
1983
1984void RooDataSet::SetNameTitle(const char *name, const char* title)
1985{
1986 if (_dir) _dir->GetList()->Remove(this);
1987 TNamed::SetNameTitle(name,title) ;
1988 if (_dir) _dir->GetList()->Add(this);
1989}
1990
1991
1992////////////////////////////////////////////////////////////////////////////////
1993/// Stream an object of class RooDataSet.
1994
1995void RooDataSet::Streamer(TBuffer &R__b)
1996{
1997 if (R__b.IsReading()) {
1998
1999 UInt_t R__s, R__c;
2000 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
2001
2002 if (R__v>1) {
2003
2004 // Use new-style streaming for version >1
2005 R__b.ReadClassBuffer(RooDataSet::Class(),this,R__v,R__s,R__c);
2006
2007 } else {
2008
2009 // Legacy dataset conversion happens here. Legacy RooDataSet inherits from RooTreeData
2010 // which in turn inherits from RooAbsData. Manually stream RooTreeData contents on
2011 // file here and convert it into a RooTreeDataStore which is installed in the
2012 // new-style RooAbsData base class
2013
2014 // --- This is the contents of the streamer code of RooTreeData version 1 ---
2015 UInt_t R__s1, R__c1;
2016 Version_t R__v1 = R__b.ReadVersion(&R__s1, &R__c1); if (R__v1) { }
2017
2018 RooAbsData::Streamer(R__b);
2019 TTree* X_tree(0) ; R__b >> X_tree;
2020 RooArgSet X_truth ; X_truth.Streamer(R__b);
2021 TString X_blindString ; X_blindString.Streamer(R__b);
2022 R__b.CheckByteCount(R__s1, R__c1, RooTreeData::Class());
2023 // --- End of RooTreeData-v1 streamer
2024
2025 // Construct RooTreeDataStore from X_tree and complete initialization of new-style RooAbsData
2026 _dstore = new RooTreeDataStore(X_tree,_vars) ;
2027 _dstore->SetName(GetName()) ;
2029 _dstore->checkInit() ;
2030
2031 // This is the contents of the streamer code of RooDataSet version 1
2032 RooDirItem::Streamer(R__b);
2033 _varsNoWgt.Streamer(R__b);
2034 R__b >> _wgtVar;
2035 R__b.CheckByteCount(R__s, R__c, RooDataSet::IsA());
2036
2037
2038 }
2039 } else {
2041 }
2042}
2043
2044
2045
2046////////////////////////////////////////////////////////////////////////////////
2047/// Convert vector-based storage to tree-based storage. This implementation overrides the base class
2048/// implementation because the latter doesn't transfer weights.
2050{
2052 RooTreeDataStore *newStore = new RooTreeDataStore(GetName(), GetTitle(), _vars, *_dstore, nullptr, _wgtVar ? _wgtVar->GetName() : nullptr);
2053 delete _dstore;
2054 _dstore = newStore;
2056 }
2057}
2058
void Class()
Definition: Class.C:29
#define f(i)
Definition: RSha256.hxx:104
#define e(i)
Definition: RSha256.hxx:103
#define coutI(a)
Definition: RooMsgService.h:31
#define ccoutE(a)
Definition: RooMsgService.h:41
#define oocoutW(o, a)
Definition: RooMsgService.h:46
#define oocxcoutD(o, a)
Definition: RooMsgService.h:81
#define coutW(a)
Definition: RooMsgService.h:33
#define oocoutE(o, a)
Definition: RooMsgService.h:47
#define oocoutI(o, a)
Definition: RooMsgService.h:44
#define coutE(a)
Definition: RooMsgService.h:34
#define TRACE_DESTROY
Definition: RooTrace.h:23
#define TRACE_CREATE
Definition: RooTrace.h:22
int Int_t
Definition: RtypesCore.h:41
float Size_t
Definition: RtypesCore.h:83
short Version_t
Definition: RtypesCore.h:61
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassImp(name)
Definition: Rtypes.h:365
static void indent(ostringstream &buf, int indent_level)
char name[80]
Definition: TGX11.cxx:109
int type
Definition: TGX11.cxx:120
float type_of_call hi(const int &, const int &)
char * Form(const char *fmt,...)
TString operator+(const TString &s1, const TString &s2)
Use the special concatenation constructor.
Definition: TString.cxx:1474
#define snprintf
Definition: civetweb.c:1540
Memory pool for RooArgSet and RooDataSet.
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:70
void attachToStore(RooAbsDataStore &store)
Definition: RooAbsArg.cxx:2280
Bool_t redirectServers(const RooAbsCollection &newServerList, Bool_t mustReplaceAll=kFALSE, Bool_t nameChange=kFALSE, Bool_t isRecursionStep=kFALSE)
Substitute our servers with those listed in newSet.
Definition: RooAbsArg.cxx:906
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:729
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
Definition: RooAbsArg.h:82
void setAttribute(const Text_t *name, Bool_t value=kTRUE)
Set (default) or clear a named boolean attribute of this object.
Definition: RooAbsArg.cxx:256
TIterator * typeIterator() const
Return iterator over all defined states.
const RooCatType * lookupType(Int_t index, Bool_t printError=kFALSE) const
Find our type corresponding to the specified index, or return 0 for no match.
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
RooAbsCollection * selectCommon(const RooAbsCollection &refColl) const
Create a subset of the current collection, consisting only of those elements that are contained as we...
void assignFast(const RooAbsCollection &other, Bool_t setValDirty=kTRUE)
Functional equivalent of operator=() but assumes this and other collection have same layout.
Bool_t allInRange(const char *rangeSpec) const
Return true if all contained object report to have their value inside the specified range.
void setAttribAll(const Text_t *name, Bool_t value=kTRUE)
Set given attribute in each element of the collection by calling each elements setAttribute() functio...
TIterator * createIterator(Bool_t dir=kIterForward) const R__SUGGEST_ALTERNATIVE("begin()
TIterator-style iteration over contained elements.
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
RooAbsArg * find(const char *name) const
Find object with given name in list.
RooAbsDataStore is the abstract base class for data collection that use a TTree as internal storage m...
const RooArgSet & cachedVars() const
virtual void append(RooAbsDataStore &other)=0
virtual Double_t sumEntries() const
Bool_t dirtyProp() const
virtual void checkInit() const
virtual void loadValues(const RooAbsDataStore *tds, const RooFormulaVar *select=0, const char *rangeName=0, Int_t nStart=0, Int_t nStop=2000000000)=0
virtual Double_t weight() const =0
virtual Double_t weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const =0
virtual RooAbsDataStore * merge(const RooArgSet &allvars, std::list< RooAbsDataStore * > dstoreList)=0
virtual RooArgSet * addColumns(const RooArgList &varList)=0
virtual Bool_t isWeighted() const =0
virtual RooAbsArg * addColumn(RooAbsArg &var, Bool_t adjustRange=kTRUE)=0
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:37
virtual const RooArgSet * get() const
Definition: RooAbsData.h:80
RooAbsDataStore * store()
Definition: RooAbsData.h:56
void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Interface for detailed printing of object.
Definition: RooAbsData.cxx:807
void checkInit() const
static StorageType defaultStorageType
Definition: RooAbsData.h:225
void addOwnedComponent(const char *idxlabel, RooAbsData &data)
virtual void fill()
Definition: RooAbsData.cxx:299
RooArgSet _vars
Definition: RooAbsData.h:260
virtual void attachCache(const RooAbsArg *newOwner, const RooArgSet &cachedVars)
Internal method – Attach dataset copied with cache contents to copied instances of functions.
Definition: RooAbsData.cxx:346
RooArgSet _cachedVars
Definition: RooAbsData.h:261
virtual Int_t numEntries() const
Definition: RooAbsData.cxx:306
StorageType storageType
Definition: RooAbsData.h:227
RooAbsDataStore * _dstore
External variables cached with this data set.
Definition: RooAbsData.h:263
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
virtual Double_t getMax(const char *name=0) const
Get maximum of currently defined range.
virtual Int_t getBins(const char *name=0) const
Get number of bins of currently defined range.
virtual Double_t getMin(const char *name=0) const
Get miniminum of currently defined range.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition: RooAbsReal.h:81
RooAbsArg * createFundamental(const char *newname=0) const
Create a RooRealVar fundamental object with our properties.
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:21
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
virtual Bool_t addOwned(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling addOwned() for each element in the source...
Definition: RooArgSet.h:92
virtual void writeToStream(std::ostream &os, Bool_t compact, const char *section=0) const
Write the contents of the argset in ASCII form to given stream.
Definition: RooArgSet.cxx:686
virtual Bool_t add(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling add() for each element in the source coll...
Definition: RooArgSet.h:88
virtual void addClone(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling addOwned() for each element in the source...
Definition: RooArgSet.h:96
RooCatType is an auxilary class for RooAbsCategory and defines a a single category state.
Definition: RooCatType.h:22
RooCategory represents a fundamental (non-derived) discrete value object.
Definition: RooCategory.h:24
virtual const char * getLabel() const
Return label string of current state.
Definition: RooCategory.h:39
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...
Bool_t defineType(const char *label)
Define a state with given name, the lowest available positive integer is assigned as index.
virtual Bool_t setIndex(Int_t index, Bool_t printError=kTRUE)
Set value by specifying the index code of the desired state.
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Definition: RooCmdArg.h:27
Class RooCmdConfig is a configurable parser for RooCmdArg named arguments.
Definition: RooCmdConfig.h:27
RooCompositeDataStore combines several disjunct datasets into one.
The RooDataHist is a container class to hold N-dimensional binned data.
Definition: RooDataHist.h:40
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:31
virtual void printArgs(std::ostream &os) const
Print argument of dataset, i.e. the observable names.
RooRealVar * _wgtVar
Definition: RooDataSet.h:158
virtual Double_t sumEntries() const
bool _doWeightErrorCheck
Counter to silence error messages when filling dataset.
Definition: RooDataSet.h:166
static void cleanup()
Definition: RooDataSet.cxx:91
RooArgSet _varsNoWgt
Definition: RooDataSet.h:157
RooAbsData * reduceEng(const RooArgSet &varSubset, const RooFormulaVar *cutVar, const char *cutRange=0, Int_t nStart=0, Int_t nStop=2000000000, Bool_t copyCache=kTRUE)
Implementation of RooAbsData virtual method that drives the RooAbsData::reduce() methods.
Definition: RooDataSet.cxx:918
virtual void weightError(Double_t &lo, Double_t &hi, ErrorType etype=SumW2) const
Return asymmetric error on weight. (Dummy implementation returning zero)
Definition: RooDataSet.cxx:998
virtual RooAbsArg * addColumn(RooAbsArg &var, Bool_t adjustRange=kTRUE)
Add a column with the values of the given (function) argument to this dataset.
virtual Double_t weight() const
Return event weight of current event.
Definition: RooDataSet.cxx:977
virtual Bool_t isWeighted() const
Return true if dataset contains weighted events.
void SetName(const char *name)
Change the name of this dataset into the given name.
Bool_t write(const char *filename) const
Write the contents of this dataset to an ASCII file with the specified name.
virtual Bool_t isNonPoissonWeighted() const
Returns true if histogram contains bins with entries with a non-integer weight.
RooArgSet addWgtVar(const RooArgSet &origVars, const RooAbsArg *wgtVar)
Helper function for constructor that adds optional weight variable to construct total set of observab...
Definition: RooDataSet.cxx:834
void initialize(const char *wgtVarName)
Initialize the dataset.
Definition: RooDataSet.cxx:893
MemPoolForRooSets< RooDataSet, 5 *150 > MemPool
Definition: RooDataSet.h:162
virtual Double_t weightSquared() const
Return event weight of current event.
Definition: RooDataSet.cxx:988
void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Print info about this dataset to the specified output stream.
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 SetNameTitle(const char *name, const char *title)
Change the title of this dataset into the given name.
static RooDataSet * read(const char *filename, const RooArgList &variables, const char *opts="", const char *commonPath="", const char *indexCatName=0)
Read given list of ascii files, and construct a data set, using the given ArgList as structure defini...
TH2F * createHistogram(const RooAbsRealLValue &var1, const RooAbsRealLValue &var2, const char *cuts="", const char *name="hist") const
Create a TH2F histogram of the distribution of the specified variable using this dataset.
virtual RooArgSet * addColumns(const RooArgList &varList)
Add a column with the values of the given list of (function) argument to this dataset.
void convertToTreeStore()
Convert vector-based storage to tree-based storage.
virtual void printValue(std::ostream &os) const
Print value of the dataset, i.e. the sum of weights contained in the dataset.
void append(RooDataSet &data)
Add all data points of given data set to this data set.
RooDataSet()
Default constructor for persistence.
Definition: RooDataSet.cxx:150
Bool_t merge(RooDataSet *data1, RooDataSet *data2=0, RooDataSet *data3=0, RooDataSet *data4=0, RooDataSet *data5=0, RooDataSet *data6=0)
virtual RooAbsData * emptyClone(const char *newName=0, const char *newTitle=0, const RooArgSet *vars=0, const char *wgtVarName=0) const
Return an empty clone of this dataset.
Definition: RooDataSet.cxx:864
virtual ~RooDataSet()
Destructor.
Definition: RooDataSet.cxx:944
unsigned short _errorMsgCount
Definition: RooDataSet.h:165
RooDataHist * binnedClone(const char *newName=0, const char *newTitle=0) const
Return binned clone of this dataset.
Definition: RooDataSet.cxx:955
virtual void addFast(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.
static MemPool * memPool()
virtual const RooArgSet * get() const
Return a RooArgSet with the coordinates of the current event.
virtual RooAbsData * cacheClone(const RooAbsArg *newCacheOwner, const RooArgSet *newCacheVars, const char *newName=0)
Return a clone of this dataset containing only the cached variables.
Definition: RooDataSet.cxx:846
virtual RooPlot * plotOnXY(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
Special plot method for 'X-Y' datasets used in fitting.
RooDirItem is a utility base class for RooFit objects that are to be attached to ROOT directories.
Definition: RooDirItem.h:22
void appendToDir(TObject *obj, Bool_t forceMemoryResident=kFALSE)
Append object to directory.
Definition: RooDirItem.cxx:86
void removeFromDir(TObject *obj)
Remove object from directory it was added to.
Definition: RooDirItem.cxx:71
TDirectory * _dir
Definition: RooDirItem.h:33
A RooFormulaVar is a generic implementation of a real-valued object, which takes a RooArgList of serv...
Definition: RooFormulaVar.h:27
RooFormula an implementation of ROOT::v5::TFormula that interfaces it to RooAbsArg value objects.
Definition: RooFormula.h:27
Bool_t ok()
Definition: RooFormula.h:50
Double_t eval(const RooArgSet *nset=0)
Evaluate ROOT::v5::TFormula using given normalization set to be used as observables definition passed...
Definition: RooFormula.cxx:234
A RooHist is a graphical representation of binned data based on the TGraphAsymmErrors class.
Definition: RooHist.h:26
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
Definition: RooLinkedList.h:36
TIterator * MakeIterator(Bool_t forward=kTRUE) const
Create a TIterator for this list.
virtual void Add(TObject *arg)
Definition: RooLinkedList.h:63
A RooPlot is a plot frame and a container for graphics objects within that frame.
Definition: RooPlot.h:41
RooAbsRealLValue * getPlotVar() const
Definition: RooPlot.h:132
void addPlotable(RooPlotable *plotable, Option_t *drawOptions="", Bool_t invisible=kFALSE, Bool_t refreshNorm=kFALSE)
Add the specified plotable object to our plot.
Definition: RooPlot.cxx:446
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:36
Double_t getErrorHi() const
Definition: RooRealVar.h:64
Double_t getErrorLo() const
Definition: RooRealVar.h:63
void removeAsymError()
Definition: RooRealVar.h:61
void setError(Double_t value)
Definition: RooRealVar.h:56
void setAsymError(Double_t lo, Double_t hi)
Definition: RooRealVar.h:62
void removeError()
Definition: RooRealVar.h:57
virtual void setVal(Double_t value)
Set value of variable to 'value'.
Definition: RooRealVar.cxx:233
static void activate()
Install atexit handler that calls CleanupRooFitAtExit() on program termination.
Definition: RooSentinel.cxx:73
RooTreeDataStore is a TTree-backed data storage.
void loadValues(const TTree *t, const RooFormulaVar *select=0, const char *rangeName=0, Int_t nStart=0, Int_t nStop=2000000000)
Load values from tree 't' into this data collection, optionally selecting events using 'select' RooFo...
RooVectorDataStore is the abstract base class for data collection that use a TTree as internal storag...
Buffer base class used for serializing objects.
Definition: TBuffer.h:42
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
Bool_t IsReading() const
Definition: TBuffer.h:85
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
virtual TList * GetList() const
Definition: TDirectory.h:154
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:48
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseGeneralPurpose, Int_t netopt=0)
Create / open a file.
Definition: TFile.cxx:3980
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:248
Int_t Fill(Double_t)
Invalid Fill method.
Definition: TH2.cxx:292
Iterator abstract base class.
Definition: TIterator.h:30
virtual TObject * Next()=0
virtual void Add(TObject *obj)
Definition: TList.h:87
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:819
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
TString fName
Definition: TNamed.h:32
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
virtual void SetNameTitle(const char *name, const char *title)
Set all the TNamed parameters (name and title).
Definition: TNamed.cxx:154
Mother of all ROOT objects.
Definition: TObject.h:37
Basic string class.
Definition: TString.h:131
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1125
const char * Data() const
Definition: TString.h:364
TString & Prepend(const char *cs)
Definition: TString.h:656
TString & Append(const char *cs)
Definition: TString.h:559
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:619
A TTree represents a columnar dataset.
Definition: TTree.h:71
TLine * line
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
@ DataHandling
Definition: RooGlobalFunc.h:59
@ InputArguments
Definition: RooGlobalFunc.h:58
static constexpr double pc
void variables(TString dataset, TString fin="TMVA.root", TString dirName="InputVariables_Id", TString title="TMVA Input Variables", Bool_t isRegression=kFALSE, Bool_t useTMVAStyle=kTRUE)
Definition: file.py:1
Definition: first.py:1
Definition: graph.py:1
auto * l
Definition: textangle.C:4