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.7 by loizides, Wed Dec 2 23:18:26 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 "MitAna/DataTree/interface/DataBase.h"
18  
19   namespace mithep
20   {
21 <  class TriggerName : public TObject
21 >  class TriggerName : public DataBase
22    {
23      public:
24 <      TriggerName() : fId(0) {}
25 <      TriggerName(const char *name, UShort_t id) : fName(name), fId(id) {}
26 <      ~TriggerName() {}
27 <
28 <      UShort_t              Id()      const { return fId; }
29 <      const char           *GetName() const { return fName; }
30 <      ULong_t               Hash()    const { return fName.Hash(); }
31 <      const char           *Name()    const { return fName; }
24 >      TriggerName() : fId(0), fHash(0) {}
25 >      TriggerName(const char *name, UShort_t id) :
26 >        fName(name), fId(id), fHash(fName.Hash()) {}
27 >      TriggerName(const std::string &name, UShort_t id) :
28 >        fName(name), fId(id), fHash(fName.Hash()) {}
29 >      TriggerName(const TString &name, UShort_t id) :
30 >        fName(name), fId(id), fHash(fName.Hash()) {}
31 >
32 >      Int_t                     Compare(const TObject *o) const;  
33 >      UShort_t              Id()         const { return fId;   }
34 >      Bool_t                IsSortable() const { return kTRUE; }
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 <      
44 >      UInt_t                fHash;        //hash
45 >
46      ClassDef(TriggerName, 1) // Trigger name class
47    };
48   }
49 +
50 + //--------------------------------------------------------------------------------------------------
51 + inline Int_t mithep::TriggerName::Compare(const TObject *o) const
52 + {
53 +  // Default compare function for sorting according to transverse momentum.
54 +  // Returns -1 if this object is smaller than given object, 0 if objects are
55 +  // equal and 1 if this is larger than given object.
56 +
57 +  const mithep::TriggerName *t = dynamic_cast<const mithep::TriggerName *>(o);
58 +  if (!t)
59 +    return 1;
60 +
61 +  Double_t myid = Id();
62 +  Double_t id   = t->Id();
63 +  if (myid<id)
64 +    return -1;
65 +  else if (id<myid)
66 +    return +1;
67 +  return 0;
68 + }
69   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines