|
ATLAS Offline Software
|
Go to the documentation of this file.
7 #include "CLHEP/Units/SystemOfUnits.h"
14 #include "GaudiKernel/ThreadLocalContext.h"
29 m_onlineHelper(nullptr),
30 m_peakParabolaTool(
"LArParabolaPeakTool"),
77 if (
m_mode ==
"PARABOLA"){
81 return StatusCode::SUCCESS;
83 ATH_MSG_DEBUG(
"LArParabolaPeakRecoTool retrieved with success!" );
99 return StatusCode::SUCCESS;
111 ATH_MSG_DEBUG(
"1) LArDigitContainer container size = " << digitContainer->
size() );
113 ATH_MSG_DEBUG(
"2) LArDigitContainer container size = " << digitContainer->
size() );
114 if( digitContainer->
empty() ) {
116 return StatusCode::SUCCESS;
119 auto larRawChannelContainer = std::make_unique<LArRawChannelContainer>();
126 ATH_MSG_DEBUG(
"No pedestal found in database. Use default values." );
134 return StatusCode::FAILURE;
149 int nMinEM(0),nMinHEC(0),nMinFCAL(0);
150 std::vector<float> fSumEM,fSumHEC,fSumFCAL;
151 std::vector<float> *pSum =
nullptr;
157 for(
int iloop=0;iloop<2;iloop++) {
165 const std::vector<short>& samples =
digit->samples();
166 unsigned int nSamples = samples.size();
171 float thePedestal=-1;
175 thePedestal=DBpedestal;
179 ATH_MSG_DEBUG(
"No pedestal found for this cell. Use default value " << thePedestal );
182 std::vector<float> mySamples;
183 mySamples.resize(samples.size());
188 for (
unsigned int i=0;
i<samples.size();
i++ )
190 mySamples[
i] = ((
float)samples[
i]) - thePedestal;
196 GainFactor = 9.8*9.8;
209 ATH_MSG_DEBUG( std::hex <<
" FebID / chid / channel = " << FebID <<
" / " << chid <<
" / " <<
channel );
217 unsigned int nAverage = 1;
259 << nAverage <<
") is larger than total number of samples ("
260 <<
nSamples <<
")! adjusting nAverage ... " );
272 for(
unsigned j=0;j<nAverage;j++ ) {
273 (*pSum)[
i] += mySamples[
i+j];
278 float maxADCPeak = 0.;
279 unsigned int iPeakSamp = 0;
280 float averagedADC = 0;
282 if ( maxADCPeak < mySamples[
i] )
284 maxADCPeak = mySamples[
i];
287 if ( (
int)
i >= nMin &&
i < nMin+nAverage )
288 averagedADC += mySamples[
i];
290 averagedADC /= myScale;
292 bool CubicFailed =
false;
300 ADCPeak = maxADCPeak;
316 const float invT[3][3]
322 if ( iPeakSamp <= 1 ) {
324 }
else if ( iPeakSamp >=
nSamples - 1 ) {
332 float A[3] = {0, 0, 0};
335 for (
int ia = 0; ia < 3; ia++)
336 for (
int it = 0;
it < 3;
it++)
337 A[ia] += invT[ia][
it] * mySamples[it0+
it];
340 if ( not ( CubicFailed = (
A[2] == 0 ) ) ) {
341 dtmax = -1.0 *
A[1] / 2.0 /
A[2];
342 if ( ! ( CubicFailed = ( dtmax < 0 || dtmax > 2 ) ) ) {
345 for(
int ia = 0; ia < 3; ia++)
346 ADCPeak +=
A[ia] *
pow(dtmax, ia);
352 float weightSum = 0.;
354 for(
int it=0;
it<3;
it++) {
356 weightSum +=
float(mySamples[it0+
it]);
368 if (
m_mode ==
"PARABOLA" &&
381 <<
" Cannot get offline identifier from online ID = " << chid );
386 ADCPeak = peak[0]-thePedestal;
387 if (peak.size()==2)
time = peak[1];
390 ATH_MSG_DEBUG(
"No pic is computed from Parabola. Use scaled average of selected samples" );
391 ADCPeak = averagedADC;
395 ATH_MSG_FATAL(
"No parabola tool available ! Choose another mode" );
400 else if (
m_mode ==
"CUBIC" &&
404 const float invT[4][4]
406 { -1.83333, 3, -1.5, 0.333333},
408 {-0.166666, 0.5, -0.5, 0.166666} };
411 if ( iPeakSamp <= 1 ) {
413 }
else if ( iPeakSamp >=
nSamples - 2 ) {
416 it0 = ( mySamples[iPeakSamp-2] > mySamples[iPeakSamp+2] )
422 float A[4] = {0, 0, 0, 0};
426 for (
int ia = 0; ia < 4; ia++)
427 for (
int it = 0;
it < 4;
it++)
428 A[ia] += invT[ia][
it] * mySamples[it0+
it];
431 disc =
A[2]*
A[2] - 3*
A[1]*
A[3];
432 if ( ! ( CubicFailed = ( disc < 0 ||
A[3] == 0 ) ) ) {
433 dtmax = (-
A[2]-std::sqrt(disc))/(
A[3]*3);
434 if ( ! ( CubicFailed = ( dtmax < 0 || dtmax > 3 ) ) ) {
436 for(
int ia = 0; ia < 4; ia++)
437 ADCPeak +=
A[ia] *
pow(dtmax, ia);
445 if(
m_mode ==
"FIXED" || CubicFailed ) {
446 ADCPeak = averagedADC;
453 << (isEM?
"EM":(isHEC?
"HEC":(
isFCAL?
"FCAL":
"none")))
466 float ADCPeakPower=ADCPeak;
470 if (ramp.size()>1 && ramp[1]<500 && ramp[1]>0) {
472 for (
unsigned i=1;
i<ramp.size();
i++)
475 ADCPeakPower*=ADCPeak;
480 ATH_MSG_DEBUG(
"No Ramp found for this cell. Use default values" );
483 float ADCtoMeV = 10.0;
500 ADCtoMeV=ADCtoMeV*(12./18.);
527 energy = ADCPeak * ADCtoMeV * GainFactor;
535 larRawChannelContainer->add(larRawChannel);
543 if ( !fSumEM.empty() ) {
544 for(
i=0;
i<fSumEM.size();
i++) {
545 if (
i == 0 || fSumEM[
i] > tmpSum ) {
550 ATH_MSG_DEBUG(
"Found best EM window starting at sample <" << nMinEM <<
">" );
553 for(
i=0;
i<fSumHEC.size();
i++) {
554 if (
i == 0 || fSumHEC[
i] > tmpSum ) {
559 if ( !fSumHEC.empty() ) {
560 ATH_MSG_DEBUG(
"Found best HEC window starting at sample <" << nMinHEC <<
">" );
563 for(
i=0;
i<fSumFCAL.size();
i++) {
564 if (
i == 0 || fSumFCAL[
i] > tmpSum ) {
566 tmpSum = fSumFCAL[
i];
569 if ( !fSumFCAL.empty() ) {
570 ATH_MSG_DEBUG(
"Found best FCAL window starting at sample <" << nMinFCAL <<
">" );
581 return StatusCode::SUCCESS;
589 return StatusCode::SUCCESS;
def retrieve(aClass, aKey=None)
SG::WriteHandleKey< LArRawChannelContainer > m_ChannelContainerName
virtual float pedestal(const HWIdentifier &id, int gain) const =0
const LArVectorProxy ADC2MEV(const HWIdentifier &id, int gain) const
const LArEM_ID * em_idHelper() const
access to EM idHelper
bool is_lar_fcal(Identifier id) const
bool is_em_endcap_outer(const Identifier id) const
test if the id belongs to the EM Endcap outer wheel
Scalar eta() const
pseudorapidity method
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
ToolHandle< LArParabolaPeakRecoTool > m_peakParabolaTool
SG::ReadCondHandleKey< LArADC2MeV > m_adc2mevKey
int module(const Identifier id) const
module [1,3]
int sampling(const Identifier id) const
return sampling according to :
const std::string & key() const
Return the StoreGate ID for the referenced object.
int eta(const Identifier id) const
return eta according to :
virtual StatusCode initialize() override
const LArHEC_ID * hec_idHelper() const
access to HEC idHelper
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
An algorithm that can be simultaneously executed in multiple threads.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
float m_ADCtoMeVEMECOuter[4]
Handle class for recording to StoreGate.
int channel(const HWIdentifier id) const
Return the channel number of a hardware cell identifier channel = [0,127] in all FEB.
Liquid Argon digit base class.
Liquid Argon ROD output object base class.
::StatusCode StatusCode
StatusCode definition for legacy code.
const LArHEC_ID * m_hecId
bool is_lar_hec(Identifier id) const
const LArFCAL_ID * m_fcalId
Helper class for offline cell identifiers.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
float m_ADCtoMeVEMECInner[2]
HWIdentifier feb_Id(int barrel_ec, int pos_neg, int feedthrough, int slot) const
Create feb_Id from fields.
bool isFCAL(const xAOD::CaloCluster *cluster)
return true if the cluster (or the majority of its energy) is in the FCAL0
StatusCode initialize(bool used=true)
LArRawChannelSimpleBuilder(const std::string &name, ISvcLocator *pSvcLocator)
bool is_em_endcap_inner(const Identifier id) const
test if the id belongs to the EM Endcap inner wheel
def time(flags, cells_name, *args, **kw)
bool is_em_barrel(const Identifier id) const
test if the id belongs to the EM barrel
#define ATH_MSG_WARNING(x)
int sampling(const Identifier id) const
return sampling [0,3] (only 0 for supercells)
std::string m_FCALmodeTime
const LArOnlineID * m_onlineHelper
virtual StatusCode execute(const EventContext &ctx) const override
Handle class for reading from StoreGate.
virtual StatusCode finalize() override
bool is_lar_em(Identifier id) const
size_type size() const noexcept
Returns the number of elements in the collection.
SG::ReadHandleKey< LArDigitContainer > m_DataLocation
Exception class for LAr Identifiers.
bool empty() const noexcept
Returns true if the collection is empty.
const LArFCAL_ID * fcal_idHelper() const
access to FCAL idHelper
Proxy for accessing a range of float values like a vector.