Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4AnalysisClient/TGo4Ratemeter.cxx

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 #include "TGo4Ratemeter.h"
00017 
00018 #include "TStopwatch.h"
00019 
00020 const Double_t TGo4Ratemeter::fgdUPDATEINTERVAL= 1.0; // time in s
00021 
00022 
00023 TGo4Ratemeter::TGo4Ratemeter()
00024 : fuCurrentCount(0), fuLastCount(0), fdRate(0), fdAveRate(0),  fdTime(0), fdLastTime(0),fdDeltaTime(0)
00025 {
00026    fxClock=new TStopwatch;
00027    fxClock->Stop();
00028 }
00029 
00030 TGo4Ratemeter::~TGo4Ratemeter()
00031 {
00032    delete fxClock;
00033 }
00034 
00035 void TGo4Ratemeter::Reset()
00036 {
00037    fdTime=0;
00038    fdDeltaTime=0;
00039    fdRate=0;
00040    fdAveRate=0;
00041    fuLastCount=0;
00042    fdLastTime=0;
00043    fuCurrentCount=0;
00044    fxClock->RealTime();
00045    fxClock->Start(kTRUE);
00046 }
00047 
00048 void TGo4Ratemeter::Update(Int_t increment)
00049 {
00050    if(increment<0)
00051       {
00052          if(increment==-2)
00053             fdRate=1; // first update after start: dummy rate
00054          else
00055             fdRate=0; // case of stopped analysis: zero rate
00056          // keep last values of time, average rate, eventnumber
00057       }
00058    else
00059      {
00060          // normal operation
00061          fdTime=fxClock->RealTime();
00062          fxClock->Continue();
00063          fdDeltaTime=fdTime-fdLastTime; // difference since last update
00064          fuCurrentCount+= (UInt_t) increment;
00065          UInt_t deltacount=fuCurrentCount-fuLastCount;
00066          if( fdDeltaTime > TGo4Ratemeter::fgdUPDATEINTERVAL)
00067          {
00068           // we reach the update point, calculate the rate
00069             if(fdDeltaTime>0 && deltacount>0)
00070                   fdRate= deltacount/fdDeltaTime;
00071             else
00072                   fdRate=0; // reset rate in case of stopped analysis
00073             if(fdTime>0)
00074                   fdAveRate= fuCurrentCount/fdTime;
00075             else
00076                ; //fdAveRate=0;
00077             fdLastTime=fdTime; // remember updata time and count
00078             fuLastCount=fuCurrentCount;
00079       }
00080    else
00081       {
00082                // too short time since last update, we do not calculate...
00083       } // if( fdDeltaTime > TGo4Ratemeter::fgdUPDATEINTERVAL)
00084      } //if(increment<0)
00085    fbUpdateDone=kTRUE; // tell watch thread we did the update
00086 }
00087 
00088 Bool_t TGo4Ratemeter::TestUpdate()
00089 {
00090    Bool_t rev=fbUpdateDone;
00091    fbUpdateDone=kFALSE;
00092    return rev;
00093 }
00094 
00095 
00096 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:55:50 2005 for Go4-v2.10-5 by doxygen1.2.15