eventAnalysis  7.0-49-g0ac7482
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
TAnalysisModuleBase.cxx
Go to the documentation of this file.
2 #include <TObjString.h>
3 
5  fFilledConfigTree(kFALSE),
6  fIsEnabled(kFALSE),
7  fIsUsedForPreselection(kFALSE),
8  fOutputTree(NULL),
9  fBufferSize(32000),
10  fSplitLevel(99),
11  fDescription("Undefined"),
12  fCVSTagName("Undefined: Problem in derived class!"),
13  fCVSID("Undefined: Problem in derived class!") {}
14 
16 
17 Bool_t ND::TAnalysisModuleBase::Configure(std::string& option) {
18  ND280Error("No configurable options defined for this class");
19  return kFALSE;
20 }
21 
22 std::string const ND::TAnalysisModuleBase::GetDirectoryName() const {
23  switch (GetTreeType()) {
24  case kHeader:
25  return "HeaderDir";
26  case kTruth:
27  return "TruthDir";
28  case kRecon:
29  return "ReconDir";
30  case kLowLevel:
31  return "LowLevelDir";
32  default:
33  throw ND::EUndefinedTreeType();
34  }
35 }
36 
38  fOutputTree = tree;
39 
40  // Fix to bug 386
41  fOutputTree->SetAutoFlush(3000000);
42 
43  InitializeModule();
44  fOutputTree->Branch("RunID", &fRunID, "RunID/I", fBufferSize);
45  fOutputTree->Branch("EventID", &fEventID, "EventID/I", fBufferSize);
46  fOutputTree->Branch("Preselected", &fPreselected, "Preselected/B",
47  fBufferSize);
48  fOutputTree->Branch("SubrunID", &fSubrunID, "SubrunID/I", fBufferSize);
49  InitializeBranches();
50 }
51 
53 
54  if(fFilledConfigTree){
55  ND280NamedWarn("TAnalysisModuleBase", "Module: " << this->GetName()
56  << " has already written the config tree this run.");
57  }
58 
59  TObjString * Description = 0;
60  TObjString * CVSTagName = 0;
61  TObjString * CVSID = 0;
62 
63  configTree->Branch("IsUsedForPreselection", &fIsUsedForPreselection,
64  "IsUsedForPreselection/O");
65  configTree->Branch("Description", &Description);
66  configTree->Branch("CVSTagName", &CVSTagName);
67  configTree->Branch("CVSID", &CVSID);
68 
69  (*Description) = fDescription.c_str();
70  (*CVSTagName) = fCVSTagName.c_str();
71  (*CVSID) = fCVSID.c_str();
72 
73  configTree->Fill();
74  fFilledConfigTree = true;
75 }
76 
77 bool ND::TAnalysisModuleBase::Process(ND::TND280Event& event) {
78  fRunID = event.GetRunId();
79  fEventID = event.GetEventId();
80  fSubrunID = event.GetContext().GetSubRun();
81  fIsMC = event.GetContext().IsMC();
82  if (!FillTree(event)) {
83  throw EAnalysisFailure();
84  }
85  fPreselected = IsFullEventWorthSaving(event);
86  fOutputTree->Fill();
87  return fPreselected;
88 }
89 
91  return false; // Do not save the main event tree entry by default, just the
92  // analysis one
93 }
94 
96  return true;
97 }
98 
100  // override this function if more details need to be printed out
101  ND280Log("Module: " << GetName()
102  << (IsEnabled() ? " (Enabled) " : " (Disabled) ")
103  << (IsUsedForPreselection() ? " (Preselecting) "
104  : " (Not Preselecting) "));
105  ND280Log("Description: " << GetDescription());
106 }
107 
109  char const* title) {
110  fName = name;
111  fTitle = title;
112 }
113 
115  return fName.c_str();
116 }
117 
119  return fTitle.c_str();
120 }
virtual void Print()
Prints a simple message describing the module.
virtual bool Process(ND::TND280Event &event)
Gets the run and event IDs and calls FillTree with the event, and then actually calls fOutputTree-&gt;Fi...
#define CVSID
virtual bool IsFullEventWorthSaving(ND::TND280Event &event)
Whether the module thinks it is worth saving the entire oaEvent event tree entry for this event...
virtual Bool_t Configure(std::string &option)
A function that allows the module to be configured from an external class without any dependencies...
std::string const GetDirectoryName() const
Returns the name of the directory which the output of a particular module will be saved in...
void SetNameTitle(char const *name, char const *title)
virtual Bool_t ProcessFirstEvent(ND::TND280Event &)=0
Is called after the first event is loaded in.
virtual void FillConfigTree(TTree *)

Package Summary
Package Name: eventAnalysis
Package Version: 7.0-49-g0ac7482
Package Manager:

Generated on Mon Mar 25 2024 14:43:58 for eventAnalysis by doxygen 1.8.5