ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/TriggerName.h
(Generate patch)

Comparing UserCode/MitAna/DataTree/interface/TriggerName.h (file contents):
Revision 1.1 by loizides, Wed Sep 17 04:07:28 2008 UTC vs.
Revision 1.5 by loizides, Wed Feb 18 15:38:55 2009 UTC

# Line 3 | Line 3
3   //
4   // TriggerName
5   //
6 < // Todo
6 > // A class to hold a name and a number, ie the trigger name and trigger bit.
7   //
8   // Authors: C.Loizides
9   //--------------------------------------------------------------------------------------------------
# Line 11 | Line 11
11   #ifndef MITANA_DATATREE_TRIGGERNAME_H
12   #define MITANA_DATATREE_TRIGGERNAME_H
13  
14 + #include <string>
15   #include <TObject.h>
16   #include <TString.h>
17 < #include "MitAna/DataTree/interface/Types.h"
17 > #include <THashTable.h>
18 > #include "MitAna/DataTree/interface/DataBase.h"
19  
20   namespace mithep
21   {
22 <  class TriggerName : public TObject
22 >  class TriggerName : public DataBase
23    {
24      public:
25 <      TriggerName() : fId(0) {}
26 <      TriggerName(const char *name, UShort_t id) : fName(name), fId(id) {}
27 <      ~TriggerName() {}
25 >      TriggerName() : fId(0), fHash(0) {}
26 >      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  
33        UShort_t              Id()      const { return fId; }
34        const char           *GetName() const { return fName; }
35 <      ULong_t               Hash()    const { return fName.Hash(); }
35 >      ULong_t               Hash()    const { return fHash; }
36        const char           *Name()    const { return fName; }
37 +      EObjType              ObjType() const { return kTriggerName; }      
38        void                  Print(Option_t *opt="") const;
39  
40      protected:
41        TString               fName;        //name
42        UShort_t              fId;          //id
43 <      
43 >      UInt_t                fHash;        //hash
44 >
45      ClassDef(TriggerName, 1) // Trigger name class
46    };
47 +
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 + }
67 +
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   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines