ATLAS Offline Software
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
LArOFPeakRecoTool Class Reference

#include <LArOFPeakRecoTool.h>

Inheritance diagram for LArOFPeakRecoTool:
Collaboration diagram for LArOFPeakRecoTool:

Public Types

enum  { ERROR = -99999999 }
 
typedef LArOFIterResults Result
 

Public Member Functions

 LArOFPeakRecoTool (const std::string &type, const std::string &name, const IInterface *parent)
 
virtual ~LArOFPeakRecoTool ()
 
LArOFIterResults peak (const std::vector< short > &samples, HWIdentifier chID, CaloGain::CaloGain gain, int delay) const
 
LArOFIterResults peak (const std::vector< float > &samples, const HWIdentifier chID, const CaloGain::CaloGain gain, const float delayIn, const unsigned nIter=0, const unsigned npeak=2, unsigned peak_low=2, unsigned peak_high=2) const
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & evtStore () const
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc. More...
 
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm. More...
 
virtual StatusCode sysStart () override
 Handle START transition. More...
 
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles. More...
 
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles. More...
 
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T > &t)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc="none")
 Declare a new Gaudi property. More...
 
void updateVHKA (Gaudi::Details::PropertyBase &)
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 

Static Public Member Functions

static const InterfaceID & interfaceID ()
 

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution More...
 
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
 
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed. More...
 

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t
 

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &t, const SG::NotHandleType &)
 specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
 

Private Attributes

bool m_iterate
 
SG::ReadCondHandleKey< ILArOFCm_keyOFC {this, "OFCKey", "LArOFC", "SG key for OFC object"}
 
SG::ReadCondHandleKey< ILArShapem_keyShape {this, "ShapeKey", "LArShape", "SG key for Shape object"}
 
bool m_useShape
 
bool m_useShapeDer
 
int m_delayShift
 
float m_samplingPeriod
 
bool m_forceHighGain
 
bool m_isSC
 
const LArOnlineID_Basem_lar_on_id = nullptr
 
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default) More...
 
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default) More...
 
std::vector< SG::VarHandleKeyArray * > m_vhka
 
bool m_varHandleArraysDeclared
 

Detailed Description

Definition at line 29 of file LArOFPeakRecoTool.h.

Member Typedef Documentation

◆ Result

Definition at line 34 of file LArOFPeakRecoTool.h.

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
ERROR 

Definition at line 64 of file LArOFPeakRecoTool.h.

64 { ERROR = -99999999 } ;

Constructor & Destructor Documentation

◆ LArOFPeakRecoTool()

LArOFPeakRecoTool::LArOFPeakRecoTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 21 of file LArOFPeakRecoTool.cxx.

22  :
24  //m_nSamples(0xFFFFFFFF) //shall compare false to any possible number of samples
25 {
26  declareProperty("Iterate",m_iterate=false) ;
27  declareProperty("UseShape",m_useShape=false,"Use the LArShape to compute quality factor");
28  declareProperty("UseShapeDer",m_useShapeDer=true,"Use the shape derivative in the quality factor computation");
29  declareProperty("isSuperCell",m_isSC=false,"switch to use SuperCells");
30 // DelayShift = different with delay run in 25/24 ns units
31 // 23 is the ad-hoc value for run 5640-5641
32  declareProperty("DelayShift",m_delayShift=23);
33  declareProperty("SamplingPeriod",m_samplingPeriod=1./(40.08*Gaudi::Units::megahertz));
34  declareProperty("forceHighGain",m_forceHighGain=false,"Force use of high gain for all shapes and OFC (default=false)");
35  declareInterface<LArOFPeakRecoTool>(this);
36 }

◆ ~LArOFPeakRecoTool()

LArOFPeakRecoTool::~LArOFPeakRecoTool ( )
virtual

Definition at line 40 of file LArOFPeakRecoTool.cxx.

40  {
41 }

Member Function Documentation

◆ declareGaudiProperty() [1/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyArrayType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKeyArray>

Definition at line 170 of file AthCommonDataStore.h.

172  {
173  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
174  hndl.value(),
175  hndl.documentation());
176 
177  }

◆ declareGaudiProperty() [2/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158  {
159  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
160  hndl.value(),
161  hndl.documentation());
162 
163  }

