ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/TriggerName.h
Revision: 1.4
Committed: Tue Dec 9 17:47:00 2008 UTC (16 years, 4 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_006b, Mit_006a
Changes since 1.3: +2 -1 lines
Log Message:
Added ObjType to retrieve type of object.

File Contents

# User Rev Content
1 loizides 1.1 //--------------------------------------------------------------------------------------------------
2 loizides 1.4 // $Id: TriggerName.h,v 1.3 2008/12/02 09:30:11 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 loizides 1.4 EObjType ObjType() const { return kTriggerName; }
39 loizides 1.1 void Print(Option_t *opt="") const;
40    
41     protected:
42     TString fName; //name
43     UShort_t fId; //id
44 loizides 1.2 UInt_t fHash; //hash
45    
46 loizides 1.3 ClassDef(TriggerName, 2) // Trigger name class
47 loizides 1.1 };
48 loizides 1.2
49     //--------------------------------------------------------------------------------------------------
50     // TriggerTable
51     //
52     // A convenient THashTable for storage of TriggerNames (not streamable).
53     //
54     // Authors: C.Loizides
55     //--------------------------------------------------------------------------------------------------
56     class TriggerTable : public THashTable
57     {
58     public:
59     TriggerTable(Int_t capacity = TCollection::kInitHashTableCapacity, Int_t rehash = 0) :
60     THashTable(capacity,rehash) {}
61     ~TriggerTable() {}
62    
63     const TriggerName *Get(const char *name) const;
64     UShort_t GetId(const char *name) const;
65     using TCollection::Print;
66     void Print(Option_t *opt="") const;
67     };
68 loizides 1.1 }
69 loizides 1.2
70     //--------------------------------------------------------------------------------------------------
71     inline const mithep::TriggerName *mithep::TriggerTable::Get(const char *name) const
72     {
73     // Return TriggerName pointer for given name.
74    
75     return dynamic_cast<const TriggerName *>(FindObject(name));
76     }
77    
78     //--------------------------------------------------------------------------------------------------
79     inline UShort_t mithep::TriggerTable::GetId(const char *name) const
80     {
81     // Return trigger id of trigger with given name.
82    
83     const mithep::TriggerName *tn = Get(name);
84     if (tn)
85     return tn->Id();
86    
87     Error("GetId", "TriggerName for %s not found. Returning 65535.", name);
88     return 65535;
89     }
90    
91 loizides 1.1 #endif