6#include "GaudiKernel/SystemOfUnits.h"
29 return StatusCode::SUCCESS;
33 return StatusCode::SUCCESS;
42 auto outputContainerCellPtr = std::make_unique<CaloCellContainer>(
SG::VIEW_ELEMENTS);
45 unsigned int hash_max =
m_onlineId->channelHashMax();
49 outputContainerCellPtr->reserve( hash_max );
73 badchannel = *larBadChan;
77 for (
const LArDigit* digit : *inputContainer) {
80 if (!(*cabling)->isOnlineConnected(
id))
continue;
84 const std::vector<short>& samples=digit->samples();
85 const size_t nSamples=samples.size();
86 const int gain=digit->gain();
87 const float p=peds->
pedestal(
id,gain);
90 const auto& ofca=ofcs->
OFC_a(
id,gain);
91 const auto& adc2mev=adc2MeVs->
ADC2MEV(
id,gain);
96 return StatusCode::FAILURE;
101 return StatusCode::FAILURE;
105 std::vector<float> samp_no_ped(nSamples,0.0);
106 for (
size_t i=0;i<nSamples;++i) {
107 samp_no_ped[i]=samples[i]-p;
114 bool passBCIDmax=
false;
116 size_t nOFC=ofca.size();
119 <<
". Found " << nSamples <<
", expect at least " << nOFC+2 <<
".");
122 for (
size_t i=0;i<nOFC;++i) {
123 A+=
static_cast<double>(samp_no_ped[i+1])*ofca[i];
127 for (
size_t i=0;i<nOFC;++i) {
128 Abefore+=
static_cast<double>(samp_no_ped[i])*ofca[i];
132 for (
size_t i=0;i<nOFC;++i) {
133 Aafter+=
static_cast<double>(samp_no_ped[i+2])*ofca[i];
136 if ( (
A>Abefore) && (
A>Aafter) ) passBCIDmax=
true;
140 const float E=adc2mev[0]+
A*adc2mev[1];
142 uint16_t iquaShort=0;
148 ATH_MSG_VERBOSE(
"Channel " <<
m_onlineId->channel_name(
id) <<
" gain " << gain <<
" above threshold for tQ computation");
151 const auto& ofcb=ofcs->
OFC_b(
id,gain);
153 for (
size_t i=0;i<nOFC;++i) {
154 At+=
static_cast<double>(samp_no_ped[i+1])*ofcb[i];
157 tau=(std::fabs(
A)>0.1) ? At/
A : 0.0;
158 const auto& fullShape=shapes->
Shape(
id,gain);
163 if (fullShape.size()>nSamples && nSamples==4 &&
m_firstSample==0) {
171 <<
" gain " << gain);
172 ATH_MSG_DEBUG(
"Got size " << fullShape.size() <<
", expected at least " << nSamples+firstSample);
174 nOFC=fullShape.size()-firstSample;
177 const float* shape=&*fullShape.begin()+firstSample;
182 const auto& fullshapeDer=shapes->
ShapeDer(
id,gain);
185 <<
" gain " << gain <<
". Will not use shape derivative.");
189 const float* shapeDer=&*fullshapeDer.begin()+firstSample;
190 for (
size_t i=0;i<nOFC;++i) {
191 q += std::pow((
A*(shape[i]-tau*shapeDer[i])-(samp_no_ped[i+1])),2);
197 for (
size_t i=0;i<nOFC;++i) {
198 q += std::pow((
A*shape[i]-(samp_no_ped[i+1])),2);
202 int iqua =
static_cast<int>(q);
203 if (iqua > 0xFFFF) iqua=0xFFFF;
204 iquaShort =
static_cast<uint16_t
>(iqua & 0xFFFF);
210 Identifier offId = cabling->cnvToIdentifier(
id);
217 float et =
ss->et()*1e-3;
231 ss->setProvenance(prov);
233 ss->setQuality(iquaShort);
234 outputContainerCellPtr->push_back(
ss);
239 ATH_CHECK(outputContainer.
record(std::move(outputContainerCellPtr) ) );
241 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
Definition of CaloDetDescrManager.
LArBadXCont< LArBadChannel > LArBadChannelCont
const ServiceHandle< StoreGateSvc > & detStore() const
Data object for each calorimeter readout cell.
This class groups all DetDescr information related to a CaloCell.
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
a typed memory pool that saves time spent allocation small object.
void reserve(unsigned int size)
Set the desired capacity.
pointer nextElementPtr()
obtain the next available element in pool by pointer pool is resized if its limit has been reached On...
unsigned int allocated()
return size already allocated OK
virtual OFCRef_t OFC_b(const HWIdentifier &id, int gain, int tbin=0) const =0
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 float timeOffset(const HWIdentifier &CellID, int gain) const =0
virtual float pedestal(const HWIdentifier &id, int gain) const =0
virtual ShapeRef_t Shape(const HWIdentifier &id, int gain, int tbin=0, int mode=0) const =0
virtual ShapeRef_t ShapeDer(const HWIdentifier &id, int gain, int tbin=0, int mode=0) const =0
const LArVectorProxy ADC2MEV(const HWIdentifier &id, int gain) const
bool statusBad(PosType pb) const
Returns true if corresponding status bit its set.
bool good() const
Returns true if no problems at all (all bits at zero)
LArBC_t offlineStatus(const Identifier id) const
Query the status of a particular channel by offline ID This is the main client access method.
Liquid Argon digit base class.
SG::ReadCondHandleKey< ILArPedestal > m_pedestalKey
SG::ReadCondHandleKey< ILArShape > m_shapeKey
Gaudi::Property< float > m_eCutFortQ
Gaudi::Property< int > m_firstSample
SG::ReadCondHandleKey< CaloSuperCellDetDescrManager > m_caloSuperCellMgrKey
Gaudi::Property< bool > m_absECutFortQ
const LArOnline_SuperCellID * m_onlineId
SG::WriteHandleKey< CaloCellContainer > m_cellKey
SG::ReadCondHandleKey< LArBadChannelCont > m_bcContKey
Bad Channel masking for Super-Cells.
StatusCode execute(const EventContext &ctx) const override
StatusCode initialize() override
SG::ReadHandleKey< LArDigitContainer > m_digitKey
SG::ReadCondHandleKey< LArADC2MeV > m_adc2MeVKey
SG::ReadCondHandleKey< ILArOFC > m_ofcKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Gaudi::Property< bool > m_useShapeDer
StatusCode finalize() override
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
hold the test vectors and ease the comparison
Extra patterns decribing particle interation process.