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-2024 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  void process(perChannelData_t&, const LArOnOffIdMapping* cabling) const;
106 
107 
108  bool verify(const HWIdentifier chid, const std::vector<float>& OFCa, const std::vector<float>& OFCb,
109  const std::vector<float>& Shape, const char* ofcversion, const unsigned phase) const;
110 
111  static void printOFCVec(const std::vector<float>& vec, MsgStream& mLog) ;
112 
113 
114  StatusCode initPhysWaveContainer(const LArOnOffIdMapping* cabling);
115  StatusCode initCaliWaveContainer();
116 
117 
118  std::string m_dumpOFCfile ;
119  std::vector<std::string> m_keylist;
120  bool m_verify;
124 
125 
126  LArCaliWaveContainer* m_waveCnt_nc=nullptr;
127 
128  unsigned int m_nSamples;
129  unsigned int m_nPhases;
130  unsigned int m_dPhases; // number of samples between two neighboring phases (OFC sets)
131  unsigned int m_nDelays ;
132  unsigned int m_nPoints;
133  float m_addOffset;
134 
135  ToolHandle<ILArAutoCorrDecoderTool> m_AutoCorrDecoder{this,"DecoderTool",{} };
136  ToolHandle<ILArAutoCorrDecoderTool> m_AutoCorrDecoderV2{this,"DecoderToolV2", {} };
137 
141 
142  double m_errAmpl;
143  double m_errTime;
144 
146  bool m_fillShape ;
147  std::string m_ofcKey;
148  std::string m_ofcKeyV2;
149  std::string m_shapeKey;
151  std::string m_ofcBinKey;
152 
153  // Grouping type
154  std::string m_groupingType;
155  std::string m_larPhysWaveBinKey;
156 
161 
163  std::string m_DSPConfigFolder;
164  std::unique_ptr<LArDSPConfig> m_DSPConfig;
165 
167 
168  Eigen::VectorXd getDelta(std::vector<float>& samples, const HWIdentifier chid, unsigned nSamples) const;
169 
170 
171 
172  bool useDelta(const HWIdentifier chid, const int jobOFlag, const LArOnOffIdMapping* cabling) const;
173 
174  static const float m_fcal3Delta[5];
175  static const float m_fcal2Delta[5];
176  static const float m_fcal1Delta[5];
177 
178 
179  //Functor for processing with TBB
181  //The way this class gets used is actually thread-safe
182  public:
183  Looper(std::vector<perChannelData_t>* p, const LArOnOffIdMapping* cabling, const LArOFCAlg* a) : m_perChanData(p), m_cabling(cabling), m_ofcAlg(a) {};
184  void operator() (tbb::blocked_range<size_t>& r) const {
185  for (size_t i=r.begin();i!=r.end();++i) {
186  m_ofcAlg->process(m_perChanData->at(i),m_cabling);
187  }
188  }
189  private:
190  std::vector<perChannelData_t>* m_perChanData;
193  };
194 
195  // Running on cells or supercells?
196  bool m_isSC;
197 };
198 
199 
200 #endif
201 
LArOFCAlg::m_DSPConfigFolder
std::string m_DSPConfigFolder
Definition: LArOFCAlg.h:163
python.TriggerHandler.tstart
string tstart
Definition: TriggerHandler.py:299
beamspotman.r
def r
Definition: beamspotman.py:676
LArOFCAlg::perChannelData_t::shapeDer
std::vector< std::vector< float > > shapeDer
Definition: LArOFCAlg.h:79
LArOFCAlg::m_normalize
bool m_normalize
Definition: LArOFCAlg.h:121
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
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
LArOFCAlg
Definition: LArOFCAlg.h:39
LArWaveCumul
Definition: LArWaveCumul.h:30
LArOFCAlg::m_nThreads
int m_nThreads
Definition: LArOFCAlg.h:160
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::m_verify
bool m_verify
Definition: LArOFCAlg.h:120
LArOFCAlg::finalize
StatusCode finalize()
Definition: LArOFCAlg.h:48
LArOFCAlg::m_fillShape
bool m_fillShape
Definition: LArOFCAlg.h:146
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:191
LArOFCAlg::perChannelData_t::ofc_b
std::vector< std::vector< float > > ofc_b
Definition: LArOFCAlg.h:73
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
LArOFCAlg::m_larPhysWaveBinKey
std::string m_larPhysWaveBinKey
Definition: LArOFCAlg.h:155
LArOFCAlg::perChannelData_t::inputWave
const LArWaveCumul * inputWave
Definition: LArOFCAlg.h:67
ILArAutoCorrDecoderTool.h
LArOFCAlg::Looper
Definition: LArOFCAlg.h:180
verify_menu_config.verify
def verify(config, trigger_level)
Definition: verify_menu_config.py:23
LArOFCAlg::m_isSC
bool m_isSC
Definition: LArOFCAlg.h:196
CaloDetDescrManager_Base
Definition: CaloDetDescrManager.h:147
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
PixelModuleFeMask_create_db.stop
int stop
Definition: PixelModuleFeMask_create_db.py:76
LArOFCAlg::Looper::m_ofcAlg
const LArOFCAlg * m_ofcAlg
Definition: LArOFCAlg.h:192
LArOFCAlg::perChannelData_t::faultyOFC
bool faultyOFC
Definition: LArOFCAlg.h:84
LArOFCAlg::m_errAmpl
double m_errAmpl
Definition: LArOFCAlg.h:142
HWIdentifier
Definition: HWIdentifier.h:13
LArOFCAlg::perChannelData_t::ofcV2_a
std::vector< std::vector< float > > ofcV2_a
Definition: LArOFCAlg.h:75
LArOFCAlg::m_nDelays
unsigned int m_nDelays
Definition: LArOFCAlg.h:131
LArOFCAlg::m_readDSPConfig
bool m_readDSPConfig
Definition: LArOFCAlg.h:162
SUSY_SimplifiedModel_PostInclude.process
string process
Definition: SUSY_SimplifiedModel_PostInclude.py:42
LArOFCAlg::m_timeShift
bool m_timeShift
Definition: LArOFCAlg.h:122
CaloDetDescrManager.h
Definition of CaloDetDescrManager.
LArCaliWaveContainer
Liquid Argon Cumulative Wave Container.
Definition: LArCaliWaveContainer.h:33
AthAlgorithm.h
LArOFCAlg::m_nSamples
unsigned int m_nSamples
Definition: LArOFCAlg.h:128
LArOFCAlg::m_useDeltaV2
int m_useDeltaV2
Definition: LArOFCAlg.h:158
LArOFCAlg::m_allChannelData
std::vector< perChannelData_t > m_allChannelData
Definition: LArOFCAlg.h:94
LArOnOffIdMapping.h
LArOFCAlg::m_ofcBinKey
std::string m_ofcBinKey
Definition: LArOFCAlg.h:151
LArDSPConfig.h
LArOFCAlg::perChannelData_t::ofcV2_b
std::vector< std::vector< float > > ofcV2_b
Definition: LArOFCAlg.h:76
LArOFCAlg::m_onlineID
const LArOnlineID_Base * m_onlineID
Definition: LArOFCAlg.h:139
LArOFCAlg::Looper::Looper
Looper(std::vector< perChannelData_t > *p, const LArOnOffIdMapping *cabling, const LArOFCAlg *a)
Definition: LArOFCAlg.h:183
LArOFCAlg::m_useDelta
int m_useDelta
Definition: LArOFCAlg.h:157
lumiFormat.i
int i
Definition: lumiFormat.py:92
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
LArOFCAlg::m_calo_dd_man
const CaloDetDescrManager_Base * m_calo_dd_man
Definition: LArOFCAlg.h:138
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
01SubmitToGrid.samples
samples
Definition: 01SubmitToGrid.py:58
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::m_ofcKeyV2
std::string m_ofcKeyV2
Definition: LArOFCAlg.h:148
LArOFCAlg::Looper::m_perChanData
std::vector< perChannelData_t > * m_perChanData
Definition: LArOFCAlg.h:190
LArOFCBinComplete
Definition: LArOFCBinComplete.h:13
LArOFCAlg::m_nPoints
unsigned int m_nPoints
Definition: LArOFCAlg.h:132
LArOFCAlg::m_DSPConfig
std::unique_ptr< LArDSPConfig > m_DSPConfig
Definition: LArOFCAlg.h:164
AthAlgorithm
Definition: AthAlgorithm.h:47
ReadCondHandleKey.h
LArOFCAlg::m_computeV2
bool m_computeV2
Definition: LArOFCAlg.h:159
LArOFCAlg::m_shapeKey
std::string m_shapeKey
Definition: LArOFCAlg.h:149
LArOFCAlg::m_addOffset
float m_addOffset
Definition: LArOFCAlg.h:133
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:195
LArOFCAlg::perChannelData_t::chid
HWIdentifier chid
Definition: LArOFCAlg.h:68
LArOFCAlg::perChannelData_t::tstart
float tstart
Definition: LArOFCAlg.h:81
LArOFCAlg::m_larPhysWaveBin
const LArOFCBinComplete * m_larPhysWaveBin
Definition: LArOFCAlg.h:140
LArOFCAlg::execute
StatusCode execute()
Definition: LArOFCAlg.h:46
LArOFCAlg::m_readCaliWave
bool m_readCaliWave
Definition: LArOFCAlg.h:145
LArOFCAlg::m_nPhases
unsigned int m_nPhases
Definition: LArOFCAlg.h:129
LArOFCAlg::m_dumpOFCfile
std::string m_dumpOFCfile
Definition: LArOFCAlg.h:118
SG::ReadCondHandleKey< LArOnOffIdMapping >
LArOFCAlg::m_storeMaxPhase
bool m_storeMaxPhase
Definition: LArOFCAlg.h:150
a
TList * a
Definition: liststreamerinfos.cxx:10
LArOFCAlg::m_errTime
double m_errTime
Definition: LArOFCAlg.h:143
LArOFCAlg::m_groupingType
std::string m_groupingType
Definition: LArOFCAlg.h:154
LArOFCAlg::m_forceShift
bool m_forceShift
Definition: LArOFCAlg.h:166
LArOFCAlg::m_ofcKey
std::string m_ofcKey
Definition: LArOFCAlg.h:147
LArDigits2NtupleDumper.nSamples
nSamples
Definition: LArDigits2NtupleDumper.py:70
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
LArOFCAlg::m_timeShiftByIndex
int m_timeShiftByIndex
Definition: LArOFCAlg.h:123
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20
LArOFCAlg::m_dPhases
unsigned int m_dPhases
Definition: LArOFCAlg.h:130
LArOFCAlg::m_keylist
std::vector< std::string > m_keylist
Definition: LArOFCAlg.h:119