eFexEMRoI_v1.h 7.08 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
// Dear emacs, this is -*- c++ -*-

/*
  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/

// $Id: eFexEMRoI_v1.h 1 2019-06-30 12:15:18 watsona $
#ifndef XAODTRIGGER_VERSIONS_EFEXEMROI_V1_H
#define XAODTRIGGER_VERSIONS_EFEXEMROI_V1_H

// System include(s):
extern "C" {
#   include <stdint.h>
}
#include <vector>
#include <string>

// xAOD include(s):
#include "AthContainers/AuxElement.h"

namespace xAOD {

   /// Class describing a LVL1 eFEX EM region of interest
   ///
   /// This class describes the properties of an EM Trigger Object (TOB)
   /// or Region of Interest (RoI) in the xAOD format.
   ///
   /// @author Alan Watson <Alan.Watson@cern.ch>
   ///
   /// $Revision: 1 $
   /// $Date: 2019-06-30 12:15:18 +0100 (Sun, 30 Jun 2019) $
   ///
   class eFexEMRoI_v1 : public SG::AuxElement {

   public:
      /// Default constructor
      eFexEMRoI_v1();

      /// Initialise the object with its most important properties
      void initialize( uint8_t eFexNumber, uint32_t Word0, uint32_t Word1 = 0 );

      /// Object types
      enum ObjectType {
         xTOB  = 0, ///< This object is an xTOB (2*32 bit words)
         TOB   = 1  ///< This object is a TOB (1*32 bit word)
      };

      /// The "raw" 32-bit words describing the e/gamma candidate
      uint32_t Word0() const;
      uint32_t Word1() const;
      /// Set the "raw" 32-bit words describing the e/gamma candidate
      void setWord0( uint32_t value );
      void setWord1( uint32_t value );

      /// The eFEX number
      uint8_t eFexNumber() const;
      /// Set the eFEX number
      void seteFexNumber( uint8_t value );

      /// TOB ET (decoded from TOB, stored for convenience)
      uint16_t tobEt() const;    /// getter for integer ET on TOB scale (100 MeV/count)
      void     setTobEt( uint16_t value); /// setter for the above
      float    et() const; /// floating point value (MeV, TOB scale)


      /// Eta Coordinates (decoded from TOB, stored for convenience)
      uint8_t iEta() const;  /// getter for integer eta index (0-49)
      void    setEta( uint8_t value); /// setter for the above 
      unsigned int seed() const; /// Seed supercell index within central tower (0 -> 3)
      float eta() const; /// Floating point, full precision (0.025)

      /// Phi coordinates
      uint8_t iPhi() const; /// Getter for integer phi index (0-63)
      void  setPhi( uint8_t value); /// Setter for the above
      float phi() const; /// Floating point, ATLAS phi convention (-pi -> pi)

      
      /// Jet Discriminants
      /// Derived floating point values (not used in actual algorithm)
      float Reta() const;
      float Rhad() const;
      float Wstot() const;

      /// Actual values used in algorithm (setters and getters)
      uint16_t RetaCore() const;
      uint16_t RetaEnv() const;
      uint16_t RhadEM() const;
      uint16_t RhadHad() const;
      uint16_t WstotNumerator() const;
      uint16_t WstotDenominator() const;
      void  setRetaCore( uint16_t value);
      void  setRetaEnv( uint16_t value);
      void  setRhadEM( uint16_t value);
      void  setRhadHad( uint16_t value);
      void  setWstotNumerator( uint16_t value);
      void  setWstotDenominator( uint16_t value);

      /// Is this one a TOB (or xTOB partner of a TOB)?
      char isTOB() const;
      void setIsTOB( char value);

      /// Pattern of thresholds passed
      uint32_t thrPattern() const;
      void     setThrPattern( uint32_t value);
   
      /// Return TOB word corresponding to this TOB or xTOB
      uint32_t tobWord() const;
      

      /// Data decoded from the TOB/RoI word and eFEX number

      /// Object type (TOB or xTOB)
      ObjectType type() const;


      /// FPGA number
      unsigned int fpga() const;

      /// eta index within FPGA
      unsigned int fpgaEta() const;

      /// phi index within FPGA
      unsigned int fpgaPhi() const;

      /// Cluster up/down flag (1 = up, 0 = down)
      unsigned int UpNotDown() const;

      /// Cluster ET (TOB ET scale, 100 MeV/count)
      unsigned int etTOB() const;

      /// Cluster ET (xTOB ET scale, 25 MeV/count)
      unsigned int etXTOB() const;

      /// Jet Discriminant 1 (R_eta) results
      unsigned int RetaThresholds() const;

      /// Jet Discriminant 2 (R_had) results
      unsigned int RhadThresholds() const;

      /// Jet Discriminant 3 (W_stot) results
      unsigned int WstotThresholds() const;

      /// Seed = max flag. Is this really useful?
      unsigned int seedMax() const;

      //? Bunch crossing number (last 4 bits, xTOB only)
      unsigned int bcn4() const;

   private:

      /// Constants used in converting to ATLAS units
      static const float s_tobEtScale;
      static const float s_xTobEtScale;
      static const float s_towerEtaWidth;
      static const float s_minEta;


      /** Constants used in decoding TOB words
          For TOB word format changes these can be replaced
          by arrays in the _v2 object so that different 
          versions can be decoded by one class */

      //  Data locations within word
      static const int s_fpgaBit         = 30;
      static const int s_etaBit          = 27;
      static const int s_phiBit          = 24;
      static const int s_veto3Bit        = 22;
      static const int s_veto2Bit        = 20;
      static const int s_veto1Bit        = 18;
      static const int s_seedBit         = 16;
      static const int s_updownBit       = 15;
      static const int s_maxBit          = 14;
      static const int s_etBit           =  0;
      static const int s_etBitXTOB       =  3;
      static const int s_bcn4Bit         = 28;

      //  Data masks
      static const int s_fpgaMask        = 0x3;
      static const int s_etaMask         = 0x7;
      static const int s_phiMask         = 0x7;
      static const int s_veto1Mask       = 0x3;
      static const int s_veto2Mask       = 0x3;
      static const int s_veto3Mask       = 0x3;
      static const int s_seedMask        = 0x3;
      static const int s_updownMask      = 0x1;
      static const int s_maxMask         = 0x1;
      static const int s_etMask          = 0xfff;
      static const int s_etFullMask      = 0xffff;
      static const int s_bcn4Mask        = 0xf;
      // For decoding coordinates
      // 
      static const int s_numPhi          = 64;
      static const int s_eFexPhiMask     = 0xf;
      static const int s_eFexPhiBit      =  0;
      static const int s_eFexPhiWidth    =  8;
      static const int s_eFexPhiOffset   =  2;
      static const int s_eFexEtaMask     = 0xf;
      static const int s_eFexEtaBit      =  4;
      static const int s_fpgaEtaWidth    =  4;
      static const int s_EtaCOffset      =  0;
      static const int s_EtaBOffset      = 17;
      static const int s_EtaAOffset      = 33;

      /// eFEX numbering (eta, 3 locations)
      enum eFEXTypes {eFexC = 0xc, eFexB = 0xb, eFexA = 0xa};

      /// Compute eta & phi indices from TOB word
      int etaIndex() const;
      int phiIndex() const;

   }; // class eFexEMRoI_v1

} // namespace xAOD

// Declare the inheritance of the type:
#include "xAODCore/BaseInfo.h"
SG_BASE( xAOD::eFexEMRoI_v1, SG::AuxElement );

#endif // XAODTRIGGER_VERSIONS_EFEXEMROI_V1_H