183 const EventContext& ctx = Gaudi::Hive::currentContext();
197 oflHVCorr = *oflHVCorrHdl;
200 return StatusCode::FAILURE;
207 return StatusCode::FAILURE;
214 float globalTimeOffset=0;
229 if (
sc.isFailure()) {
230 ATH_MSG_WARNING (
"Can't retrieve LArShape from Conditions Store" << std::endl
231 <<
"Quality factor will not be caluclated." );
247 const TBPhase* theTBPhase =
nullptr;
258 StatusCode
sc=
detStore()->retrieve(larGlobalTimeOffset);
259 if (
sc.isSuccess()) globalTimeOffset = larGlobalTimeOffset->
TimeOffset();
263 if (
sc.isFailure()) larFebTimeOffset=NULL;
268 larRawChannelContainer->reserve(digitContainer->
size());
271 ATH_MSG_ERROR (
"Can't record LArRawChannelContainer in StoreGate" );
278 bool debugPrint=
false;
279 if (
msgLvl(MSG::DEBUG) ) debugPrint=
true;
284 for (
const LArDigit* digit : *(digitContainer)) {
295 const std::vector<short>& samples=digit->samples();
296 const unsigned nSamples=samples.size();
304 int region = -99999 ;
305 if (
msgLvl(MSG::DEBUG) ) {
308 id = cabling->cnvToIdentifier(chid);
310 ATH_MSG_DEBUG (
"A Cabling exception was caught for channel 0x!"
314 layer =
m_emId->sampling(
id);
317 region =
m_emId->region(
id);
319 <<
" [ Layer = " << layer <<
" - Eta = " <<
eta
320 <<
" - Phi = " <<
phi <<
" - Region = " << region <<
" ] " );
325 for (
unsigned iSample=0;iSample<samples.size();iSample++) {
332 msg() << MSG::DEBUG <<
"Saturation on channel 0x" << MSG::hex << chid.
get_compact() << MSG::dec ;
336 msg() <<
". Skipping channel." <<
endmsg;
338 }
else if ( nSatur>-1 ) {
345 float pedestal=larPedestal->
pedestal(chid,gain);
347 float pedestalAverage;
351 <<
" Gain " << gain <<
". Using time sample " <<
m_iPedestal );
355 <<
" [ Layer = " << layer <<
" - Eta = " <<
eta <<
" - Phi = " <<
phi <<
" - Region = " << region <<
" ]"
356 <<
" Gain = " << gain <<
". Skipping channel." );
365 << MSG::dec <<
" Gain=" << gain <<
". Using time sample " <<
m_iPedestal );
368 pedestalAverage=pedestal;
376 float febTimeOffset=0;
378 if (larFebTimeOffset)
379 febTimeOffset=larFebTimeOffset->
TimeOffset(febid);
380 double timeShift=PhaseTime+globalTimeOffset+febTimeOffset;
382 msg() << MSG::VERBOSE <<
"Channel 0x" << MSG::hex << chid.
get_compact() << MSG::dec
383 <<
" phase=" << PhaseTime <<
" Feb=" << febTimeOffset
384 <<
" Global=" << globalTimeOffset;
387 const double ofcTimeOffset=larOFC->timeOffset(chid,gain);
388 timeShift+=ofcTimeOffset;
389 if (debugPrint)
msg() << MSG::VERBOSE <<
" OFC=" << ofcTimeOffset;
392 if (debugPrint)
msg() << MSG::VERBOSE <<
" Total=" << timeShift <<
endmsg;
396 timeSampleShift -= 1;
402 timeSampleShift += 1;
410 ATH_MSG_ERROR ( noEnergy <<
". Time offset out of range for channel 0x" << MSG::hex << chid.
get_compact() << MSG::dec
418 ATH_MSG_ERROR ( noEnergy <<
". Negative time sample (" << timeSampleShift <<
") shift for channel 0x" << MSG::hex << chid.
get_compact() << MSG::dec
419 <<
" Found. Skipping channel." );
431 if (debugPrint)
ATH_MSG_VERBOSE (
"OFC bin width = " <<
m_OFCTimeBin <<
" - OFCBin = " << OFCTimeBin <<
" - timeShift = " << timeShift );
433 if ( OFCTimeBin < 0 ) {
434 ATH_MSG_ERROR (
"Channel " << MSG::hex << chid.
get_compact() << MSG::dec <<
" asks for OFC bin = " << OFCTimeBin <<
". Set to 0." );
441 ofc_a=larOFC->OFC_a(chid,gain,OFCTimeBin);
446 if (ofc_a.size()==0) {
449 <<
" [ Layer = " << layer <<
" - Eta = " <<
eta <<
" - Phi = " <<
phi <<
" - Region = " << region <<
" ]"
450 <<
" Time bin = " << OFCTimeBin <<
", Gain = " << gain <<
". Skipping channel." );
453 if (ofc_a.size()+timeSampleShift>nSamples) {
456 if (timeSampleShift==0)
457 ATH_MSG_DEBUG (
"Found LArDigit with " << nSamples <<
" samples, but OFCs for "
458 << ofc_a.size() <<
" samples. Skipping Channel ");
460 ATH_MSG_DEBUG (
"After time sample shift of " << timeSampleShift <<
", " << nSamples-timeSampleShift
461 <<
" samples left, but have OFCs for " << ofc_a.size() <<
" samples. Skipping Channel ");
467 for (
unsigned i=0;i<(ofc_a.size());i++)
468 ADCPeak+=(samples[i+timeSampleShift]-pedestalAverage)*ofc_a.
at(i);
470 if (debugPrint)
ATH_MSG_VERBOSE (
"ADC Height calculated " << ADCPeak <<
" TimeBin=" << OFCTimeBin );
476 if (ramp.size()==0) {
479 <<
" [ Layer = " << layer <<
" - Eta = " <<
eta <<
" - Phi = " <<
phi <<
" - Region = " << region <<
" ]"
480 <<
" Gain = " << gain <<
". Skipping channel." );
487 ATH_MSG_DEBUG (
"Bad ramp for channel " << chid <<
" (ramp[1] = " << ramp[1] <<
"): skip this channel" );
491 float ADCPeakPower=ADCPeak;
496 for (
unsigned i=1;i<ramp.size();i++)
497 {energy+=ramp[i]*ADCPeakPower;
498 ADCPeakPower*=ADCPeak;
504 Identifier id = cabling->cnvToIdentifier(chid);
513 float hvCorr = oflHVCorr-> HVScaleCorr(chid);
514 energy = energy*hvCorr;
520 ofc_b=larOFC->OFC_b(chid,gain,OFCTimeBin);
521 if (ofc_b.size() != ofc_a.size()) {
524 <<
" Gain "<< gain <<
" found. Time not calculated." );
527 <<
" not equal to OFC for energy size " << ofc_a.size()
528 <<
" Time not calculated " );
531 for (
unsigned i=0;i<(ofc_b.size());i++)
532 time+=(samples[i+timeSampleShift]-pedestalAverage)*ofc_b.
at(i);
537 if (debugPrint)
ATH_MSG_VERBOSE (
"Time calculated " << time <<
" TimeBin=" << OFCTimeBin );
551 if (shape.size() < ofc_a.size()) {
554 <<
" Gain "<< gain <<
". Quality factor not calculated." );
557 <<
"smaller than OFC size " << ofc_a.size()
558 <<
"for channel 0x" << MSG::hex << chid.
get_compact()
559 << MSG::dec <<
". Quality factor not calculated." );
564 if (time!=0 && shapeDer.size()!=shape.size()) {
566 ATH_MSG_DEBUG (
"Shape-Derivative has different size than Shape for channel 0x" << MSG::hex << chid.
get_compact() << MSG::dec
567 <<
". Derivative not taken into accout for quality factor." );
570 if (time==0 || shapeDer.size()!=shape.size() ) {
571 for (
unsigned i=0;i<(ofc_a.size());i++)
572 quality+=((samples[i+timeSampleShift]-pedestalAverage)-shape[i]*ADCPeak)*
573 ((samples[i+timeSampleShift]-pedestalAverage)-shape[i]*ADCPeak);
576 for (
unsigned i=0;i<(ofc_a.size());i++)
577 quality+=((samples[i+timeSampleShift]-pedestalAverage)-((shape[i]-shapeDer[i]*time)*ADCPeak))*
578 ((samples[i+timeSampleShift]-pedestalAverage)-((shape[i]-shapeDer[i]*time)*ADCPeak));
592 time=time/picosecond;
596 uint16_t iprovenance=0xA5;
598 iquality = ((int)(quality) ) & 0xFFFF;
599 iprovenance=iprovenance | 0x2000;
603 LArRawChannel larRawChannel(chid,(
int)energy,(
int)time,iquality,iprovenance, gain);
604 larRawChannelContainer->push_back(larRawChannel);
608 <<
" e=" << energy <<
" t=" << time <<
" Q=" << quality );
611 ATH_MSG_DEBUG ( ntot_raw <<
" channels successfully processed, (" << highE <<
" with high energy)" );
615 ATH_MSG_ERROR (
"Too many channels (" <<BadTiming<<
" !) have a bad timing !!" );
616 ATH_MSG_ERROR (
"OFC time constants should be revisited !!!" );
618 larRawChannelContainer->clear();
624 ATH_MSG_ERROR ( saturation <<
" saturating channels were found. Event is skipped." );
625 larRawChannelContainer->clear();
667 || ( msgSvc()->outputLevel(name()) <= MSG::DEBUG && ( noEnergy || noTime || noShape || noShapeDer || saturation ) )
681 msg() << msglvl <<
" *** Error & Warning summary for this event *** " << std::endl;
684 msg() << msglvl <<
" " << noEnergy <<
" out of "
685 << digitContainer->
size() <<
" channel(s) skipped due to a lack of basic calibration constants."
689 msg() << msglvl <<
" " << noTime <<
" out of "
690 << highE <<
" high-enegy channel(s) have no time-info due to a lack of Optimal Filtering Coefficients."
694 msg() << msglvl <<
" " << noShape <<
" out of "
695 << highE <<
" high-enegy channel(s) have no quality factor due to a lack of shape."
699 msg() << msglvl <<
" " << noShapeDer <<
" out of "
700 << highE <<
" high-enegy channel(s) lack the derivative of the shape. Not taken into accout for Quality factor."
705 msg() << MSG::ERROR <<
" " << saturation <<
" out of "
706 << digitContainer->
size() <<
" channel(s) showed saturations. The complete event was skipped." << std::endl;
708 msg() << MSG::ERROR <<
" " << saturation <<
" out of "
709 << digitContainer->
size() <<
" channel(s) showed saturations and were skipped." << std::endl;
711 msg() << MSG::WARNING <<
" " << saturation <<
" out of "
712 << digitContainer->
size() <<
" channel(s) showed saturations." << std::endl;
720 return StatusCode::SUCCESS;