40 TString* fSubEventTag;
46 Int_t fSetObservableCalls = 0;
47 Int_t fSetObservableIndex = 0;
48 Bool_t fQuickSetObservableValue =
true;
49 std::vector<RESTValue> fObservables;
50 std::map<std::string, int> fObservableIdMap;
51 std::map<std::string, int> fObservableIdSearchMap;
56 std::vector<TString> fObservableNames;
57 std::vector<TString> fObservableDescriptions;
58 std::vector<TString> fObservableTypes;
64 void InitObservables();
66 void ReadLeafValueToObservable(TLeaf* lf,
RESTValue& obs);
67 bool BranchesExist() {
return GetListOfBranches()->GetEntriesFast() > 0; }
104 inline int GetStatus()
const {
return fStatus; }
110 Int_t GetSubEventID() {
113 Double_t GetTimeStamp() {
116 TString GetSubEventTag() {
121 Int_t GetRunOrigin() {
return fRunOrigin; }
122 Int_t GetSubRunOrigin() {
return fSubRunOrigin; }
126 RESTValue GetObservable(
const std::string& obsName);
141 std::cout <<
"Error! TRestAnalysisTree::GetObservableValue(): index outside limits!" << std::endl;
142 return std::numeric_limits<T>::quiet_NaN();
147 return fObservables[n].GetValue<T>();
164 return std::numeric_limits<T>::quiet_NaN();
167 return GetObservableValue<T>(
id);
176 std::cout <<
"Error! TRestAnalysisTree::SetObservableValue(): index outside limits!" << std::endl;
180 std::cout <<
"Error! cannot set observable! AnalysisTree is in chain state" << std::endl;
183 fObservables[id].SetValue(value);
225 if (fQuickSetObservableValue && fStatus == Filled && fSetObservableCalls ==
fNObservables) {
227 fSetObservableIndex++;
235 AddObservable<T>(name);
239 fSetObservableCalls++;
247 void PrintObservables();
248 void PrintObservable(
int N);
250 void SetRunOrigin(Int_t run_origin) { fRunOrigin = run_origin; }
251 void SetSubRunOrigin(Int_t sub_run_origin) { fSubRunOrigin = sub_run_origin; }
257 RESTValue AddObservable(
const TString& observableName,
const TString& observableType =
"double",
258 const TString& description =
"");
259 template <
typename T>
260 T& AddObservable(TString observableName, TString description =
"") {
261 return *(T*)AddObservable(observableName, REST_Reflection::GetTypeName<T>(), description);
264 Int_t GetEntry(Long64_t entry = 0, Int_t getall = 0);
282 Double_t GetIntegral(
const TString& obsName, Double_t xLow = -1, Double_t xHigh = -1) {
286 Double_t GetAverage(
const TString& obsName, Double_t xLow = -1, Double_t xHigh = -1) {
290 Double_t GetRMS(
const TString& obsName, Double_t xLow = -1, Double_t xHigh = -1) {
294 Double_t GetMinimum(
const TString& obsName, Double_t xLow = -1, Double_t xHigh = -1) {
298 Double_t GetMaximum(
const TString& obsName, Double_t xLow = -1, Double_t xHigh = -1) {
302 Double_t GetContour(
const TString& obsName,
const TString& obsIndexer, Double_t level = 0.5,
303 Int_t nBins = -1, Double_t xLow = -1, Double_t xHigh = -1) {
311 Double_t
GetObservableRMS(
const TString& obsName, Double_t xLow = -1, Double_t xHigh = -1);
316 Double_t
GetObservableContour(
const TString& obsName,
const TString& obsIndexer, Double_t level = 0.5,
317 Int_t nBins = -1, Double_t xLow = -1, Double_t xHigh = -1);
319 Int_t
WriteAsTTree(
const char* name = 0, Int_t option = 0, Int_t bufsize = 0);
325 TChain* GetChain() {
return fChain; }
329 Long64_t GetEntries()
const;
331 Long64_t GetEntries(
const char* sel);
333 void Browse(TBrowser* b) {
fChain ?
fChain->Browse(b) : TTree::Browse(b); }
334 Long64_t Draw(
const char* varexp,
const TCut& selection, Option_t* option =
"",
335 Long64_t nentries = kMaxEntries, Long64_t firstentry = 0) {
336 return fChain ?
fChain->Draw(varexp, selection, option, nentries, firstentry)
337 : TTree::Draw(varexp, selection, option, nentries, firstentry);
339 Long64_t Draw(
const char* varexp,
const char* selection, Option_t* option =
"",
340 Long64_t nentries = kMaxEntries, Long64_t firstentry = 0) {
341 return fChain ?
fChain->Draw(varexp, selection, option, nentries, firstentry)
342 : TTree::Draw(varexp, selection, option, nentries, firstentry);
344 void Draw(Option_t* opt) {
fChain ?
fChain->Draw(opt) : TTree::Draw(opt); }
345 TBranch* FindBranch(
const char* name) {
346 return fChain ?
fChain->FindBranch(name) : TTree::FindBranch(name);
348 TLeaf* FindLeaf(
const char* name) {
return fChain ?
fChain->FindLeaf(name) : TTree::FindLeaf(name); }
349 TBranch* GetBranch(
const char* name) {
return fChain ?
fChain->GetBranch(name) : TTree::GetBranch(name); }
350 Bool_t GetBranchStatus(
const char* branchname)
const {
351 return fChain ?
fChain->GetBranchStatus(branchname) : TTree::GetBranchStatus(branchname);
353 Long64_t GetCacheSize()
const {
return fChain ?
fChain->GetCacheSize() : TTree::GetCacheSize(); }
354 Long64_t GetChainEntryNumber(Long64_t entry)
const {
355 return fChain ?
fChain->GetChainEntryNumber(entry) : TTree::GetChainEntryNumber(entry);
357 Long64_t GetEntryNumber(Long64_t entry)
const {
358 return fChain ?
fChain->GetEntryNumber(entry) : TTree::GetEntryNumber(entry);
360 Long64_t GetReadEntry()
const {
return fChain ?
fChain->GetReadEntry() : TTree::GetReadEntry(); }
362 TH1* GetHistogram() {
return fChain ?
fChain->GetHistogram() : TTree::GetHistogram(); }
363 TLeaf* GetLeaf(
const char* branchname,
const char* leafname) {
364 return fChain ?
fChain->GetLeaf(branchname, leafname) : TTree::GetLeaf(branchname, leafname);
366 TLeaf* GetLeaf(
const char* name) {
return fChain ?
fChain->GetLeaf(name) : TTree::GetLeaf(name); }
367 TObjArray* GetListOfBranches() {
368 return fChain ?
fChain->GetListOfBranches() : TTree::GetListOfBranches();
370 TObjArray* GetListOfLeaves() {
return fChain ?
fChain->GetListOfLeaves() : TTree::GetListOfLeaves(); }
371 Long64_t Process(
const char* filename, Option_t* option =
"", Long64_t nentries = kMaxEntries,
372 Long64_t firstentry = 0) {
373 return fChain ?
fChain->Process(filename, option, nentries, firstentry)
374 : TTree::Process(filename, option, nentries, firstentry);
376 Long64_t Process(TSelector* selector, Option_t* option =
"", Long64_t nentries = kMaxEntries,
377 Long64_t firstentry = 0) {
378 return fChain ?
fChain->Process(selector, option, nentries, firstentry)
379 : TTree::Process(selector, option, nentries, firstentry);
381 Long64_t Scan(
const char* varexp =
"",
const char* selection =
"", Option_t* option =
"",
382 Long64_t nentries = kMaxEntries, Long64_t firstentry = 0) {
383 return fChain ?
fChain->Scan(varexp, selection, option, nentries, firstentry)
384 : TTree::Scan(varexp, selection, option, nentries, firstentry);
386 Int_t SetBranchAddress(
const char* bname,
void* add, TBranch** ptr = 0) {
387 return fChain ?
fChain->SetBranchAddress(bname, add, ptr) : TTree::SetBranchAddress(bname, add, ptr);
389 Int_t SetBranchAddress(
const char* bname,
void* add, TBranch** ptr, TClass* realClass, EDataType datatype,
391 return fChain ?
fChain->SetBranchAddress(bname, add, ptr, realClass, datatype, isptr)
392 : TTree::SetBranchAddress(bname, add, ptr, realClass, datatype, isptr);
394 Int_t SetBranchAddress(
const char* bname,
void* add, TClass* realClass, EDataType datatype,
396 return fChain ?
fChain->SetBranchAddress(bname, add, realClass, datatype, isptr)
397 : TTree::SetBranchAddress(bname, add, realClass, datatype, isptr);
399 void SetBranchStatus(
const char* bname, Bool_t status = 1, UInt_t* found = 0) {
400 fChain ?
fChain->SetBranchStatus(bname, status, found) : TTree::SetBranchStatus(bname, status, found);
402 void SetDirectory(TDirectory* dir) {
fChain ?
fChain->SetDirectory(dir) : TTree::SetDirectory(dir); }
404 void ResetBranchAddress(TBranch* br) {
405 fChain ?
fChain->ResetBranchAddress(br) : TTree::ResetBranchAddress(br);
407 void ResetBranchAddresses() {
fChain ?
fChain->ResetBranchAddresses() : TTree::ResetBranchAddresses(); }