ATLAS Offline Software
LArStripsCrossTalkCorrector.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //Dear emacs, this is -*-c++-*-
6 #ifndef LARSTRIPSCROSSTALKCORRECTOR_H
7 #define LARSTRIPSCROSSTALKCORRECTOR_H
8 
10 
18 
19 #include <vector>
20 #include <string>
21 #include <bitset>
22 #include <array>
23 
24 class LArEM_ID;
25 class LArOnlineID;
27 
28 //Poor man's histogramming class to monitor difference introduced by xtalk corr
30 public:
31  XtalkCorrHisto(const unsigned nBins, const float maxbin);
32  void add(const LArAccumulatedCalibDigit* dig, const float reldiff);
33  void print(MsgStream& stream, const LArOnlineID* onlId, MSG::Level lvl=MSG::INFO);
34 
35 private:
36  struct maxlistitem {
37  public:
38  maxlistitem(HWIdentifier chidin, int dacin , int delayin ,float reldiffin) :
39  chid(chidin), dac(dacin), delay(delayin), reldiff(reldiffin) {}
41  int dac;
42  int delay;
43  float reldiff;
44  };
45 
46  const unsigned m_nBins;
47  const float m_binwidth;
48  std::vector<unsigned> m_diffs;
49 
50  std::vector<maxlistitem> m_maxlist;
51 };
52 
53 
54 
55 
56 //===================================================================================
57 
59 {
60  public:
62 
63  //standard algorithm methods
64  virtual StatusCode initialize() override final;
65  virtual StatusCode execute() override final;
66  virtual StatusCode finalize() override final;
67 
68 
69  private:
70 
71  SG::ReadCondHandleKey<LArBadChannelCont> m_BCKey {this, "BadChanKey", "LArBadChannel", "SG key for LArBadChan object"};
72  SG::ReadCondHandleKey<LArBadFebCont> m_BFKey {this, "MissingFEBKey", "LArBadFeb", "SG key for miffing FEB object"};
73  SG::ReadCondHandleKey<LArOnOffIdMapping> m_cablingKey{this, "OnOffMap", "LArOnOffIdMap", "SG key for mapping object"};
74 
75 
76  Gaudi::Property<std::vector<std::string> > m_dontUseForCorr{this,"DontUseForXtalkCorr",{}, "Types of bad channel should not be taken into accout for xtalk correction of their neighbor"};
77 
78 
80  Gaudi::Property<std::vector<std::string> > m_dontCorr{this,"NoXtalkCorr",{}, "Types of bad channel should be ignored and not x-talk corrected"};
82 
83 
84 
85  const LArOnlineID* m_onlineHelper{nullptr};
86  const LArEM_ID* m_emId{nullptr};
87  unsigned int m_event_counter=0;
88  //Ranges for eta and phi indices for barrel(0) and endcap(1)
89  static constexpr auto m_MAXeta=std::to_array<unsigned>({448,208});
90  static constexpr auto m_MINeta=std::to_array<unsigned>({1,0});
91  const unsigned int m_MAXphi=64;
92  int m_nStrips=-1;
93  //Algorithm-Properties:
94  Gaudi::Property<std::vector<std::string> > m_keylist{this,"KeyList",{},"List of input keys ('HIGH','MEDIUM','LOW')"};
95  Gaudi::Property<unsigned int> m_ADCsatur {this,"ADCsaturation",0,"Cutoff value to ignore saturated digits"};
96  Gaudi::Property<float> m_acceptableDifference{this,"AcceptableDifference",20, "For sanity check: By how much the corrected value may differ from the original one (in %)"};
97 
98 
99  SG::ReadCondHandleKey<ILArPedestal> m_pedKey{this,"PedestalKey","Pedestal","Key of Pedestal object"};
100 
101  uint16_t m_fatalFebErrorPattern{0xffff};
102 
103  const size_t m_noIdx{9999999};
104 
105  //2D Eta-phi array of strip cells. A/C side is accomodated by duplicating the number of phi-bins
106  //One such array for barrel, one for endcap
107  //Idexing: Barrel/EC, eta-index, phi-index
108  std::array<std::vector < std::vector < const LArAccumulatedCalibDigit* > >,2> m_stripsLookUp;
109 
110  std::array<std::vector < std::bitset< 128 > >,2> m_knownMissingFebs;
111 
112  bool m_missingFEBsDone=false;
113 
114  std::set<HWIdentifier> m_uncorrectedIds;
115 
116  struct neighbour_t{
117  int dist{};
119  double ped{};
120  double weight{};
121  };
122 
123 
124  XtalkCorrHisto m_differences{6,0.3};
125 
126  static std::string printMaxSample(const LArAccumulatedCalibDigit* thisDig);
127  StatusCode initKnownMissingFebs();
128 
129  size_t getEtaIndex(const Identifier) const;
130  size_t getPhiIndex(const Identifier) const;
131 
132  void correctSamples(std::vector<double>& dest, const neighbour_t& neighbor) const;
133 
134 
135 };
136 
137 
139  const size_t nSamples=std::min(dest.size(),nb.dig->sampleSum().size());
140  const double pedTimesTrig=nb.ped*(double)nb.dig->nTriggers();
141  for (size_t i=0;i<nSamples;++i) {
142  dest[i]+=nb.weight*(nb.dig->sampleSum()[i]-pedTimesTrig);
143  }
144  return;
145 }
146 
148  if (m_emId->sampling(id)!=1) return m_noIdx; //Deal only with layer 1
149  const int region = m_emId->region(id);
150  const int keta = m_emId->eta(id);
151  if (abs(m_emId->barrel_ec(id))== 1) { // Barrel case
152  if (region==0)
153  return keta;
154  else
155  return m_noIdx;
156  }// end if barrel
157  else if (abs(m_emId->barrel_ec(id))== 2) { //Endcap case
158  switch (region) {
159  case 2:
160  return keta;
161  break;
162  case 3:
163  return keta+96;
164  break;
165  case 4:
166  return keta+144;
167  break;
168  default:
169  return m_noIdx;
170  break;
171  }
172  }// end if endcap
173  return m_noIdx; //endcap OW or unknown region
174 }
175 
177  const int kphi = m_emId->phi(id);
178  const int kside=m_emId->barrel_ec(id)>0;
179  return kphi+kside*m_MAXphi;
180  }
181 
182 
183 
184 #endif
LArStripsCrossTalkCorrector::getPhiIndex
size_t getPhiIndex(const Identifier) const
Definition: LArStripsCrossTalkCorrector.h:176
LArEM_Base_ID::phi
int phi(const Identifier id) const
return phi according to :
LArAccumulatedCalibDigit
Data class for calibration ADC samples preprocessed by the DSP.
Definition: LArAccumulatedCalibDigit.h:42
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:50
ATLAS_NOT_THREAD_SAFE
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
Definition: checker_macros.h:212
XtalkCorrHisto::m_binwidth
const float m_binwidth
Definition: LArStripsCrossTalkCorrector.h:47
LArStripsCrossTalkCorrector::getEtaIndex
size_t getEtaIndex(const Identifier) const
Definition: LArStripsCrossTalkCorrector.h:147
LArStripsCrossTalkCorrector::m_dontCorrMask
LArBadChannelMask m_dontCorrMask
Definition: LArStripsCrossTalkCorrector.h:81
initialize
void initialize()
Definition: run_EoverP.cxx:894
XtalkCorrHisto::maxlistitem::dac
int dac
Definition: LArStripsCrossTalkCorrector.h:41
LArStripsCrossTalkCorrector::neighbour_t
Definition: LArStripsCrossTalkCorrector.h:116
LArEM_Base_ID::region
int region(const Identifier id) const
return region according to :
LArEM_Base_ID::sampling
int sampling(const Identifier id) const
return sampling according to :
perfmonmt-printer.dest
dest
Definition: perfmonmt-printer.py:189
XtalkCorrHisto::m_diffs
std::vector< unsigned > m_diffs
Definition: LArStripsCrossTalkCorrector.h:48
LArStripsCrossTalkCorrector::m_MAXphi
const unsigned int m_MAXphi
Definition: LArStripsCrossTalkCorrector.h:91
XtalkCorrHisto::maxlistitem::maxlistitem
maxlistitem(HWIdentifier chidin, int dacin, int delayin, float reldiffin)
Definition: LArStripsCrossTalkCorrector.h:38
HWIdentifier
Definition: HWIdentifier.h:13
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
LArEM_Base_ID::eta
int eta(const Identifier id) const
return eta according to :
LArStripsCrossTalkCorrector::m_stripsLookUp
std::array< std::vector< std::vector< const LArAccumulatedCalibDigit * > >, 2 > m_stripsLookUp
Definition: LArStripsCrossTalkCorrector.h:108
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
LArG4FSStartPointFilterLegacy.execute
execute
Definition: LArG4FSStartPointFilterLegacy.py:20
AthAlgorithm.h
LArStripsCrossTalkCorrector::m_emId
const LArEM_ID * m_emId
Definition: LArStripsCrossTalkCorrector.h:86
LArBadChannelCont.h
LArStripsCrossTalkCorrector::m_noIdx
const size_t m_noIdx
Definition: LArStripsCrossTalkCorrector.h:103
LArStripsCrossTalkCorrector::m_knownMissingFebs
std::array< std::vector< std::bitset< 128 > >, 2 > m_knownMissingFebs
Definition: LArStripsCrossTalkCorrector.h:110
XtalkCorrHisto::print
void print(MsgStream &stream, const LArOnlineID *onlId, MSG::Level lvl=MSG::INFO)
Definition: LArStripsCrossTalkCorrector.cxx:534
LArOnOffIdMapping.h
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
lumiFormat.i
int i
Definition: lumiFormat.py:85
XtalkCorrHisto::maxlistitem::chid
HWIdentifier chid
Definition: LArStripsCrossTalkCorrector.h:40
LArStripsCrossTalkCorrector::correctSamples
void correctSamples(std::vector< double > &dest, const neighbour_t &neighbor) const
Definition: LArStripsCrossTalkCorrector.h:138
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
LArStripsCrossTalkCorrector::m_uncorrectedIds
std::set< HWIdentifier > m_uncorrectedIds
Definition: LArStripsCrossTalkCorrector.h:114
XtalkCorrHisto::add
void add(const LArAccumulatedCalibDigit *dig, const float reldiff)
Definition: LArStripsCrossTalkCorrector.cxx:524
XtalkCorrHisto::XtalkCorrHisto
XtalkCorrHisto(const unsigned nBins, const float maxbin)
Definition: LArStripsCrossTalkCorrector.cxx:518
LArStripsCrossTalkCorrector
Definition: LArStripsCrossTalkCorrector.h:59
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
LArAccumulatedCalibDigit.h
AthAlgorithm
Definition: AthAlgorithm.h:47
XtalkCorrHisto::m_nBins
const unsigned m_nBins
Definition: LArStripsCrossTalkCorrector.h:46
min
#define min(a, b)
Definition: cfImp.cxx:40
ReadCondHandleKey.h
dumpTgcDigiJitter.nBins
list nBins
Definition: dumpTgcDigiJitter.py:29
LArEM_Base_ID::barrel_ec
int barrel_ec(const Identifier id) const
return barrel_ec according to :
LArOnlineID
Definition: LArOnlineID.h:20
XtalkCorrHisto::maxlistitem::delay
int delay
Definition: LArStripsCrossTalkCorrector.h:42
Example_ReadSampleNoise.ped
ped
Definition: Example_ReadSampleNoise.py:45
SG::ReadCondHandleKey
Definition: ReadCondHandleKey.h:20
LArStripsCrossTalkCorrector::m_dontUseForCorrMask
LArBadChannelMask m_dontUseForCorrMask
Definition: LArStripsCrossTalkCorrector.h:79
ILArPedestal.h
XtalkCorrHisto::maxlistitem::reldiff
float reldiff
Definition: LArStripsCrossTalkCorrector.h:43
XtalkCorrHisto::maxlistitem
Definition: LArStripsCrossTalkCorrector.h:36
AthAlgorithm::AthAlgorithm
AthAlgorithm()
Default constructor:
LArDigits2NtupleDumper.nSamples
nSamples
Definition: LArDigits2NtupleDumper.py:70
LArEM_ID
Helper class for LArEM offline identifiers.
Definition: LArEM_ID.h:118
hotSpotInTAG.nb
nb
Definition: hotSpotInTAG.py:164
checker_macros.h
Define macros for attributes used to control the static checker.
LArBadChannelMask.h
TileRawChannelBuilderTestConfig.reldiff
def reldiff(a, b)
Definition: TileRawChannelBuilderTestConfig.py:18
XtalkCorrHisto
Definition: LArStripsCrossTalkCorrector.h:29
XtalkCorrHisto::m_maxlist
std::vector< maxlistitem > m_maxlist
Definition: LArStripsCrossTalkCorrector.h:50
LArBadChannelMask
Definition: LArBadChannelMask.h:18
Identifier
Definition: IdentifierFieldParser.cxx:14