ATLAS Offline Software
Loading...
Searching...
No Matches
LArMasterWaveBuilder Class Reference

#include <LArMasterWaveBuilder.h>

Inheritance diagram for LArMasterWaveBuilder:
Collaboration diagram for LArMasterWaveBuilder:

Public Member Functions

 LArMasterWaveBuilder (const std::string &name, ISvcLocator *pSvcLocator)
 ~LArMasterWaveBuilder ()
StatusCode initialize ()
StatusCode execute ()
StatusCode stop ()
StatusCode finalize ()
StatusCode perMWCal (const std::vector< LArCaliWave * >, LArWave &mwfWave, LArWave &intrWave)
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

double diffWave (const LArCaliWave &w1, const LArCaliWave &w2, int &tbin, bool normPeak) const
double diffWave (const LArCaliWave &w1, const LArCaliWave &w2, bool normPeak) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

SG::ReadCondHandleKey< LArOnOffIdMappingm_cablingKey {this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"}
SG::ReadCondHandleKey< LArCalibLineMappingm_CLKey {this, "CalibLineKey", "LArCalibLineMap", "SG calib line key"}
LArWaveHelperm_waveHelper
std::string m_keyinput
std::string m_keyoutput
std::string m_groupingType
int m_ADCsatur
int m_DACmin
bool m_timeShift
bool m_normalize
bool m_diffWaveNormPeak
bool m_buildMWoneDAC
bool m_listAllAnalysedChannels
double m_linearityTolerance
std::vector< unsigned > m_dacMinLayer0
std::vector< unsigned > m_dacMinLayer1
std::vector< unsigned > m_dacMinLayer2
std::vector< unsigned > m_dacMinLayer3
std::vector< unsigned > m_dacMaxLayer0
std::vector< unsigned > m_dacMaxLayer1
std::vector< unsigned > m_dacMaxLayer2
std::vector< unsigned > m_dacMaxLayer3
DataObjIDColl m_extendedExtraObjects
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 25 of file LArMasterWaveBuilder.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ LArMasterWaveBuilder()

LArMasterWaveBuilder::LArMasterWaveBuilder ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 33 of file LArMasterWaveBuilder.cxx.

33 :
34 AthAlgorithm(name, pSvcLocator),
35 m_waveHelper(nullptr),
36 m_groupingType("FeedThrough") // SubDetector, Single, FeedThrough
37{
38 declareProperty("KeyInput", m_keyinput = "LArCaliWave" );
39 declareProperty("KeyOutput", m_keyoutput = "LArMasterWave" );
40 declareProperty("Normalize", m_normalize = false);
41 declareProperty("TimeShift", m_timeShift = false);
42 declareProperty("DiffWaveNormPeak", m_diffWaveNormPeak = false);
43 declareProperty("BuildMWwithOneDAC", m_buildMWoneDAC = false);
44 declareProperty("ListAllAnalysedChannels",m_listAllAnalysedChannels = false);
45 declareProperty("LinearityTolerance",m_linearityTolerance=0);
46 declareProperty("ADCsaturation", m_ADCsatur=0) ;
47 declareProperty("DACminimum", m_DACmin=0) ;
48 m_dacMinLayer0.resize(0);
49 m_dacMinLayer1.resize(0);
50 m_dacMinLayer2.resize(0);
51 m_dacMinLayer3.resize(0);
53 declareProperty("DACMinStrips",m_dacMinLayer1);
54 declareProperty("DACMinMiddle",m_dacMinLayer2);
55 declareProperty("DACMinBack", m_dacMinLayer3);
56 m_dacMaxLayer0.resize(0);
57 m_dacMaxLayer1.resize(0);
58 m_dacMaxLayer2.resize(0);
59 m_dacMaxLayer3.resize(0);
61 declareProperty("DACMaxStrips",m_dacMaxLayer1);
62 declareProperty("DACMaxMiddle",m_dacMaxLayer2);
63 declareProperty("DACMaxBack", m_dacMaxLayer3);
64 declareProperty("GroupingType",m_groupingType);
65}
AthAlgorithm()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
std::vector< unsigned > m_dacMaxLayer1
std::vector< unsigned > m_dacMinLayer0
std::vector< unsigned > m_dacMaxLayer2
std::vector< unsigned > m_dacMinLayer1
std::vector< unsigned > m_dacMaxLayer3
std::vector< unsigned > m_dacMaxLayer0
std::vector< unsigned > m_dacMinLayer3
std::vector< unsigned > m_dacMinLayer2

◆ ~LArMasterWaveBuilder()

LArMasterWaveBuilder::~LArMasterWaveBuilder ( )
default

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ diffWave() [1/2]

double LArMasterWaveBuilder::diffWave ( const LArCaliWave & w1,
const LArCaliWave & w2,
bool normPeak = false ) const
private

Definition at line 516 of file LArMasterWaveBuilder.cxx.

516 {
517 int tbin=0 ;
518 return diffWave(w1,w2,tbin,normPeak) ;
519}
double diffWave(const LArCaliWave &w1, const LArCaliWave &w2, int &tbin, bool normPeak) const

◆ diffWave() [2/2]

double LArMasterWaveBuilder::diffWave ( const LArCaliWave & w1,
const LArCaliWave & w2,
int & tbin,
bool normPeak = false ) const
private

Definition at line 521 of file LArMasterWaveBuilder.cxx.

521 {
522 double norm1, norm2 ;
523 if ( normPeak ) {
524 norm1 = w1.getSample( m_waveHelper->getMax(w1) ) ;
525 norm2 = w2.getSample( m_waveHelper->getMax(w2) ) ;
526 } else {
527 norm1 = w1.getDAC() ;
528 norm2 = w2.getDAC() ;
529 }
530 if ( norm1 <=0 || norm2 <= 0 ) return -1 ;
531 double resid = 0 ;
532 for ( unsigned u=0 ; u < w1.getSize() ; u++ ) {
533 if ( u >= w2.getSize() ) break ;
534 double diff1 = fabs( w1.getSample(u)/norm1 - w2.getSample(u)/norm2 ) ;
535 if ( diff1 > resid ) {
536 resid = diff1 ;
537 tbin = u ;
538 }
539 }
540 return resid ;
541}
int getDAC() const
DAC value.
size_t getSize() const
number of time samples
Definition LArWave.h:62
const double & getSample(const unsigned int i) const
Amplitude per time bin.
Definition LArWave.h:53
@ u
Enums for curvilinear frames.
Definition ParamDefs.h:77

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode LArMasterWaveBuilder::execute ( )
inline

Definition at line 33 of file LArMasterWaveBuilder.h.

33{return StatusCode::SUCCESS;} //empty method

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 50 of file AthAlgorithm.cxx.

51{
52 // If we didn't find any symlinks to add, just return the collection
53 // from the base class. Otherwise, return the extended collection.
54 if (!m_extendedExtraObjects.empty()) {
56 }
57 return Algorithm::extraOutputDeps();
58}
DataObjIDColl m_extendedExtraObjects

◆ finalize()

StatusCode LArMasterWaveBuilder::finalize ( )
inline

Definition at line 35 of file LArMasterWaveBuilder.h.

35{return StatusCode::SUCCESS;}

◆ initialize()

StatusCode LArMasterWaveBuilder::initialize ( )

Definition at line 70 of file LArMasterWaveBuilder.cxx.

70 {
71 // Check DACMin jobOption consistency, in case setup default values
72 if ( m_dacMinLayer0.size()<3 ) {
73 ATH_MSG_WARNING ( "DACMinPS jobOption has wrong size. Will use default." );
74 m_dacMinLayer0.resize(3);
75 m_dacMinLayer0[0] = 50;
76 m_dacMinLayer0[1] = 50 ;
77 m_dacMinLayer0[2] = 50 ;
78 }
79 if ( m_dacMinLayer1.size()<3 ) {
80 ATH_MSG_WARNING ( "DACMinStrips jobOption has wrong size. Will use default." );
81 m_dacMinLayer1.resize(3);
82 m_dacMinLayer1[0] = 50 ;
83 m_dacMinLayer1[1] = 50 ;
84 m_dacMinLayer1[2] = 50 ;
85 }
86 if ( m_dacMinLayer2.size()<3 ) {
87 ATH_MSG_WARNING ( "DACMinMiddle jobOption has wrong size. Will use default." );
88 m_dacMinLayer2.resize(3);
89 m_dacMinLayer2[0] = 50 ;
90 m_dacMinLayer2[1] = 50 ;
91 m_dacMinLayer2[2] = 50 ;
92 }
93 if ( m_dacMinLayer3.size()<3 ) {
94 ATH_MSG_WARNING ( "DACMinBack jobOption has wrong size. Will use default." );
95 m_dacMinLayer3.resize(3);
96 m_dacMinLayer3[0] = 50 ;
97 m_dacMinLayer3[1] = 50 ;
98 m_dacMinLayer3[2] = 50 ;
99 }
100
101 // Check DACMax jobOption consistency, in case setup default values
102 if ( m_dacMaxLayer0.size()<3 ) {
103 ATH_MSG_WARNING ( "DACMaxPS jobOption has wrong size. Will use default." );
104 m_dacMaxLayer0.resize(3);
105 m_dacMaxLayer0[0] = 15000;
106 m_dacMaxLayer0[1] = 50000 ;
107 m_dacMaxLayer0[2] = 65000 ;
108 }
109 if ( m_dacMaxLayer1.size()<3 ) {
110 ATH_MSG_WARNING ( "DACMaxStrips jobOption has wrong size. Will use default." );
111 m_dacMaxLayer1.resize(3);
112 m_dacMaxLayer1[0] = 800 ;
113 m_dacMaxLayer1[1] = 8000 ;
114 m_dacMaxLayer1[2] = 65000 ;
115 }
116 if ( m_dacMaxLayer2.size()<3 ) {
117 ATH_MSG_WARNING ( "DACMaxMiddle jobOption has wrong size. Will use default." );
118 m_dacMaxLayer2.resize(3);
119 m_dacMaxLayer2[0] = 1000 ;
120 m_dacMaxLayer2[1] = 10000 ;
121 m_dacMaxLayer2[2] = 65000 ;
122 }
123 if ( m_dacMaxLayer3.size()<3 ) {
124 ATH_MSG_WARNING ( "DACMaxBack jobOption has wrong size. Will use default." );
125 m_dacMaxLayer3.resize(3);
126 m_dacMaxLayer3[0] = 800 ;
127 m_dacMaxLayer3[1] = 8000 ;
128 m_dacMaxLayer3[2] = 65000 ;
129 }
130
131 m_waveHelper = new LArWaveHelper() ;
132
133 ATH_CHECK( m_cablingKey.initialize() );
134 ATH_CHECK( m_CLKey.initialize() );
135
136 return StatusCode::SUCCESS ;
137}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
SG::ReadCondHandleKey< LArCalibLineMapping > m_CLKey

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ msg()

MsgStream & AthCommonMsg< Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ perMWCal()

StatusCode LArMasterWaveBuilder::perMWCal ( const std::vector< LArCaliWave * > ,
LArWave & mwfWave,
LArWave & intrWave )

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ stop()

StatusCode LArMasterWaveBuilder::stop ( )

Definition at line 139 of file LArMasterWaveBuilder.cxx.

140{
141 ATH_MSG_INFO ( "LArMasterWaveBuilder in stop..." );
142
143 const LArOnlineID* onlineHelper;
144 const LArEM_ID* emId;
145
146 SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{m_cablingKey};
147 const LArOnOffIdMapping* cabling{*cablingHdl};
148 if(!cabling){
149 ATH_MSG_ERROR("Do not have mapping object " << m_cablingKey.key() );
150 return StatusCode::FAILURE;
151 }
152 SG::ReadCondHandle<LArCalibLineMapping> clHdl{m_CLKey};
153 const LArCalibLineMapping *clCont {*clHdl};
154 if(!clCont){
155 ATH_MSG_ERROR("Do not have calib mapping object " << m_CLKey.key() );
156 return StatusCode::FAILURE;
157 }
158 ATH_CHECK( detStore()->retrieve(onlineHelper, "LArOnlineID") );
159
160 const CaloCell_ID* idHelper = nullptr;
161 ATH_CHECK( detStore()->retrieve (idHelper, "CaloCell_ID") );
162 emId = idHelper->em_idHelper();
163
164 msg() << MSG::INFO << "Check on ADC saturation: " ;
165 if ( m_ADCsatur > 0 ) {
166 msg() << "absolute maximum less than " << m_ADCsatur << endmsg ;
167 } else if ( m_ADCsatur < 0 ) {
168 msg() << "maximum relative to sample 0 less than " << -m_ADCsatur << endmsg ;
169 } else {
170 msg() << "none!" << endmsg ;
171 }
172 msg() << MSG::INFO << "Check on mimimum DAC value: " ;
173 if ( m_DACmin > 0 ) {
174 msg() << m_DACmin << endmsg ;
175 } else {
176 msg() << "none!" << endmsg ;
177 }
178 if ( m_normalize ) {
179 ATH_MSG_INFO ( "Master Waveforms will be normalized" );
180 } else {
181 ATH_MSG_INFO ( "Master Waveforms will NOT be normalized" );
182 }
183 if ( m_timeShift ) {
184 ATH_MSG_INFO ( "Master Waveforms will be shifted to the origin" );
185 } else {
186 ATH_MSG_INFO ( "Master Waveforms will NOT be shifted to the origin" );
187 }
188 if ( m_buildMWoneDAC ) {
189 ATH_MSG_INFO ( "Build MWs even with only one usable DAC" );
190 } else {
191 ATH_MSG_INFO ( "Don't build MWs if only one usable DAC" );
192 }
193 if ( m_diffWaveNormPeak ) {
194 ATH_MSG_INFO ( "For linearity check, normalize to peak " );
195 } else {
196 ATH_MSG_INFO ( "For linearity check, normalize to DAC " );
197 }
198 ATH_MSG_INFO ( "Linearity tolerance = " << m_linearityTolerance );
199
200 // Retrieve container
201 const LArCaliWaveContainer* caliWaveContainer = nullptr;
202 ATH_CHECK( detStore()->retrieve(caliWaveContainer,m_keyinput) );
203
204 if ( caliWaveContainer == nullptr ) {
205 ATH_MSG_DEBUG ( "LArCaliWaveContainer (" << m_keyinput << ") is empty" );
206 return StatusCode::FAILURE;
207 }
208
209 ATH_MSG_INFO ( "Processing LArCaliWaveContainer from StoreGate, key = " << m_keyinput );
210
211 // create new LArCaliWaveContainer for master waveforms and dac0 waveforms
212 auto mwContainer = std::make_unique<LArCaliWaveContainer>();
213
214 ATH_CHECK( mwContainer->setGroupingType(m_groupingType,msg()) );
215 ATH_CHECK( mwContainer->initialize() );
216
217 // prepare a map for bad channels/DACs (i.e.not linear, not pulsed...). Access is badDACs[gain][channel][k-DAC]
218 std::vector< std::map<HWIdentifier, std::vector<int> > > badDACs ;
219 badDACs.resize((int)CaloGain::LARNGAIN) ;
220
221 unsigned nMasterWaves = 0 ;
222
223 for ( unsigned gain_it = CaloGain::LARHIGHGAIN; gain_it!=CaloGain::LARNGAIN; ++gain_it ) { // Loop over Gains
224
225 ATH_MSG_DEBUG ( "Evaluating master wavefroms for gain " << gain_it );
226
227 // set gain factor
228 unsigned gainFactor = (unsigned)(pow(10,2-gain_it)) ; // 100 for HG, 10 for MG, 1 for LG
229
230 // set min/max values for DAC for all layers, in this gain
231 std::vector<int> minDAC , maxDAC ;
232 minDAC.push_back(m_dacMinLayer0[gain_it]) ;
233 minDAC.push_back(m_dacMinLayer1[gain_it]) ;
234 minDAC.push_back(m_dacMinLayer2[gain_it]) ;
235 minDAC.push_back(m_dacMinLayer3[gain_it]) ;
236 maxDAC.push_back(m_dacMaxLayer0[gain_it]) ;
237 maxDAC.push_back(m_dacMaxLayer1[gain_it]) ;
238 maxDAC.push_back(m_dacMaxLayer2[gain_it]) ;
239 maxDAC.push_back(m_dacMaxLayer3[gain_it]) ;
240
241 ATH_MSG_INFO ( "Minimum DAC allowed for layers 0,1,2,3 and gain " << gain_it );
242 ATH_MSG_INFO ( " " << minDAC );
243 ATH_MSG_INFO ( "Maximum DAC allowed for layers 0,1,2,3 and gain " << gain_it );
244 ATH_MSG_INFO ( " " << maxDAC );
245
246 int DACMin = 0 ;
247 int DACMax = 65000 ;
248
249 CaliCellIt cell_it = caliWaveContainer->begin(gain_it);
250 CaliCellIt cell_it_e = caliWaveContainer->end(gain_it);
251
252 if ( cell_it == cell_it_e ) {
253 ATH_MSG_DEBUG ( "LArCaliWaveContainer (key = " << m_keyinput << ") has no wave with gain = " << gain_it );
254 continue;
255 } else {
256 ATH_MSG_DEBUG ( "Processing LArCaliWaveContainer (key = " << m_keyinput << ") in gain = " << gain_it );
257 }
258
259 for ( ; cell_it!=cell_it_e ; ++cell_it ) { // loop through channels
260
261 CaliWaveIt wave_it = cell_it->begin();
262 CaliWaveIt wave_it_e = cell_it->end();
263 if ( wave_it == wave_it_e ) {
264 ATH_MSG_DEBUG ( "Empty channel found..." );
265 continue; // skip empty channels
266 }
267
268 const LArCaliWaveContainer::LArCaliWaves& vCaliWaves = *cell_it;
269
270 HWIdentifier chID = cell_it.channelId() ;
271 double dt = vCaliWaves[0].getDt() ;
272 unsigned nDACs = vCaliWaves.size() ;
273
274 ATH_MSG_DEBUG ( nDACs << " DAC's found for channel 0x" << MSG::hex << chID.get_compact() << MSG::dec
275 << " in gain " << gain_it );
276 msg() << MSG::DEBUG << "DAC list: " ;
277 for ( unsigned i=0 ; i<nDACs ; i++ )
278 msg() << vCaliWaves[i].getDAC() << " " ;
279 msg() << endmsg ;
280
281 long layer = -1;
282 long region = -1;
283
284 try {
285 Identifier id = cabling->cnvToIdentifier(chID);
286 layer = emId->sampling(id) ;
287 region = emId->region(id) ;
288 } catch ( LArID_Exception & except ) {
289 ATH_MSG_WARNING ( "A Cabling exception was caught for channel 0x"
290 << MSG::hex << chID.get_compact() << MSG::dec
291 << ". Skipping." );
292 continue ;
293 }
294
295 if ( region==0 && layer>=0 && layer<=3 ) { // so far, only for EMB
296 DACMin = minDAC[layer] ;
297 DACMax = maxDAC[layer] ;
298 }
299
300 std::vector<double> vDACs ;
301 std::vector<const LArWave*> vWaves ;
302 std::vector<bool> usable ;
303 std::vector<int> thisDAC ;
304 std::vector<double> thisPeak ;
305 usable.resize(nDACs) ;
306 thisDAC.resize(nDACs) ;
307 thisPeak.resize(nDACs) ;
308
309 // first loop on the waves of this channel: reject waves out of range and with weak signal
310 for ( unsigned i=0 ; i<nDACs ; i++ ) {
311 thisDAC[i] = vCaliWaves[i].getDAC() ;
312 thisPeak[i] = vCaliWaves[i].getSample(m_waveHelper->getMax(vCaliWaves[i])) ;
313 // check overall DAC threshold
314 if ( m_DACmin > 0 && thisDAC[i] < m_DACmin ) {
315 ATH_MSG_DEBUG ( ChanDacGain(chID,thisDAC[i],gain_it)
316 << "DAC below threshold... skip!" );
317 usable[i] = false ;
318 continue ;
319 }
320 // check overall ADC saturation
321 if ( m_ADCsatur != 0 ) {
322 if ( m_ADCsatur>0 && thisPeak[i]>m_ADCsatur ) { // suitable if no pedestal subtraction
323 ATH_MSG_DEBUG ( ChanDacGain(chID,thisDAC[i],gain_it)
324 << " absolute ADC saturation... skip!" );
325 usable[i] = false ;
326 continue ;
327 } else if ( m_ADCsatur<0 && (thisPeak[i]-vCaliWaves[i].getSample(0))>(-m_ADCsatur) ) {
328 // for pedestal subtracted
329 ATH_MSG_DEBUG ( ChanDacGain(chID,thisDAC[i],gain_it)
330 << " relative ADC saturation... skip!" );
331 usable[i] = false ;
332 continue ;
333 }
334 }
335 // check if clearly no signal
336 if ( fabs( thisPeak[i]/thisDAC[i] ) < gainFactor*0.0001 ) {
337 ATH_MSG_DEBUG ( ChanDacGain(chID,thisDAC[i],gain_it) << " low signal... skip!" );
338 usable[i] = false ;
339 continue ;
340 }
341 usable[i] = true ;
342 }
343
344 // seek reference cali wave (for linearity check)
345 int refIndex = -1 ;
346 double minOverallDiff = 9.e+99 ;
347 for ( unsigned i=0 ; i<nDACs ; i++ ) {
348 if ( ! usable[i] ) continue ;
349 if ( thisDAC[i]<DACMin || thisDAC[i]>DACMax ) continue ;
350 double thisOverallDiff = 0 ;
351 for ( unsigned k=0 ; k<nDACs ; k++ ) {
352 if ( ! usable[k] ) continue ;
353 if ( k == i ) continue ;
354 double theDiff = diffWave( vCaliWaves[i] , vCaliWaves[k] , m_diffWaveNormPeak ) ;
355 if ( theDiff>0 ) thisOverallDiff += theDiff ;
356 }
357 if ( thisOverallDiff < minOverallDiff ) {
358 refIndex = i ;
359 minOverallDiff = thisOverallDiff ;
360 }
361 }
362 // reject strongly non-linear waves (if reference wave was found)
363 if ( refIndex >=0 ) {
364 int refDAC = thisDAC[refIndex] ;
365 ATH_MSG_DEBUG ( "Check non-linearity against DAC " << refDAC );
366 for ( unsigned i=0 ; i<nDACs ; i++ ) {
367 if ( ! usable[i] ) continue ;
368 int tbin ;
369 double relDiff = diffWave(vCaliWaves[i],vCaliWaves[refIndex],tbin,m_diffWaveNormPeak) ;
370 if ( ! m_diffWaveNormPeak ) relDiff *= (refDAC/thisPeak[refIndex]) ;
371 if ( relDiff > m_linearityTolerance ) {
372 ATH_MSG_DEBUG ( ChanDacGain(chID,thisDAC[i],gain_it)
373 << " non-linearity detected, rel.resid= " << relDiff
374 << " at t= " << tbin*vCaliWaves[i].getDt() << " tbin= " << tbin
375 << " ... skip!" );
376 usable[i] = false ;
377 } else if ( relDiff < 0 ) {
378 ATH_MSG_DEBUG ( ChanDacGain(chID,thisDAC[i],gain_it)
379 << " could not check linearity... skip!" );
380 usable[i] = false ;
381 } else {
382 ATH_MSG_DEBUG ( ChanDacGain(chID,thisDAC[i],gain_it)
383 << " linear within " << relDiff );
384 }
385 } // end for i
386 } else {
387 ATH_MSG_DEBUG ( "Could not find reference DAC, just reject all waves not in DAC ["
388 << DACMin << "," << DACMax << "]" );
389 for ( unsigned i=0 ; i<nDACs ; i++ ) {
390 if ( thisDAC[i]<DACMin || thisDAC[i]>DACMax ) usable[i] = false ;
391 }
392 }
393
394 for ( unsigned i=0 ; i<nDACs ; i++ ) {
395 if ( usable[i] ) {
396 vDACs.push_back( (double)( thisDAC[i] ) ) ;
397 const LArWave* wave = &vCaliWaves[i];
398 vWaves.push_back(wave);
399 } else {
400 if ( (unsigned int)thisDAC[i] > 1000/gainFactor ) // record bad "non-zero" DACs
401 ( badDACs[(unsigned)gain_it][chID] ).push_back(thisDAC[i]) ;
402 }
403 }
404 unsigned nGoodDACs = vDACs.size() ;
405 ATH_MSG_DEBUG ( nGoodDACs << " DAC's selected for MW evaluation, channel 0x"
406 << MSG::hex << chID.get_compact() << MSG::dec );
407 ATH_MSG_DEBUG ( " : " << vDACs );
408
409 std::vector<LArWave> fitWave ;
410 if ( nGoodDACs >= 2 ) {
411 fitWave = m_waveHelper->linearMasterWave(vWaves,vDACs) ;
412 if ( fitWave.empty() ) {
413 ATH_MSG_ERROR ( "Master waveform linear fit failed! Channel 0x"
414 << MSG::hex << chID.get_compact() << MSG::dec << ", gain = " << gain_it );
415 continue ; // skip rest and go to next wave
416 }
417 } else if ( m_buildMWoneDAC && nGoodDACs==1 && vDACs[0]>=DACMin && vDACs[0]<=DACMax ) {
418 ATH_MSG_WARNING ( "Only one DAC available: " << vDACs[0]
419 << " just divide caliwave by DAC! Channel 0x"
420 << MSG::hex << chID.get_compact() << MSG::dec << ", gain = " << gain_it );
421 fitWave.resize(2) ;
422 fitWave[1] = (*vWaves[0])*(1./vDACs[0]) ;
423 fitWave[1].setFlag(LArWave::mwf) ;
424 fitWave[0] = LArWave(vWaves[0]->getSize(),vWaves[0]->getDt(),LArWave::dac0) ;
425 } else {
426 ATH_MSG_ERROR ( "No DACs available, cannot build MW! Channel 0x"
427 << MSG::hex << chID.get_compact() << MSG::dec << ", gain = " << gain_it );
428 continue ; // skip rest and go to next wave
429 }
430
431 ATH_MSG_DEBUG ( "master waveform evaluation succeeded for channel 0x"
432 << MSG::hex << chID.get_compact() << MSG::dec << ", gain = " << gain_it );
433 ATH_MSG_DEBUG ( " ... with " << nGoodDACs << " DAC values: " << vDACs );
434
435 if ( m_timeShift ) {
436 int tStart = m_waveHelper->getStart(fitWave[1]) ;
437 fitWave[1] = m_waveHelper->translate(fitWave[1],-tStart,0) ;
438 fitWave[0] = m_waveHelper->translate(fitWave[0],-tStart,0) ;
439 }
440
441 if ( m_normalize ) {
442 double peak = fitWave[1].getSample( m_waveHelper->getMax(fitWave[1]) ) ;
443 if ( peak != 0 ) {
444 fitWave[1] = fitWave[1] * (1/peak) ;
445 } else {
446 ATH_MSG_WARNING ( "Wave peak = 0 , cannot normalize" );
447 }
448 }
449
450 LArCaliWaveContainer::LArCaliWaves& dacWaves = mwContainer->get(chID, gain_it);
451 LArCaliWave masterWave( fitWave[1].getWave(),
452 dt, -1, 0x1, LArWave::mwf );
453 LArCaliWave dac0Wave ( fitWave[0].getWave(),
454 dt, -2, 0x1, LArWave::dac0 );
455 dacWaves.push_back( masterWave );
456 dacWaves.push_back( dac0Wave );
457 nMasterWaves ++ ;
458
459 ATH_MSG_DEBUG ( "MW and DAC0 evaluated and written in container, channel 0x"
460 << MSG::hex << chID.get_compact() << MSG::dec );
461
462 } // end loop over channels
463
464 ATH_MSG_INFO ( nMasterWaves << " master wfs generated for gain " << gain_it );
465
466 } // end loop over gains
467
468 // register MW/DAC0 container into detStore
469 ATH_CHECK( detStore()->record(std::move(mwContainer),m_keyoutput) );
470 ATH_MSG_INFO ( "Master waveforms' container recorded into StoreGate, key = " << m_keyoutput );
471
472 ATH_MSG_INFO ( "List of DACs rejected" );
473
474 for ( unsigned gain_it=0 ; gain_it<CaloGain::LARNGAIN ; gain_it++ ) {
475
476 std::map<HWIdentifier, std::vector<int> > & badDACsGain = badDACs[gain_it] ;
477
478 for (const auto& p : badDACsGain) {
479 const HWIdentifier chId = p.first ;
480 const std::vector<int> & DACs = p.second ;
481
482 if ( m_listAllAnalysedChannels || !DACs.empty() ) {
483 try {
484 Identifier id = cabling->cnvToIdentifier(chId);
485 int region = emId->region(id);
486 int eta = emId->eta(id);
487 int phi = emId->phi(id);
488 int layer = emId->sampling(id);
489 const std::vector<HWIdentifier>& calibLineV=clCont->calibSlotLine(chId);
490 std::vector<HWIdentifier>::const_iterator calibLineIt=calibLineV.begin();
491 int calibLine = 0;
492 if ( !calibLineV.empty() )
493 calibLine = onlineHelper->channel(*calibLineIt);
494 int channel = onlineHelper->channel(chId) ;
495 int slot = onlineHelper->slot(chId) ;
496 int FT = onlineHelper->feedthrough(chId) ;
497 const char gainName[3][3] = { "HG" , "MG" , "LG" } ;
498 char formOut[200] ;
499 int ich = chId.get_identifier32().get_compact() ;
500 sprintf( formOut, "%2s 0x%8x [%1d;%1d;%3d;%2d] [%2d;%3d;%3d;%3d]",
501 gainName[gain_it], ich, region, layer, eta, phi,
502 FT, slot, channel, calibLine ) ;
503 ATH_MSG_INFO ( "*** " << std::string(formOut) << " : " << DACs );
504 }
505 catch( LArID_Exception & except ) {
506 ATH_MSG_ERROR ( "LArID_Exception: channel 0x" << MSG::hex << chId << MSG::dec << " not registered " );
507 }
508
509 }
510 }
511 }
512
513 return StatusCode::SUCCESS;
514}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define endmsg
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
LArCaliWaveContainer::LArCaliWaves::const_iterator CaliWaveIt
LArCaliWaveContainer::ConstConditionsMapIterator CaliCellIt
std::string ChanDacGain(HWIdentifier ch, int DAC, int gain)
int getSize(std::map< std::string, std::vector< std::string > > &collection, const std::string &object)
constexpr int pow(int base, int exp) noexcept
const ServiceHandle< StoreGateSvc > & detStore() const
MsgStream & msg() const
const LArEM_ID * em_idHelper() const
access to EM idHelper
Definition CaloCell_ID.h:63
value_type get_compact() const
Get the compact id.
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
const std::vector< HWIdentifier > & calibSlotLine(const HWIdentifier id) const
ConstConditionsMapIterator begin(unsigned int gain) const
get iterator for all channels for a gain
ConstConditionsMapIterator end(unsigned int gain) const
end of all channels for this gain
int region(const Identifier id) const
return region according to :
int eta(const Identifier id) const
return eta according to :
int phi(const Identifier id) const
return phi according to :
int sampling(const Identifier id) const
return sampling according to :
int feedthrough(const HWIdentifier id) const
Return the feedthrough of a hardware cell identifier : feedthrough = [0,31] Barrel - A/C side or H/...
int slot(const HWIdentifier id) const
Return the slot number of a hardware cell identifier: slot = [1,15] Slot-ID in top part of the crat...
int channel(const HWIdentifier id) const
Return the channel number of a hardware cell identifier channel = [0,127] in all FEB.
@ LARNGAIN
Definition CaloGain.h:19
@ LARHIGHGAIN
Definition CaloGain.h:18
@ layer
Definition HitInfo.h:79
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

◆ sysInitialize()

StatusCode AthAlgorithm::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, AthHistogramAlgorithm, and PyAthena::Alg.

Definition at line 66 of file AthAlgorithm.cxx.

66 {
68
69 if (sc.isFailure()) {
70 return sc;
71 }
72 ServiceHandle<ICondSvc> cs("CondSvc",name());
73 for (auto h : outputHandles()) {
74 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
75 // do this inside the loop so we don't create the CondSvc until needed
76 if ( cs.retrieve().isFailure() ) {
77 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
78 return StatusCode::SUCCESS;
79 }
80 if (cs->regHandle(this,*h).isFailure()) {
81 sc = StatusCode::FAILURE;
82 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
83 << " with CondSvc");
84 }
85 }
86 }
87 return sc;
88}
static Double_t sc
virtual StatusCode sysInitialize() override
Override sysInitialize.
AthCommonDataStore(const std::string &name, T... args)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_ADCsatur

