ATLAS Offline Software
LArOFCAlg.h
Go to the documentation of this file.
1 
2 //Dear emacs, this is -*- c++ -*-
3 
4 /*
5  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
6 */
7 
8 #ifndef LARCALIBUTILS_LAROFCALGORITHM_H
9 #define LARCALIBUTILS_LAROFCALGORITHM_H
10 
11 
13 #include "GaudiKernel/ToolHandle.h"
15 
17 #include "LArCOOLConditions/LArDSPConfig.h" //unique_ptr template param with no explicit d'tor
20 
21 #include <Eigen/Dense> //Eigen::MatrixXd
22 
23 #include "tbb/blocked_range.h"
24 #include "tbb/global_control.h"
25 
26 #include <memory>
27 #include <vector>
28 #include <string>
29 
31 
32 class LArOnlineID_Base;
35 class LArOFCBinComplete;
36 class LArWaveCumul;
37 
38 
40  //Acutally this algo can do internal multi-threading at finalize
41  //but not the way regular athenaMT works, so the thread-safety checker complains
42 public:
43 
44  LArOFCAlg (const std::string& name, ISvcLocator* pSvcLocator);
46  StatusCode execute() {return StatusCode::SUCCESS;}
47  virtual StatusCode stop();
48  StatusCode finalize(){return StatusCode::SUCCESS;}
49 
50 private:
51 
52  SG::ReadCondHandleKey<LArOnOffIdMapping> m_cablingKey{this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"};
53  SG::ReadCondHandleKey<LArOnOffIdMapping> m_cablingKeySC{this,"ScCablingKey","LArOnOffIdMapSC","SG Key of SC LArOnOffIdMapping object"};
54 
56  , "CaloDetDescrManager"
57  , "CaloDetDescrManager"
58  , "SG Key for CaloDetDescrManager in the Condition Store" };
59 
61  , "CaloSuperCellDetDescrManager"
62  , "CaloSuperCellDetDescrManager"
63  , "SG Key for CaloSuperCellDetDescrManager in the Condition Store" };
64 
66  //Input:
69  unsigned gain;
70 
71  //Output:
72  std::vector<std::vector<float> > ofc_a;
73  std::vector<std::vector<float> > ofc_b;
74 
75  std::vector<std::vector<float> > ofcV2_a;
76  std::vector<std::vector<float> > ofcV2_b;
77 
78  std::vector<std::vector<float> >shape;
79  std::vector<std::vector<float> >shapeDer;
80 
81  float tstart;
83  unsigned phasewMaxAt3;
84  bool faultyOFC;
85  bool shortWave;
86 
87 
88  perChannelData_t(const LArWaveCumul* wave, const HWIdentifier hi, const unsigned g) :
89  inputWave(wave), chid(hi), gain(g),tstart(0), timeBinWidthOFC(25./24), phasewMaxAt3(0), faultyOFC(false), shortWave(false) {};
90 
91  };
92 
93 
94  std::vector<perChannelData_t> m_allChannelData;
95 
96  static void optFilt(const std::vector<float> &gWave_in, const std::vector<float> &gDerivWave_in, const Eigen::MatrixXd& autoCorrInv, //input variables
97  std::vector<float>& OFCa, std::vector<float>& OFCb // Output variables;
98  ) ;
99 
100  static void optFiltDelta(const std::vector<float> &gWave_in, const std::vector<float> &gDerivWave_in, const Eigen::MatrixXd& autoCorrInv,
101  const Eigen::VectorXd& delta, //input variables
102  std::vector<float>& vecOFCa, std::vector<float>& vecOFCb // Output variables;
103  ) ;
104 
105  static void optFiltPed(const std::vector<float> &gWave_in, const std::vector<float> &gDerivWave_in, const Eigen::MatrixXd& autoCorrInv, //input variables
106  std::vector<float>& OFCa, std::vector<float>& OFCb // Output variables;
107  ) ;
108 
109  void process(perChannelData_t&, const LArOnOffIdMapping* cabling) const;
110 
111 
112  bool verify(const HWIdentifier chid, const std::vector<float>& OFCa, const std::vector<float>& OFCb,
113  const std::vector<float>& Shape, const char* ofcversion, const unsigned phase) const;
114 
115  static void printOFCVec(const std::vector<float>& vec, MsgStream& mLog) ;
116 
117 
118  StatusCode initPhysWaveContainer(const LArOnOffIdMapping* cabling);
119  StatusCode initCaliWaveContainer();
120 
121  unsigned int m_nPoints{0};
122 
123  StringProperty m_dumpOFCfile{this, "DumpOFCfile", ""};
124  StringArrayProperty m_keylist{this, "KeyList", {}, "List of keys to process"};
125  BooleanProperty m_verify{this, "Verify", true, "Verufy OFCs after computation"};
126  BooleanProperty m_normalize{this, "Normalize", false, "Normalize input wave"};
127  BooleanProperty m_timeShift{this, "TimeShift", false, "Shifting input wave"};
128  IntegerProperty m_timeShiftByIndex{this, "TimeShiftByIndex", -1, "shifting by n bins input wave"} ;
129 
130 
131  LArCaliWaveContainer* m_waveCnt_nc=nullptr;
132 
133  UnsignedIntegerProperty m_nSamples{this, "Nsample", 5, "How many sample to compute"};
134  UnsignedIntegerProperty m_nPhases{this, "Nphase", 50, "How many sphases to compute"};
135  UnsignedIntegerProperty m_dPhases{this, "Dphase", 1, "Number of samples between two neighboring phases (OFC sets)"};
136  UnsignedIntegerProperty m_nDelays{this, "Ndelay", 24, "Number of delays in one clock"};
137  FloatProperty m_addOffset{this, "AddTimeOffset", 0., "Time offset to add"} ;
138 
139  ToolHandle<ILArAutoCorrDecoderTool> m_AutoCorrDecoder{this,"DecoderTool",{} };
140  ToolHandle<ILArAutoCorrDecoderTool> m_AutoCorrDecoderV2{this,"DecoderToolV2", {} };
141 
142  const CaloDetDescrManager_Base* m_calo_dd_man{};
143  const LArOnlineID_Base* m_onlineID{};
144  const LArOFCBinComplete* m_larPhysWaveBin{};
145 
146  DoubleProperty m_errAmpl{this, "ErrAmplitude", 0.01, "Allowed amplitude difference in check"};
147  DoubleProperty m_errTime{this, "ErrTime", 0.01, "Allowed time difference in check"};
148 
149  BooleanProperty m_readCaliWave{this, "ReadCaliWave", true, "If false PhysWave is input"};
150  BooleanProperty m_fillShape{this, "FillShape", false, "Fill also shape object"};
151  StringProperty m_ofcKey{this, "KeyOFC", "LArOFC", "Output key non-pileup OFCs"};
152  StringProperty m_ofcKeyV2{this, "KeyOFCV2", "LArOFCV2", "Output key pileup OFCs"};
153  StringProperty m_shapeKey{this, "KeyShape", "LArShape", "Output key Shape object"};
154  BooleanProperty m_storeMaxPhase{this,"StoreMaxPhase", false, "Store phase of input wave max.?"};
155  StringProperty m_ofcBinKey{this, "LArOFCBinKey", "LArOFCPhase","Key for storing OFCBin object for MAx phase"};
156 
157  StringProperty m_groupingType{this, "GroupingType", "SubDetector","Which grouping type to use"};
158  StringProperty m_larPhysWaveBinKey{this,"LArPhysWaveBinKey", "", "Key for object to choose bin"};
159 
160  IntegerProperty m_useDelta{this, "UseDelta", 0, "0= not use Delta, 1=only EMECIW/HEC/FCAL, 2=all , 3 = only EMECIW/HEC/FCAL1+high eta FCAL2-3"};
161  IntegerProperty m_useDeltaV2{this, "UseDeltaV2", 0, "Same af before for Delta"};
162  BooleanProperty m_computeV2{this, "ComputeOFCV2", false, "Compute pileup OFCs?"};
163  BooleanProperty m_computePed{this, "ComputeOFCPed", false, "Compute OFCs with additional constraint to pedestal?"};
164  IntegerProperty m_nThreads{this, "nThreads", -1, "-1: No TBB, 0: Let TBB decide, >0 number of threads"};
165 
166  BooleanProperty m_readDSPConfig{this, "ReadDSPConfig", false, "Read DSPConfig object ?"};
167  StringProperty m_DSPConfigFolder{this,"DSPConfigFolder","/LAR/Configuration/DSPConfiguration", "Folder for DSPConfig object"};
168  std::unique_ptr<LArDSPConfig> m_DSPConfig;
169 
170  BooleanProperty m_forceShift{this, "ForceShift", false, "Forcing shift of input wave ?"};
171 
172  BooleanProperty m_isSC{this, "isSC", false, "Running on cells or supercells?"};
173 
174  Eigen::VectorXd getDelta(std::vector<float>& samples, const HWIdentifier chid, unsigned nSamples) const;
175 
176 
177 
178  bool useDelta(const HWIdentifier chid, const int jobOFlag, const LArOnOffIdMapping* cabling) const;
179 
180  static const float m_fcal3Delta[5];
181  static const float m_fcal2Delta[5];
182  static const float m_fcal1Delta[5];
183 
184 
185  //Functor for processing with TBB
187  //The way this class gets used is actually thread-safe
188  public:
189  Looper(std::vector<perChannelData_t>* p, const LArOnOffIdMapping* cabling, const LArOFCAlg* a) : m_perChanData(p), m_cabling(cabling), m_ofcAlg(a) {};
190  void operator() (tbb::blocked_range<size_t>& r) const {
191  for (size_t i=r.begin();i!=r.end();++i) {
192  m_ofcAlg->process(m_perChanData->at(i),m_cabling);
193  }
194  }
195  private:
196  std::vector<perChannelData_t>* m_perChanData;
199  };
200 };
201 
202 
203 #endif
204 
python.TriggerHandler.tstart
string tstart
Definition: TriggerHandler.py:298
beamspotman.r
def r
Definition: beamspotman.py:674
LArOFCAlg::perChannelData_t::shapeDer
std::vector< std::vector< float > > shapeDer
Definition: LArOFCAlg.h:79
LArOFCAlg::perChannelData_t::perChannelData_t
perChannelData_t(const LArWaveCumul *wave, const HWIdentifier hi, const unsigned g)
Definition: LArOFCAlg.h:88
ReadOfcFromCool.phase
phase
Definition: ReadOfcFromCool.py:127
LArOFCAlg::perChannelData_t::ofc_a
std::vector< std::vector< float > > ofc_a
Definition: LArOFCAlg.h:72
LArOFCAlg
Definition: LArOFCAlg.h:39
LArWaveCumul
Definition: LArWaveCumul.h:30
LArOFCAlg::perChannelData_t::shortWave
bool shortWave
Definition: LArOFCAlg.h:85
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
LArOFCAlg::finalize
StatusCode finalize()
Definition: LArOFCAlg.h:48
LArOFCAlg::perChannelData_t
Definition: LArOFCAlg.h:65
initialize
void initialize()
Definition: run_EoverP.cxx:894
LArOFCAlg::Looper::m_cabling
const LArOnOffIdMapping * m_cabling
Definition: LArOFCAlg.h:197
LArOFCAlg::perChannelData_t::ofc_b
std::vector< std::vector< float > > ofc_b
Definition: LArOFCAlg.h:73
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
LArOFCAlg::perChannelData_t::inputWave
const LArWaveCumul * inputWave
Definition: LArOFCAlg.h:67
ILArAutoCorrDecoderTool.h
LArOFCAlg::Looper
Definition: LArOFCAlg.h:186
verify_menu_config.verify
def verify(config, trigger_level)
Definition: verify_menu_config.py:22
CaloDetDescrManager_Base
Definition: CaloDetDescrManager.h:147
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:9
PixelModuleFeMask_create_db.stop
int stop
Definition: PixelModuleFeMask_create_db.py:76
LArOFCAlg::Looper::m_ofcAlg
const LArOFCAlg * m_ofcAlg
Definition: LArOFCAlg.h:198
LArOFCAlg::perChannelData_t::faultyOFC
bool faultyOFC
Definition: LArOFCAlg.h:84
HWIdentifier
Definition: HWIdentifier.h:13
LArOFCAlg::perChannelData_t::ofcV2_a
std::vector< std::vector< float > > ofcV2_a
Definition: LArOFCAlg.h:75
SUSY_SimplifiedModel_PostInclude.process
string process
Definition: SUSY_SimplifiedModel_PostInclude.py:43
CaloDetDescrManager.h
Definition of CaloDetDescrManager.
LArCaliWaveContainer
Liquid Argon Cumulative Wave Container.
Definition: LArCaliWaveContainer.h:33
AthAlgorithm.h
LArOFCAlg::m_allChannelData
std::vector< perChannelData_t > m_allChannelData
Definition: LArOFCAlg.h:94
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
LArOnOffIdMapping.h
LArDSPConfig.h
LArOFCAlg::perChannelData_t::ofcV2_b
std::vector< std::vector< float > > ofcV2_b
Definition: LArOFCAlg.h:76
LArOFCAlg::Looper::Looper
Looper(std::vector< perChannelData_t > *p, const LArOnOffIdMapping *cabling, const LArOFCAlg *a)
Definition: LArOFCAlg.h:189
lumiFormat.i
int i
Definition: lumiFormat.py:85
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
LArOFCAlg::perChannelData_t::gain
unsigned gain
Definition: LArOFCAlg.h:69
LArOFCAlg::perChannelData_t::shape
std::vector< std::vector< float > > shape
Definition: LArOFCAlg.h:78
LArOFCAlg::Looper::m_perChanData
std::vector< perChannelData_t > * m_perChanData
Definition: LArOFCAlg.h:196
LArOFCBinComplete
Definition: LArOFCBinComplete.h:13
LArOFCAlg::m_DSPConfig
std::unique_ptr< LArDSPConfig > m_DSPConfig
Definition: LArOFCAlg.h:168
AthAlgorithm
Definition: AthAlgorithm.h:47
ReadCondHandleKey.h
LArOnlineID_Base
Helper for the Liquid Argon Calorimeter cell identifiers.
Definition: LArOnlineID_Base.h:105
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
LArOFCAlg::perChannelData_t::chid
HWIdentifier chid
Definition: LArOFCAlg.h:68
LArOFCAlg::perChannelData_t::tstart
float tstart
Definition: LArOFCAlg.h:81
LArOFCAlg::execute
StatusCode execute()
Definition: LArOFCAlg.h:46
SG::ReadCondHandleKey< LArOnOffIdMapping >
a
TList * a
Definition: liststreamerinfos.cxx:10
LArDigits2NtupleDumper.nSamples
nSamples
Definition: LArDigits2NtupleDumper.py:85
columnar::operator()
decltype(auto) operator()(ObjectId< CI, CM > id) const noexcept
Definition: ColumnAccessor.h:173
checker_macros.h
Define macros for attributes used to control the static checker.
LArOFCAlg::perChannelData_t::timeBinWidthOFC
float timeBinWidthOFC
Definition: LArOFCAlg.h:82
LArOFCAlg::perChannelData_t::phasewMaxAt3
unsigned phasewMaxAt3
Definition: LArOFCAlg.h:83
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20