GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DoMyTree.C
Go to the documentation of this file.
1 
2 // ROOT includes
3 #include "TROOT.h"
4 
5 // Gammaware and ADF related
6 #include "RootAFP.h"
7 #include "FrameDispatcher.h"
8 #include "MyTree.h"
9 
10 // the emulator (better to keep this include as the last include ...)
11 #include "Emulator.h"
12 
13 using namespace Gw;
14 using namespace ADF;
15 
16 void DoMyTree(TFile *file = 0x0)
17 {
18  // MainDir is the top dir to organise histograms in subdirectories
19  // each one being attached to a given task.
20  // Warning, a Watcher creates a new root directory (in the constructor) in the current directory
21  // if you want to keep the same tree structures as for directories,
22  // before allocating a new Watcher, think to set correctly its parent directory
23  // see for instance mainADF->GetDirectory()->cd();
24  TDirectory *MainDir = gROOT;
25  if ( file )
26  MainDir = file;
27 
28  // chain a producer and a FrameDispacher to which Watchers are attached
30 
31  if ( ! emulator.Init() ) {
32  std::cout << "Cannot Init emulator" << std::endl; return;
33  }
34 
35  MainDir->cd();
36  // build a trigger and add it to the dispatcher
37  // BE carefull to have all the Frame defined
38  AgataFrameTrigger *trig = AgataFrameTrigger::Build("FullEvent", "event:data event:data:psa data:tracked data:ranc1");
39  emulator.GetConsumer()->SetTrigger(trig);
40 
41  // create a TreeMaster which takes care of the TTree part
42  // It opens a root file (TreeMaster.root), build a tree and call Fill in the Exec method
43  TTreeMaster *rootmaster = emulator.GetConsumer()->Add<TTreeMaster>("TreeMaster","Own the tree");
44  // to this tree, add a watcher which adds branches and takes cares to fill them
45  rootmaster->Add<DoMyKeyTree>("KeyTree","Branch on event number and timestam");
46  rootmaster->Add<DoMyRawAncillaryTree>("RawAncTree","Branch on ancillary");
47  rootmaster->Add<DoMyHitTree>("HitTree","Branch on hits");
48  rootmaster->Add<DoMyTrackTree>("TrackTree","Branch on track");
49 
50  // run
51  emulator.Run();
52 }
53 
54 #if !defined(__CINT__)
55 int main(int argc, char **argv)
56 {
57  // run your analysis on it
58  DoMyTree();
59 
60  return 1;
61 }
62 #endif
63 
virtual Bool_t Run(UInt_t max_loop=kMaxUInt_t)
loop
built a root tree for the tracked part
Definition: MyTree.h:162
built a root tree for the ancillary part
Definition: MyTree.h:78
Watcher_T * Add(const Char_t *name, const Char_t *title, Short_t do_spectra, Short_t do_tree)
Allocate a watcher in charge of filling one part of the tree ==> Should inherits from TreeBuilder...
virtual Bool_t SetTrigger(ADF::DFTrigger *)
This is the default trigger for any added watcher.
Cons_actor * GetConsumer()
Watcher_T * Add(const Char_t *name, const Char_t *title, ADF::DFTrigger *t=0x0)
allocate a new watcher so that it creates corectly its directory under the dispatcher directory ...
built a root tree for the tracked part
Definition: MyTree.h:125
To be used for Agata Data Flow.
Definition: Trigger.h:462
built a tree with the event # and the timestamp of the main Frame
Definition: MyTree.h:43
int main(int argc, char **argv)
Definition: DoMyTree.C:55
virtual Bool_t Init(const Char_t *rootafp)
Init the emulator using a different root afp file for the producer.
header file for RootAFP.cpp
Watcher to build a tree with branches processed in several watchers.
ADF::LogMessage & endl(ADF::LogMessage &log)
void DoMyTree(TFile *file=0x0)
Definition: DoMyTree.C:16