ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/TriggerName.h
Revision: 1.5
Committed: Wed Feb 18 15:38:55 2009 UTC (16 years, 2 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_008pre2, Mit_008pre1
Changes since 1.4: +3 -6 lines
Log Message:
Reworked particle interface to cache FourVectorM

File Contents

# User Rev Content
1 loizides 1.1 //--------------------------------------------------------------------------------------------------
2 loizides 1.5 // $Id: TriggerName.h,v 1.4 2008/12/09 17:47:00 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 loizides 1.5 TriggerName() : fId(0), fHash(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
33     UShort_t Id() const { return fId; }
34     const char *GetName() const { return fName; }
35 loizides 1.2 ULong_t Hash() const { return fHash; }
36 loizides 1.1 const char *Name() const { return fName; }
37 loizides 1.4 EObjType ObjType() const { return kTriggerName; }
38 loizides 1.1 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.5 ClassDef(TriggerName, 1) // 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    
61     const TriggerName *Get(const char *name) const;
62     UShort_t GetId(const char *name) const;
63     using TCollection::Print;
64     void Print(Option_t *opt="") const;
65     };
66 loizides 1.1 }
67 loizides 1.2
68     //--------------------------------------------------------------------------------------------------
69     inline const mithep::TriggerName *mithep::TriggerTable::Get(const char *name) const
70     {
71     // Return TriggerName pointer for given name.
72    
73     return dynamic_cast<const TriggerName *>(FindObject(name));
74     }
75    
76     //--------------------------------------------------------------------------------------------------
77     inline UShort_t mithep::TriggerTable::GetId(const char *name) const
78     {
79     // Return trigger id of trigger with given name.
80    
81     const mithep::TriggerName *tn = Get(name);
82     if (tn)
83     return tn->Id();
84    
85     Error("GetId", "TriggerName for %s not found. Returning 65535.", name);
86     return 65535;
87     }
88 loizides 1.1 #endif