GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
adf/Macros/SetupWatchers.C
Go to the documentation of this file.
1 
2 #if !defined(__CINT__)
3 
4 #include "WatchersConfig.h"
5 
6 // GW
7 #include "FrameDispatcher.h"
8 
9 // Watchers
10 #include "WatcherClient.h"
11 #include "ADFWatchers.h"
12 #include "CrystalWatchers.h"
13 #include "PSAWatchers.h"
14 #include "TrackedWatchers.h"
15 #include "EventPSAWatchers.h"
16 #include "EventWatchers.h"
17 #include "MetaWatchers.h"
18 #include "RancLegnaroWatchers.h"
19 #include "DanteWatchers.h"
20 #include "MyTree.h"
21 
22 #ifdef HAS_PRISMA
23 #include "PrismaWatchers.h"
24 #endif
25 
26 using namespace Gw;
27 using namespace ADF;
28 
30 const char *GetWN(const char *name, const char *ext)
31 {
32  return Form("%s%s",name,ext);
33 }
34 
36 void DoTSRateCollector(TTask *top_task, TSRateCollector *collector)
37 {
38  TTask *task; FrameDispatcher *fd; TSRate *ts_rate;
39 
40  // loop on task to get FrameDispatchers
41  TIter next(top_task->GetListOfTasks());
42  while ( (task = (TTask *)next()) ) {
43  if ( task == collector )
44  continue;
45  fd = dynamic_cast<FrameDispatcher *> (task);
46  if ( fd ) {
47  TIter next_w(fd->GetListOfTasks());
48  while ( (task = (TTask *)next_w()) ) {
49  ts_rate = dynamic_cast<TSRate *> (task);
50  if ( ts_rate ) {
51  collector->AddHook(ts_rate,fd->GetName());
52  }
53  }
54  }
55  }
56 }
57 
59 /*
60  i
61 */
62 Bool_t SetupWatchers(const char *df_type, FrameDispatcher *fd, const char *ext = "")
63 {
64  Bool_t ok = false; TString DFtype = df_type;
65 
66 // ANY KIND OF DATA FLOW
67  // ADF ----------------------------------------------------------------
68  // General to any kind of data flow, based on the key part of the frame
69  if ( DFtype.Contains("ADF") ) {
70  // Watchers on any kind of Agata Frame ... the trigger should not be changed !
71  AgataFrameTrigger *trig =
72  new AgataFrameTrigger("ADF");
73  trig->Add(FactoryItem("Agata","agata",Version(1,0)),
74  FactoryItem("Agata","agata",Version(0,0)));
75  trig->Universal(true);
76  fd->SetTrigger(trig);
77 
78  // Just dump the frames in a file for decoding
79  // fd->GetDirectory()->cd(); Watcher *dumper = new Dumper();
80  // dumper->SetActive(false);
81  // fd->Add(dumper);
82 
83  // frame length, message type, event number of time stamp
84  fd->Add<AgataKeyWatcher>(GetWN("AgataKey",ext),"To check the keys on the Data Flow");
85 
86  ok = true;
87  }
88  // ADF -----------------------------------------------------------------
89 
90 // LOCAL LEVEL PROCESSING
91  // Crystal -------------------------------------------------------------
92  // to analyse output data flow at the crystal level
93  if ( DFtype.Contains("CRYSTAL") && ! DFtype.Contains("CCRYSTAL") ) {
94 
95  // It defines triggers on crystal frames
96  AgataFrameTrigger *trig1 =
97  AgataFrameTrigger::Build("Crystal", "data:crystal");
98 
99  // main trigger for the Dispatcher, delete by fd
100  fd->SetTrigger(trig1);
101 
102  // watcher to displays all signals
103  fd->Add<ShowSignals>(GetWN("RawSignals",ext),"Display the signals for one crystal",trig1);
104  // watcher to keep rates
105  fd->Add<TSRate>(GetWN("TSRate",ext),"To get rate form consecutive TS value");
106 
107  ok = true;
108  }
109  // Crystal -------------------------------------------------------------
110  // Calibrated Crystal --------------------------------------------------
111  // to analyse output data flow at the pre-processing level
112  if ( DFtype.Contains("CCRYSTAL") ) {
113 
114  // It defines triggers on crystal frames
115  AgataFrameTrigger *trig2 =
116  AgataFrameTrigger::Build("CCrystal", "data:ccrystal");
117 
118  // main trigger for the Dispatcher, delete by fd
119  fd->SetTrigger(trig2);
120 
121  // watcher to displays all signals
122  fd->Add<ShowSignals>(GetWN("CalibSignals",ext),"Display the calibrated signals for one crystal",trig2);
123  // watcher to keep rates
124  fd->Add<TSRate>(GetWN("TSRate",ext),"To get rate form consecutive TS value");
125 
126  ok = true;
127  }
128  // Crystal -------------------------------------------------------------
129  // PSA -----------------------------------------------------------------
130  if ( DFtype.Contains("PSA") ) {
131 
132  // It defines a trigger on a psa frame
133  AgataFrameTrigger *trig =
134  AgataFrameTrigger::Build("PSA", "data:psa");
135  // main trigger for the Dispatcher
136  fd->SetTrigger(trig);
137 
138  // 3D view of Hits in a crystal
139  fd->Add<PSACrystal3D>(GetWN("PSAHits",ext),"Hits in a Crystal");
140  // watcher to keep rates
141  fd->Add<TSRate>(GetWN("TSRate",ext),"To get rate form consecutive TS value");
142 
143  ok = true;
144  }
145  // PSA -------------------------------------------------------------------
146  // RANC0 -----------------------------------------------------------------
147  // output of the ancillary producer or Filter
148  if ( DFtype.Contains("RANC0") ) {
149 
150  // define WatcherClient for a specific trigger
151  // it defines a trigger on an ancilary frame
152  AgataFrameTrigger *trig =
153  AgataFrameTrigger::Build("RANC0", "data:ranc0");
154  fd->SetTrigger(trig);
155 
156  // to get all the raw spectra for ancillaries
157  fd->Add<DisplayRancLegnaro>(GetWN("DisplayRanc",ext),"RawData as produced by the Ancillary Filter");
158  // watcher to keep rates
159  fd->Add<TSRate>(GetWN("TSRate",ext),"To get rate form consecutive TS value");
160 
161  ok = true;
162  }
163  // RANC0 -----------------------------------------------------------------
164  // RANC1 -----------------------------------------------------------------
165  // output of the ancillary producer or Filter
166  if ( DFtype.Contains("RANC1") ) {
167 
168  // define WatcherClient for a specific trigger
169  // it defines a trigger on an ancilary frame
170  AgataFrameTrigger *trig =
171  AgataFrameTrigger::Build("RANC1", "data:ranc1");
172  fd->SetTrigger(trig);
173 
174  // to get all the raw spectra for ancillaries
175  fd->Add<DisplayRancLegnaro>(GetWN("DisplayRanc",ext),"RawData as produced by the Ancillary Filter");
176  // watcher to keep rates
177  fd->Add<TSRate>(GetWN("TSRate",ext),"To get rate form consecutive TS value");
178 
179 //Others
180  // to get Dante specific spectra (required Dante.conf)
181  // fd->Add<DisplayDante>(GetWN("DisplayDante",ext),"Display Calibrated Data for Dante");
182 
183  ok = true;
184  }
185  // RANC1 -----------------------------------------------------------------
186 // END LOCAL LEVEL PROCESSING
187 
188 // GLOBAL LEVEL PROCESSING
189 // EB Level //
190  if ( DFtype.Contains("EB") ) {
191 
192  // It defines a trigger on an event:data:psa Frame
193  AgataFrameTrigger *trig =
194  AgataFrameTrigger::Build("EventPSA", "event:data:psa" );
195  fd->SetTrigger(trig);
196 
197  // Add a watcher that display the rate content
198  fd->Add<RateDisplay>(GetWN("RateDisplay",ext),"To get the counting rates in each crystal");
199  fd->Add<HitsSpectra>(GetWN("HitsSpectra",ext),"Gamma-ray spectra from Hits");
200  // watcher to keep rates
201  fd->Add<TSRate>(GetWN("TSRate",ext),"To get rate form consecutive TS value");
202  ok = true;
203  }
204 // MERGER Level //
205  if ( DFtype.Contains("MERGER") ) {
206 
207  AgataFrameTrigger *trig =
208  AgataFrameTrigger::Build("Event", "event:data event:data:psa data:ranc0");
209 
210  // set the main trigger to coincidences between ancillary et gammas
211  fd->SetTrigger(trig);
212 
213  fd->Add<TSCoinc>(GetWN("TSCoinc",ext),"TS distribution in events");
214  fd->Add<HitsSpectra>(GetWN("HitsSpectra",ext),"Gamma-ray spectra from Hits");
215 
216 // Any kind of Watcher on event:data:psa, data:ranc1 or
217  fd->Add<DisplayRancLegnaro>(GetWN("DisplayRanc",ext),"RawData as produced by the Ancillary Filter");
218  //fd->Add<DisplayDante>(GetWN("DisplayDante",ext),"Display Raw and Calibrated Data for Dante");
219  // watcher to keep rates
220  fd->Add<TSRate>(GetWN("TSRate",ext),"To get rate form consecutive TS value");
221 
222 // Build and Fill TTrees
223  // create a TreeMaster which takes care of the TTree part
224  // It opens a root file (TreeMaster.root), build a tree and call Fill in the Exec method
225  // TTreeMaster *rootmaster = fd->Add<TTreeMaster>(GetWN("TreeMaster",ext),"Own the tree");
226  // to this tree, add a watcher which adds branches and takes cares to fill them
227  // rootmaster->Add<DoMyRawAncillaryTree>("RawAncTree","Branch on ancillary");
228  // rootmaster->Add<DoMyHitTree>("HitTree","Branch on hits");
229 
230  ok = true;
231  }
232 // TRACKING Level //
233  if ( DFtype.Contains("TRACKING") ) {
234 
235  // a trigger on event with hits, tracked gammas and ancillary
236  AgataFrameTrigger *trig =
237  AgataFrameTrigger::Build("TRACKING", "event:data event:data:psa data:tracked data:ranc1");
238 
239  // set the main trigger to coincidences between ancillary et gammas
240  fd->SetTrigger(trig);
241 
242 #ifdef HAS_PRISMA
243  // apply doppler correction from PRISMA if configuand check it
244  DoPrismaDoppler *prisma_dop = fd->Add<DoPrismaDoppler>("DoDoppler","Set Doppler event by event");
245  prisma_dop->Configure("Conf/PRISMA/manager.conf","Conf/PRISMA/lutPRISMA_WEEK49.txt");
246 
247  fd->Add<GlobalDC>(GetWN("CheckDoppler",ext),"Doppler as delivered by Prisma");
248 
249  // add a wacther on raw data
250  DisplayPrisma *prisma_2 = fd->Add<DisplayPrisma>("DisplayPrima","Some usefull calibrated spectra for PRISMA ");
251  prisma_2->Configure("Conf/PRISMA/manager.conf","Conf/PRISMA/lutPRISMA_WEEK49.txt");
252 #endif
253 
254  // specific to tracked frame
255  // gamma-gamma matrix
256  fd->Add<Coinc2D>(GetWN("GxG",ext),"Gamma Gamma coincidence");
257 // fd->Add<EveTrack>(GetWN("Eve",ext),"Gamma Gamma coincidence");
258 
259  // Any kind of Watcher on event:data:psa, data:ranc1 or
260  fd->Add<TSCoinc>(GetWN("TSCoinc",ext),"TS distribution in events");
261  // watcher to keep rates
262  fd->Add<TSRate>(GetWN("TSRate",ext),"To get rate form consecutive TS value");
263 
264  // fd->Add<DisplayRancLegnaro>(GetWN("DisplayRanc",ext),"RawData as produced by the Ancillary Filter");
265  // fd->Add<DisplayDante>(GetWN("DisplayDante",ext),"Display Raw and Calibrated Data for Dante");
266 
267 // Build and Fill TTrees : add branches related to the tracking
268  // create a TreeMaster which takes care of the TTree part
269  // It opens a root file (TreeMaster.root), build a tree and call Fill in the Exec method
270  // TTreeMaster *rootmaster = fd->Add<TTreeMaster>(GetWN("TreeMaster",ext),"Own the tree");
271  // to this tree, add a watcher which adds branches and takes cares to fill them
272  // rootmaster->Add<DoMyRawAncillaryTree>("RawAncTree","Branch on ancillary");
273  // rootmaster->Add<DoMyHitTree>("HitTree","Branch on hits");
274  // rootmaster->Add<DoMyTrackTree>("TrackTree","Branch on track");
275 #ifdef HAS_PRISMA
276  // MyPrismaTree *prisma_tree = rootmaster->Add<MyPrismaTree>("Prisma","Branch on track");
277  // prisma_tree->Configure("Conf/PRISMA/manager.conf","Conf/PRISMA/lutPRISMA_WEEK49.txt");
278 #endif
279 
280  ok = true;
281  }
282 
283  return ok;
284 }
285 
286 
287 // META -------------------------------------------------------------
288 // meta data frame
289 /*
290 if ( DFtype.Contains("META") ) {
291 
292  // define WatcherClient for a specific trigger
293  AgataFrameTrigger *trig = AgataFrameTrigger::Build("Vertex", "meta:vertex" );
294  fd->SetTrigger(trig);
295 
296  // just to keep a global vertex frame.
297  fd->Add<VertexWatcher>("GSource","To get a Global Vertex");
298  // recoil velocity distribution
299  fd->Add<GlobalDC>("GRecoil","Recoil velocity distribution");
300 
301  ok = true;
302 }
303  */
304 // META ----------------------------------------------------------------
305 
306 #endif
307 
308 
309 
310 
311 
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.
const char * GetWN(const char *name, const char *ext)
Build the Watcher name adding an extension.
Watcher that built the spectra expected for a Vertex.
void AddHook(Watcher *, const char *)
Add a timestamp rate.
virtual SharedFP * Add(const FactoryItem &key_item, const FactoryItem &frame_item, bool iscons=true, const Char_t *option="")
Add a frame to the list of required frames.
Definition: Trigger.h:492
Watcher to keep last TS values.
Apply the doppler correction.
Process a buffer, trigg and dispachs the work to sub-watchers.
To Display the content of raw ancillary frames ranc0 and ranc1 as defined @ Legnaro.
virtual Bool_t SetTrigger(ADF::DFTrigger *)
This is the default trigger for any added watcher.
To get a 3D map of hits in a particular crystal.
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 ...
To check and display the Data Flow structure by the key content of the frame.
Base class for version numbers.
Definition: Version.h:38
Show rates (counts) per Crystal.
To be used for Agata Data Flow.
Definition: Trigger.h:462
To work on Signals.
*********************************** HitsSpectra Class **************************************/// ...
Gives the distribution of the different timstamps in a composite frame.
void DoTSRateCollector(TTask *top_task, TSRateCollector *collector)
browse all dispatchers to look for TSRate Watcher and add them to the rate collector ...
void Universal(Bool_t b=true)
Set this trigger as universal or not.
Definition: Trigger.h:130
void Configure(const char *pmanager="Conf/", const char *plut="Conf/")
Base class that described an item in a Factory.
Definition: FactoryItem.h:52
compute histograms for several TSRate