ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/TreeMod/src/BaseMod.cc
Revision: 1.6
Committed: Tue Dec 9 10:16:24 2008 UTC (16 years, 4 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_009, Mit_008, Mit_008pre2, Mit_008pre1, Mit_006b, Mit_006a
Changes since 1.5: +6 -5 lines
Log Message:
Added function to add histograms to output.

File Contents

# Content
1 // $Id: BaseMod.cc,v 1.5 2008/12/03 17:38:17 loizides Exp $
2
3 #include "MitAna/TreeMod/interface/BaseMod.h"
4 #include "MitAna/TreeMod/interface/HLTFwkMod.h"
5 #include <TH1D.h>
6
7 using namespace mithep;
8
9 ClassImp(mithep::BaseMod)
10
11 //--------------------------------------------------------------------------------------------------
12 BaseMod::BaseMod(const char *name, const char *title) :
13 TAModule(name,title),
14 fFillHist(kFALSE),
15 fHltFwkMod(0),
16 fHltFwkModName("HLTFwkMod"),
17 fNEventsProc(0)
18 {
19 // Constructor.
20 }
21
22 //--------------------------------------------------------------------------------------------------
23 const TriggerObjectsTable *BaseMod::GetHLTObjectsTable() const
24 {
25 // Get pointer to HLT objects table obtained by module with given name. (Note: normally
26 // you want to stick to the default argument.)
27
28 if (!HasHLTInfo())
29 return 0;
30
31 return (dynamic_cast<const TriggerObjectsTable *>(FindPublicObj(fHltFwkMod->HLTObjsNamePub())));
32 }
33
34 //--------------------------------------------------------------------------------------------------
35 const TriggerTable *BaseMod::GetHLTTable() const
36 {
37 // Get pointer to HLT trigger table obtained by module with given name.
38
39 if (!HasHLTInfo())
40 return 0;
41
42 return (dynamic_cast<const TriggerTable *>(FindPublicObj(fHltFwkMod->HLTTabNamePub())));
43 }
44
45 //--------------------------------------------------------------------------------------------------
46 Bool_t BaseMod::HasHLTInfo() const
47 {
48 // Check if HLT framework module is in list of modules.
49
50 if (fHltFwkMod)
51 return kTRUE;
52
53 if (!GetSelector() || !GetSelector()->GetTopModule())
54 return kFALSE;
55
56 const TList *tasks = GetSelector()->GetTopModule()->GetSubModules();
57 if (!tasks)
58 return kFALSE;
59
60 fHltFwkMod = dynamic_cast<const HLTFwkMod*>(tasks->FindObject(fHltFwkModName));
61 if (fHltFwkMod)
62 return kTRUE;
63 return kFALSE;
64 }
65
66 //--------------------------------------------------------------------------------------------------
67 void BaseMod::SaveNEventsProcessed(const char *name)
68 {
69 // Save the number of processed events in a one-bin histogram.
70
71 TH1D *hDEvents = new TH1D(name,"Total number of processed events",1,-0.5,0.5);
72 hDEvents->Fill(0.0,fNEventsProc);
73 hDEvents->SetEntries(fNEventsProc);
74 AddOutput(hDEvents);
75 }