Loading [MathJax]/extensions/tex2jax.js
 |
ATLAS Offline Software
|
Go to the documentation of this file.
14 #include "GaudiKernel/ToolHandle.h"
24 using CaliWaveIt = LArCaliWaveContainer::LArCaliWaves::const_iterator;
28 int ich =
ch.get_identifier32().get_compact() ;
29 sprintf(compact,
"[%10d;%5d,%1d]",ich,DAC,
gain) ;
30 return std::string(compact) ;
35 m_waveHelper(nullptr),
36 m_groupingType(
"FeedThrough")
73 ATH_MSG_WARNING (
"DACMinPS jobOption has wrong size. Will use default." );
80 ATH_MSG_WARNING (
"DACMinStrips jobOption has wrong size. Will use default." );
87 ATH_MSG_WARNING (
"DACMinMiddle jobOption has wrong size. Will use default." );
94 ATH_MSG_WARNING (
"DACMinBack jobOption has wrong size. Will use default." );
103 ATH_MSG_WARNING (
"DACMaxPS jobOption has wrong size. Will use default." );
110 ATH_MSG_WARNING (
"DACMaxStrips jobOption has wrong size. Will use default." );
117 ATH_MSG_WARNING (
"DACMaxMiddle jobOption has wrong size. Will use default." );
124 ATH_MSG_WARNING (
"DACMaxBack jobOption has wrong size. Will use default." );
136 return StatusCode::SUCCESS ;
150 return StatusCode::FAILURE;
156 return StatusCode::FAILURE;
164 msg() << MSG::INFO <<
"Check on ADC saturation: " ;
172 msg() << MSG::INFO <<
"Check on mimimum DAC value: " ;
181 ATH_MSG_INFO (
"Master Waveforms will NOT be normalized" );
184 ATH_MSG_INFO (
"Master Waveforms will be shifted to the origin" );
186 ATH_MSG_INFO (
"Master Waveforms will NOT be shifted to the origin" );
189 ATH_MSG_INFO (
"Build MWs even with only one usable DAC" );
191 ATH_MSG_INFO (
"Don't build MWs if only one usable DAC" );
194 ATH_MSG_INFO (
"For linearity check, normalize to peak " );
196 ATH_MSG_INFO (
"For linearity check, normalize to DAC " );
204 if ( caliWaveContainer ==
nullptr ) {
206 return StatusCode::FAILURE;
212 auto mwContainer = std::make_unique<LArCaliWaveContainer>();
218 std::vector< std::map<HWIdentifier, std::vector<int> > > badDACs ;
221 unsigned nMasterWaves = 0 ;
225 ATH_MSG_DEBUG (
"Evaluating master wavefroms for gain " << gain_it );
228 unsigned gainFactor = (
unsigned)(
pow(10,2-gain_it)) ;
231 std::vector<int> minDAC , maxDAC ;
241 ATH_MSG_INFO (
"Minimum DAC allowed for layers 0,1,2,3 and gain " << gain_it );
243 ATH_MSG_INFO (
"Maximum DAC allowed for layers 0,1,2,3 and gain " << gain_it );
252 if ( cell_it == cell_it_e ) {
259 for ( ; cell_it!=cell_it_e ; ++cell_it ) {
263 if ( wave_it == wave_it_e ) {
271 double dt = vCaliWaves[0].getDt() ;
272 unsigned nDACs = vCaliWaves.size() ;
275 <<
" in gain " << gain_it );
277 for (
unsigned i=0 ;
i<nDACs ;
i++ )
278 msg() << vCaliWaves[
i].getDAC() <<
" " ;
287 region = emId->
region(
id) ;
296 DACMin = minDAC[
layer] ;
297 DACMax = maxDAC[
layer] ;
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) ;
310 for (
unsigned i=0 ;
i<nDACs ;
i++ ) {
311 thisDAC[
i] = vCaliWaves[
i].getDAC() ;
316 <<
"DAC below threshold... skip!" );
324 <<
" absolute ADC saturation... skip!" );
330 <<
" relative ADC saturation... skip!" );
336 if ( fabs( thisPeak[
i]/thisDAC[
i] ) < gainFactor*0.0001 ) {
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 ;
355 if ( theDiff>0 ) thisOverallDiff += theDiff ;
357 if ( thisOverallDiff < minOverallDiff ) {
359 minOverallDiff = thisOverallDiff ;
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 ;
373 <<
" non-linearity detected, rel.resid= " << relDiff
374 <<
" at t= " << tbin*vCaliWaves[
i].getDt() <<
" tbin= " << tbin
377 }
else if ( relDiff < 0 ) {
379 <<
" could not check linearity... skip!" );
383 <<
" linear within " << relDiff );
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 ;
394 for (
unsigned i=0 ;
i<nDACs ;
i++ ) {
396 vDACs.push_back( (
double)( thisDAC[
i] ) ) ;
397 const LArWave* wave = &vCaliWaves[
i];
398 vWaves.push_back(wave);
400 if ( (
unsigned int)thisDAC[
i] > 1000/gainFactor )
401 ( badDACs[(
unsigned)gain_it][chID] ).push_back(thisDAC[
i]) ;
404 unsigned nGoodDACs = vDACs.size() ;
405 ATH_MSG_DEBUG ( nGoodDACs <<
" DAC's selected for MW evaluation, channel 0x"
409 std::vector<LArWave> fitWave ;
410 if ( nGoodDACs >= 2 ) {
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 );
417 }
else if (
m_buildMWoneDAC && nGoodDACs==1 && vDACs[0]>=DACMin && vDACs[0]<=DACMax ) {
419 <<
" just divide caliwave by DAC! Channel 0x"
420 << MSG::hex << chID.
get_compact() << MSG::dec <<
", gain = " << gain_it );
422 fitWave[1] = (*vWaves[0])*(1./vDACs[0]) ;
426 ATH_MSG_ERROR (
"No DACs available, cannot build MW! Channel 0x"
427 << MSG::hex << chID.
get_compact() << MSG::dec <<
", gain = " << gain_it );
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 );
444 fitWave[1] = fitWave[1] * (1/peak) ;
455 dacWaves.push_back( masterWave );
456 dacWaves.push_back( dac0Wave );
459 ATH_MSG_DEBUG (
"MW and DAC0 evaluated and written in container, channel 0x"
464 ATH_MSG_INFO ( nMasterWaves <<
" master wfs generated for gain " << gain_it );
476 std::map<HWIdentifier, std::vector<int> > & badDACsGain = badDACs[gain_it] ;
478 for (
const auto&
p : badDACsGain) {
480 const std::vector<int> & DACs =
p.second ;
485 int region = emId->
region(
id);
489 const std::vector<HWIdentifier>& calibLineV=clCont->calibSlotLine(chId);
490 std::vector<HWIdentifier>::const_iterator calibLineIt=calibLineV.begin();
492 if ( !calibLineV.empty() )
493 calibLine = onlineHelper->
channel(*calibLineIt);
495 int slot = onlineHelper->
slot(chId) ;
497 const char gainName[3][3] = {
"HG" ,
"MG" ,
"LG" } ;
500 sprintf( formOut,
"%2s 0x%8x [%1d;%1d;%3d;%2d] [%2d;%3d;%3d;%3d]",
503 ATH_MSG_INFO (
"*** " << std::string(formOut) <<
" : " << DACs );
506 ATH_MSG_ERROR (
"LArID_Exception: channel 0x" << MSG::hex << chId << MSG::dec <<
" not registered " );
513 return StatusCode::SUCCESS;
518 return diffWave(w1,w2,tbin,normPeak) ;
522 double norm1, norm2 ;
530 if ( norm1 <=0 || norm2 <= 0 )
return -1 ;
532 for (
unsigned u=0 ;
u < w1.
getSize() ;
u++ ) {
535 if ( diff1 > resid ) {
def retrieve(aClass, aKey=None)
ConditionsMap::const_iterator ConstConditionsMapIterator
int phi(const Identifier id) const
return phi according to :
HWIdentifier channelId() const
LArMasterWaveBuilder(const std::string &name, ISvcLocator *pSvcLocator)
std::string ChanDacGain(HWIdentifier ch, int DAC, int gain)
Scalar phi() const
phi method
size_t getSize() const
number of time samples
const LArEM_ID * em_idHelper() const
access to EM idHelper
unsigned getStart(const LArWave &theWave) const
Scalar eta() const
pseudorapidity method
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Declaration of const iterator.
double m_linearityTolerance
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...
LArWave translate(const LArWave &theWave, int nShift, double baseline=0.) const
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
bool m_listAllAnalysedChannels
value_type get_compact() const
Get the compact id.
int region(const Identifier id) const
return region according to :
int getDAC() const
DAC value.
int sampling(const Identifier id) const
return sampling according to :
std::vector< unsigned > m_dacMinLayer2
const std::string & key() const
Return the StoreGate ID for the referenced object.
unsigned int getMax(const LArWave &theWave) const
return index of maximum sample
std::vector< unsigned > m_dacMinLayer1
value_type get_compact() const
Get the compact id.
@ u
Enums for curvilinear frames.
int eta(const Identifier id) const
return eta according to :
Liquid Argon Cumulative Wave Container.
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
std::vector< unsigned > m_dacMaxLayer2
const double & getSample(const unsigned int i) const
Amplitude per time bin.
int channel(const HWIdentifier id) const
Return the channel number of a hardware cell identifier channel = [0,127] in all FEB.
ConstConditionsMapIterator end(unsigned int gain) const
end of all channels for this gain
::StatusCode StatusCode
StatusCode definition for legacy code.
double diffWave(const LArCaliWave &w1, const LArCaliWave &w2, int &tbin, bool normPeak) const
std::vector< unsigned > m_dacMaxLayer1
Helper class for offline cell identifiers.
LArCaliWaveContainer::LArCaliWaves::const_iterator CaliWaveIt
std::vector< unsigned > m_dacMinLayer3
std::vector< LArWave > linearMasterWave(const std::vector< const LArWave * > &vWaves, const std::vector< double > &vAmpli) const
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
SG::ReadCondHandleKey< LArCalibLineMapping > m_CLKey
StatusCode initialize(bool used=true)
int feedthrough(const HWIdentifier id) const
Return the feedthrough of a hardware cell identifier : feedthrough = [0,31] Barrel - A/C side or H/...
#define ATH_MSG_WARNING(x)
std::vector< unsigned > m_dacMinLayer0
ConstConditionsMapIterator begin(unsigned int gain) const
get iterator for all channels for a gain
Helper class for LArEM offline identifiers.
LArWaveHelper * m_waveHelper
std::vector< unsigned > m_dacMaxLayer3
constexpr int pow(int base, int exp) noexcept
std::string m_groupingType
std::vector< unsigned > m_dacMaxLayer0
Exception class for LAr Identifiers.