195 oflHVCorr = *oflHVCorrHdl;
198 return StatusCode::FAILURE;
205 return StatusCode::FAILURE;
212 float globalTimeOffset=0;
227 if (
sc.isFailure()) {
228 ATH_MSG_WARNING (
"Can't retrieve LArShape from Conditions Store" << std::endl
229 <<
"Quality factor will not be caluclated." );
245 const TBPhase* theTBPhase =
nullptr;
256 StatusCode
sc=
detStore()->retrieve(larGlobalTimeOffset);
257 if (
sc.isSuccess()) globalTimeOffset = larGlobalTimeOffset->
TimeOffset();
261 if (
sc.isFailure()) larFebTimeOffset=NULL;
266 larRawChannelContainer->reserve(digitContainer->
size());
269 ATH_MSG_ERROR (
"Can't record LArRawChannelContainer in StoreGate" );
276 bool debugPrint=
false;
277 if (
msgLvl(MSG::DEBUG) ) debugPrint=
true;
282 for (
const LArDigit* digit : *(digitContainer)) {
293 const std::vector<short>& samples=digit->samples();
294 const unsigned nSamples=samples.size();
302 int region = -99999 ;
303 if (
msgLvl(MSG::DEBUG) ) {
306 id = cabling->cnvToIdentifier(chid);
308 ATH_MSG_DEBUG (
"A Cabling exception was caught for channel 0x!"
312 layer =
m_emId->sampling(
id);
315 region =
m_emId->region(
id);
317 <<
" [ Layer = " << layer <<
" - Eta = " <<
eta
318 <<
" - Phi = " <<
phi <<
" - Region = " << region <<
" ] " );
323 for (
unsigned iSample=0;iSample<samples.size();iSample++) {
330 msg() << MSG::DEBUG <<
"Saturation on channel 0x" << MSG::hex << chid.
get_compact() << MSG::dec ;
334 msg() <<
". Skipping channel." <<
endmsg;
336 }
else if ( nSatur>-1 ) {
343 float pedestal=larPedestal->
pedestal(chid,gain);
345 float pedestalAverage;
349 <<
" Gain " << gain <<
". Using time sample " <<
m_iPedestal );
353 <<
" [ Layer = " << layer <<
" - Eta = " <<
eta <<
" - Phi = " <<
phi <<
" - Region = " << region <<
" ]"
354 <<
" Gain = " << gain <<
". Skipping channel." );
363 << MSG::dec <<
" Gain=" << gain <<
". Using time sample " <<
m_iPedestal );
366 pedestalAverage=pedestal;
374 float febTimeOffset=0;
376 if (larFebTimeOffset)
377 febTimeOffset=larFebTimeOffset->
TimeOffset(febid);
378 double timeShift=PhaseTime+globalTimeOffset+febTimeOffset;
380 msg() << MSG::VERBOSE <<
"Channel 0x" << MSG::hex << chid.
get_compact() << MSG::dec
381 <<
" phase=" << PhaseTime <<
" Feb=" << febTimeOffset
382 <<
" Global=" << globalTimeOffset;
385 const double ofcTimeOffset=larOFC->timeOffset(chid,gain);
386 timeShift+=ofcTimeOffset;
387 if (debugPrint)
msg() << MSG::VERBOSE <<
" OFC=" << ofcTimeOffset;
390 if (debugPrint)
msg() << MSG::VERBOSE <<
" Total=" << timeShift <<
endmsg;
394 timeSampleShift -= 1;
400 timeSampleShift += 1;
408 ATH_MSG_ERROR ( noEnergy <<
". Time offset out of range for channel 0x" << MSG::hex << chid.
get_compact() << MSG::dec
416 ATH_MSG_ERROR ( noEnergy <<
". Negative time sample (" << timeSampleShift <<
") shift for channel 0x" << MSG::hex << chid.
get_compact() << MSG::dec
417 <<
" Found. Skipping channel." );
429 if (debugPrint)
ATH_MSG_VERBOSE (
"OFC bin width = " <<
m_OFCTimeBin <<
" - OFCBin = " << OFCTimeBin <<
" - timeShift = " << timeShift );
431 if ( OFCTimeBin < 0 ) {
432 ATH_MSG_ERROR (
"Channel " << MSG::hex << chid.
get_compact() << MSG::dec <<
" asks for OFC bin = " << OFCTimeBin <<
". Set to 0." );
439 ofc_a=larOFC->OFC_a(chid,gain,OFCTimeBin);
444 if (ofc_a.size()==0) {
447 <<
" [ Layer = " << layer <<
" - Eta = " <<
eta <<
" - Phi = " <<
phi <<
" - Region = " << region <<
" ]"
448 <<
" Time bin = " << OFCTimeBin <<
", Gain = " << gain <<
". Skipping channel." );
451 if (ofc_a.size()+timeSampleShift>nSamples) {
454 if (timeSampleShift==0)
455 ATH_MSG_DEBUG (
"Found LArDigit with " << nSamples <<
" samples, but OFCs for "
456 << ofc_a.size() <<
" samples. Skipping Channel ");
458 ATH_MSG_DEBUG (
"After time sample shift of " << timeSampleShift <<
", " << nSamples-timeSampleShift
459 <<
" samples left, but have OFCs for " << ofc_a.size() <<
" samples. Skipping Channel ");
465 for (
unsigned i=0;i<(ofc_a.size());i++)
466 ADCPeak+=(samples[i+timeSampleShift]-pedestalAverage)*ofc_a.
at(i);
468 if (debugPrint)
ATH_MSG_VERBOSE (
"ADC Height calculated " << ADCPeak <<
" TimeBin=" << OFCTimeBin );
474 if (ramp.size()==0) {
477 <<
" [ Layer = " << layer <<
" - Eta = " <<
eta <<
" - Phi = " <<
phi <<
" - Region = " << region <<
" ]"
478 <<
" Gain = " << gain <<
". Skipping channel." );
485 ATH_MSG_DEBUG (
"Bad ramp for channel " << chid <<
" (ramp[1] = " << ramp[1] <<
"): skip this channel" );
489 float ADCPeakPower=ADCPeak;
494 for (
unsigned i=1;i<ramp.size();i++)
495 {energy+=ramp[i]*ADCPeakPower;
496 ADCPeakPower*=ADCPeak;
502 Identifier id = cabling->cnvToIdentifier(chid);
511 float hvCorr = oflHVCorr-> HVScaleCorr(chid);
512 energy = energy*hvCorr;
518 ofc_b=larOFC->OFC_b(chid,gain,OFCTimeBin);
519 if (ofc_b.size() != ofc_a.size()) {
522 <<
" Gain "<< gain <<
" found. Time not calculated." );
525 <<
" not equal to OFC for energy size " << ofc_a.size()
526 <<
" Time not calculated " );
529 for (
unsigned i=0;i<(ofc_b.size());i++)
530 time+=(samples[i+timeSampleShift]-pedestalAverage)*ofc_b.
at(i);
535 if (debugPrint)
ATH_MSG_VERBOSE (
"Time calculated " << time <<
" TimeBin=" << OFCTimeBin );
549 if (shape.size() < ofc_a.size()) {
552 <<
" Gain "<< gain <<
". Quality factor not calculated." );
555 <<
"smaller than OFC size " << ofc_a.size()
556 <<
"for channel 0x" << MSG::hex << chid.
get_compact()
557 << MSG::dec <<
". Quality factor not calculated." );
562 if (time!=0 && shapeDer.size()!=shape.size()) {
564 ATH_MSG_DEBUG (
"Shape-Derivative has different size than Shape for channel 0x" << MSG::hex << chid.
get_compact() << MSG::dec
565 <<
". Derivative not taken into accout for quality factor." );
568 if (time==0 || shapeDer.size()!=shape.size() ) {
569 for (
unsigned i=0;i<(ofc_a.size());i++)
570 quality+=((samples[i+timeSampleShift]-pedestalAverage)-shape[i]*ADCPeak)*
571 ((samples[i+timeSampleShift]-pedestalAverage)-shape[i]*ADCPeak);
574 for (
unsigned i=0;i<(ofc_a.size());i++)
575 quality+=((samples[i+timeSampleShift]-pedestalAverage)-((shape[i]-shapeDer[i]*time)*ADCPeak))*
576 ((samples[i+timeSampleShift]-pedestalAverage)-((shape[i]-shapeDer[i]*time)*ADCPeak));
590 time=time/picosecond;
594 uint16_t iprovenance=0xA5;
596 iquality = ((int)(quality) ) & 0xFFFF;
597 iprovenance=iprovenance | 0x2000;
601 LArRawChannel larRawChannel(chid,(
int)energy,(
int)time,iquality,iprovenance, gain);
602 larRawChannelContainer->push_back(larRawChannel);
606 <<
" e=" << energy <<
" t=" << time <<
" Q=" << quality );
609 ATH_MSG_DEBUG ( ntot_raw <<
" channels successfully processed, (" << highE <<
" with high energy)" );
613 ATH_MSG_ERROR (
"Too many channels (" <<BadTiming<<
" !) have a bad timing !!" );
614 ATH_MSG_ERROR (
"OFC time constants should be revisited !!!" );
616 larRawChannelContainer->clear();
622 ATH_MSG_ERROR ( saturation <<
" saturating channels were found. Event is skipped." );
623 larRawChannelContainer->clear();
665 || ( msgSvc()->outputLevel(name()) <= MSG::DEBUG && ( noEnergy || noTime || noShape || noShapeDer || saturation ) )
679 msg() << msglvl <<
" *** Error & Warning summary for this event *** " << std::endl;
682 msg() << msglvl <<
" " << noEnergy <<
" out of "
683 << digitContainer->
size() <<
" channel(s) skipped due to a lack of basic calibration constants."
687 msg() << msglvl <<
" " << noTime <<
" out of "
688 << highE <<
" high-enegy channel(s) have no time-info due to a lack of Optimal Filtering Coefficients."
692 msg() << msglvl <<
" " << noShape <<
" out of "
693 << highE <<
" high-enegy channel(s) have no quality factor due to a lack of shape."
697 msg() << msglvl <<
" " << noShapeDer <<
" out of "
698 << highE <<
" high-enegy channel(s) lack the derivative of the shape. Not taken into accout for Quality factor."
703 msg() << MSG::ERROR <<
" " << saturation <<
" out of "
704 << digitContainer->
size() <<
" channel(s) showed saturations. The complete event was skipped." << std::endl;
706 msg() << MSG::ERROR <<
" " << saturation <<
" out of "
707 << digitContainer->
size() <<
" channel(s) showed saturations and were skipped." << std::endl;
709 msg() << MSG::WARNING <<
" " << saturation <<
" out of "
710 << digitContainer->
size() <<
" channel(s) showed saturations." << std::endl;
718 return StatusCode::SUCCESS;