ATLAS Offline Software
Loading...
Searching...
No Matches
LArMasterWaveBuilder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
10
13
14#include "GaudiKernel/ToolHandle.h"
17
18#include <cstdio>
19#include <fstream>
20#include <iostream>
21#include <memory>
22
24using CaliWaveIt = LArCaliWaveContainer::LArCaliWaves::const_iterator;
25
26inline std::string ChanDacGain(HWIdentifier ch,int DAC,int gain) {
27 char compact[25]{} ;
28 int ich = ch.get_identifier32().get_compact() ;
29 sprintf(compact,"[%10d;%5d,%1d]",ich,DAC,gain) ;
30 return std::string(compact) ;
31}
32
33LArMasterWaveBuilder::LArMasterWaveBuilder (const std::string& name, ISvcLocator* pSvcLocator) :
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}
66
68= default;
69
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
132
133 ATH_CHECK( m_cablingKey.initialize() );
134 ATH_CHECK( m_CLKey.initialize() );
135
136 return StatusCode::SUCCESS ;
137}
138
140{
141 ATH_MSG_INFO ( "LArMasterWaveBuilder in stop..." );
142
143 const LArOnlineID* onlineHelper;
144 const LArEM_ID* emId;
145
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 }
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}
515
516double LArMasterWaveBuilder::diffWave(const LArCaliWave& w1, const LArCaliWave& w2,bool normPeak=false) const {
517 int tbin=0 ;
518 return diffWave(w1,w2,tbin,normPeak) ;
519}
520
521double LArMasterWaveBuilder::diffWave(const LArCaliWave& w1, const LArCaliWave& w2,int& tbin,bool normPeak=false) const {
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}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(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
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
MsgStream & msg() const
Helper class for offline cell identifiers.
Definition CaloCell_ID.h:34
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.
Liquid Argon Cumulative Wave Container.
int getDAC() const
DAC value.
const std::vector< HWIdentifier > & calibSlotLine(const HWIdentifier id) const
ConditionsMap::const_iterator ConstConditionsMapIterator
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 :
Helper class for LArEM offline identifiers.
Definition LArEM_ID.h:111
Exception class for LAr Identifiers.
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
double diffWave(const LArCaliWave &w1, const LArCaliWave &w2, int &tbin, bool normPeak) const
std::vector< unsigned > m_dacMaxLayer1
std::vector< unsigned > m_dacMinLayer0
std::vector< unsigned > m_dacMaxLayer2
SG::ReadCondHandleKey< LArCalibLineMapping > m_CLKey
std::vector< unsigned > m_dacMinLayer1
std::vector< unsigned > m_dacMaxLayer3
std::vector< unsigned > m_dacMaxLayer0
std::vector< unsigned > m_dacMinLayer3
LArMasterWaveBuilder(const std::string &name, ISvcLocator *pSvcLocator)
std::vector< unsigned > m_dacMinLayer2
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.
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
@ LARNGAIN
Definition CaloGain.h:19
@ LARHIGHGAIN
Definition CaloGain.h:18