int LArMasterWaveBuilder::m_ADCsatur
private

Definition at line 54 of file LArMasterWaveBuilder.h.

◆ m_buildMWoneDAC

bool LArMasterWaveBuilder::m_buildMWoneDAC
private

Definition at line 55 of file LArMasterWaveBuilder.h.

◆ m_cablingKey

SG::ReadCondHandleKey<LArOnOffIdMapping> LArMasterWaveBuilder::m_cablingKey {this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"}
private

Definition at line 41 of file LArMasterWaveBuilder.h.

41{this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"};

◆ m_CLKey

SG::ReadCondHandleKey<LArCalibLineMapping> LArMasterWaveBuilder::m_CLKey {this, "CalibLineKey", "LArCalibLineMap", "SG calib line key"}
private

Definition at line 42 of file LArMasterWaveBuilder.h.

42{this, "CalibLineKey", "LArCalibLineMap", "SG calib line key"};

◆ m_dacMaxLayer0

std::vector<unsigned> LArMasterWaveBuilder::m_dacMaxLayer0
private

Definition at line 63 of file LArMasterWaveBuilder.h.

◆ m_dacMaxLayer1

std::vector<unsigned> LArMasterWaveBuilder::m_dacMaxLayer1
private

Definition at line 64 of file LArMasterWaveBuilder.h.

◆ m_dacMaxLayer2

std::vector<unsigned> LArMasterWaveBuilder::m_dacMaxLayer2
private

Definition at line 65 of file LArMasterWaveBuilder.h.

◆ m_dacMaxLayer3

std::vector<unsigned> LArMasterWaveBuilder::m_dacMaxLayer3
private

Definition at line 66 of file LArMasterWaveBuilder.h.

◆ m_DACmin

int LArMasterWaveBuilder::m_DACmin
private

Definition at line 54 of file LArMasterWaveBuilder.h.

◆ m_dacMinLayer0

std::vector<unsigned> LArMasterWaveBuilder::m_dacMinLayer0
private

Definition at line 58 of file LArMasterWaveBuilder.h.

◆ m_dacMinLayer1

std::vector<unsigned> LArMasterWaveBuilder::m_dacMinLayer1
private

Definition at line 59 of file LArMasterWaveBuilder.h.

◆ m_dacMinLayer2

std::vector<unsigned> LArMasterWaveBuilder::m_dacMinLayer2
private

Definition at line 60 of file LArMasterWaveBuilder.h.

◆ m_dacMinLayer3

std::vector<unsigned> LArMasterWaveBuilder::m_dacMinLayer3
private

Definition at line 61 of file LArMasterWaveBuilder.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_diffWaveNormPeak

bool LArMasterWaveBuilder::m_diffWaveNormPeak
private

Definition at line 55 of file LArMasterWaveBuilder.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 79 of file AthAlgorithm.h.

◆ m_groupingType

std::string LArMasterWaveBuilder::m_groupingType
private

Definition at line 52 of file LArMasterWaveBuilder.h.

◆ m_keyinput

std::string LArMasterWaveBuilder::m_keyinput
private

Definition at line 49 of file LArMasterWaveBuilder.h.

◆ m_keyoutput

std::string LArMasterWaveBuilder::m_keyoutput
private

Definition at line 49 of file LArMasterWaveBuilder.h.

◆ m_linearityTolerance

double LArMasterWaveBuilder::m_linearityTolerance
private

Definition at line 56 of file LArMasterWaveBuilder.h.

◆ m_listAllAnalysedChannels

bool LArMasterWaveBuilder::m_listAllAnalysedChannels
private

Definition at line 55 of file LArMasterWaveBuilder.h.

◆ m_normalize

bool LArMasterWaveBuilder::m_normalize
private

Definition at line 55 of file LArMasterWaveBuilder.h.

◆ m_timeShift

bool LArMasterWaveBuilder::m_timeShift
private

Definition at line 55 of file LArMasterWaveBuilder.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.

◆ m_waveHelper

LArWaveHelper* LArMasterWaveBuilder::m_waveHelper
private

Definition at line 47 of file LArMasterWaveBuilder.h.


The documentation for this class was generated from the following files: