1 |
loizides |
1.1 |
//--------------------------------------------------------------------------------------------------
|
2 |
bendavid |
1.3 |
// $Id: TriggerTable.h,v 1.2 2009/11/24 15:57:37 loizides Exp $
|
3 |
loizides |
1.1 |
//
|
4 |
|
|
// TriggerTable
|
5 |
|
|
//
|
6 |
|
|
// A convenient THashTable for storage of TriggerNames (not streamable).
|
7 |
|
|
//
|
8 |
|
|
// Authors: C.Loizides
|
9 |
|
|
//--------------------------------------------------------------------------------------------------
|
10 |
|
|
|
11 |
|
|
#ifndef MITANA_DATATREE_TRIGGERTABLE_H
|
12 |
|
|
#define MITANA_DATATREE_TRIGGERTABLE_H
|
13 |
|
|
|
14 |
|
|
#include <string>
|
15 |
|
|
#include <TObject.h>
|
16 |
|
|
#include <TString.h>
|
17 |
|
|
#include <THashTable.h>
|
18 |
|
|
#include "MitAna/DataTree/interface/TriggerName.h"
|
19 |
|
|
|
20 |
|
|
namespace mithep
|
21 |
|
|
{
|
22 |
|
|
class TriggerTable : public THashTable
|
23 |
|
|
{
|
24 |
|
|
public:
|
25 |
|
|
TriggerTable(Int_t capacity = TCollection::kInitHashTableCapacity, Int_t rehash = 0) :
|
26 |
|
|
THashTable(capacity,rehash) {}
|
27 |
|
|
|
28 |
loizides |
1.2 |
const TriggerName *Get(const char *name) const;
|
29 |
bendavid |
1.3 |
const TriggerName *GetWildcard(const char *name) const;
|
30 |
loizides |
1.2 |
const TriggerName *Get(const std::string &s) const { return Get(s.c_str()); }
|
31 |
|
|
UShort_t GetId(const char *name) const;
|
32 |
loizides |
1.1 |
using TCollection::Print;
|
33 |
loizides |
1.2 |
void Print(Option_t *opt="") const;
|
34 |
loizides |
1.1 |
|
35 |
|
|
ClassDef(TriggerTable, 0) // A convenient trigger table
|
36 |
|
|
};
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
//--------------------------------------------------------------------------------------------------
|
40 |
|
|
inline const mithep::TriggerName *mithep::TriggerTable::Get(const char *name) const
|
41 |
|
|
{
|
42 |
|
|
// Return TriggerName pointer for given name.
|
43 |
|
|
|
44 |
|
|
return dynamic_cast<const TriggerName *>(FindObject(name));
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
//--------------------------------------------------------------------------------------------------
|
48 |
bendavid |
1.3 |
inline const mithep::TriggerName *mithep::TriggerTable::GetWildcard(const char *name) const
|
49 |
|
|
{
|
50 |
|
|
// Return TriggerName pointer for given name.
|
51 |
|
|
|
52 |
|
|
TIterator *it = MakeIterator();
|
53 |
|
|
|
54 |
|
|
TObject* tempObj=0;
|
55 |
|
|
|
56 |
|
|
while((tempObj=it->Next())) {
|
57 |
|
|
TString tmpstr(tempObj->GetName());
|
58 |
|
|
if (tmpstr.BeginsWith(name)) {
|
59 |
|
|
delete it;
|
60 |
|
|
printf("returning wildcard trigger %s\n",tempObj->GetName());
|
61 |
|
|
return dynamic_cast<const TriggerName *>(tempObj);
|
62 |
|
|
}
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
return 0;
|
66 |
|
|
|
67 |
|
|
}
|
68 |
|
|
|
69 |
|
|
//--------------------------------------------------------------------------------------------------
|
70 |
loizides |
1.1 |
inline UShort_t mithep::TriggerTable::GetId(const char *name) const
|
71 |
|
|
{
|
72 |
|
|
// Return trigger id of trigger with given name.
|
73 |
|
|
|
74 |
|
|
const mithep::TriggerName *tn = Get(name);
|
75 |
|
|
if (tn)
|
76 |
|
|
return tn->Id();
|
77 |
|
|
|
78 |
|
|
Error("GetId", "TriggerName for %s not found. Returning 65535.", name);
|
79 |
|
|
return 65535;
|
80 |
|
|
}
|
81 |
|
|
#endif
|