24 #ifndef Gw_FrameDispatcher
38 Short_t FrameDispatcher::gDoTimer = 0;
42 FrameDispatcher::FrameDispatcher() :
43 Watcher(
"FD",
"An unamed Frame Dispatcher",0x0,0x0),
50 fRealTime (new TList()),
51 fCPUTime (new TList()),
56 NarvalInterface::process_config(
"./",&error_code);
62 fTriggerRate = MakeTH1<TH1D>(
"RateWatchers",
"Gives the number of time at least one Watcher is called", 10,0,10,
"Performances");
63 fBufferSize = MakeTH1<TH1F>(
"BufferSize",
"Size of the buffer [MB] treated", kMaxCycle,0,kMaxCycle,
"Performances") ;
65 std::pair<Double_t, Double_t> p; fCurrentValues.push_back(p);
67 h = MakeTH1<TH1F>(Form(
"%s_RealTime",GetName()),
"Real time [ms] to execute the Dispacher", kMaxCycle,0,kMaxCycle,
"Performances");
69 h = MakeTH1<TH1F>(Form(
"%s_CPUTime",GetName()),
"CPU time [ms] to execute the Dispacher", kMaxCycle,0,kMaxCycle,
"Performances");
73 fRealTime->SetOwner(
false); fCPUTime->SetOwner(
false);
77 Watcher(name,title,mother_watcher_dir,mother_tag_watcher_dir),
84 fRealTime (new TList()),
85 fCPUTime (new TList()),
90 NarvalInterface::process_config(
"./",&error_code);
96 fTriggerRate = MakeTH1<TH1D>(
"RateWatchers",
"Gives the number of time at least one Watcher is called", 10,0,10,
"Performances");
97 fBufferSize = MakeTH1<TH1F>(
"BufferSize",
"Size of the buffer [MB] treated", kMaxCycle,0,kMaxCycle,
"Performances") ;
99 std::pair<Double_t, Double_t> p; fCurrentValues.push_back(p);
101 h = MakeTH1<TH1F>(Form(
"%s_RealTime",GetName()),
"Real time [ms] to execute the Dispacher", kMaxCycle,0,kMaxCycle,
"Performances");
103 h = MakeTH1<TH1F>(Form(
"%s_CPUTime",GetName()),
"CPU time [ms] to execute the Dispacher", kMaxCycle,0,kMaxCycle,
"Performances");
107 fRealTime->SetOwner(
false); fCPUTime->SetOwner(
false);
123 {
delete fRealTime; fRealTime = 0x0; }
125 {
delete fCPUTime; fCPUTime = 0x0; }
131 if ( trigger && !trigger->
IsZombie() ) {
145 if ( option ==
"" ) {
146 c->Divide(2,2,0.001,0.001);
148 fTriggerRate->Draw();
152 fRealTime->At(0)->Draw();
153 for (Int_t i = 1u; i < fRealTime->GetSize(); i++) {
154 if ( fRealTime->At(i) )
155 fRealTime->At(i)->Draw(
"same");
158 fCPUTime->At(0)->Draw();
159 for (Int_t i = 1u; i < fCPUTime->GetSize(); i++) {
160 fCPUTime->At(i)->Draw(
"same");
263 if ( task == 0x0 ||
fTrigger == 0x0 )
276 if ( watch == 0x0 || trig == 0x0 )
283 (TFolder *)gROOT->GetRootFolder()->FindObject(
"//root/GwWatchers");
284 TFolder *w_folder = (TFolder *)gROOT->GetRootFolder()->FindObjectAny( Form(
"//root/GwWatchers/%s", watch->GetName() ) );
286 topfolder->Remove(w_folder);
291 Bool_t ok_dir =
false;
329 h = MakeTH1<TH1F>(Form(
"%s_RealTime_%lu",watch->GetName(),fCurrentValues.size()),
"Real time [ms] to execute the task", kMaxCycle,0,kMaxCycle,
"Performances");
331 h = MakeTH1<TH1F>(Form(
"%s_CPUTime_%lu",watch->GetName(),fCurrentValues.size()),
"CPU time [ms] to execute the task", kMaxCycle,0,kMaxCycle,
"Performances");
334 std::pair<Double_t, Double_t> p; fCurrentValues.push_back(p);
342 Bool_t to_add =
true;
344 for ( UInt_t i = 0u; i < fListOfTriggers.
GetSize(); i++ ) {
345 if ( fListOfTriggers.
At(i) == trig )
346 { to_add =
false;
break; }
353 fListOfTriggers.
Add(trig);
359 TStopwatch loop_time;
368 loop_time.Start(
true);
370 for (UInt_t i = 0u; i < fCurrentValues.size(); i++ ) {
371 fCurrentValues[i].first = 0.0;
372 fCurrentValues[i].second = 0.0;
379 printf(
"FrameDispatcher::ProcessBlock \n");
382 UInt_t error_code = 0u; UInt_t size_input_i, size_input_j;
385 fTriggerRate->Fill(0);
388 Log <<
info <<
"Dispacher called " << GetName() <<
nline;
397 for (UInt_t i = 0u; i < size_input_i; i++) {
402 size_input_i = fListOfTriggers.
GetSize();
403 for (UInt_t i = 0; i < size_input_i ; i++ ) {
404 if ( fListOfTriggers.
At(i)->
IsFired() ) {
406 for (UInt_t j = 0u; j < size_input_j ; j++)
415 TTask *task; TObjLink *lnk = GetListOfTasks()->FirstLink();
419 task = (TTask *)lnk->GetObject();
420 if ( !task->IsActive() ) {
430 if ( gDoTimer > 0 ) {
434 if ( gDoTimer > 0 ) {
440 fTriggerRate->Fill(slot);
491 if ( !gROOT->IsBatch() ) {
492 gSystem->DispatchOneEvent(
true);
493 gSystem->ProcessEvents();
497 fBufferSize->Fill(fWhichBin, block.
GetSize()/Float_t(
aMByte));
500 if ( gDoTimer > 0 ) {
502 for (UInt_t i = 0u; i < fCurrentValues.size(); i++ ) {
507 hr = (TH1 *)(fRealTime->At(i));
508 hc = (TH1 *)(fCPUTime->At(i));
510 hr->Fill(fWhichBin, 1000*fCurrentValues[i].first );
511 hc->Fill(fWhichBin, 1000*fCurrentValues[i].second );
515 hr = (TH1 *)(fRealTime->At(0));
516 hc = (TH1 *)(fCPUTime->At(0));
518 hr->Fill(fWhichBin, 1000*loop_time.RealTime() );
519 hc->Fill(fWhichBin, 1000*loop_time.CpuTime() );
522 if ( fWhichBin == kMaxCycle )
533 TIter next(GetListOfTasks());
536 while ( (task = (TTask *)next()) ) {
void Pass()
force fHasExecuted (recursively) to true
printf("******************************************************************** \n")
virtual Long64_t GetSize(UInt_t=0u) const
size of the current block
void SetOwner(Bool_t own=false)
virtual void DoCanvas(TCanvas *c, Option_t *)
To be overwritten by real implementation if a canvas is produced.
TDirectory * fTagDirectory
Tagged Objects are in folders. They can be saved/load in/from directory. This is the mother in which ...
virtual ~FrameDispatcher()
virtual UInt_t Read()
It reads the content into dedicated structures from the Frame (data part)
LogMessage & warning(LogMessage &)
virtual UInt_t ProcessBlock(ADF::FrameBlock &)
look for a Frame using the Trigger and dispatch it to sustasks
ClassImp(FrameDispatcher)
TFolder * fTopFolder
Top folder in which ae stored all spectra.
Process a buffer, trigg and dispachs the work to sub-watchers.
virtual void Zero(Option_t *hname="pool", Option_t *binning="")
watch the current frame ... to be overwritten by the watcher
LogMessage & nline(LogMessage &)
virtual void CleanTasks()
overloaded for efficiency reasons. allocation of TIter is see in Shark (macos) as time consuming ...
TStopwatch fTimeControl
Histograms that displays some statistics.
virtual Bool_t SetTrigger(ADF::DFTrigger *)
This is the default trigger for any added watcher.
Base class for a Watcher.
TDirectory * fDirectory
Objects are in folders. They can be saved/load in/from directory. This is the mother in which this wa...
virtual UInt_t GetNbInputFrame() const =0
number of input frames that define this trigger
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 ...
virtual Bool_t Register(DFTrigger *)
To register a trigger.
LogMessage & info(LogMessage &)
manipulator to modify the LogMessage
virtual void Detach(FrameBlock *in, FrameBlock *out)
void SetStatus(EStatus stat)
virtual void SetProcessMethod(const char *)
To set the current method.
Bool_t MakeDir(TFolder *f, TDirectory *mother_dir, Bool_t do_top=true)
in order to save/load, the structure of the top folders should exists in the root dir ...
virtual Frame * GetInputFrame(UInt_t which=0u)=0
to get back the frames that define this trigger
It defines the interface needed to be a consumer.
S GetSize() const
to get the current position in the stack
void Add(T *t)
Add a new pointer on the stack.
LogMessage & dolog(LogMessage &)
virtual void ClearMessage()
To clear the current message.
Bool_t IsFired() const
Check if this trigger is in fired state.
Bool_t IsZombie() const
Check if this trigger is in fired state.
virtual void Zero(Option_t *hname="pool", Option_t *binning="")
call Zero for all the watchers
Base class for a trigger on a data flow.
ADF::DFTrigger * fTrigger
trigger associated to this watcher
virtual void Print(std::ostream &out=std::cout) const
Print some informations (statistics)
virtual void Attach(FrameBlock *in, FrameBlock *out)
Attach a block to this. Rewind called if DoRewind set to true (Default)
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
virtual ADF::DFTrigger * GetTrigger() const
To know the trigger in which the frame to be watched is embedded.
virtual Bool_t SetTrigger(ADF::DFTrigger *)
To set the Frames (through a trigger) associated to this watcher.
LogMessage Log
to send messages to the log server
virtual Bool_t IsIndividualFired(UInt_t which=0u) const =0
fine tuning of the trigger current conditions
virtual void SetDirectory(TDirectory *mother_dir_of_watcher, TDirectory *mother_dir_for_tag, Bool_t load_objects=true)
change directories and Load objects if required