GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GSI/ADFWatchers.h
Go to the documentation of this file.
1 
2 /***************************************************************************
3  * Copyright (C) 2010 by Olivier Stezowski *
4  * stezow(AT)ipnl.in2p3.fr *
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 #ifndef _ADFWatchers
23 #define _ADFWatchers
24 
25 // Watcher definition
26 #ifndef Gw_Watchers
27 #include "Watchers.h"
28 #endif
29 
30 // ADF definitions
31 #ifndef ADF_AgataKeyFactory
32 #include "AgataKeyFactory.h"
33 #endif
34 
35 // ROOT definitions
36 #include "TH1.h"
37 #include "TRegexp.h"
38 
39 using namespace ADF;
40 using namespace Gw;
41 
42 
44 
47 class ADFWatcher : public Watcher
48 {
49 protected:
51  SharedFP *fFrame;
52 
53 public:
55  Watcher("ADFWatcher","ADFWatcher"),
56  fFrame(0x0)
57  {;}
58  ADFWatcher(const char *name, const char *title, TDirectory *sp_dir = 0x0, TDirectory *tag_dir = 0x0):
59  Watcher(name,title,sp_dir,tag_dir), fFrame(0x0)
60  {;}
61  virtual ~ADFWatcher()
62  {;}
63 
65 
68  virtual Bool_t SetTrigger( ADF::DFTrigger */*trigger*/ = 0x0 );
69 
70  ClassDef(ADFWatcher,0) // Watcher on any kind of Frames
71 };
72 
74 
77 class Dumper : public ADFWatcher
78 {
79 private:
80  TString fFilename;
81  Bool_t fIsNew;
82 
83 public:
84  Dumper(const char *name = "Dumper", const char *title = "Just dump the frames in a file"):
85  ADFWatcher(name,title),
86  fFilename(Form("%s.adf",name)),
87  fIsNew(true)
88  {;}
89  Dumper(const char *name, const char *title, TDirectory *sp_dir, TDirectory *tag_dir):
90  ADFWatcher(name,title,sp_dir,tag_dir),
91  fFilename(Form("%s.adf",name)),
92  fIsNew(true)
93  {
94  SetActive(false) ;
95  }
96  virtual ~Dumper()
97  {;}
98 
99  void SetOutputFile(const Char_t *filename); //*MENU*
100 
102  virtual void Exec(Option_t *option="");
103 
104  ClassDef(Dumper,0) // Dump the frames in a file
105 };
106 
108 
111 class AgataKeyWatcher : public ADFWatcher
112 {
113 private:
114  const AgataKey *fKey;
115 
116 private:
117  static const Int_t kMaxCycle = 1000u;
118  Int_t fWhichBin;
119 
120 private:
121  TRegexp fKeyFilter;
122  TRegexp fSubKeyFilter;
123 
124 private:
126  UInt_t fLastEventNumber;
128  ULong64_t flastTimestamp;
129 
130 private:
131  Bool_t fShowGlobalConf;
132 
133 private:
134  TH1F *fLengthFrame;
135  TH1F *fKeyMessage;
136  TH1D *fEventNumber;
137  TH1D *fTimeStamp;
138  TH1F *fCEventNumber;
139  TH1F *fCTimeStamp;
140  TH1F *fCoincTimeStamp;
141 
142  TH1F *fLengthSubFrame;
143  TH1F *fKeyMessageSubFrame;
144 
145 protected:
147  virtual void DoCanvas(TCanvas *c, Option_t *);
148 
149 public:
150  AgataKeyWatcher(const Char_t *name, const Char_t *title, TDirectory *sp_dir = 0x0, TDirectory *tag_dir = 0x0);
151  virtual ~AgataKeyWatcher();
152 
154  void SetKeyFilter(const Char_t *keypattern = "*", const Char_t *subkeypattern = "*"); //*MENU*
155 
156 // virtual Bool_t SetTrigger( ADF::DFTrigger */*trigger*/ = 0x0 );
157 
159  virtual void Exec(Option_t *option="");
160 
161  ClassDef(AgataKeyWatcher,0) // Watcher on AgataKey
162 };
163 
164 #include <vector>
165 
167 /*
168  This Watcher keeps an array of the last timestamps for the given trigger.
169  This array has to be reset (using LastValues().resize(0)) outside the class for the intance by a TSRateCollector
170 */
171 class TSRate : public ADFWatcher
172 {
173 private:
175  std::vector < ULong64_t > fTSRates;
176 
177 public:
178  TSRate(const Char_t *name, const Char_t *title, TDirectory *sp_dir = 0x0, TDirectory *tag_dir = 0x0);
179  virtual ~TSRate()
180  {;}
181 
182  std::vector <ULong64_t> &LastValues()
183  { return fTSRates; }
184 
186  virtual void Exec(Option_t *option="");
187 
188  ClassDef(TSRate,0) // to get rate using the timestamp
189 };
190 
191 #include "THStack.h"
192 
194 /*
195  */
196 class TSRateCollector : public Watcher
197 {
198 protected:
199  static const ULong64_t fgkOneSecond = 100000000UL; // one second in TS unit
200 
201 public:
203  class D_Rate {
204  public:
205  // number of scales on which rates are computes
206  UShort_t fNbScales;
207 
208  // scales's definitions
209  std::vector<ULong64_t> fPrecision; // in TS unit
210  std::vector<Int_t> fNbSamples;
211 
212  public:
213  D_Rate(): fNbScales(0), fPrecision(0), fNbSamples(0)
214  {;}
216  void Add(ULong64_t precision, Int_t nb_samples)
217  {
218  fNbScales++; fPrecision.push_back(precision); fNbSamples.push_back(nb_samples);
219  }
220  };
222  class C_Rate {
223  public:
224  std::vector<ULong64_t> fCycle;
225  std::vector<Int_t> fNbCounts;
226  std::vector<Double_t> fSum;
227 
228  ULong64_t fLastTS;
229  public:
230  C_Rate(Int_t nb_scales = 1): fCycle(0), fNbCounts(0), fSum(0), fLastTS(0UL)
231  { Reset(nb_scales) ; }
232  void Reset(Int_t nb_scales = 1)
233  { fCycle.resize(nb_scales,0); fNbCounts.resize(nb_scales,0); fSum.resize(nb_scales,0); fLastTS = 0UL; }
234  };
235 private:
237  D_Rate fDefinitionRate;
239  std::vector<C_Rate> fCurrentRate;
240 
241 private:
243  TList fTSRates;
244 
245 private:
247  static const Short_t gEmptyBins = 50 ;
249  THStack fRates;
251  TObjArray fPacketWidth;
253  TObjArray fDeadTime;
254 
255 private:
257  ULong64_t fT0;
258 
259 protected:
260  Bool_t SetT0();
261 
262 protected:
264  virtual void DoCanvas(TCanvas *c, Option_t *);
265 
266 public:
267  TSRateCollector(const Char_t *name, const Char_t *title, TDirectory *sp_dir = 0x0, TDirectory *tag_dir = 0x0);
268  virtual ~TSRateCollector()
269  {;}
270 
272  void AddHook(Watcher *, const char *);
273 
275  virtual void Exec(Option_t *option="");
276 
277  ClassDef(TSRateCollector,0) // to get rate using the timestamp
278 };
279 
280 class TimeStampWatcher : public ADFWatcher
281 {
282 public:
283 
284  TH1F *TimeStampHist;
285  ULong64_t FirstTimeStamp;
286  ULong64_t LastTimeStamp;
287 
288 protected:
290  virtual void DoCanvas(TCanvas *c, Option_t *);
291 
292 public:
293  TimeStampWatcher(const char * name, const char * title, TDirectory *sp_dir = 0x0, TDirectory *tag_dir = 0x0);
294  virtual ~TimeStampWatcher();
295 
296  virtual void Exec(Option_t * option="");
297 
298  virtual void Zero(Option_t *opt1, Option_t *opt2); //*MENU*
299 
300  ClassDef(TimeStampWatcher,0) // To get a 3D map of hits in a particular crystal
301 };
302 
303 #endif
304 
Just dump the frame in a file.
Watcher to keep last TS values.
Interface to AgataKey.
ADFWatcher(const char *name, const char *title, TDirectory *sp_dir=0x0, TDirectory *tag_dir=0x0)
Dumper(const char *name="Dumper", const char *title="Just dump the frames in a file")
virtual ~TSRate()
Base class for a Watcher.
Definition: Watchers.h:60
virtual ~TSRateCollector()
virtual ~Dumper()
To check and display the Data Flow structure by the key content of the frame.
virtual ~ADFWatcher()
C_Rate(Int_t nb_scales=1)
Dumper(const char *name, const char *title, TDirectory *sp_dir, TDirectory *tag_dir)
header file for AgataKeyFactory.cpp
A Shared Frame Pointer.
Definition: Frame.h:597
void Add(ULong64_t precision, Int_t nb_samples)
precision is given in TS unit (use fgkOneSecond for conversion)
Base class for a trigger on a data flow.
Definition: Trigger.h:155
void Reset(Int_t nb_scales=1)
Base Watcher working for any kind of Frame (Frame interface)
std::vector< ULong64_t > & LastValues()
compute histograms for several TSRate