ATLAS Offline Software
Loading...
Searching...
No Matches
LArStripCell.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3 */
4
5#ifndef GLOBALSIM_LARSTRIPCELL_H
6#define GLOBALSIM_LARSTRIPCELL_H
7
9
10namespace GlobalSim {
11
12 namespace v1 {
13 class LArStripCell : public BitSpec<LArStripCell,32> {
14
15 // this is the "6-40-4" MLE ... only 6 of the 13 bits of et field will encode energy
16 // the 2 MSB are the "range index" and the remaining bits are the "code" within the range
17 // the LSBs in each range are 40, 40*4, 40*4*4, 40*4*4*4 MeV
18 public:
19 static const int sBITS = 6;
20 static const int sLSB = 40; // in MeV! Assumes cannot have fractional MeV!
21 static const int sGAIN = 4;
22 protected:
23 static const size_t sMAXCODE = (1<<(sBITS-2)) - 1; // max code in a given range
24
25 static std::pair<float,float> et_mld(std::bitset<13> et) {
26 auto range = std::min (3ul, (et.to_ulong() >> (sBITS-2)));
27 auto code = (et.to_ulong()) & sMAXCODE;
28 int out = 0;
29 auto scale = sLSB;
30 while(range>0) {
31 out += scale*sMAXCODE;
32 scale *= sGAIN;
33 range--;
34 }
35 return {out + scale*code,out+scale*(code+1)};
36 }
37
38 static Bitset<13> et_mle(float et) {
39 // this code is based off "LArCellPreparationAlg::encodeEnergy"
40
41 if(et < 0) return 0;
42 int et_int = std::round(et); // uses only integer MeV values
43 unsigned int out_range = 0;
44 auto scale = sLSB;
45 float offset = 0;
46 while(et_int >= (offset + sMAXCODE*scale)) {
47 out_range++;
48 if(out_range==4) {
49 // saturated cell, return max code
50 return (1<<sBITS)-1;
51 }
52 offset += sMAXCODE*scale;
53 scale *= sGAIN;
54 }
55 // return out_range in top 2 bits, and code in remaining bits
56 return (out_range << (sBITS-2)) + (et_int - offset)/scale;
57 }
58
59 public:
60 static inline const BitField<0, 12, float> et{{.name="et", .auxvar="et", .description="Transverse energy", .encoder=et_mle, .decoder=et_mld,.centre=0}};
61 static inline const SignedBitField<13, 22, float> eta{{.name="eta", .auxvar="eta", .description="Eta coordinate", .scale=0.0125}};
62 static inline const UnclampedBitField<23, 31, float> phi{{.name="phi", .auxvar="phi", .description="Phi coordinate", .scale=M_PI / 256}};
63
65 };
66
67 }
68
70
71}
72
73#endif
#define M_PI
Custom Bitset class that can handle clamping of values.
Definition BitSpec.h:157
static const SignedBitField< 13, 22, float > eta
static const size_t sMAXCODE
static const UnclampedBitField< 23, 31, float > phi
static std::pair< float, float > et_mld(std::bitset< 13 > et)
static Bitset< 13 > et_mle(float et)
static const BitField< 0, 12, float > et
AlgTool to read in LArStripNeighborhoods, and run the BDT Algorithm.
Definition BitSpec.h:56
BitField< Lo, Hi, AuxValue, Value, true > SignedBitField
Definition BitSpec.h:572
BitField< Lo, Hi, AuxValue, Value, false, false > UnclampedBitField
Definition BitSpec.h:575
v1::LArStripCell LArStripCell