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

# User Rev Content
1 loizides 1.6 // $Id: BaseMod.cc,v 1.5 2008/12/03 17:38:17 loizides Exp $
2 loizides 1.1
3     #include "MitAna/TreeMod/interface/BaseMod.h"
4 loizides 1.2 #include "MitAna/TreeMod/interface/HLTFwkMod.h"
5 loizides 1.3 #include <TH1D.h>
6 loizides 1.1
7     using namespace mithep;
8    
9     ClassImp(mithep::BaseMod)
10 loizides 1.2
11     //--------------------------------------------------------------------------------------------------
12 loizides 1.5 BaseMod::BaseMod(const char *name, const char *title) :
13 loizides 1.6 TAModule(name,title),
14     fFillHist(kFALSE),
15 loizides 1.5 fHltFwkMod(0),
16     fHltFwkModName("HLTFwkMod"),
17 loizides 1.6 fNEventsProc(0)
18 loizides 1.5 {
19     // Constructor.
20     }
21    
22     //--------------------------------------------------------------------------------------------------
23     const TriggerObjectsTable *BaseMod::GetHLTObjectsTable() const
24 loizides 1.2 {
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 loizides 1.5 return (dynamic_cast<const TriggerObjectsTable *>(FindPublicObj(fHltFwkMod->HLTObjsNamePub())));
32 loizides 1.2 }
33    
34     //--------------------------------------------------------------------------------------------------
35 loizides 1.5 const TriggerTable *BaseMod::GetHLTTable() const
36 loizides 1.2 {
37 loizides 1.5 // Get pointer to HLT trigger table obtained by module with given name.
38 loizides 1.2
39 loizides 1.5 if (!HasHLTInfo())
40 loizides 1.2 return 0;
41    
42 loizides 1.5 return (dynamic_cast<const TriggerTable *>(FindPublicObj(fHltFwkMod->HLTTabNamePub())));
43 loizides 1.2 }
44    
45     //--------------------------------------------------------------------------------------------------
46 loizides 1.5 Bool_t BaseMod::HasHLTInfo() const
47 loizides 1.2 {
48 loizides 1.5 // Check if HLT framework module is in list of modules.
49    
50     if (fHltFwkMod)
51     return kTRUE;
52 loizides 1.2
53     if (!GetSelector() || !GetSelector()->GetTopModule())
54     return kFALSE;
55    
56     const TList *tasks = GetSelector()->GetTopModule()->GetSubModules();
57     if (!tasks)
58     return kFALSE;
59    
60 loizides 1.5 fHltFwkMod = dynamic_cast<const HLTFwkMod*>(tasks->FindObject(fHltFwkModName));
61     if (fHltFwkMod)
62 loizides 1.2 return kTRUE;
63     return kFALSE;
64     }
65 loizides 1.3
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 loizides 1.6 hDEvents->Fill(0.0,fNEventsProc);
73     hDEvents->SetEntries(fNEventsProc);
74 loizides 1.3 AddOutput(hDEvents);
75     }