|
ATLAS Offline Software
|
Go to the documentation of this file.
6 #include "GaudiKernel/SystemOfUnits.h"
16 #define MAXINT INT_MAX
17 #define MAXINT2 -INT_MAX
32 ATH_MSG_ERROR (
"useDB requested but neither Run1DSPThresholdsKey nor Run2DSPThresholdsKey initialized.");
33 return StatusCode::FAILURE;
39 const std::string cutmsg =
m_absECutFortQ.value() ?
" fabs(E) < " :
" E < ";
40 ATH_MSG_INFO(
"Energy cut for time and quality computation: " << cutmsg <<
41 " taken from COOL folder "<<
47 return StatusCode::SUCCESS;
51 return StatusCode::SUCCESS;
61 ATH_CHECK(outputContainer.
record(std::make_unique<LArRawChannelContainer>()));
67 ATH_CHECK(timingContHandle.
record(std::make_unique<LArOFIterResultsContainer>()));
68 outputTimingContainer = timingContHandle.
ptr();
85 std::unique_ptr<LArDSPThresholdsFlat> run2DSPThresh;
90 run2DSPThresh = std::make_unique<LArDSPThresholdsFlat>(*dspThrshAttr);
94 return StatusCode::FAILURE;
99 run1DSPThresh = dspThresh.
cptr();
103 return StatusCode::FAILURE;
107 std::vector<float>
signal;
109 const float fMAXINT =
static_cast<float>(
MAXINT);
110 const float fMAXINT2 =
static_cast<float>(
MAXINT2);
116 const bool connected=(*cabling)->isOnlineConnected(
id);
120 const std::vector<short>& samples=
digit->samples();
129 if (!connected)
continue;
131 <<
" gain " <<
gain);
132 return StatusCode::FAILURE;
136 if (!connected)
continue;
138 <<
" gain " <<
gain);
139 return StatusCode::FAILURE;
144 float peakval = -999.;
145 unsigned short ipeak = 0;
147 const unsigned int sampsize = (
unsigned int) samples.size();
150 for (
unsigned int ii = 0; ii < sampsize; ++ii) {
151 if (samples[ii]==0 || samples[ii]>=
m_AdcMax) {
153 MSG::hex <<
id.get_compact() << MSG::dec <<
" ADC=" << samples[ii]);
160 currval = (
float)(samples[ii] -
p);
163 ipeak = ii; peakval = currval;
166 ATH_MSG_DEBUG(
"Peak value: " << peakval <<
", peak sample:" << ipeak);
187 if (ipeak > sampsize - 3) ipeak = sampsize - 3 ;
188 if (ipeak < 2) ipeak = 2;
190 unsigned int peak_min = ipeak - 1 ;
191 unsigned int peak_max = ipeak + 1 ;
197 nIteration, ipeak,peak_min, peak_max );
198 if(outputTimingContainer) {
199 outputTimingContainer->push_back(
results);
202 ADCPeak =
results.getAmplitude();
209 ATH_MSG_DEBUG(
"Peak and time properly retrieved with OFPeakRecoTool: ADCPeak = "
210 << ADCPeak <<
", time = "<<
time);
212 ATH_MSG_DEBUG(
". OFC iteration not valid for channel 0x"<< MSG::hex <<
213 id.get_compact() << MSG::dec <<
" Gain = " <<
gain <<
214 ". Skipping channel.");
219 float E=adc2mev[0]+ADCPeak*adc2mev[1];
221 if (
E>fMAXINT)
E=fMAXINT;
222 if (
E<fMAXINT2)
E=fMAXINT2;
224 if (
results.getConverged()) prov |= 0x0100;
225 prov = prov & 0x3FFF;
237 ecut = run2DSPThresh->
tQThr(
id);
239 else if (run1DSPThresh) {
240 ecut = run1DSPThresh->
tQThr(
id);
244 return StatusCode::FAILURE;
253 gain <<
" above threshold for tQ computation");
257 if (tau>fMAXINT) tau=fMAXINT;
258 if (tau<fMAXINT2) tau=fMAXINT2;
263 if (iqua > 0xFFFF) iqua=0xFFFF;
264 iquaShort =
static_cast<uint16_t>(iqua & 0xFFFF);
269 outputContainer->emplace_back(
id,
static_cast<int>(std::floor(
E+0.5)),
270 static_cast<int>(std::floor(tau+0.5)),
274 return StatusCode::SUCCESS;
280 const unsigned npeak,
unsigned peak_low,
unsigned peak_high)
const
282 const float epsilon=0.001;
293 result.m_delay_final = delayIn;
294 result.m_peakSample_init = npeak;
295 result.m_peakSample_final = npeak;
299 unsigned& kMax =
result.m_peakSample_final;
302 unsigned& delayIdx=
result.m_ofcIndex;
313 const unsigned nSamples=samples.size();
322 const unsigned nOFCPhase=ofcs->
nTimeBins(chID,usedGain);
323 float timeOffset = ofcs->
timeOffset(chID,usedGain);
333 timeMax=(nOFCPhase-1)*timeBinWidth;
336 timeMax = (nOFCPhase-1)*timeBinWidth;
337 if (timeBinWidth==0.) {
351 const unsigned ofcSize=this_OFC_a.size();
354 if ( ofcSize == 0 || this_OFC_b.size() == 0 ) {
359 if ( this_OFC_a.size() != this_OFC_b.size() ) {
361 ")and b (" << this_OFC_b.size() <<
") are not the same size for channel 0x"
367 if (peak_low<2) peak_low=2;
369 if (peak_high<peak_low) {
371 <<
"Not enough ADC samples (" <<
nSamples <<
") to apply " << ofcSize <<
" OFCs." );
374 if(kMax<peak_low) kMax=peak_low;
375 if(kMax>peak_high) kMax=peak_high;
377 float amplitude_save=0.;
378 float tau_save= 99999.;
379 unsigned int kMax_save=0;
381 unsigned int delayIdx_save=0;
383 unsigned int mynIter = nIter;
406 for (
unsigned k=0 ; (
k<ofcSize);
k++ ) {
408 const float& this_sample = samples[kMax-2+
k];
409 A += this_OFC_a.
at(
k) * this_sample ;
410 At += this_OFC_b.
at(
k) * this_sample ;
425 delay = delayIdx*timeBinWidth;
430 if (samples.size() == ofcSize && nOFCPhase<2) {
431 delay = delayIdx*timeBinWidth;
436 if (std::fabs(
result.m_tau) <= (0.5*timeBinWidth)) {
438 delay = delayIdx*timeBinWidth;
442 if (kIter>=mynIter) {
443 delay = delayIdx*timeBinWidth;
445 if (std::fabs(tau_save) < std::fabs(
result.m_tau)) {
446 result.m_amplitude = amplitude_save;
450 delayIdx = delayIdx_save;
453 if (std::fabs(
result.m_tau) <= timeBinWidth)
result.m_converged=
true;
459 if (std::fabs(
result.m_tau) <= timeBinWidth) {
460 result.m_converged =
true;
462 amplitude_save =
result.m_amplitude;
465 delay_save = delayIdx*timeBinWidth;
466 delayIdx_save = delayIdx;
471 if(
delay<(-0.5*timeBinWidth)) {
476 if (
delay > timeMax )
delay = timeMax-epsilon;
482 if(
delay>(timeMax+0.5*timeBinWidth) ) {
487 if(
delay > timeMax )
delay = timeMax-epsilon;
490 delay = timeMax-epsilon;
496 if (delayIdx>=nOFCPhase) delayIdx = nOFCPhase-1;
498 this_OFC_a = ofcs->
OFC_a(chID,(
int)usedGain,delayIdx);
499 this_OFC_b = ofcs->
OFC_b(chID,(
int)usedGain,delayIdx);
510 if( thisShape.size() >= ofcSize ) {
511 for (
unsigned k=0 ;
k<ofcSize ;
k++ ) {
512 const float& this_sample = samples[kMax-2+
k];
523 result.m_nIterPerf = kIter;
def retrieve(aClass, aKey=None)
virtual float pedestal(const HWIdentifier &id, int gain) const =0
const LArVectorProxy ADC2MEV(const HWIdentifier &id, int gain) const
Gaudi::Property< float > m_eCutFortQ
Gaudi::Property< bool > m_skipSaturatedCells
virtual OFCRef_t OFC_b(const HWIdentifier &id, int gain, int tbin=0) const =0
virtual ShapeRef_t ShapeDer(const HWIdentifier &id, int gain, int tbin=0, int mode=0) const =0
SG::ReadCondHandleKey< ILArPedestal > m_pedestalKey
Gaudi::Property< bool > m_absECutFortQ
Gaudi::Property< unsigned short > m_minSample
SG::ReadHandleKey< LArDigitContainer > m_digitKey
value_type get_compact() const
Get the compact id.
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Gaudi::Property< unsigned short > m_AdcMax
#define ATH_MSG_VERBOSE(x)
const std::string & key() const
Return the StoreGate ID for the referenced object.
bool empty() const
Test if the key is blank.
SG::WriteHandleKey< LArRawChannelContainer > m_rawChannelKey
StatusCode finalize() override
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual float timeOffset(const HWIdentifier &CellID, int gain) const =0
value_type at(size_t i) const
Vector indexing with bounds check.
float tQThr(const HWIdentifier &CellID) const
Liquid Argon digit base class.
SG::ReadCondHandleKey< AthenaAttributeList > m_run2DSPThresholdsKey
::StatusCode StatusCode
StatusCode definition for legacy code.
pointer_type ptr()
Dereference the pointer.
virtual float timeBinWidth(const HWIdentifier &CellID, int gain) const =0
Gaudi::Property< unsigned short > m_minADCforIter
Gaudi::Property< int > m_defaultShiftTimeSamples
double delay(std::size_t d)
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
SG::ReadCondHandleKey< LArADC2MeV > m_adc2MeVKey
StatusCode execute(const EventContext &ctx) const override
float tQThr(const HWIdentifier chid) const
LArOFIterResults peak(const std::vector< float > &samples, const HWIdentifier chID, const CaloGain::CaloGain gain, const float delayIn, const ILArOFC *ofcs, const ILArShape *shapes, const unsigned nIter=0, const unsigned npeak=2, unsigned peak_low=2, unsigned peak_high=2) const
StatusCode initialize() override
StatusCode initialize(bool used=true)
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
def time(flags, cells_name, *args, **kw)
SG::ReadCondHandleKey< ILArOFC > m_ofcKey
#define ATH_MSG_WARNING(x)
Gaudi::Property< unsigned short > m_maxSample
SG::ReadCondHandleKey< ILArShape > m_shapeKey
Gaudi::Property< bool > m_forceHighGain
virtual OFCRef_t OFC_a(const HWIdentifier &id, int gain, int tbin=0) const =0
access to OFCs by online ID, gain, and tbin (!=0 for testbeam)
virtual unsigned nTimeBins(const HWIdentifier &CellID, int gain) const =0
Gaudi::Property< bool > m_useDBFortQ
bool isHECchannel(const HWIdentifier id) const override final
Gaudi::Property< unsigned short > m_nIterProp
std::string channel_name(const HWIdentifier id) const
Return a string corresponding to a feedthrough name given an identifier.
virtual float pedestalRMS(const HWIdentifier &id, int gain) const =0
access to RMS of Pedestal index by Identifier, and gain setting
SG::ReadCondHandleKey< LArDSPThresholdsComplete > m_run1DSPThresholdsKey
SG::WriteHandleKey< LArOFIterResultsContainer > m_timingContKey
Gaudi::Property< bool > m_useShapeDer
Gaudi::Property< float > m_minADCforIterInSigma
Proxy for accessing a range of float values like a vector.
const LArOnlineID * m_onlineId
virtual ShapeRef_t Shape(const HWIdentifier &id, int gain, int tbin=0, int mode=0) const =0
const_pointer_type cptr()
Gaudi::Property< float > m_defaultPhase