◆ declareGaudiProperty() [3/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleBase>

Definition at line 184 of file AthCommonDataStore.h.

186  {
187  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
188  hndl.value(),
189  hndl.documentation());
190  }

◆ declareGaudiProperty() [4/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  t,
const SG::NotHandleType  
)
inlineprivateinherited

specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray>

Definition at line 199 of file AthCommonDataStore.h.

200  {
201  return PBASE::declareProperty(t);
202  }

◆ declareProperty() [1/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleBase hndl,
const std::string &  doc,
const SG::VarHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleBase. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 245 of file AthCommonDataStore.h.

249  {
250  this->declare(hndl.vhKey());
251  hndl.vhKey().setOwner(this);
252 
253  return PBASE::declareProperty(name,hndl,doc);
254  }

◆ declareProperty() [2/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKey hndl,
const std::string &  doc,
const SG::VarHandleKeyType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleKey. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 221 of file AthCommonDataStore.h.

225  {
226  this->declare(hndl);
227  hndl.setOwner(this);
228 
229  return PBASE::declareProperty(name,hndl,doc);
230  }

◆ declareProperty() [3/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKeyArray hndArr,
const std::string &  doc,
const SG::VarHandleKeyArrayType  
)
inlineinherited

Definition at line 259 of file AthCommonDataStore.h.

263  {
264 
265  // std::ostringstream ost;
266  // ost << Algorithm::name() << " VHKA declareProp: " << name
267  // << " size: " << hndArr.keys().size()
268  // << " mode: " << hndArr.mode()
269  // << " vhka size: " << m_vhka.size()
270  // << "\n";
271  // debug() << ost.str() << endmsg;
272 
273  hndArr.setOwner(this);
274  m_vhka.push_back(&hndArr);
275 
276  Gaudi::Details::PropertyBase* p = PBASE::declareProperty(name, hndArr, doc);
277  if (p != 0) {
278  p->declareUpdateHandler(&AthCommonDataStore<PBASE>::updateVHKA, this);
279  } else {
280  ATH_MSG_ERROR("unable to call declareProperty on VarHandleKeyArray "
281  << name);
282  }
283 
284  return p;
285 
286  }

◆ declareProperty() [4/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc,
const SG::NotHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This is the generic version, for types that do not derive from SG::VarHandleKey. It just forwards to the base class version of declareProperty.

Definition at line 333 of file AthCommonDataStore.h.

337  {
338  return PBASE::declareProperty(name, property, doc);
339  }

◆ declareProperty() [5/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This dispatches to either the generic declareProperty or the one for VarHandle/Key/KeyArray.

Definition at line 352 of file AthCommonDataStore.h.

355  {
356  typedef typename SG::HandleClassifier<T>::type htype;
357  return declareProperty (name, property, doc, htype());
358  }

◆ declareProperty() [6/6]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T > &  t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145  {
146  typedef typename SG::HandleClassifier<T>::type htype;
148  }

◆ detStore()

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

95 { return m_detStore; }

◆ evtStore() [1/2]

ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

85 { return m_evtStore; }

◆ evtStore() [2/2]

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( ) const
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 90 of file AthCommonDataStore.h.

90 { return m_evtStore; }

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase &  ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ finalize()

virtual StatusCode LArOFPeakRecoTool::finalize ( )
inlinevirtual

Definition at line 60 of file LArOFPeakRecoTool.h.

60 {return StatusCode::SUCCESS ; } ;

◆ initialize()

StatusCode LArOFPeakRecoTool::initialize ( )
virtual

Definition at line 43 of file LArOFPeakRecoTool.cxx.

43  {
44  ATH_MSG_DEBUG("initializing LArOFPeakRecoTool...");
45 
47 
49  if (!m_useShape) {
50  ATH_MSG_WARNING( "jobOption 'UseShape' set to false. Will work without shape" );
51  }
52 
53  if(!m_isSC) {
54  const LArOnlineID* laron;
55  StatusCode sc = detStore()->retrieve(laron,"LArOnlineID");
56  if (sc.isFailure()) {
57  ATH_MSG_ERROR("Unable to retrieve LArOnlineID from DetectorStore");
58  return StatusCode::FAILURE;
59  } else m_lar_on_id = (LArOnlineID_Base*) laron;
60  } else {
61  const LArOnline_SuperCellID* laron;
62  StatusCode sc = detStore()->retrieve(laron,"LArOnline_SuperCellID");
63  if (sc.isFailure()) {
64  ATH_MSG_ERROR("Unable to retrieve LArOnlineID from DetectorStore");
65  return StatusCode::FAILURE;
66  } else m_lar_on_id = (LArOnlineID_Base*) laron;
67  }
68  return StatusCode::SUCCESS;
69 }

◆ inputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

static const InterfaceID& LArOFPeakRecoTool::interfaceID ( )
inlinestatic

Definition at line 44 of file LArOFPeakRecoTool.h.

44 { return IID_LArOFPeakRecoTool;}

◆ msg() [1/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24  {
25  return this->msgStream();
26  }

◆ msg() [2/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30  {
31  return this->msgLevel(lvl);
32  }

◆ outputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ peak() [1/2]

LArOFIterResults LArOFPeakRecoTool::peak ( const std::vector< float > &  samples,
const HWIdentifier  chID,
const CaloGain::CaloGain  gain,
const float  delayIn,
const unsigned  nIter = 0,
const unsigned  npeak = 2,
unsigned  peak_low = 2,
unsigned  peak_high = 2 
) const

Definition at line 88 of file LArOFPeakRecoTool.cxx.

96  {
97 
98  const float epsilon=0.001;
100 
101  //Fill m_result with default/input values,
102  //calculation will be done with this object
103  result.m_valid=false;
104  result.m_converged=false;
105  result.m_amplitude= 0;
106  result.m_tau = 0;
107  result.m_quality = 0;
108  result.m_delay_final = delayIn;
109  result.m_peakSample_init = npeak;
110  result.m_peakSample_final = npeak; //Assumed index of highest sample (may change in the process)
111  result.m_chid = chID;
112  //Set some reference to improve readablity of the code:
113  unsigned& kMax = result.m_peakSample_final; //Make reference just to have code more readable
114  float& delay = result.m_delay_final;
115  float& q=result.m_quality;
116  unsigned& delayIdx=result.m_ofcIndex;
117  //Quantities used during iteration
118  unsigned kIter=0;
119  //Computation is done as double
120  double At=0;
121  double A=0;
122 
123  //Tying to avoid doing all checks for every event/channel/iteation step by assuming that
124  //the number of OFC samples is the same for all delays of a certain cell/gain.
125  //Code will segfault if not the case.
126 
127  const unsigned nSamples=samples.size();
128  //if (samples.size()<5){
129  // msg() << MSG::WARNING << "Not enough ADC samples (" << nSamples << ") found for channel 0x"
130  // << std::hex << chID.get_compact() << std::dec << endmsg;
131  // return result;
132  // }
133 
134  // force uses of high gain if required for OFC and shape
135  CaloGain::CaloGain usedGain = gain;
136  if (m_forceHighGain) {
137  if (m_lar_on_id->isHECchannel(chID)) usedGain = CaloGain::LARMEDIUMGAIN;
138  else usedGain = CaloGain::LARHIGHGAIN;
139  }
140 
141  const ILArOFC* dd_ofc=nullptr;
142  StatusCode sc=detStore()->retrieve(dd_ofc);
143  if (sc.isFailure()){
144  ATH_MSG_ERROR("Failed to retrieve LArOFC object " );
145  return result;
146  }
147 
148  // Quantities depending on this cell
149  const unsigned nOFCPhase=dd_ofc->nTimeBins(chID,usedGain);
150  float timeOffset = dd_ofc->timeOffset(chID,usedGain);
151 
152  // convert delay to internal OFC delay (from 0 to Nphases*timeBinWidth)
153  delay = delay-timeOffset;
154 
155  float timeBinWidth;
156  float timeMax;
157  if (nOFCPhase<2) { //Only one time bin
158  delayIdx=0;
159  timeBinWidth=25.; //ns
160  timeMax=(nOFCPhase-1)*timeBinWidth;
161  } else { //Have more than one OFC bin
162  timeBinWidth=dd_ofc->timeBinWidth(chID,usedGain);
163  timeMax = (nOFCPhase-1)*timeBinWidth;
164  if (timeBinWidth==0.) {
165  ATH_MSG_ERROR( "timeBinWidth is zero for channel " << m_lar_on_id->channel_name(chID) );
166  return result;
167  }
168  //Check if initial delay isn't too big
169  if (delay>timeMax) delay=timeMax-epsilon;
170  if (delay<0.) delay=0.;
171  //Index of the in in the vector according to the delay
172  delayIdx=(unsigned)floor(0.5+delay/timeBinWidth);
173  }
174 
175  //Get first set of OFC's
176  ILArOFC::OFCRef_t this_OFC_a = dd_ofc->OFC_a(chID,(int)usedGain,delayIdx);
177  ILArOFC::OFCRef_t this_OFC_b = dd_ofc->OFC_b(chID,(int)usedGain,delayIdx);
178  const unsigned ofcSize=this_OFC_a.size(); //Assumed to be the same of all delay-indices
179 
180  //some sanity check on the OFCs
181  if ( ofcSize == 0 || this_OFC_b.size() == 0 ) {
182  ATH_MSG_DEBUG("OFC not found for channel " << m_lar_on_id->channel_name(chID) << ", gain=" << usedGain << ", delayIdx=" << delayIdx);
183  return result;
184  }
185 
186  if ( this_OFC_a.size() != this_OFC_b.size() ) {
187  ATH_MSG_ERROR( "OFC a (" << this_OFC_a.size() <<
188  ")and b (" << this_OFC_b.size() << ") are not the same size for channel 0x"
189  << std::hex << chID.get_compact() << std::dec );
190  return result;
191  }
192 
193  //Coerce kmax, peak_high and peak_low to someting that can work
194  if (peak_low<2) peak_low=2; //By convention we expect at least 2 samples before the peak
195  if (peak_high>(nSamples+2-ofcSize)) peak_high=(nSamples+2-ofcSize);
196  if (peak_high<peak_low) {
197  ATH_MSG_WARNING( "Channel 0x" << std::hex << chID.get_compact() << std::dec
198  << "Not enough ADC samples (" << nSamples << ") to apply " << ofcSize << " OFCs." );
199  return result;
200  }
201  if(kMax<peak_low) kMax=peak_low;
202  if(kMax>peak_high) kMax=peak_high;
203 
204  float amplitude_save=0.;
205  float tau_save= 99999.;
206  unsigned int kMax_save=0;
207  float delay_save=0.;
208  unsigned int delayIdx_save=0;
209 
210  unsigned int mynIter = nIter;
211 
212  do {
213 
214  // Uncomment the following if you suspect that the ofc are corrupt for some phases:
215  /*
216  if ( this_OFC_a.size() == 0 || this_OFC_b.size() == 0 ) {
217  ATH_MSG_DEBUG( "OFC not found for channel 0x" << std::hex << chID.get_compact() << std::dec );
218  std::cout << "OFC not found for channel 0x" << std::hex << chID.get_compact() << std::dec << std::endl;
219  return result;
220  }
221 
222  if ( this_OFC_a.size() != this_OFC_b.size() ) {
223  ATH_MSG_ERROR( "OFC a (" << this_OFC_a.size() <<
224  ")and b (" << this_OFC_b.size() << ") are not the same size for channel 0x"
225  << std::hex << chID.get_compact() << std::dec );
226  return result;
227  }
228  */
229 
230 
231  //Apply Optimal Filtering coefficients
232  A = At = 0 ;
233  for ( unsigned k=0 ; (k<ofcSize); k++ ) {
234  //for ( unsigned k=0 ; (k<ofcSize) && (kMax-2+k<nSamples); k++ ) {
235  const float& this_sample = samples[kMax-2+k];
236  A += this_OFC_a.at(k) * this_sample ;
237  At += this_OFC_b.at(k) * this_sample ;
238  }
239  //Validate the result
240  result.m_valid = true; //Doesn't mean that the result is really good, but we have something
241  if ( A == 0 ) {
242  ATH_MSG_DEBUG("Null amplitude: " << A << " for channel" << m_lar_on_id->channel_name(chID));
243  result.m_amplitude=0;
244  result.m_tau=0;
245  return result;
246  }
247  result.m_amplitude=A;
248  result.m_tau = At / A ;
249 
250  //First iteration done, break loop if possible....
251  if (mynIter<=1) {
252  delay = delayIdx*timeBinWidth;
253  break; //No iteration requested
254  }
255 
256  // Nsamples=OFCsize and only one phase available, no point to iterate
257  if (samples.size() == ofcSize && nOFCPhase<2) {
258  delay = delayIdx*timeBinWidth;
259  break;
260  }
261 
262  // if we are within +-0.5*Dt of time bin, we have converged for sure
263  if (std::abs(result.m_tau) <= (0.5*timeBinWidth)) {
264  result.m_converged=true;
265  delay = delayIdx*timeBinWidth;
266  break;
267  }
268 
269  if (kIter>=mynIter) { //Max. number of iterations reached
270  delay = delayIdx*timeBinWidth;
271  if (result.m_converged) {
272  if (std::abs(tau_save) < std::abs(result.m_tau)) {
273  result.m_amplitude = amplitude_save;
274  result.m_tau = tau_save;
275  kMax = kMax_save;
276  delay = delay_save;
277  delayIdx = delayIdx_save;
278  }
279  }
280  if (std::abs(result.m_tau) <= timeBinWidth) result.m_converged=true;
281  break;
282  }
283 
284  // if we are within +-Dt of time bin, we consider that we have converged but we allow for one more
285  // iteration to see if we can find a smaller tau, if not we keep the previous one
286  if (std::abs(result.m_tau) <= timeBinWidth) {
287  result.m_converged = true;
288  mynIter = kIter+1; // allow only for more iteration
289  amplitude_save = result.m_amplitude;
290  tau_save = result.m_tau;
291  kMax_save = kMax;
292  delay_save = delayIdx*timeBinWidth;
293  delayIdx_save = delayIdx;
294  }
295 
296  delay = delay - result.m_tau; // moved this line up so first iteration delay results treated like subsequent
297 
298  if(delay<(-0.5*timeBinWidth)) {
299  if(kMax<peak_high){
300  kMax = kMax+1 ;
302  if( delay < 0 ) delay = 0;
303  if (delay > timeMax ) delay = timeMax-epsilon;
304  } else { // don't shift sample
305  delay = 0 ;
306  }
307  }//else if delay<0
308  else
309  if( delay>(timeMax+0.5*timeBinWidth) ) {
310  if(kMax>peak_low){
311  kMax = kMax-1 ;
313  if (delay < 0 ) delay=0.;
314  if( delay > timeMax ) delay = timeMax-epsilon;
315  } else {
316  // don't shift sample
317  delay = timeMax-epsilon;
318  }
319  }//end if delay>nOFCPhase
320  //Prepare next iteration step:
321  kIter++;
322  delayIdx=(unsigned)floor(0.5+delay/timeBinWidth);
323  if (delayIdx>=nOFCPhase) delayIdx = nOFCPhase-1;
324  //Get next set of OFC's
325  this_OFC_a = dd_ofc->OFC_a(chID,(int)usedGain,delayIdx);
326  this_OFC_b = dd_ofc->OFC_b(chID,(int)usedGain,delayIdx);
327  }
328  while(1); // end for iteration loop
329 
330  // go back to overal time
331  delay = delay + timeOffset; // sign to check
332 
333  // get shape
334  if (m_useShape){
335  const ILArShape* dd_shape=nullptr;
336  StatusCode sc=detStore()->retrieve(dd_shape);
337  if (sc.isFailure()){
338  ATH_MSG_ERROR("Failed to retrieve LArShape object with " );
339  return result;
340  }
341  q = 0.;
342  ILArShape::ShapeRef_t thisShape = dd_shape->Shape(chID,(int)usedGain,delayIdx) ;
343  ILArShape::ShapeRef_t thisShapeDer;
344  if (m_useShapeDer) thisShapeDer = dd_shape->ShapeDer(chID,(int)usedGain,delayIdx) ;
345  if( thisShape.size() >= ofcSize ) {
346  for ( unsigned k=0 ; k<ofcSize ; k++ ) {
347  const float& this_sample = samples[kMax-2+k];
348  if (m_useShapeDer && thisShapeDer.size() >= ofcSize)
349  q += std::pow((result.m_amplitude*(thisShape[k]-result.m_tau*thisShapeDer[k]) - this_sample),2);
350  else
351  q += std::pow((result.m_amplitude*thisShape[k] - this_sample),2);
352  }
353  }
354  else {
355  ATH_MSG_DEBUG("No shape for this channel");
356  }
357  }
358 
359  result.m_nIterPerf = kIter;
360  result.m_valid = true;
361  return result;
362 }

◆ peak() [2/2]

LArOFIterResults LArOFPeakRecoTool::peak ( const std::vector< short > &  samples,
HWIdentifier  chID,
CaloGain::CaloGain  gain,
int  delay 
) const

Definition at line 74 of file LArOFPeakRecoTool.cxx.

75  {
76 
77  std::vector<float> newsamples;
78  for(unsigned int i=0;i<samples.size();i++)
79  {
80  newsamples.push_back((float)samples[i]);
81  }
82  return peak(newsamples,chID,gain,delay);
83 
84 }

◆ renounce()

std::enable_if_t<std::is_void_v<std::result_of_t<decltype(&T::renounce)(T)> > && !std::is_base_of_v<SG::VarHandleKeyArray, T> && std::is_base_of_v<Gaudi::DataHandle, T>, void> AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T &  h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381  {
382  h.renounce();
383  PBASE::renounce (h);
384  }

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364  {
365  handlesArray.renounce();
366  }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in DerivationFramework::CfAthAlgTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and asg::AsgMetadataTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase &  )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308  {
309  // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310  // << " size: " << m_vhka.size() << endmsg;
311  for (auto &a : m_vhka) {
312  std::vector<SG::VarHandleKey*> keys = a->keys();
313  for (auto k : keys) {
314  k->setOwner(this);
315  }
316  }
317  }

Member Data Documentation

◆ m_delayShift

int LArOFPeakRecoTool::m_delayShift
private

Definition at line 72 of file LArOFPeakRecoTool.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_forceHighGain

bool LArOFPeakRecoTool::m_forceHighGain
private

Definition at line 74 of file LArOFPeakRecoTool.h.

◆ m_isSC

bool LArOFPeakRecoTool::m_isSC
private

Definition at line 75 of file LArOFPeakRecoTool.h.

◆ m_iterate

bool LArOFPeakRecoTool::m_iterate
private

Definition at line 67 of file LArOFPeakRecoTool.h.

◆ m_keyOFC

SG::ReadCondHandleKey<ILArOFC> LArOFPeakRecoTool::m_keyOFC {this, "OFCKey", "LArOFC", "SG key for OFC object"}
private

Definition at line 68 of file LArOFPeakRecoTool.h.

◆ m_keyShape

SG::ReadCondHandleKey<ILArShape> LArOFPeakRecoTool::m_keyShape {this, "ShapeKey", "LArShape", "SG key for Shape object"}
private

Definition at line 69 of file LArOFPeakRecoTool.h.

◆ m_lar_on_id

const LArOnlineID_Base* LArOFPeakRecoTool::m_lar_on_id = nullptr
private

Definition at line 76 of file LArOFPeakRecoTool.h.

◆ m_samplingPeriod

float LArOFPeakRecoTool::m_samplingPeriod
private

Definition at line 73 of file LArOFPeakRecoTool.h.

◆ m_useShape

bool LArOFPeakRecoTool::m_useShape
private

Definition at line 70 of file LArOFPeakRecoTool.h.

◆ m_useShapeDer

bool LArOFPeakRecoTool::m_useShapeDer
private

Definition at line 71 of file LArOFPeakRecoTool.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files:
LArOFPeakRecoTool::m_keyShape
SG::ReadCondHandleKey< ILArShape > m_keyShape
Definition: LArOFPeakRecoTool.h:69
get_generator_info.result
result
Definition: get_generator_info.py:21
LArOFPeakRecoTool::m_useShape
bool m_useShape
Definition: LArOFPeakRecoTool.h:70
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
LArOFPeakRecoTool::peak
LArOFIterResults peak(const std::vector< short > &samples, HWIdentifier chID, CaloGain::CaloGain gain, int delay) const
Definition: LArOFPeakRecoTool.cxx:74
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
ILArOFC::OFC_b
virtual OFCRef_t OFC_b(const HWIdentifier &id, int gain, int tbin=0) const =0
ILArShape::ShapeDer
virtual ShapeRef_t ShapeDer(const HWIdentifier &id, int gain, int tbin=0, int mode=0) const =0
LArOFPeakRecoTool::m_samplingPeriod
float m_samplingPeriod
Definition: LArOFPeakRecoTool.h:73
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
LArOFPeakRecoTool::m_useShapeDer
bool m_useShapeDer
Definition: LArOFPeakRecoTool.h:71
xAOD::unsigned
unsigned
Definition: RingSetConf_v1.cxx:662
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
dqt_zlumi_alleff_HIST.A
A
Definition: dqt_zlumi_alleff_HIST.py:110
python.SystemOfUnits.megahertz
int megahertz
Definition: SystemOfUnits.py:127
ILArOFC::timeOffset
virtual float timeOffset(const HWIdentifier &CellID, int gain) const =0
AthCommonDataStore
Definition: AthCommonDataStore.h:52
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArVectorProxy::at
value_type at(size_t i) const
Vector indexing with bounds check.
lumiFormat.i
int i
Definition: lumiFormat.py:92
LArOnlineID_Base::isHECchannel
virtual bool isHECchannel(const HWIdentifier id) const =0
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
01SubmitToGrid.samples
samples
Definition: 01SubmitToGrid.py:58
ILArOFC::timeBinWidth
virtual float timeBinWidth(const HWIdentifier &CellID, int gain) const =0
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LArOFPeakRecoTool::m_lar_on_id
const LArOnlineID_Base * m_lar_on_id
Definition: LArOFPeakRecoTool.h:76
delay
double delay(std::size_t d)
Definition: JetTrigTimerTest.cxx:14
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
AthAlgTool::AthAlgTool
AthAlgTool()
Default constructor:
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
SG::HandleClassifier::type
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
Definition: HandleClassifier.h:54
ILArOFC
Definition: ILArOFC.h:14
LArOnlineID_Base
Helper for the Liquid Argon Calorimeter cell identifiers.
Definition: LArOnlineID_Base.h:105
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
LArOFPeakRecoTool::ERROR
@ ERROR
Definition: LArOFPeakRecoTool.h:64
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArOnlineID
Definition: LArOnlineID.h:20
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition: CaloGain.h:18
LArOnline_SuperCellID
Definition: LArOnline_SuperCellID.h:20
CaloGain::CaloGain
CaloGain
Definition: CaloGain.h:11
CaloGain::LARMEDIUMGAIN
@ LARMEDIUMGAIN
Definition: CaloGain.h:18
a
TList * a
Definition: liststreamerinfos.cxx:10
h
Identifier::get_compact
value_type get_compact(void) const
Get the compact id.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:616
LArOFPeakRecoTool::m_isSC
bool m_isSC
Definition: LArOFPeakRecoTool.h:75
ILArOFC::OFC_a
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)
ILArOFC::nTimeBins
virtual unsigned nTimeBins(const HWIdentifier &CellID, int gain) const =0
extractSporadic.q
list q
Definition: extractSporadic.py:98
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
LArDigits2NtupleDumper.nSamples
nSamples
Definition: LArDigits2NtupleDumper.py:70
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
LArOFPeakRecoTool::m_forceHighGain
bool m_forceHighGain
Definition: LArOFPeakRecoTool.h:74
LArOFPeakRecoTool::m_delayShift
int m_delayShift
Definition: LArOFPeakRecoTool.h:72
LArOnlineID_Base::channel_name
std::string channel_name(const HWIdentifier id) const
Return a string corresponding to a feedthrough name given an identifier.
Definition: LArOnlineID_Base.cxx:218
ILArShape
Definition: ILArShape.h:13
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
LArOFPeakRecoTool::m_iterate
bool m_iterate
Definition: LArOFPeakRecoTool.h:67
fitman.k
k
Definition: fitman.py:528
LArVectorProxy
Proxy for accessing a range of float values like a vector.
Definition: LArVectorProxy.h:38
LArOFIterResults
Definition: LArOFIterResults.h:15
ILArShape::Shape
virtual ShapeRef_t Shape(const HWIdentifier &id, int gain, int tbin=0, int mode=0) const =0
LArOFPeakRecoTool::m_keyOFC
SG::ReadCondHandleKey< ILArOFC > m_keyOFC
Definition: LArOFPeakRecoTool.h:68