ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/TreeMod/src/AnaFwkMod.cc
Revision: 1.3
Committed: Tue Nov 25 15:57:49 2008 UTC (16 years, 5 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_008pre1, Mit_006b, Mit_006a
Changes since 1.2: +11 -17 lines
Log Message:
Implement event counter plus storing in BaseMod. Used by AnaFwkMod.

File Contents

# Content
1 // $Id: AnaFwkMod.cc,v 1.2 2008/11/19 17:16:10 loizides 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 fSWtotal(0),
16 fSWevent(0)
17 {
18 // Constructor.
19 }
20
21 //--------------------------------------------------------------------------------------------------
22 void AnaFwkMod::Process()
23 {
24 // Do event counting and print out timing information.
25
26 // counting events
27 IncNEventsProcessed();
28
29 // check if printout should be done
30 Bool_t doPrint = 0;
31
32 MDB(kAnalysis, 4) {
33 if (GetNEventsProcessed() % 1000 == 0)
34 doPrint = 1;
35 } else {
36 MDB(kAnalysis, 3) {
37 if (GetNEventsProcessed() % 10000 == 0)
38 doPrint = 1;
39 } else {
40 MDB(kAnalysis, 2) {
41 if (GetNEventsProcessed() % 50000 == 0)
42 doPrint = 1;
43 } else {
44 MDB(kAnalysis, 1) {
45 if (GetNEventsProcessed() % 250000 == 0)
46 doPrint = 1;
47 }
48 }
49 }
50 }
51
52 if (doPrint) {
53 fSWevent->Stop();
54 Info("Process", "Events %d -> %.2gs real, %.2gs cpu (%.2g real, %.2g cpu per event)",
55 GetNEventsProcessed(), fSWevent->RealTime(), fSWevent->CpuTime(),
56 fSWevent->RealTime()/GetNEventsProcessed(), fSWevent->CpuTime()/GetNEventsProcessed());
57 fSWevent->Start();
58 }
59 }
60
61 //--------------------------------------------------------------------------------------------------
62 void AnaFwkMod::SlaveBegin()
63 {
64 // Book our histogram and start the stop watches.
65
66 fSWtotal = new TStopwatch;
67 fSWevent = new TStopwatch;
68 }
69
70 //--------------------------------------------------------------------------------------------------
71 void AnaFwkMod::SlaveTerminate()
72 {
73 // Fill event histogram and printout timing information.
74
75 SaveNEventsProcessed();
76
77 fSWtotal->Stop();
78 fSWevent->Stop();
79
80 MDB(kAnalysis, 1)
81 Info("SlaveTerminate", "Events %d -> %.2gs real, %.2gs cpu (%.2gs real, %.2gs cpu per event)",
82 GetNEventsProcessed(), fSWtotal->RealTime(), fSWtotal->CpuTime(),
83 fSWtotal->RealTime()/GetNEventsProcessed(), fSWtotal->CpuTime()/GetNEventsProcessed());
84
85 delete fSWtotal;
86 delete fSWevent;
87 }