GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GANIL/OnlineWatchersGLP.C
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (c) IPNL, IN2P3, CNRS *
3  * Contibutor(s) : *
4  * Olivier Stezowski stezow(AT)ipnl.in2p3.fr [2014] *
5  * *
6  * This program is free software; you can redistribute it and/or modify *
7  * it under the terms of the GNU General Public License as published by *
8  * the Free Software Foundation; either version 2 of the License, or *
9  * (at your option) any later version. *
10  * *
11  * This program is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with this program; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20  ***************************************************************************/
21 
22 #include "TROOT.h"
23 #include "TBrowser.h"
24 #include "WatcherClient.h"
25 
26 using namespace ADF;
27 using namespace Gw;
28 
29 // include there the macros that contains your own setup
30 // i.e. what are the watchers you would like to execute for a given data flow.
31 
32 #include "WatchersConfig.h"
33 #include "SetupWatchers.C"
34 
36 /*
37 */
38 void OnlineWatchersGLP(TFile *file = 0x0, TFile *file_tag = 0x0, Bool_t start_loop = false)
39 {
40  TDirectory *Watcher_dir = gROOT, *Watcher_dir_tag = gROOT;
41  if ( file )
42  Watcher_dir = file;
43  if ( file_tag )
44  Watcher_dir_tag = file_tag;
45 
46  // main task.
47  // Adding all emulators to this helps to loop in case Option is l in ExecuteTasks
48  TTask *Snooper = new LoopOnTasks(Watcher_dir,Watcher_dir_tag);
49  if ( start_loop ) {
50  LoopControl *control = (LoopControl *)Snooper->GetListOfTasks()->FindObject("LoopControl");
51  if ( control ) {
52  control->SetAutoTime(3600); // save every hours
53  }
54  }
55 
56  // ADF //
57  // Can scan any kind of data flow
58 // WatcherClient *wADF = new WatcherClient("ADF","Watchers on any Agata Frame",Watcher_dir,Watcher_dir_tag);
59 // if ( SetupWatchers("ADF",wADF) ) {
60 // Snooper->Add ( wADF );
61 // wADF->SetConnection("172.16.1.125", 9021);
62 // }
63  // EB //
64  // to analyse the data flow coming out from the Event Builder i.e. a Data Flow composed of event:data:pa Frames
65  WatcherClient *wEventPSA = new WatcherClient("EB","Watchers to analyse data after the Event Builder",Watcher_dir,Watcher_dir_tag);
66  if ( SetupWatchers("EB",wEventPSA,"_Built") ){
67  Snooper->Add ( wEventPSA );
68  wEventPSA->SetConnection("172.16.1.125", 9000);
69  }
70  // MERGER //
71  // to analyse the data flow coming out from the Merger i.e. a Data Flow composed of any combinaisons of
72  // event:data:pa
73  // data:ranc1
74  WatcherClient *wMerger = new WatcherClient("MERGER","Watchers to analyse data @ the MERGER level",Watcher_dir,Watcher_dir_tag);
75  if ( SetupWatchers("MERGER",wMerger,"_Merged") ){
76  Snooper->Add ( wMerger );
77  wMerger->SetConnection("172.16.1.125", 9001);
78  }
79  // TRACKING //
80  // to analyse the data flow coming out from the Event Builder i.e. a Data Flow composed of any combinaisons of
81  // event:data:pa
82  // data:ranc1
83  // data:tracked
84  WatcherClient *wTrack = new WatcherClient("TRACKING","Watchers to analyse data after TRACKING",Watcher_dir,Watcher_dir_tag);
85  if ( SetupWatchers("TRACKING",wTrack,"_Tracked") ){
86  Snooper->Add ( wTrack );
87  wTrack->SetConnection("172.16.1.125", 9002);
88  }
89 
90 // add the main ADF to the list of task
91 
92  // add the main ADF to the list of task
93  TSRateCollector *TSCollector = new TSRateCollector("GTS_Rate","Global Timestamp rates");
94  TSCollector->SetDirectory(Watcher_dir,Watcher_dir_tag);
95  Snooper->Add(TSCollector);
96  DoTSRateCollector(Snooper,TSCollector);
97 
98  gROOT->GetListOfTasks()->Add(Snooper);
99 
100  if ( !gROOT->IsBatch() ) {
101  TBrowser *b = (TBrowser*)gROOT->GetListOfBrowsers()->Last();
102 
103  TFolder *GwWatchersFolder = (TFolder*)gROOT->GetRootFolder()->FindObject("GwWatchers");
104  if(GwWatchersFolder) b->Add(GwWatchersFolder);
105 
106  TFolder *RootFilesFolder = (TFolder*)gROOT->GetRootFolder()->FindObject("ROOT Files");
107  if(RootFilesFolder) b->Add(RootFilesFolder);
108  }
109  if ( start_loop )
110  Snooper->ExecuteTask("l");
111 }
112 
113 void CloseOnlineWatchers() { gROOT->GetListOfTasks()->At(0)->Delete(); }
114 
115 
116 
TBrowser * b
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 CloseOnlineWatchers()
void SetAutoTime(Int_t autotime=0)
change time to autosave
Definition: Watchers.cpp:1751
void DoTSRateCollector(TTask *top_task, TSRateCollector *collector)
browse all dispatchers to look for TSRate Watcher and add them to the rate collector ...
To get a buffer from an actor, trigg on a Frame and dispach the Frame to sub-watchers.
Bool_t SetConnection(const Char_t *machine="localhost", UInt_t port=9090)
change the place where are picked data
void OnlineWatchersGLP(TFile *file=0x0, TFile *file_tag=0x0, Bool_t start_loop=false)
This is the default configuration.
To start a loop on tasks.
Definition: Watchers.h:551
virtual void SetDirectory(TDirectory *mother_dir_of_watcher, TDirectory *mother_dir_tag, Bool_t load_objects=true)
to change the directory in which watcher's objects are stored
Definition: Watchers.cpp:458
compute histograms for several TSRate