GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GSIOnlyOffline.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_t 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 
24 // Gw and Watchers
25 #include "RootAFP.h"
26 #include "FrameDispatcher.h"
27 
28 
29 #include "EmulatorControl.h"
30 #include "Emulator.h"
31 
32 #include "GSIOnlySetup.C"
33 
34 using namespace Gw;
35 using namespace ADF;
36 
38 /*
39  An emulator is composed of producer that reads data from .adf files
40  and send the buffer to an FrameDispatcher.
41 
42  Watchers, in which the analysis is done are attached to the FrameDispatcher.
43 
44  Watchers are added to the FrameDispacher using the SetupWatcher function
45  that is in the SetupWtachers.C (in order to be shared with other macros see OnlineWatchers examples)
46 
47  Of course one can define everything in a single macro like it is done in DoMyTree.
48 
49  @author O.Stezowski
50 
51 */
52 void OfflineWatchers(TFile *file = 0x0)
53 {
54  // MainDir is the top dir to organise histograms in subdirectories
55  // each one being attached to a given task.
56  TDirectory *MainDir = gROOT;
57  if ( file )
58  MainDir = file;
59 
60  // chain a producer and a FrameDispacher to which Watchers are attached
62 
63  if ( ! emulator->Init() ) {
64  std::cout << "Cannot Init emulator" << std::endl; return;
65  }
66  else
67  if ( MainDir != gROOT )
68  emulator->GetConsumer()->SetDirectory(MainDir,MainDir);
69 
70  // to have all watcher in the task folder
71  gROOT->GetListOfTasks()->Add( new EmulatorControl(emulator) );
72  gROOT->GetListOfTasks()->Add(emulator->GetConsumer());
73 
74  // add watchers to the dispatcher
75  // ADF ----------------------------------------------------------------
76  // watchers on the key part
77  SetupWatchers("ADF",emulator->GetConsumer());
78 
79  // RANC1 --------------------------------------------------------------
80  // watchers on the ancillary frame
81  // SetupWatchers("RANC0",emulator->GetConsumer());
82  // -------------------------------------------------------------------
83 
84  // PSA --------------------------------------------------------------
85  // watchers on the PSA frame
86  //SetupWatchers("PSA",emulator->GetConsumer());
87  // -------------------------------------------------------------------
88 
89  // EB -----------------------------------------------------------------
90  // output of the EB ... hits only
91  // SetupWatchers("EB",emulator->GetConsumer());
92  // -------------------------------------------------------------------
93 
94  // MERGER -------------------------------------------------------------
95  // output of the merger ... hits correlated to ancillary
96  SetupWatchers("MERGER",emulator->GetConsumer());
97  // -------------------------------------------------------------------
98 
99  // After TRACKING -----------------------------------------------------
100  // output of the tracking ... hits, tracked gamma-rays correlated to ancillary
101  //SetupWatchers("TRACKING",emulator->GetConsumer());
102  // -------------------------------------------------------------------
103 
104  // run
105  // emulator->Run();
106 
107  // displays statistics and keeps all histograms
108  // write all the spectra produced by the different watchers in a root file
109 
110 
111 // MainDir->Write();
112 }
113 
114 #if !defined(__CINT__)
115 int main(int argc, char **argv)
116 {
117  // a new root file is created
118  TFile f("Offline.root","RECREATE");
119  // run your analysis on it
120  OfflineWatchers(&f);
121 
122  return 1;
123 }
124 #endif
125 
126 
127 
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.
void OfflineWatchers(TFile *file=0x0)
This function shows how to do offline analysis using the watchers.
Cons_actor * GetConsumer()
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
ADF::LogMessage & endl(ADF::LogMessage &log)
int main(int argc, char **argv)
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