LoopRunLimitHelper Class Reference

Helper class for keeping track of run limits in event-adding loops. More...

List of all members.

Public Member Functions

 LoopRunLimitHelper (int runLimit, int eventTot, const NCEventInfo *eventInfo)
 ~LoopRunLimitHelper ()
bool AreDone (int i, const NCEventInfo *eventInfo)
 You must call this function in every iteration of the loop.
int GetRunCounter ()

Protected Attributes

TStopwatch fStopwatch
 For progress reporting. Starts when class created.
int fEventTot
 Total number of events in the chain.
int fRunLimit
 Number of (sub)runs allowed.
int fPrevSubRun
 Subrun of the previous event.
int fPrevRun
 Run of the previous event.
int fRunCounter
 Number of (sub)runs seen so far.

Detailed Description

Helper class for keeping track of run limits in event-adding loops.

Definition at line 165 of file NCEventAdder.cxx.


Constructor & Destructor Documentation

LoopRunLimitHelper::LoopRunLimitHelper ( int  runLimit,
int  eventTot,
const NCEventInfo eventInfo 
) [inline]
Parameters:
runLimit Number of (sub)runs wanted
eventTot Total number of entries in the chain, for use in progress reporting
eventInfo Used to determine the initial run and subrun

Definition at line 172 of file NCEventAdder.cxx.

References fEventTot, fPrevRun, fPrevSubRun, fRunLimit, NCEventInfo::header, Msg::kInfo, MSG, ANtpHeaderInfo::run, and ANtpHeaderInfo::subRun.

00173     : fEventTot(eventTot), fRunLimit(runLimit), fRunCounter(0)
00174   {
00175     fPrevSubRun = eventInfo->header->subRun;
00176     fPrevRun = eventInfo->header->run;
00177 
00178     if(fRunLimit != INT_MAX){
00179       MSG("RunLimitHelper", Msg::kInfo)
00180         << fEventTot << " total events "
00181         << "limited to " << fRunLimit  << " (sub)runs" << endl;
00182     }
00183     else{
00184       MSG("RunLimitHelper", Msg::kInfo)
00185         << fEventTot << " total events, no (sub)run limit" << endl;
00186     }
00187   }

LoopRunLimitHelper::~LoopRunLimitHelper (  )  [inline]

Definition at line 189 of file NCEventAdder.cxx.

References fStopwatch, Msg::kInfo, MSG, and NC::Utility::ReportProgress().

00190   {
00191      NC::Utility::ReportProgress(1, fStopwatch);
00192      MSG("RunLimitHelper", Msg::kInfo) << endl;
00193   }


Member Function Documentation

bool LoopRunLimitHelper::AreDone ( int  i,
const NCEventInfo eventInfo 
) [inline]

You must call this function in every iteration of the loop.

Parameters:
i Loop index, used for progress reporting
eventInfo Description of event i, must be updated before this call. Used to determine current run and subrun
Returns:
If true, you should break from the loop before adding this event

Also prints progress reports to the screen

Definition at line 203 of file NCEventAdder.cxx.

References fEventTot, fPrevRun, fPrevSubRun, fRunCounter, fRunLimit, fStopwatch, NCEventInfo::header, max, NC::Utility::ReportProgress(), ANtpHeaderInfo::run, and ANtpHeaderInfo::subRun.

Referenced by NC::RealDataAdder::AddEventsToExtrapolations(), NC::MockDataAdder::AddEventsToExtrapolations(), NC::FakeDataAdder::AddEventsToExtrapolations(), and NC::SplitFakeDataAdder::AddEventsToExtrapolations().

00204   {
00205     const int thisSubRun = eventInfo->header->subRun;
00206     const int thisRun = eventInfo->header->run;
00207 
00208     if(thisRun != fPrevRun || thisSubRun != fPrevSubRun){
00209       fPrevRun = thisRun;
00210       fPrevSubRun = thisSubRun;
00211       ++fRunCounter;
00212     }
00213 
00214     // Don't do it on the very first few, other people want to print
00215     if(i % 1000 == 10)
00216       NC::Utility::ReportProgress(std::max(float(i)/fEventTot,
00217                                            float(fRunCounter)/fRunLimit),
00218                                   fStopwatch);
00219 
00220     return (fRunCounter > fRunLimit || i >= fEventTot);
00221   }

int LoopRunLimitHelper::GetRunCounter (  )  [inline]

Definition at line 223 of file NCEventAdder.cxx.

References fRunCounter.

Referenced by NC::SplitFakeDataAdder::AddEventsToExtrapolations().

00223 {return fRunCounter;}


Member Data Documentation

Total number of events in the chain.

Definition at line 228 of file NCEventAdder.cxx.

Referenced by AreDone(), and LoopRunLimitHelper().

Run of the previous event.

Definition at line 231 of file NCEventAdder.cxx.

Referenced by AreDone(), and LoopRunLimitHelper().

Subrun of the previous event.

Definition at line 230 of file NCEventAdder.cxx.

Referenced by AreDone(), and LoopRunLimitHelper().

Number of (sub)runs seen so far.

Definition at line 232 of file NCEventAdder.cxx.

Referenced by AreDone(), and GetRunCounter().

Number of (sub)runs allowed.

Definition at line 229 of file NCEventAdder.cxx.

Referenced by AreDone(), and LoopRunLimitHelper().

TStopwatch LoopRunLimitHelper::fStopwatch [protected]

For progress reporting. Starts when class created.

Definition at line 226 of file NCEventAdder.cxx.

Referenced by AreDone(), and ~LoopRunLimitHelper().


The documentation for this class was generated from the following file:

Generated on 16 Jan 2018 for loon by  doxygen 1.6.1