GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DoExTracking.C
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2010 by Olivier Stezowski *
3  * stezow(AT)ipnl.in2p3.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
21 // ROOT includes
22 #include "TROOT.h"
23 #include "WatchersConfig.h"
24 
25 #include "AGAPROConfig.h" // defines for your system is set there by cmake
26 
27 // Gw and Watchers
28 #include "RootAFP.h"
29 #include "FrameDispatcher.h"
30 
31 #include "EmulatorControl.h"
32 #include "Emulator.h"
33 #include "GSIOnlySetup.C"
34 
35  #include "DEmulator.h"
36 
37 
38 #include "TrackingFilterOFT.h"
39 
40 #include "ExTracking.h"
41 #include "ExTracking.C"
42 
43 using namespace Gw;
44 using namespace ADF;
45 
47 /*
48  An emulator is composed of producer that reads data from .adf files
49  and send the buffer to an FrameDispatcher.
50 
51  Watchers, in which the analysis is done are attached to the FrameDispatcher.
52 
53  Watchers are added to the FrameDispacher using the SetupWatcher function
54  that is in the SetupWtachers.C (in order to be shared with other macros see OnlineWatchers examples)
55 
56  Of course one can define everything in a single macro like it is done in DoMyTree.
57 
58  @author O.Stezowski
59 
60 */
61 void DoExTracking(TFile *file = 0x0)
62 {
63  // MainDir is the top dir to organise histograms in subdirectories
64  // each one being attached to a given task.
65  // Warning, a Watcher creates a new root directory (in the constructor) in the current directory
66  // if you want to keep the same tree structures as for directories,
67  // before allocating a new Watcher, think to set correctly its parent directory
68  // see for instance mainADF->GetDirectory()->cd();
69  TDirectory *MainDir = gROOT;
70  if ( file )
71  MainDir = file;
72 
73  // Emulator is a chain of a NOMADFile, a NOMADFilter and a FrameDispacher to which Watchers are attached
74  DEmulator *emulator = new DEmulator();
75 
76  emulator->SetGlobal ( NamedItem<Short_t>("Generation",0) );
77 
78  // customization of the emulator
79  emulator->Add<RootAFP>("-","Producer");
80  //
81  emulator->SetGlobal ( NamedItem<UInt_t>("SizeDataBlockC",aMByte) );
82  emulator->Add<ExTracking>("Producer","Calib");
83  //
84  emulator->SetGlobal ( NamedItem<UInt_t>("SizeDataBlockC",5*aMByte) );
85  // emulator.Add<BlackHole>("Calib","Watchers");
86  emulator->Add<FrameDispatcher>("Calib","Watchers");
87  // Create all actors in the topology
88  emulator->Init() ;
89 
90  FrameDispatcher *d =
91  emulator->GetActorByName<FrameDispatcher>("Watchers");
92  d->SetDirectory(MainDir, MainDir);
93 
94  // chain a producer a filter and a consume which is a FrameDispacher to which Watchers are attached
95  /*
96 // EmulatorPFC<RootAFP,TrackingFilterOFT,FrameDispatcher> emulator("./");
97 // EmulatorPFC<RootAFP,ExTracking,FrameDispatcher> emulator("./");
98  EmulatorPFC<RootAFP,ExTracking,FrameDispatcher> emulator("./");
99 
100  if ( ! emulator.Init() ) {
101  std::cout << "Cannot Init emulator" << std::endl;
102  return;
103  }
104  else
105  emulator.GetConsumer()->SetDirectory(MainDir,MainDir); */
106 
107  // add watchers to the dispatcher
108  // watchers on the key part
109  SetupWatchers("ADF",d);
110  // watcher on track
111  // SetupWatchers("TRACKING",emulator.GetConsumer());
112 
113  // run
114  emulator->Run();
115  // displays statistics and keeps all histograms
116  d->GetFrameIO().Print();
117 
118  // write all the spectra produced by the different watchers in a root file
119  MainDir->Write();
120 }
121 
122 #if !defined(__CINT__)
123 int main(int argc, char **argv)
124 {
125  // a new root file is created
126  TFile f("Offline.root","RECREATE");
127  // run your analysis on it
128  DoExTracking(&f);
129 
130  return 1;
131 }
132 #endif
133 
134 
135 
virtual void SetGlobal(const ANamedItem &)
This method allows to modified some options of the emulator.
void DoExTracking(TFile *file=0x0)
This function shows how to do offline analysis using the watchers.
Definition: DoExTracking.C:61
DLActor * Add(const Char_t *name_left, const Char_t *name_new_actor, const Char_t *name_right="-", const Char_t *conf_dir="./")
Definition: DEmulator.h:138
An general emulator, could run or not in multi-threading environement.
Definition: DEmulator.h:125
virtual void Run(Int_t max_loop=-1)
Run max loop.
Process a buffer, trigg and dispachs the work to sub-watchers.
Bool_t SetupWatchers(const char *df_type, FrameDispatcher *fd, const char *ext="")
It shows how to set up the watchers for different kind of data flow.
RootAFP.
Definition: RootAFP.h:42
int main(int argc, char **argv)
Definition: DoExTracking.C:123
const UInt_t aMByte
Definition: BaseBuffer.h:36
header file for ExTracking.cpp
virtual void Init(const NamedItem< std::string > &init_sequence=NamedItem< std::string >("InitSequence","config load init"))
Init the emulator. To be called before calling Run.
header file for RootAFP.cpp
ExTracking.
Definition: ExTracking.h:54
virtual void Print(std::ostream &out=std::cout) const
Print some informations (statistics)
Definition: FrameIO.cpp:571
header file for DEmulator.cpp
virtual NarvalInterface * GetActorByName(const Char_t *) const
search for an actor in the emulator
virtual void SetDirectory(TDirectory *mother_dir_of_watcher, TDirectory *mother_dir_for_tag, Bool_t load_objects=true)
change directories and Load objects if required