ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/TriggerName.h
Revision: 1.3
Committed: Tue Dec 2 09:30:11 2008 UTC (16 years, 5 months ago) by loizides
Content type: text/plain
Branch: MAIN
Changes since 1.2: +4 -4 lines
Log Message:
Added DataBase for objects that do not need to the TObjects bits.

File Contents

# User Rev Content
1 loizides 1.1 //--------------------------------------------------------------------------------------------------
2 loizides 1.3 // $Id: TriggerName.h,v 1.2 2008/09/27 06:06:36 loizides Exp $
3 loizides 1.1 //
4     // TriggerName
5     //
6 loizides 1.2 // A class to hold a name and a number, ie the trigger name and trigger bit.
7 loizides 1.1 //
8     // Authors: C.Loizides
9     //--------------------------------------------------------------------------------------------------
10    
11     #ifndef MITANA_DATATREE_TRIGGERNAME_H
12     #define MITANA_DATATREE_TRIGGERNAME_H
13    
14 loizides 1.2 #include <string>
15 loizides 1.1 #include <TObject.h>
16     #include <TString.h>
17 loizides 1.2 #include <THashTable.h>
18 loizides 1.3 #include "MitAna/DataTree/interface/DataBase.h"
19 loizides 1.1
20     namespace mithep
21     {
22 loizides 1.3 class TriggerName : public DataBase
23 loizides 1.1 {
24     public:
25     TriggerName() : fId(0) {}
26 loizides 1.2 TriggerName(const char *name, UShort_t id) :
27     fName(name), fId(id), fHash(fName.Hash()) {}
28     TriggerName(const std::string &name, UShort_t id) :
29     fName(name), fId(id), fHash(fName.Hash()) {}
30     TriggerName(const TString &name, UShort_t id) :
31     fName(name), fId(id), fHash(fName.Hash()) {}
32 loizides 1.1 ~TriggerName() {}
33    
34     UShort_t Id() const { return fId; }
35     const char *GetName() const { return fName; }
36 loizides 1.2 ULong_t Hash() const { return fHash; }
37 loizides 1.1 const char *Name() const { return fName; }
38     void Print(Option_t *opt="") const;
39    
40     protected:
41     TString fName; //name
42     UShort_t fId; //id
43 loizides 1.2 UInt_t fHash; //hash
44    
45 loizides 1.3 ClassDef(TriggerName, 2) // Trigger name class
46 loizides 1.1 };
47 loizides 1.2
48     //--------------------------------------------------------------------------------------------------
49     // TriggerTable
50     //
51     // A convenient THashTable for storage of TriggerNames (not streamable).
52     //
53     // Authors: C.Loizides
54     //--------------------------------------------------------------------------------------------------
55     class TriggerTable : public THashTable
56     {
57     public:
58     TriggerTable(Int_t capacity = TCollection::kInitHashTableCapacity, Int_t rehash = 0) :
59     THashTable(capacity,rehash) {}
60     ~TriggerTable() {}
61    
62     const TriggerName *Get(const char *name) const;
63     UShort_t GetId(const char *name) const;
64     using TCollection::Print;
65     void Print(Option_t *opt="") const;
66     };
67 loizides 1.1 }
68 loizides 1.2
69     //--------------------------------------------------------------------------------------------------
70     inline const mithep::TriggerName *mithep::TriggerTable::Get(const char *name) const
71     {
72     // Return TriggerName pointer for given name.
73    
74     return dynamic_cast<const TriggerName *>(FindObject(name));
75     }
76    
77     //--------------------------------------------------------------------------------------------------
78     inline UShort_t mithep::TriggerTable::GetId(const char *name) const
79     {
80     // Return trigger id of trigger with given name.
81    
82     const mithep::TriggerName *tn = Get(name);
83     if (tn)
84     return tn->Id();
85    
86     Error("GetId", "TriggerName for %s not found. Returning 65535.", name);
87     return 65535;
88     }
89    
90 loizides 1.1 #endif