Main Page | Namespace List | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

EventAuditor Class Reference

Experiment the monitoring of algorithms. More...

List of all members.

Public Member Functions

 EventAuditor (const std::string &, ISvcLocator *)
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual ~EventAuditor ()
virtual StatusCode beforeExecute (IAlgorithm *)
virtual StatusCode afterExecute (IAlgorithm *)

Private Attributes

INTupleWriterSvc * m_rootTupleSvc
StringProperty m_root_tree
bool m_save_tuple
std::vector< std::string > m_algoNames
 names of algorithms to audit

int m_nAlgs
MsgStream * m_log
IChronoStatSvc * m_chronoSvc
std::map< IAlgorithm *, bool > m_algoStatus
std::vector< float > m_timeVals


Detailed Description

Experiment the monitoring of algorithms.

Header
/nfs/slac/g/glast/ground/cvs/AnalysisNtuple/src/EventAuditor.cxx,v 1.4 2008/07/27 22:45:48 lsrea Exp

Definition at line 21 of file EventAuditor.cxx.


Constructor & Destructor Documentation

EventAuditor::EventAuditor const std::string &  ,
ISvcLocator * 
 

Definition at line 78 of file EventAuditor.cxx.

References m_algoNames, and m_root_tree.

00079 : Auditor(name,svcLocator)
00080 {
00081     std::vector<std::string> algoNamesVec ;
00082     algoNamesVec.push_back("Event");
00083     algoNamesVec.push_back("Generation");
00084     algoNamesVec.push_back("Reconstruction");
00085     algoNamesVec.push_back("Tkr");
00086     algoNamesVec.push_back("Cal2");
00087 
00088     declareProperty("algoNames",m_algoNames=algoNamesVec);
00089     declareProperty("tree_name",  m_root_tree="MeritTuple");
00090 }

EventAuditor::~EventAuditor  )  [virtual]
 

Definition at line 260 of file EventAuditor.cxx.

00261 {}


Member Function Documentation

StatusCode EventAuditor::afterExecute IAlgorithm *   )  [virtual]
 

Definition at line 192 of file EventAuditor.cxx.

References m_algoNames, m_algoStatus, m_chronoSvc, m_nAlgs, and m_timeVals.

00193 {
00194     // look if the algo is under monitoring
00195     if (m_algoStatus[algo]==false)
00196     { return StatusCode::SUCCESS ; }
00197 
00198     std::string thisName = algo->name();
00199 
00200     // stop chrono
00201     m_chronoSvc->chronoStop("EA_"+thisName) ;
00202 
00203     // retrieve and log the last time interval
00204     
00205     IChronoStatSvc::ChronoTime delta
00206         = m_chronoSvc->chronoDelta("EA_"+thisName,IChronoStatSvc::USER) ;
00207 
00208     float fDelta = static_cast<float>(delta)*0.000001;
00209     (*m_log) << MSG::DEBUG << thisName <<" user time: " << fDelta << " sec" << endreq ;
00210 
00211     const std::vector< std::string > & algoNames = m_algoNames ;
00212     int i;
00213     for(i=0;i<m_nAlgs;++i) {
00214         if(thisName==algoNames[i]) {
00215             m_timeVals[i] = fDelta;
00216             break;
00217         }
00218     }
00219 
00220 /* HMK Apr172008
00221     Do not want EventAuditor forcing events to be stored to the MeritTuple
00222     without meeting our trigger requirements.  Other algorithms will set
00223     this flag for us, such as AnalysisNtupleAlg
00224 
00225     m_save_tuple = true;
00226     if( m_rootTupleSvc!=0 && !m_root_tree.value().empty()){
00227         m_rootTupleSvc->storeRowFlag(m_root_tree.value(), m_save_tuple);
00228     }
00229 */
00230 
00231     return StatusCode::SUCCESS ;
00232 }

StatusCode EventAuditor::beforeExecute IAlgorithm *   )  [virtual]
 

Definition at line 160 of file EventAuditor.cxx.

References m_algoNames, m_algoStatus, m_chronoSvc, m_nAlgs, and m_timeVals.

00161 {
00162     // upgrade m_algoStatus
00163     std::string thisName = algo->name();
00164     if(thisName=="Event") {
00165         // initialize the timers
00166         m_timeVals.assign(m_nAlgs, -1.0);
00167     } 
00168 
00169     std::map< IAlgorithm *, bool >::iterator itr ;
00170     itr = m_algoStatus.find(algo) ;
00171     if ( itr == m_algoStatus.end() )
00172     {
00173         const std::vector< std::string > & algoNames = m_algoNames ;
00174         std::vector< std::string >::const_iterator algoName ;
00175 
00176         algoName = std::find(algoNames.begin(), algoNames.end(), thisName);
00177         if(algoName==algoNames.end()) {
00178             m_algoStatus[algo] = false ; 
00179             return StatusCode::SUCCESS ;
00180         } else {
00181             m_algoStatus[algo] = true ;
00182         }
00183     }
00184 
00185     if(m_algoStatus[algo]) {
00186         m_chronoSvc->chronoStart("EA_"+thisName) ;
00187         (*m_log) << MSG::DEBUG << "start " << thisName << std::endl;
00188     }
00189     return StatusCode::SUCCESS ;
00190 }

StatusCode EventAuditor::finalize  )  [virtual]
 

Definition at line 252 of file EventAuditor.cxx.

00253 {
00254     (*m_log) << MSG::DEBUG <<"finalize() "<< endreq ;
00255 //    return Auditor::finalize() ;
00256   return StatusCode::SUCCESS;
00257 
00258 }

StatusCode EventAuditor::initialize  )  [virtual]
 

Definition at line 92 of file EventAuditor.cxx.

References m_algoNames, m_chronoSvc, m_log, m_nAlgs, m_root_tree, m_rootTupleSvc, and m_timeVals.

00093 {
00094     Auditor::initialize() ;
00095     StatusCode sc = StatusCode::SUCCESS;
00096 
00097     setProperties();
00098     std::vector<std::string>& algoNames = m_algoNames;
00099     // make sure that Event is one of the monitored algs
00100     // this is so that we know when there's a new event
00101     // and can set the times to a default value (-1 sec)
00102     std::vector< std::string >::const_iterator algoName ;
00103     algoName = std::find(algoNames.begin(), algoNames.end(), "Event");
00104     if(algoName==algoNames.end()) {
00105         algoNames.insert(algoNames.begin(),"Event");
00106     }
00107 
00108     m_nAlgs = algoNames.size();
00109     m_timeVals.assign(m_nAlgs, -1.0);
00110 
00111     // message stream
00112     IMessageSvc * messageSvc ;
00113     service("MessageSvc",messageSvc,true) ;
00114     m_log = new MsgStream(messageSvc,name()) ;
00115 
00116     // chrono stat svc
00117     if (service("ChronoStatSvc",m_chronoSvc,true).isFailure())
00118     {
00119         (*m_log)<<MSG::ERROR<<"Could not find TkrReconSvc"<<endreq ;
00120         return StatusCode::FAILURE ;
00121     }
00122 
00123     // get a pointer to RootTupleSvc
00124     if( (service("RootTupleSvc", m_rootTupleSvc, true) ). isFailure() ) {
00125         (*m_log) << MSG::ERROR << " RootTupleSvc is not available" << endreq;
00126         m_rootTupleSvc=0;
00127         return StatusCode::FAILURE;
00128     }
00129 
00130     if( m_rootTupleSvc==0 ) return sc;
00131 
00132     std::string tname = m_root_tree.value();
00133 
00134     int i;
00135     for(i=0;i<m_nAlgs;++i) {
00136         m_rootTupleSvc->addItem(tname, "Aud"+m_algoNames[i] , &m_timeVals[i]);
00137     }
00138 
00139     (*m_log)<<MSG::DEBUG<<"initialize() "<<endreq ;
00140     return StatusCode::SUCCESS ;
00141 }


Member Data Documentation

std::vector<std::string> EventAuditor::m_algoNames [private]
 

names of algorithms to audit

Definition at line 46 of file EventAuditor.cxx.

Referenced by afterExecute(), beforeExecute(), EventAuditor(), and initialize().

std::map< IAlgorithm *, bool > EventAuditor::m_algoStatus [private]
 

Definition at line 54 of file EventAuditor.cxx.

Referenced by afterExecute(), and beforeExecute().

IChronoStatSvc* EventAuditor::m_chronoSvc [private]
 

Definition at line 51 of file EventAuditor.cxx.

Referenced by afterExecute(), beforeExecute(), and initialize().

MsgStream* EventAuditor::m_log [private]
 

Definition at line 50 of file EventAuditor.cxx.

Referenced by initialize().

int EventAuditor::m_nAlgs [private]
 

Definition at line 47 of file EventAuditor.cxx.

Referenced by afterExecute(), beforeExecute(), and initialize().

StringProperty EventAuditor::m_root_tree [private]
 

Definition at line 40 of file EventAuditor.cxx.

Referenced by EventAuditor(), and initialize().

INTupleWriterSvc* EventAuditor::m_rootTupleSvc [private]
 

Definition at line 39 of file EventAuditor.cxx.

Referenced by initialize().

bool EventAuditor::m_save_tuple [private]
 

Definition at line 41 of file EventAuditor.cxx.

std::vector<float> EventAuditor::m_timeVals [private]
 

Definition at line 56 of file EventAuditor.cxx.

Referenced by afterExecute(), beforeExecute(), and initialize().


The documentation for this class was generated from the following file:
Generated on Wed Nov 26 14:03:25 2008 by doxygen 1.3.3