|
ATLAS Offline Software
|
Go to the documentation of this file.
10 #include "CaloDetDescr/CaloDetDescrElement.h"
13 #include <Eigen/Dense>
23 ISvcLocator *pSvcLocator)
25 m_LArOnOffIdMappingObjKey(
"LArOnOffIdMap"),
26 m_LArShapeObjKey(
"LArShapeSym"),
27 m_LArNoiseObjKey(
"LArNoiseSym"),
28 m_LArPedestalObjKey(
"LArPedestal"),
29 m_LArAutoCorrTotalObjKey(
"LArAutoCorrTotal"),
30 m_LArOFCObjKey(
"LArOFC"),
31 m_Nminbias(0), m_isMC(true),
32 m_isSuperCell(false), m_firstSample(0),
33 m_useHighestGainAutoCorr(false), m_Dump(false) {
35 "Key to read LArOnOffIdMapping object");
37 "Key to read LArShape object");
39 "Key to read LArNoise object");
41 "Key to read LArPedestal object");
43 "Key to read LArAutoCorrTotal object");
45 "Key to write LArOFC object");
51 "First sample to use for in-time event on the full pulse shape");
81 return StatusCode::SUCCESS;
92 << writeHandle.
fullKey() <<
" is already valid.");
93 return StatusCode::SUCCESS;
102 larOnlineID = scidhelper;
106 larOnlineID = idhelper;
114 larOnOffIdMapping = *larOnOffIdMappingHdl;
115 if (larOnOffIdMapping ==
nullptr) {
116 ATH_MSG_ERROR(
"Failed to retrieve LArOnOffIdMapping object");
117 return StatusCode::FAILURE;
128 if (larShape ==
nullptr) {
130 return StatusCode::FAILURE;
136 larAutoCorrTotal= *AutoCorrTotalHdl;
137 if (larAutoCorrTotal ==
nullptr) {
139 return StatusCode::FAILURE;
149 larNoise = *NoiseHdl;
150 if (larNoise ==
nullptr) {
152 return StatusCode::FAILURE;
157 larPedestal = *PedestalHdl;
158 if (larPedestal ==
nullptr) {
160 return StatusCode::FAILURE;
165 ATH_MSG_INFO(
"IOV found from intersection for LArOFCCondObj object: "
171 std::unique_ptr<LArOFC> larOFC =
172 std::make_unique<LArOFC>(larOnlineID, larOnOffIdMapping,
m_nGains);
174 std::vector<float> OFCa_tmp, OFCb_tmp;
188 unsigned int nsamples_shape = Shape.size();
193 int igain_autocorr = 0;
198 const std::vector<double>
AutoCorr =
201 unsigned int nsamples_AC_OFC = (1+((
int)(sqrt(1+8*
AutoCorr.size()))))/2;
203 const std::vector<double>& rmsSampl =
205 unsigned int nsamples2 = rmsSampl.size();
206 if (nsamples2 != nsamples_AC_OFC) {
218 unsigned int iBeginOfNSamples = firstSample;
219 if(nsamples_AC_OFC + iBeginOfNSamples > nsamples_shape)
233 <<chid<<
" at gain "<<
igain );
239 if(Shape.size()==0 || ShapeDer.size()==0 ||
AutoCorr.empty())
242 <<chid<<
" at gain "<<
igain );
246 if (Shape.size()!=ShapeDer.size()) {
247 ATH_MSG_ERROR(
"Got invalid shape object: Size=" << Shape.size() <<
", DerSize=" << ShapeDer.size());
248 return StatusCode::SUCCESS;
260 for(
l=0;
l<nsamples_AC_OFC;++
l) {
261 for(
c=0;
c<nsamples_AC_OFC;++
c) {
268 int index = i1*nsamples_AC_OFC - i1*(i1+1)/2 -(i1+1) + i2;
285 for(
l=0;
l<nsamples_AC_OFC;++
l)
287 ACinv_PS[
l]=0.; ACinv_PSD[
l]=0.;
288 for(
c=0;
c<nsamples_AC_OFC;++
c){
289 ACinv_PS[
l]+=ACinv(
l,
c)*Shape[
c+iBeginOfNSamples];
290 ACinv_PSD[
l]+=ACinv(
l,
c)*ShapeDer[
c+iBeginOfNSamples];
292 Q1+=Shape[
l+iBeginOfNSamples]*ACinv_PS[
l];
293 Q2+=ShapeDer[
l+iBeginOfNSamples]*ACinv_PSD[
l];
294 Q3+=ShapeDer[
l+iBeginOfNSamples]*ACinv_PS[
l];
296 float DELTA=Q1*Q2-Q3*Q3;
299 OFCa_tmp.resize(nsamples_AC_OFC);
300 for(
i=0;
i<nsamples_AC_OFC;++
i)
301 OFCa_tmp[
i]=(ACinv_PS[
i]*Q2-ACinv_PSD[
i]*Q3)/DELTA;
303 OFCb_tmp.resize(nsamples_AC_OFC);
304 for(
i=0;
i<nsamples_AC_OFC;++
i)
305 OFCb_tmp[
i]=(ACinv_PS[
i]*Q3-ACinv_PSD[
i]*Q1)/DELTA;
310 std::cout<<larOnlineID
313 std::cout<<
"Shape: ";
314 for(
c=0;
c<nsamples_shape;++
c)
315 std::cout<<Shape[
c]<<
" ";
316 std::cout<<std::endl;
317 std::cout<<
"ShapeDer: ";
318 for(
c=0;
c<nsamples_shape;++
c)
319 std::cout<<ShapeDer[
c]<<
" ";
320 std::cout<<std::endl;
321 for(
c=0;
c<nsamples_AC_OFC;++
c)
322 std::cout<<Shape[
c+iBeginOfNSamples]<<
" ";
323 std::cout<<
" <- "<<iBeginOfNSamples<<std::endl;
324 for(
i=0;
i<nsamples_AC_OFC;++
i) std::cout<<ACinv_PS[
i]<<
" ";
325 std::cout<<std::endl;
326 for(
i=0;
i<nsamples_AC_OFC;++
i) std::cout<<ACinv_PSD[
i]<<
" ";
327 std::cout<<std::endl;
328 std::cout<<
" Q1="<<Q1<<
" Q2="<<Q2<<
" Q3="<<Q3
329 <<
" DELTA="<<DELTA<<std::endl;
330 std::cout <<
" OFCa: ";
331 for(
i=0;
i<nsamples_AC_OFC;++
i)
332 std::cout<<(ACinv_PS[
i]*Q2-ACinv_PSD[
i]*Q3)/DELTA<<
" ";
333 std::cout<<std::endl;
335 bool stat = larOFC->
setOFC(hid,
igain, std::make_pair(OFCa_tmp, OFCb_tmp));
337 msg(MSG::ERROR) <<
"LArOFC::setOFC fails for gain " <<
igain <<
", hash " << hid <<
endmsg;
342 std::vector<float>
empty;
345 msg(MSG::ERROR) <<
"LArOFC::setOFC fails for gain " <<
igain <<
", hash " << hid <<
endmsg;
355 return StatusCode::SUCCESS;
359 unsigned int nsamples_AC_OFC,
360 unsigned int nsamples_shape)
const
362 unsigned int i_ShapeMax=0;
364 for(
unsigned int i=0;
i<nsamples_shape;++
i)
367 if(
value>ShapeMax) { ShapeMax=
value; i_ShapeMax=
i; }
368 else if(value<0 && i>3)
break;
371 unsigned int tmp=
int(nsamples_AC_OFC/2.);
372 if(
tmp>i_ShapeMax)
return 0;
373 else return i_ShapeMax-
tmp;
virtual StatusCode initialize() override
def retrieve(aClass, aKey=None)
SG::ReadCondHandleKey< ILArPedestal > m_LArPedestalObjKey
IdentifierHash channel_Hash(HWIdentifier channelId) const
Create channel_hash from channel_Id.
SG::WriteCondHandleKey< LArOFC > m_LArOFCObjKey
virtual ~LArOFCCondAlg() override
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
const EventIDRange & getRange() const
unsigned int m_firstSample
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
virtual StatusCode execute() override
const std::vector< double > autoCorrTotal(const IdentifierHash &hid, int gain, float Nminbias) const
unsigned int findTheNSamples(ILArShape::ShapeRef_t Shape, unsigned int nsamples_AC_OFC, unsigned int nsamples_shape) const
Definition of CaloDetDescrManager.
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
SG::ReadCondHandleKey< LArOnOffIdMapping > m_LArOnOffIdMappingObjKey
bool isFCALchannel(const HWIdentifier id) const
const DataObjID & fullKey() const
bool m_useHighestGainAutoCorr
id_range channel_range() const
SG::ReadCondHandleKey< ILArShape > m_LArShapeObjKey
SG::ReadCondHandleKey< ILArNoise > m_LArNoiseObjKey
virtual bool isHECchannel(const HWIdentifier id) const =0
::StatusCode StatusCode
StatusCode definition for legacy code.
SG::ReadCondHandleKey< LArAutoCorrTotal > m_LArAutoCorrTotalObjKey
const std::vector< double > samplRMS(const IdentifierHash &hid, int gain, float Nminbias) const
bool setOFC(const IdentifierHash &hid, const int gain, std::pair< std::vector< float >, std::vector< float >> ofcab)
Helper for the Liquid Argon Calorimeter cell identifiers.
StatusCode initialize(bool used=true)
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
Identifier cnvToIdentifier(const HWIdentifier &sid) const
create an Identifier from a HWIdentifier (inline)
#define ATH_MSG_WARNING(x)
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
virtual float pedestalRMS(const HWIdentifier &id, int gain) const =0
access to RMS of Pedestal index by Identifier, and gain setting
LArOFCCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
bool isOnlineConnected(const HWIdentifier &sid) const
Test whether a HWIdentifier is connected of not (inline)
Proxy for accessing a range of float values like a vector.
void addDependency(const EventIDRange &range)