ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/TreeMod/src/AnaFwkMod.cc
Revision: 1.1
Committed: Wed Nov 19 15:30:26 2008 UTC (16 years, 5 months ago) by loizides
Content type: text/plain
Branch: MAIN
Log Message:
Added general ana fwk module. Currently only used to give an overall event counter. Could be extended for other purposes.

File Contents

# User Rev Content
1 loizides 1.1 // $Id: GeneratorMod.cc,v 1.4 2008/11/11 21:22:54 ceballos Exp $
2    
3     #include "MitAna/TreeMod/interface/AnaFwkMod.h"
4     #include "MitAna/DataUtil/interface/Debug.h"
5     #include <TH1D.h>
6     #include <TStopwatch.h>
7    
8     using namespace mithep;
9    
10     ClassImp(mithep::AnaFwkMod)
11    
12     //--------------------------------------------------------------------------------------------------
13     AnaFwkMod::AnaFwkMod(const char *name, const char *title) :
14     BaseMod(name,title),
15     fNEventsProcessed(0),
16     hDEvents(0),
17     fSWtotal(0),
18     fSWevent(0)
19     {
20     // Constructor.
21     }
22    
23     //--------------------------------------------------------------------------------------------------
24     void AnaFwkMod::Process()
25     {
26     // Do event counting and print out timing information.
27    
28     // counting events
29     fNEventsProcessed++;
30    
31     // check if printout should be done
32     Bool_t doPrint = 0;
33    
34     MDB(kAnalysis, 4) {
35     if (fNEventsProcessed % 1000 == 0)
36     doPrint = 1;
37     } else {
38     MDB(kAnalysis, 3) {
39     if (fNEventsProcessed % 10000 == 0)
40     doPrint = 1;
41     } else {
42     MDB(kAnalysis, 2) {
43     if (fNEventsProcessed % 50000 == 0)
44     doPrint = 1;
45     } else {
46     MDB(kAnalysis, 1) {
47     if (fNEventsProcessed % 250000 == 0)
48     doPrint = 1;
49     }
50     }
51     }
52     }
53    
54     if (doPrint) {
55     fSWevent->Stop();
56     Info("Process", "Events %d -> %.2gs real, %.2gs cpu (%.2g real, %.2g cpu per event)",
57     fNEventsProcessed, fSWevent->RealTime(), fSWevent->CpuTime(),
58     fSWevent->RealTime()/fNEventsProcessed, fSWevent->CpuTime()/fNEventsProcessed);
59     fSWevent->Start();
60     }
61     }
62    
63     //--------------------------------------------------------------------------------------------------
64     void AnaFwkMod::SlaveBegin()
65     {
66     // Book our histogram and start the stop watches.
67    
68     hDEvents = new TH1D("hDEvents","hDEvents for overall event count",1,-0.5,0.5);
69     AddOutput(hDEvents);
70    
71     fSWtotal = new TStopwatch;
72     fSWevent = new TStopwatch;
73     }
74    
75     //--------------------------------------------------------------------------------------------------
76     void AnaFwkMod::SlaveTerminate()
77     {
78     // Fill event histogram and printout timing information.
79    
80     hDEvents->Fill(0.0,fNEventsProcessed);
81     hDEvents->SetEntries(fNEventsProcessed);
82    
83     fSWtotal->Stop();
84     fSWevent->Stop();
85    
86     MDB(kAnalysis, 1)
87     Info("SlaveTerminate", "Events %d -> %.2gs real, %.2gs cpu (%.2gs real, %.2gs cpu per event)",
88     fNEventsProcessed, fSWtotal->RealTime(), fSWtotal->CpuTime(),
89     fSWtotal->RealTime()/fNEventsProcessed, fSWtotal->CpuTime()/fNEventsProcessed);
90    
91     delete fSWtotal;
92     delete fSWevent;
93     }