CMS 3D CMS Logo

ntupleEnum.py
Go to the documentation of this file.
1 # Poor-man enum class with string conversion
2 class _Enum:
3  def __init__(self, **values):
4  import six
5  self._reverse = {}
6  for key, value in six.iteritems(values):
7  setattr(self, key, value)
8  if value in self._reverse:
9  raise Exception("Value %s is already used for a key %s, tried to re-add it for key %s" % (value, self._reverse[value], key))
10  self._reverse[value] = key
11 
12  def toString(self, val):
13  return self._reverse[val]
14 
15 SubDet = _Enum(
16  BPix = 1,
17  FPix = 2,
18  TIB = 3,
19  TID = 4,
20  TOB = 5,
21  TEC = 6
22 )
23 
24 # Needs to be kept consistent with
25 # DataFormats/TrackReco/interface/TrackBase.h
26 Algo = _Enum(
27  undefAlgorithm = 0, ctf = 1,
28  duplicateMerge = 2, cosmics = 3,
29  initialStep = 4,
30  lowPtTripletStep = 5,
31  pixelPairStep = 6,
32  detachedTripletStep = 7,
33  mixedTripletStep = 8,
34  pixelLessStep = 9,
35  tobTecStep = 10,
36  jetCoreRegionalStep = 11,
37  conversionStep = 12,
38  muonSeededStepInOut = 13,
39  muonSeededStepOutIn = 14,
40  outInEcalSeededConv = 15, inOutEcalSeededConv = 16,
41  nuclInter = 17,
42  standAloneMuon = 18, globalMuon = 19, cosmicStandAloneMuon = 20, cosmicGlobalMuon = 21,
43  # Phase1
44  highPtTripletStep = 22, lowPtQuadStep = 23, detachedQuadStep = 24,
45  displacedGeneralStep = 25,
46  reservedForUpgrades2 = 26,
47  bTagGhostTracks = 27,
48  beamhalo = 28,
49  gsf = 29,
50  # HLT algo name
51  hltPixel = 30,
52  # steps used by PF
53  hltIter0 = 31,
54  hltIter1 = 32,
55  hltIter2 = 33,
56  hltIter3 = 34,
57  hltIter4 = 35,
58  # steps used by all other objects @HLT
59  hltIterX = 36,
60  # steps used by HI muon regional iterative tracking
61  hiRegitMuInitialStep = 37,
62  hiRegitMuLowPtTripletStep = 38,
63  hiRegitMuPixelPairStep = 39,
64  hiRegitMuDetachedTripletStep = 40,
65  hiRegitMuMixedTripletStep = 41,
66  hiRegitMuPixelLessStep = 42,
67  hiRegitMuTobTecStep = 43,
68  hiRegitMuMuonSeededStepInOut = 44,
69  hiRegitMuMuonSeededStepOutIn = 45,
70  algoSize = 46
71 )
72 
73 # Needs to kept consistent with
74 # DataFormats/TrackReco/interface/TrajectoryStopReasons.h
75 StopReason = _Enum(
76  UNINITIALIZED = 0,
77  MAX_HITS = 1,
78  MAX_LOST_HITS = 2,
79  MAX_CONSECUTIVE_LOST_HITS = 3,
80  LOST_HIT_FRACTION = 4,
81  MIN_PT = 5,
82  CHARGE_SIGNIFICANCE = 6,
83  LOOPER = 7,
84  MAX_CCC_LOST_HITS = 8,
85  NO_SEGMENTS_FOR_VALID_LAYERS = 9,
86  SEED_EXTENSION = 10,
87  SIZE = 12,
88  NOT_STOPPED = 255
89 )
90 
91 # Need to be kept consistent with
92 # DataFormats/TrackReco/interface/SeedStopReason.h
93 SeedStopReason = _Enum(
94  UNINITIALIZED = 0,
95  NOT_STOPPED = 1,
96  SEED_CLEANING = 2,
97  NO_TRAJECTORY = 3,
98  SEED_REGION_REBUILD = 4,
99  FINAL_CLEAN = 5,
100  SMOOTHING_FAILED = 6,
101  SIZE = 7
102 )
103 
104 # to be kept is synch with enum HitSimType in TrackingNtuple.py
105 HitSimType = _Enum(
106  Signal = 0,
107  ITPileup = 1,
108  OOTPileup = 2,
109  Noise = 3,
110  Unknown = 99
111 )
112 
ntupleEnum._Enum.toString
def toString(self, val)
Definition: ntupleEnum.py:12
Exception
ntupleEnum._Enum._reverse
_reverse
Definition: ntupleEnum.py:5
ntupleEnum._Enum.__init__
def __init__(self, **values)
Definition: ntupleEnum.py:3
ntupleEnum._Enum
Definition: ntupleEnum.py:2