GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GANIL/ADFWatchers.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 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 // Watcher definition
22 #ifndef _ADFWatchers
23 #include "ADFWatchers.h"
24 #endif
25 
26 #include "TSystem.h"
27 #include <stdexcept>
28 
29 using namespace ADF;
30 
34 
36 {
37  if ( ! Watcher::SetTrigger(trigger) ){
38  fFrame = 0x0;
39  return false;
40  }
41 
42  // set the unique frame to be watched
43  fFrame = GetTrigger()->GetInputSharedFP();
44 
45  return true;
46 }
47 
51 
52 void Dumper::Exec(Option_t */*option*/)
53 {
54  // Frame by Frame action
55  // be sure the key (the frame) has been set properly
56  if ( fFrame == 0x0 )
57  return;
58 
59  // if new file is asked, next open erase the file
60  if ( fIsNew )
61  { fFrame->GetFrame()->Dump(fFilename.Data(), fIsNew); fIsNew = false; }
62  else
63  { fFrame->GetFrame()->Dump(fFilename.Data(), fIsNew); }
64 }
65 
67 
68 void Dumper::SetOutputFile(const Char_t *filename)
69 {
70  fFilename = filename; fIsNew = true;
71 }
72 
76 
77 AgataKeyWatcher::AgataKeyWatcher(const Char_t *name, const Char_t *title, TDirectory *sp_dir, TDirectory *tag_dir):
78  ADFWatcher(name,title,sp_dir,tag_dir),
79  fKey(0x0),
80  fWhichBin(-1),
81  fKeyFilter("*",true),
82  fSubKeyFilter("*",true),
83  fLastEventNumber(0u),
84  flastTimestamp(0UL),
85  fShowGlobalConf(false),
86  fLengthFrame(0x0),
87  fKeyMessage(0x0),
88  fEventNumber(0x0),
89  fTimeStamp(0x0),
90  fCEventNumber(0x0),
91  fCTimeStamp(0x0),
92  fCoincTimeStamp(0x0),
93  fLengthSubFrame(0x0),
94  fKeyMessageSubFrame(0x0)
95 {
96  // allocation of the histograms you would like to fill
97  fLengthFrame = MakeTH1<TH1F>("LengthFrame","Length of the Frames (bytes)", aKByte,0,20*aKByte);
98  fKeyMessage = MakeTH1<TH1F>("KeyMessage","Message type", 3,0,3) ;
99  #if ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0)
100  fKeyMessage->GetXaxis()->SetCanExtend(true);
101  #else
102  fKeyMessage->SetBit(TH1::kCanRebin);
103  #endif
104  fEventNumber = MakeTH1<TH1D>("EventNumber","Last event numbers", kMaxCycle,0.,kMaxCycle) ;
105  fTimeStamp = MakeTH1<TH1D>("TimeStamp","Last time stamps", kMaxCycle,0.,kMaxCycle) ;
106  fCEventNumber = MakeTH1<TH1F>("CEventNumber","Consecutive event numbers", 1000,0, 10000) ;
107  fCTimeStamp = MakeTH1<TH1F>("CTimeStamp","Consecutive time stamps", 1000,0, 10000000) ;
108  fCoincTimeStamp = MakeTH1<TH1F>("CoincTimeStamp","Time stamp distribution in composite frames", 500,0,1000 ) ;
109  fLengthSubFrame = MakeTH1<TH1F>("LengthSubFrame","Length of the SubFrames (bytes)", aKByte,0,20*aKByte);
110  fKeyMessageSubFrame = MakeTH1<TH1F>("KeyMessageSubFrame","Message type for SubFrames in Composite Frame", 1,0,1);
111  #if ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0)
112  fKeyMessageSubFrame->GetXaxis()->SetCanExtend(true);
113  #else
114  fKeyMessageSubFrame->SetBit(TH1::kCanRebin);
115  #endif
116 }
117 
119 
121 {
122  // destruction of the histograms done because they have been added to the pool
123 }
124 
126 
127 void AgataKeyWatcher::SetKeyFilter(const Char_t *keypattern, const Char_t *subkeypattern)
128 {
129  TString stmp1(keypattern), stmp2(subkeypattern);
130 
131  Bool_t wildcard1 = false, wildcard2 = false;
132  if ( stmp1.Contains("*") )
133  wildcard1 = true;
134  if ( stmp2.Contains("*") )
135  wildcard2 = true;
136 
137  TRegexp tmp1(keypattern,wildcard1), tmp2(subkeypattern,wildcard2);
138 
139  // change the filters only if it is a valid expression
140  if ( tmp1.Status() == TRegexp::kOK ) {
141  fKeyFilter = tmp1;
142  }
143  if ( tmp2.Status() == TRegexp::kOK ) {
144  fSubKeyFilter = tmp2;
145  }
146 }
147 
149 
150 void AgataKeyWatcher::DoCanvas(TCanvas *c, Option_t *o)
151 {
152  TString option = o;
153  if ( option == "" ) {
154  c->Divide(3,2,0.001,0.001);
155  c->cd(1);
156  fLengthFrame->Draw();
157  c->cd(2);
158  fLengthSubFrame->Draw();
159  c->cd(3);
160  fEventNumber->Draw();
161  c->cd(4);
162  fKeyMessage->Draw();
163  c->cd(5);
164  fKeyMessageSubFrame->Draw();
165  c->cd(6);
166  fTimeStamp->Draw();
167  }
168  if ( option == "q" ) {
169  c->Divide(1,3,0.001,0.001);
170  c->cd(1);
171  fCEventNumber->Draw();
172  c->cd(2);
173  fCTimeStamp->Draw();
174  c->cd(3);
175  fCoincTimeStamp->Draw();
176  }
177 }
178 
180 
181 void AgataKeyWatcher::Exec(Option_t */*option*/)
182 {
183  if ( gDebug > 2 )
184  printf("AgataKeyWatcher::Exec is called \n");
185 
186  UInt_t length, current, eventnumber, message; ULong64_t timestamp; TString mess, mess_sec, mess_tmp;
187 
188  if ( fFrame != 0x0 ) {
189  if ( fFrame->IsValid() )
190  fKey = dynamic_cast<const AgataKey *>(fFrame->GetFrame()->GetKey());
191  else
192  fKey = 0x0;
193  }
194  else
195  fKey = 0x0;
196 
197  // be sure the key (the frame) has been set properly
198  if ( fKey == 0x0 )
199  return;
200 
201  // first test if a filter is applied
202  mess = AgataKeyFactory::theFactory()->GetMessage(fKey->GetMessage());
203  if ( ! mess.Contains(fKeyFilter) )
204  return;
205 
206  // now fill histograms
207  fLengthFrame->Fill(fKey->GetFrameLength()); fKeyMessage->Fill(mess.Data(),1);
208  if ( mess.Contains("UnknownKey") ) { // an unknown key
209  std::cout << " WARNING, unknown key " << std::endl;
210  fKey->Print();
211  }
212  // try and read the possible event# and timestamp (may not exists in case of low version number of agata key
213  const BufferIO *buf = fFrame->GetFrame()->GetRealBuffer();
214  buf->SetOffset();
215  if ( fKey->GetFrameLength() < 12u ) {
216  eventnumber = 0u;
217  timestamp = 0UL;
218  }
219  else {
220  (*buf) >> eventnumber;
221  if ( fKey->GetFrameLength() < 20u )
222  timestamp = 0UL;
223  else (*buf) >> timestamp;
224  }
225 
226  // which is negative if this method has never been called
227  if ( fWhichBin == -1 ) {
228  fLastEventNumber = eventnumber;
229  flastTimestamp = timestamp;
230  fWhichBin = 0;
231  }
232 
233  // fill timestamp and event number related
234  fEventNumber->Fill(fWhichBin,eventnumber);
235  fTimeStamp->Fill(fWhichBin,timestamp);
236 
237  fCEventNumber->Fill(eventnumber-fLastEventNumber);
238  fCTimeStamp->Fill(timestamp-flastTimestamp);
239 
240  /*
241  if ( eventnumber < fLastEventNumber ) {
242  fEventNumberQuality->Fill(-1);
243  // cout << " Current event # " << eventnumber << " Previous event # " << fLastEventNumber << endl;
244  }
245  else
246  eventnumber == fLastEventNumber ? fEventNumberQuality->Fill(0) : fEventNumberQuality->Fill(1);
247 
248  if ( timestamp < flastTimestamp ) {
249  fTimeStampQuality->Fill(-1);
250  // cout << " Current timestamp # " << timestamp << " Previous timestamp # " << flastTimestamp << endl;
251  }
252  else
253  timestamp == flastTimestamp ? fTimeStampQuality->Fill(0) : fTimeStampQuality->Fill(1); */
254 
255  fLastEventNumber = eventnumber;
256  flastTimestamp = timestamp;
257 
258  // check if message contains conf. if yes dump the content in a file
259  if ( mess.Contains("conf") && fShowGlobalConf ) {
260  FILE *fp; Short_t which = 0;
261  while ( which < 20 ) {
262  if ( gSystem->AccessPathName(Form("./%s%d.conf",mess.Data(),which)) )
263  break;
264  which++;
265  }
266  fp = ::fopen(Form("./%s%d.conf",mess.Data(),which),"w"); fFrame->GetFrame()->Dump(fp); ::fclose(fp);
267  }
268  if ( mess.Contains("event") ) {
269 
270  fKeyMessageSubFrame->Fill(mess.Data(),1);
271 
272  // try to look for a true message type at the beginning of the buffer
273  Bool_t is_a_start = false; Short_t max_loop = 0u;
274  buf->SetOffset();
275  while ( buf->FreeSize() > 20u ) {
276 
277  // up to ten embedded frames in one frame
278  if ( max_loop++ == 10u )
279  { fLog << " Max has been reached in scan of composite frame " << nline; break; }
280 
281  current = buf->Offset();
282 
283  (*buf) >> length >> message >> eventnumber >> timestamp ;
284 
285  mess_tmp = AgataKeyFactory::theFactory()->GetMessage(message);
286 
287  // cout << "[" << mess_tmp.Data() << "]" << endl;
288  if ( mess_tmp.Contains("UnknownKey") ) { // an unknown key
289  is_a_start = false;
290  }
291  else is_a_start = true;
292 
293  if ( is_a_start ) { // a known key has been found
294 
295  buf->SetOffset( current + length );
296 
297  mess_sec = "|";
298  mess_sec += mess_tmp;
299  mess_sec += "|";
300 
301  mess_sec = Form("|%s|",mess_tmp.Data());
302 
303  if ( mess_tmp.Contains(fSubKeyFilter ) ) {
304 
305  fLengthSubFrame->Fill(length);
306  fKeyMessageSubFrame->Fill(mess_sec.Data(),1);
307 
308  fCoincTimeStamp->Fill(timestamp-flastTimestamp);
309  }
310  }
311  else buf->SetOffset( current + 4u );
312  }
313  }
314 
315  if ( fWhichBin == kMaxCycle ) {
316  fWhichBin = 0u;
317  fEventNumber->Reset("ICE"); fTimeStamp->Reset("ICE");
318  }
319  else fWhichBin++;
320 }
321 
325 
326 TSRate::TSRate(const Char_t *name, const Char_t *title, TDirectory *sp_dir, TDirectory *tag_dir) :
327  ADFWatcher(name,title,sp_dir,tag_dir),
328  fTSRates(0)
329 {
330 }
331 
333 
334 void TSRate::Exec(Option_t * /*option*/)
335 {
336  // fLog << debug << " In TSRate::Exec() " << nline;
337 
338  if ( fFrame && fFrame->IsValid() ) {
339  AgataKey *key = dynamic_cast<AgataKey *>(fFrame->GetFrame()->GetKey());
340  if ( key ) {
341  ULong64_t ts = key->GetTimeStamp() ;
342  if ( fTSRates.size() > 0 ) {
343  if ( fTSRates.back() < ts )
344  fTSRates.push_back( ts ) ;
345  // else
346  // std::cout << " Two consecutive TS in a bunch inversed !" << std::endl;
347  }
348  else fTSRates.push_back( ts ) ;
349  }
350  }
351 
352  // fLog << debug << " Out TSRate::Exec() " << dolog;
353 
354 }
355 
359 
360 #include "TMath.h"
361 
362 TSRateCollector::TSRateCollector(const Char_t *name, const Char_t *title, TDirectory *sp_dir, TDirectory *tag_dir) :
363  Watcher(name,title,sp_dir,tag_dir),
364  fDefinitionRate(),
365  fCurrentRate(),
366  fTSRates(),
367  fRates(),
368  fPacketWidth(),
369  fDeadTime(),
370  fT0(kMaxULong64)
371 {
372  fTSRates.SetOwner(false); fPacketWidth.SetOwner(false); fDeadTime.SetOwner(false);
373 
374  // rate every 30 second for one hour
375  fDefinitionRate.Add(30*fgkOneSecond,120);
376  // rate every 10 minutes for 12 hour
377  fDefinitionRate.Add(600*fgkOneSecond,72);
378  // rate every hour for 48 hours
379  fDefinitionRate.Add(3600*fgkOneSecond,48);
380 }
381 
383 
385 {
386  ULong64_t val, min = kMaxULong64;
387 
388  // try and see if first time it is called or if timestamp has been reset
389  TIter next(&fTSRates);
390  TSRate *ts_rate;
391  while ( (ts_rate = (TSRate *)next()) ) {
392  if ( ts_rate->LastValues().size() ) {
393  val = ts_rate->LastValues().at(0);
394  if ( val < min )
395  min = val;
396  }
397  }
398  if ( min < fT0 ) {
399  // change histograms title to include starting time
400  TDatime dt;
401  for (Int_t i = 0; i < fRates.GetHists()->GetSize(); i++) {
402 
403  // reset stat
404  fCurrentRate[i].Reset(fDefinitionRate.fNbScales);
405 
406  if ( fRates.GetHists()->At(i) == 0x0 )
407  continue;
408  TString tmp = fRates.GetHists()->At(i)->GetName();
409  tmp += " since ";
410  tmp += dt.AsString();
411 
412  ((TH1 *)fRates.GetHists()->At(i))->Reset();
413  ((TH1 *)fRates.GetHists()->At(i))->SetTitle(tmp.Data());
414 
415  }
416  fT0 = min;
417  std::cout << " New TIMESTAMP in TSRateCollector" << fT0 << std::endl;
418  }
419 
420  return (fT0 != kMaxULong64);
421 }
422 
424 
425 void TSRateCollector::AddHook(Watcher *ts_rate, const char *fd_name)
426 {
427  const Short_t wheel_size = 5;
428  Color_t color_wheel[wheel_size] = { kBlue, kGreen+2, kOrange, kRed, kViolet };
429  Style_t style_wheel[wheel_size] = { 3001, 3002, 3003, 3004, 3005 };
430 
431  if ( !ts_rate->InheritsFrom("TSRate") )
432  return;
433 
434  if ( ts_rate ) {
435  // keep an hook on it and creates the associated struct to compute stats
436  fTSRates.Add ( ts_rate );
437  C_Rate c_rate(fDefinitionRate.fNbScales); fCurrentRate.push_back( c_rate );
438 
439  // now add histograms
440  TString hname = fd_name;
441  hname += "_Rate";
442 
443  Int_t hsize = 0;
444  for (Int_t i = 0; i < fDefinitionRate.fNbScales; i++)
445  hsize += fDefinitionRate.fNbSamples[i] + gEmptyBins;
446 
447  hsize += 10;
448  TH1F *h = MakeTH1<TH1F>(hname.Data(),"Rate",hsize,0,hsize);
449  fRates.Add(h);
450  h->SetFillColor(color_wheel[(fRates.GetHists()->GetSize()-1)%wheel_size]);
451  h->SetFillStyle(style_wheel[(fRates.GetHists()->GetSize()-1)%wheel_size]);
452  h->SetXTitle("[0][30s/bin = 1hour] -- [170][10m/bin = 12hours] -- [292][1h/bin = 2days]");
453  h->SetYTitle("k/s");
454 
455  hname = fd_name; hname += "_Width";
456  h = MakeTH1<TH1F>(hname.Data(),"Width distribution of packets (s)",200,0,20);
457  fPacketWidth.Add(h);
458  h->SetFillColor(color_wheel[(fRates.GetHists()->GetSize()-1)%wheel_size]);
459  h->SetFillStyle(style_wheel[(fRates.GetHists()->GetSize()-1)%wheel_size]);
460 
461  hname = fd_name; hname += "_Deadtime";
462  h = MakeTH1<TH1F>(hname.Data(),"Dead time distribution between consecutive packets (s)",100,0,100);
463  fDeadTime.Add(h);
464  h->SetFillColor(color_wheel[(fRates.GetHists()->GetSize()-1)%wheel_size]);
465  h->SetFillStyle(style_wheel[(fRates.GetHists()->GetSize()-1)%wheel_size]);
466  }
467 }
468 
470 
471 void TSRateCollector::DoCanvas(TCanvas *c, Option_t * /*o*/)
472 {
473  Int_t nbcolumn = 3; c->Divide(nbcolumn,fRates.GetHists()->GetSize()/nbcolumn,0.001,0.001);
474 
475  for (Int_t i = 0; i < fRates.GetHists()->GetSize(); i++) {
476  c->cd(i+1);
477  TH1 *h = (TH1F *)fRates.GetHists()->At(i);
478  if ( h )
479  h->Draw();
480  }
482  TString cmd = Form("RunLoupeOnPad( (TCanvas *)gROOT->GetListOfCanvases()->FindObject(\"%s\") )", c->GetName());
483  gROOT->ProcessLine(cmd.Data());
484 }
485 
487 
488 void TSRateCollector::Exec(Option_t * /*option*/)
489 {
490  const static Double_t to_rate = fgkOneSecond/(1000.);
491 
492  TSRate *ts_rate; TH1 *h; ULong64_t dt0, dt, slot, cycle;
493 
494  if ( gDebug > 0 )
495  printf("TSRateCollector::Exec is called \n");
496 
497  if ( fTSRates.GetSize() == 0 )
498  return; // to avoid doing things in case there are no input
499 
500  // first time this is called, computes T0
501  if ( ! SetT0() ) {
502  printf(" WARNING in TSRateCollector::Exec Cannot get First timestamp \n");
503  return;
504  }
505 
506  // loop on all registered TSRate
507 
508  for (Int_t i = 0; i < fTSRates.GetSize(); i++) {
509 
510  // get TSRate
511  ts_rate = (TSRate *)fTSRates.At(i);
512 
513  // std::cout << " TSRate name : " << ts_rate->GetName()
514  // << " , registered @ position " << i << " , has view # TS : " << ts_rate->LastValues().size() << std::endl;
515 
516  // nothing to do
517  if ( ts_rate->LastValues().size() < 2 )
518  continue;
519 
520  // compute some value to have an idea of the TS structure
521  h = (TH1F *)fPacketWidth.At(i);
522  Double_t width = ts_rate->LastValues().at(ts_rate->LastValues().size()-1) - ts_rate->LastValues().at(0);
523  width /= fgkOneSecond;
524  h->Fill(width);
525 
526  h = (TH1F *)fDeadTime.At(i);
527  if ( ts_rate->LastValues().at(0) > fCurrentRate[i].fLastTS ) {
528  h->Fill((ts_rate->LastValues().at(0)-fCurrentRate[i].fLastTS)/fgkOneSecond);
529  }
530  else { // ste underflow
531  h->Fill(-(fCurrentRate[i].fLastTS-ts_rate->LastValues().at(0))/fgkOneSecond);
532  // continue;
533  }
534  // h->Fill(ts_rate->LastValues().size());
535 
536  // std::cout << " WIDTH " << width << std::endl;
537 
538  // keep last TS of the packet for next packet
539  fCurrentRate[i].fLastTS = ts_rate->LastValues().at(ts_rate->LastValues().size()-1);
540 
541  /* // only one frame ... very low counting rate ...
542  if ( ts_rate->LastValues().size() < 2 ) {
543 // ts_rate->LastValues().resize(0);
544  // do not resize so that the value is kept in the TSRate and a new one is going to be added
545  // not really a good way to proceed but should give a quite good idea in case of very low counting rates
546  continue;
547  } */
548 
549  // statistics
550  h = (TH1F *)fRates.GetHists()->At(i);
551 
552  for (size_t j = 1; j < ts_rate->LastValues().size(); j++) {
553 
554  if ( ts_rate->LastValues().at(j) < fT0 ) {
555  std::cout << " ERROR Timestamp in array smaller that T0 " << std::endl;
556  continue;
557  }
558 
559  // compute time since T0 and since first timestamp
560  dt0 = ts_rate->LastValues().at(j) - fT0;
561  // compute time between two consecutive TS and the associated rate
562  dt = ts_rate->LastValues().at(j) - ts_rate->LastValues().at(j-1);
563 
564  // loop on the different scales to compute statistics
565  Int_t h0 = 0;
566  for (Int_t k = 0; k < fDefinitionRate.fNbScales; k++) {
567  // cycle since T0
568  cycle = dt0 / fDefinitionRate.fPrecision[k];
569  //
570  if ( cycle == fCurrentRate[i].fCycle[k] ) { // add to current for integration
571  fCurrentRate[i].fSum[k] += dt;
572  fCurrentRate[i].fNbCounts[k]++;
573  }
574  else { // a new input in the histogram
575 
576  // bin number to be changed
577  slot = fCurrentRate[i].fCycle[k] % fDefinitionRate.fNbSamples[k];
578 
579  // fill h
580  // it has to be with Sum to take into account the real time counting time and remove empty cycle
581  /* if ( slot == 0 ) {
582  for (Int_t bin = h0; bin < h0+fDefinitionRate.fNbSamples[k]; bin++) {
583  h->SetBinContent(bin+1,0);
584  }
585  } */
586  if ( fCurrentRate[i].fSum[k] > 0
587  && ((slot+h0+1) < UInt_t(h->GetNbinsX()))
588  && ((slot+h0+1) > 0) ) {
589  h->SetBinContent(slot+h0+1,fCurrentRate[i].fNbCounts[k]*to_rate/fCurrentRate[i].fSum[k]);
590  }
591  else {
592  std::cout << " SUM is O !! "
593  << fCurrentRate[i].fSum[k] << " j " << j << " " << ts_rate->LastValues().size()
594  << " " << fCurrentRate[i].fNbCounts[k] << " " << dt << std::endl;
595  }
596 
597  /* else
598  std::cout << slot+h0+1 << std::endl;
599  std::cout << fCurrentRate[i].fNbCounts[k]*to_rate/fCurrentRate[i].fSum[k] << std::endl; */
600 
601  // keep the current situation
602  fCurrentRate[i].fSum[k] = dt;
603  fCurrentRate[i].fNbCounts[k] = 1;
604 
605  fCurrentRate[i].fCycle[k] = cycle;
606  }
607  h0 += (fDefinitionRate.fNbSamples[k] + gEmptyBins);
608  }
609  }
610 
611  ts_rate->LastValues().resize(0);
612  } // i
613 
614  if ( 0 )
615  printf("TSRateCollector::Exec is done \n");
616 }
617 
621 
622 TimeStampWatcher::TimeStampWatcher( const char * name, const char * title, TDirectory *sp_dir, TDirectory *tag_dir):
623  ADFWatcher(name,title,sp_dir,tag_dir)
624 {
625  int TMax = 3600;
626  TimeStampHist = MakeTH1<TH1F>("TimeStampHist", "Time stamp distribution",TMax*10, 0, TMax);
627  FirstTimeStamp = 0;
628 }
629 
631 
633 {
634 }
635 
637 
638 void TimeStampWatcher::DoCanvas(TCanvas * /*c*/, Option_t *o)
639 {
640  TimeStampHist->Draw(o);
641 }
642 
644 
645 void TimeStampWatcher::Exec(Option_t * /*option*/)
646 {
647 
648  ULong64_t fTimestamp = ((AgataKey *)fFrame->GetFrame()->GetKey())->GetTimeStamp();
649 
650  if(fTimestamp != 0 && FirstTimeStamp==0) FirstTimeStamp = fTimestamp;
651 
652  double TSinSec = (fTimestamp-FirstTimeStamp)*10*1e-9;
653 
654  TimeStampHist->Fill(TSinSec);
655  LastTimeStamp = fTimestamp;
656 
657 }
658 
660 
661 void TimeStampWatcher::Zero(Option_t * /*opt1*/, Option_t * /*opt2*/)
662 {
663  TimeStampHist->Reset();
665 }
666 
670 
std::vector< Int_t > fNbSamples
virtual Bool_t IsValid() const
true if it is a valid pointer
Definition: Frame.h:616
void SetOutputFile(const Char_t *filename)
******************************************************************************************/// ...
virtual void Exec(Option_t *option="")
watch the current frame
virtual Key * GetKey()=0
To get the Key associated to this frame.
SharedFP * fFrame
the frame to be watched
printf("******************************************************************** \n")
virtual Frame * GetFrame() const
Definition: Frame.h:625
virtual void Exec(Option_t *option="")
watch the current frame
virtual void DoCanvas(TCanvas *c, Option_t *)
To be overwritten by real implementation if a canvas is produced.
Bool_t SetT0()
******************************************************************************************/// ...
Just dump the frame in a file.
void AddHook(Watcher *, const char *)
Add a timestamp rate.
Watcher to keep last TS values.
AgataKeyWatcher(const Char_t *name, const Char_t *title, TDirectory *sp_dir=0x0, TDirectory *tag_dir=0x0)
*/
Interface to AgataKey.
virtual const BufferIO * GetRealBuffer() const =0
give access to the underlying buffer of the data part
static const ULong64_t fgkOneSecond
virtual Bool_t SetTrigger(ADF::DFTrigger *=0x0)
Set the Frame to be watched.
LogMessage & nline(LogMessage &)
keep some values to compute rates
virtual void Print(std::ostream &out=std::cout) const
Print the content of the key.
virtual ULong64_t GetTimeStamp() const =0
To set the timestamp.
Base class for a Watcher.
Definition: Watchers.h:60
UInt_t Offset() const
it returns the current position in the buffer
Definition: BufferIO.h:240
const UInt_t aKByte
Definition: BaseBuffer.h:35
virtual void Exec(Option_t *option="")
watch the current frame
TSRateCollector(const Char_t *name, const Char_t *title, TDirectory *sp_dir=0x0, TDirectory *tag_dir=0x0)
*/
To check and display the Data Flow structure by the key content of the frame.
virtual void DoCanvas(TCanvas *c, Option_t *)
To be overwritten by real implementation if a canvas is produced.
virtual void Zero(Option_t *opt1, Option_t *opt2)
******************************************************************************************/// ...
LogMessage fLog
Definition: Watchers.h:86
virtual ~TimeStampWatcher()
******************************************************************************************/// ...
virtual void DoCanvas(TCanvas *c, Option_t *)
To be overwritten by real implementation if a canvas is produced.
UInt_t FreeSize() const
it returns the number of free bytes to the end
Definition: BufferIO.h:236
std::vector< ULong64_t > fPrecision
TimeStampWatcher(const char *name, const char *title, TDirectory *sp_dir=0x0, TDirectory *tag_dir=0x0)
*/
virtual void Exec(Option_t *option="")
******************************************************************************************/// ...
ClassImp(BaseNucleus)
TSRate(const Char_t *name, const Char_t *title, TDirectory *sp_dir=0x0, TDirectory *tag_dir=0x0)
*/
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
ADF::LogMessage & endl(ADF::LogMessage &log)
void SetKeyFilter(const Char_t *keypattern="*", const Char_t *subkeypattern="*")
change the filters applied on the main key and on subkeys
virtual void Exec(Option_t *option="")
watch the current frame
virtual UInt_t GetFrameLength() const
Base Watcher working for any kind of Frame (Frame interface)
virtual void Dump(const Char_t *filename, Bool_t anew=false) const =0
Dump the content of the frame in a file (for debugging)
std::vector< ULong64_t > & LastValues()
virtual ~AgataKeyWatcher()
******************************************************************************************/// ...
virtual UInt_t GetMessage() const =0
To get the message type encoded.
compute histograms for several TSRate
UInt_t SetOffset(UInt_t off=0u) const
change the current position.
Definition: BufferIO.cpp:122