GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OnlineWatchersLLP.C
Go to the documentation of this file.
1 
2 
3 #include "TROOT.h"
4 #include "WatcherClient.h"
5 #include "TBrowser.h"
6 #include "TFolder.h"
7 
8 using namespace ADF;
9 using namespace Gw;
10 
11 // include there the macros that contains your own setup
12 // i.e. what are the watchers you would like to execute for a given data flow.
13 
14 #include "GANILSetup.C"
15 
16 // protected by a namespace
17 namespace _OnlineWatchersLLP_ {
18 
19  // Crystal in there, just set empty string to remove some of them
20  const Int_t gNumberOfCrystals = 15;
21  //
22  std::string gCrysLabel[gNumberOfCrystals] = {
23  "04A",
24  "04C",
25  "04B",
26  "03A",
27  "03B",
28  "03C",
29  "13A",
30  "13B",
31  "13C",
32  "",
33  "",
34  "",
35  "",
36  "",
37  "",
38  };
39 // in principle all preprocessing actors are one the same node
40  std::string gBaseName = "172.16.1.1";
41  std::string gMachine[gNumberOfCrystals] = {
42  "01",
43  "06",
44  "05",
45  "11",
46  "08",
47  "09",
48  "10",
49  "07",
50  "12",
51  "",
52  "",
53  "",
54  "",
55  "",
56  "",
57  };
58 }
59 
60 using namespace _OnlineWatchersLLP_;
61 
62 // logic for AGATA local level processing : 1 X YY Z
63 // X : in case processes along the chain are on the same machine 0,1,2,3 etc depending on the depth
64 // YY : crystal number
65 // Z : ABC = 012
66 Int_t ComputePort(std::string &which_crys, Int_t level_in_dataflow)
67 {
68  TString result = "", tmp = which_crys.data();
69 
70  tmp.ReplaceAll("A","0");
71  tmp.ReplaceAll("B","1");
72  tmp.ReplaceAll("C","2");
73 
74  result = Form("1%d%s",level_in_dataflow,tmp.Data());
75  return result.Atoi();
76 }
77 
78 void OnlineWatchersLLP(TFile *file = 0x0, TFile *file_tag = 0x0, Bool_t full = false)
79 {
80  TDirectory *Watcher_dir = gROOT, *Watcher_dir_tag = gROOT;
81 // TDirectory *Watcher_dir = 0x0, *Watcher_dir_tag = 0x0;
82 
83  if ( file )
84  Watcher_dir = file;
85  if ( file_tag )
86  Watcher_dir_tag = file_tag;
87 
88  // main task.
89  // Adding all emulators to this helps to loop in case Option is l in ExecuteTasks
90  TTask *Snooper = new LoopOnTasks(Watcher_dir,Watcher_dir_tag);
91 
92 // ADF -------------------------------------------------------------
93  WatcherClient *wADF = new WatcherClient("ADF","Watchers on any Agata Frame",Watcher_dir,Watcher_dir_tag);
94  if ( SetupWatchers("ADF",wADF) ) {
95  Snooper->Add ( wADF );
96  wADF->SetConnection( Form("%s%s",gBaseName.data(),gMachine[1].data()), ComputePort(gCrysLabel[1],2) );
97  }
98 // Crystal -------------------------------------------------------------
99  // to know if a Watcher has been added to the dispatcher
100  if ( full ) {
101  for (Int_t i = 0; i < gNumberOfCrystals ; i++ ) {
102  // not in the setup
103  if ( gCrysLabel[i] == "" )
104  continue;
105 
106  WatcherClient *wCrys = new WatcherClient(Form("Crystal_%s",gCrysLabel[i].data()),
107  "Watchers on Crystal Frame",Watcher_dir,Watcher_dir_tag);
108  if ( SetupWatchers("CRYSTAL",wCrys,gCrysLabel[i].data()) ) {
109  wCrys->SetConnection(Form("%s%s",gBaseName.data(),gMachine[i].data()), ComputePort(gCrysLabel[i],0) );
110  Snooper->Add ( wCrys );
111  }
112  else delete wCrys;
113  Int_t p = ComputePort(gCrysLabel[i],0);
114  printf("%d \n",p);
115  }
116  }
117  else {
118  WatcherClient *wCrys = new WatcherClient("CRYSTAL","Watchers on Crystal Frame",Watcher_dir,Watcher_dir_tag);
119  if ( SetupWatchers("CRYSTAL",wCrys) )
120  Snooper->Add ( wCrys );
121  else delete wCrys;
122  }
123 // CCrystal -------------------------------------------------------------
124  // to know if a Watcher has been added to the dispatcher
125  if ( full ) {
126  for (Int_t i = 0; i < gNumberOfCrystals ; i++ ) {
127 
128  // not in the setup
129  if ( gCrysLabel[i] == "" )
130  continue;
131 
132  WatcherClient *wCrys = new WatcherClient(Form("CCrystal_%s",gCrysLabel[i].data()),
133  "Watchers on Calibrated Crystal Frame",Watcher_dir,Watcher_dir_tag);
134  if ( SetupWatchers("CCRYSTAL",wCrys,gCrysLabel[i].data()) ) {
135  wCrys->SetConnection(Form("%s%s",gBaseName.data(),gMachine[i].data()), ComputePort(gCrysLabel[i],1) );
136  Snooper->Add ( wCrys );
137  }
138  else delete wCrys;
139  }
140  }
141  else {
142  WatcherClient *wCrys = new WatcherClient("CCRYSTAL","Watchers on Calibrated Crystal Frame",Watcher_dir,Watcher_dir_tag);
143  if ( SetupWatchers("CCRYSTAL",wCrys) )
144  Snooper->Add ( wCrys );
145  else delete wCrys;
146  }
147 // PSA -------------------------------------------------------------
148  // to know if a Watcher has been added to the dispatcher
149  if ( full ) {
150  for (Int_t i = 0; i < gNumberOfCrystals ; i++ ) {
151  // not in the setup
152  if ( gCrysLabel[i] == "" )
153  continue;
154 
155  WatcherClient *wPSA = new WatcherClient(Form("PSA_%s",gCrysLabel[i].data()),
156  "Watchers on PSA Frame",Watcher_dir,Watcher_dir_tag);
157  if ( SetupWatchers("PSA",wPSA,gCrysLabel[i].data()) ) {
158  wPSA->SetConnection(Form("%s%s",gBaseName.data(),gMachine[i].data()), ComputePort(gCrysLabel[i],2));
159  Snooper->Add ( wPSA );
160  }
161  else delete wPSA;
162  }
163  }
164  else {
165  WatcherClient *wPSA = new WatcherClient("PSA","Watchers on PSA Frame",Watcher_dir,Watcher_dir_tag);
166  if ( SetupWatchers("PSA",wPSA) )
167  Snooper->Add ( wPSA );
168  else delete wPSA;
169  }
170 // ANCILLARY
171  /*
172  WatcherClient *wAnc0 = new WatcherClient("ANC_PRO","Watchers on ancillary Data (ranc0)",Watcher_dir,Watcher_dir_tag);
173  if ( SetupWatchers("RANC0",wAnc0) ) {
174  Snooper->Add ( wAnc0 );
175  wAnc0->SetConnection("10.10.1.102", 9013);
176  }
177  else
178  delete wAnc0;
179  */
180  /*
181  WatcherClient *wAnc1 = new WatcherClient("ANC_FIL","Watchers on ancillary Data (ranc1)",Watcher_dir,Watcher_dir_tag);
182  if ( SetupWatchers("RANC1",wAnc1) ) {
183  Snooper->Add ( wAnc1 );
184  wAnc1->SetConnection("172.16.1.102", 9026);
185  }
186  else
187  delete wAnc1;
188 
189  WatcherClient *wAncGSI = new WatcherClient("ANC_GSI","Watchers on ancillary Data (GSI)",Watcher_dir,Watcher_dir_tag);
190  if ( SetupWatchers("ANC_GSI",wAncGSI) ) {
191  Snooper->Add ( wAncGSI );
192  wAncGSI->SetConnection( Form("%s%s",gBaseName.data(),"91"), 8000);
193  }
194  else
195  delete wAncGSI;
196  */
197 
198 // add the main ADF to the list of task
199  TSRateCollector *TSCollector = new TSRateCollector("GTS_Rate","Global Timestamp rates");
200  TSCollector->SetDirectory(Watcher_dir,Watcher_dir_tag);
201  Snooper->Add(TSCollector);
202  DoTSRateCollector(Snooper,TSCollector);
203 
204  gROOT->GetListOfTasks()->Add(Snooper);
205 
206 /* for (Int_t i = 0; i < gNumberOfCrystals ; i++ ) {
207  printf("%d %s %d \n",i,gCrysLabel[i].data(),ComputePort(gCrysLabel[i],0) );
208  printf("%d %s %d \n",i,gCrysLabel[i].data(),ComputePort(gCrysLabel[i],1) );
209  printf("%d %s %d \n",i,gCrysLabel[i].data(),ComputePort(gCrysLabel[i],2) );
210  } */
211 
212 
213  TBrowser *b = (TBrowser*)gROOT->GetListOfBrowsers()->Last();
214 
215  TFolder *GwWatchersFolder = (TFolder*)gROOT->GetRootFolder()->FindObject("GwWatchers");
216  if(GwWatchersFolder) b->Add(GwWatchersFolder);
217 
218  TFolder *RootFilesFolder = (TFolder*)gROOT->GetRootFolder()->FindObject("ROOT Files");
219  if(RootFilesFolder) b->Add(RootFilesFolder);
220 
221 }
222 
223 void CloseOnlineWatchers() { gROOT->GetListOfTasks()->At(0)->Delete(); }
224 
225 
226 
TBrowser * b
printf("******************************************************************** \n")
Int_t ComputePort(std::string &which_crys, Int_t level_in_dataflow)
EvapLMOF & full(EvapLMOF &reader)
Definition: EvapLMOF.h:295
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 OnlineWatchersLLP(TFile *file=0x0, TFile *file_tag=0x0, Bool_t full=false)
std::string gCrysLabel[gNumberOfCrystals]
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
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
std::string gMachine[gNumberOfCrystals]
compute histograms for several TSRate