1 |
//--------------------------------------------------------------------------------------------------
|
2 |
// $Id: TriggerName.h,v 1.3 2008/12/02 09:30:11 loizides Exp $
|
3 |
//
|
4 |
// TriggerName
|
5 |
//
|
6 |
// A class to hold a name and a number, ie the trigger name and trigger bit.
|
7 |
//
|
8 |
// Authors: C.Loizides
|
9 |
//--------------------------------------------------------------------------------------------------
|
10 |
|
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 <THashTable.h>
|
18 |
#include "MitAna/DataTree/interface/DataBase.h"
|
19 |
|
20 |
namespace mithep
|
21 |
{
|
22 |
class TriggerName : public DataBase
|
23 |
{
|
24 |
public:
|
25 |
TriggerName() : fId(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 |
~TriggerName() {}
|
33 |
|
34 |
UShort_t Id() const { return fId; }
|
35 |
const char *GetName() const { return fName; }
|
36 |
ULong_t Hash() const { return fHash; }
|
37 |
const char *Name() const { return fName; }
|
38 |
EObjType ObjType() const { return kTriggerName; }
|
39 |
void Print(Option_t *opt="") const;
|
40 |
|
41 |
protected:
|
42 |
TString fName; //name
|
43 |
UShort_t fId; //id
|
44 |
UInt_t fHash; //hash
|
45 |
|
46 |
ClassDef(TriggerName, 2) // Trigger name class
|
47 |
};
|
48 |
|
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 |
}
|
69 |
|
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 |
#endif
|