ATLAS Offline Software
Loading...
Searching...
No Matches
LArShapePeakRecoTool Class Reference

#include <LArShapePeakRecoTool.h>

Inheritance diagram for LArShapePeakRecoTool:
Collaboration diagram for LArShapePeakRecoTool:

Public Member Functions

 LArShapePeakRecoTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~LArShapePeakRecoTool ()
std::vector< float > peak (const std::vector< float > &samples, const std::vector< double > &wave) const
void GetShapeParMax (float &xmax, float &ymax, float x1, float y1, float x2, float y2, float x3, float y3) const
void GetShapeSampleLimits (int &s1, int &s2, float sample_max, float delay_max, int nbin, int nsample) const
virtual StatusCode initialize ()
virtual StatusCode finalize ()
float ParabolaRawToTrueTime (float &QT_fittime, int &layer) const
float ParabolaRawToTrueADC (float &QT_true_time, float &ADCref, float &PEDref, int &layer) const
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () 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
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.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 12 of file LArShapePeakRecoTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ LArShapePeakRecoTool()

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

Definition at line 18 of file LArShapePeakRecoTool.cxx.

20 : AthAlgTool(type, name, parent)
21{}
AthAlgTool()
Default constructor:

◆ ~LArShapePeakRecoTool()

virtual LArShapePeakRecoTool::~LArShapePeakRecoTool ( )
inlinevirtual

Definition at line 23 of file LArShapePeakRecoTool.h.

23{};

Member Function Documentation

◆ declareGaudiProperty()

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

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

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

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

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ 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.

◆ evtStore()

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.

◆ 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()

StatusCode LArShapePeakRecoTool::finalize ( )
virtual

Definition at line 28 of file LArShapePeakRecoTool.cxx.

29{return StatusCode::SUCCESS;}

◆ GetShapeParMax()

void LArShapePeakRecoTool::GetShapeParMax ( float & xmax,
float & ymax,
float x1,
float y1,
float x2,
float y2,
float x3,
float y3 ) const

Definition at line 147 of file LArShapePeakRecoTool.cxx.

149{
150 float a,b,c;
151 float x12, x13, xx12, xx13, y12, y13;
152 float n,d;
153
154 y13 = y1 - y3;
155 y12 = y1 - y2;
156 x13 = x1 - x3;
157 x12 = x1 - x2;
158 xx12 = x1*x1 - x2*x2;
159 xx13 = x1*x1 - x3*x3;
160
161 n = y13 - x13/x12*y12;
162 d = xx13 - x13/x12*xx12;
163 a = n/d;
164 b = (y12 - a*xx12)/x12;
165 c = y1 - a*x1*x1 - b*x1;
166
167 xmax = -b/2/a;
168 ymax = a*xmax*xmax+b*xmax+c;
169}
static Double_t a
double xmax
Definition listroot.cxx:61
double ymax
Definition listroot.cxx:64

◆ GetShapeSampleLimits()

void LArShapePeakRecoTool::GetShapeSampleLimits ( int & s1,
int & s2,
float sample_max,
float delay_max,
int nbin,
int nsample ) const

Definition at line 172 of file LArShapePeakRecoTool.cxx.

174{
175 s1=0; s2=nsample-1;
176
177 s1 = (int) (sample_max - (delay_max - 5.)/25.) +1;
178 if(s1<0) s1=0;
179 s2 = (int) (sample_max + (nbin - delay_max - 5.)/25.);
180 if(s2>=nsample) s2=nsample-1;
181
182 while(s2-s1>=3) {
183 if(s2-sample_max>sample_max-s1) s2--;
184 else s1++;
185 }
186
187}

◆ initialize()

StatusCode LArShapePeakRecoTool::initialize ( )
virtual

Definition at line 23 of file LArShapePeakRecoTool.cxx.

24{
25 return StatusCode::SUCCESS;
26}

◆ 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()

const InterfaceID & LArShapePeakRecoTool::interfaceID ( )
inlinestatic

Definition at line 26 of file LArShapePeakRecoTool.h.

static const InterfaceID IID_LArShapePeakRecoTool("LArShapePeakRecoTool", 1, 0)

◆ msg()

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ 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.

◆ ParabolaRawToTrueADC()

float LArShapePeakRecoTool::ParabolaRawToTrueADC ( float & QT_true_time,
float & ADCref,
float & PEDref,
int & layer ) const

◆ ParabolaRawToTrueTime()

float LArShapePeakRecoTool::ParabolaRawToTrueTime ( float & QT_fittime,
int & layer ) const

◆ peak()

std::vector< float > LArShapePeakRecoTool::peak ( const std::vector< float > & samples,
const std::vector< double > & wave ) const

Definition at line 32 of file LArShapePeakRecoTool.cxx.

33{
34 std::vector<float> solution;
35
36 float shape_max,delay_max;
37 float sample_max,adc_max;
38 int i,s,s1,s2,d,d1,d2;
39 double chi2,chi2_best,yi2,yigi,gi2,lambda=0;
40 int nbin;
41
42 nbin = wave.size();
43
44 // find maximum of delay profile
45 const std::vector<double>::const_iterator wave_max=max_element(wave.begin(),wave.end());
46 if (wave_max==wave.end())
47 {ATH_MSG_ERROR( "Maximum of Delay Profile not found!" );
48 return solution;
49 }
50 shape_max = *wave_max;
51
52 delay_max = distance(wave.begin(),wave_max);
53
54 // parabola approximation of shape maximum
55 d = (int) delay_max;
56 GetShapeParMax(delay_max,shape_max,delay_max-1,wave[d-1],
57 delay_max,wave[d], delay_max+1,wave[d+1]);
58
59 // find maximum of ADC samples
60
61 const std::vector<float>::const_iterator it_max=max_element(samples.begin(),samples.end());
62 if (it_max==samples.end())
63 {ATH_MSG_ERROR( "Maximum ADC sample not found!" );
64 return solution;
65 }
66 adc_max = *it_max;
67 sample_max = distance(samples.begin(),it_max);
68
69 // Get sample limits
70 // GetShapeSampleLimits(s1,s2,sample_max,delay_max,nbin,samples.size());
71
72 // find 2nd maximum of ADC samples
73 std::vector<float>::const_iterator it_sample = samples.begin();
74 std::vector<float>::const_iterator it_sample_end = samples.end();
75
76 float adc_2ndmax = 0;
77 int sample_2ndmax = static_cast<int> (sample_max);
78 for (;it_sample!=it_sample_end;++it_sample) { //Loop over sample vector
79 if((*it_sample>adc_2ndmax) && (*it_sample<=adc_max)) {
80 adc_2ndmax = *it_sample;
81 sample_2ndmax = distance(samples.begin(),it_sample);
82 }
83 }
84
85 // determine s1 and s2
86 if(std::abs(sample_max-sample_2ndmax)>1) std::cout << "maxima are far away ? index(max) = " << sample_max << ", index(2nd max) = " << sample_2ndmax << ", samples = " << samples[0] << ", " << samples[1] << ", " << samples[2] << ", " << samples[3] << ", " << samples[4] << ", " << samples[5] << ", " << std::endl;
87
88 if(sample_max-sample_2ndmax > 0) {
89 s1 = sample_2ndmax - 1;
90 s2 = static_cast<int> (sample_max + 1);
91 }else{
92 s1 = static_cast<int> (sample_max - 1);
93 s2 = sample_2ndmax + 1;
94 }
95
96 // Get delay Limits
97 d1 = 0;
98 d2 = nbin-1-(s2-s1)*24;
99
100 // Loop on all delays to find the best chi2
101 // i.e. minimise
102 // chi2 = yi2-yigi*lambda = yi2-yigi*yigi/gi2
103 // where yi : samples in ADC counts
104 // gi : normalised pulse shape
105 // maximum is then given by the lagrange factor
106 // lambda = yigi/gi2 in ADC counts
107
108 chi2_best=1e30;
109 int delay_best=-999;
110
111 for(d=d1;d<=d2;d++)
112 {
113 yi2=0; gi2=0; yigi=0;
114
115 for(s=s1;s<=s2;s++) {
116 i = (s-s1)*24+d;
117 yi2+=samples[s]*samples[s];
118 gi2+=wave[i]*wave[i];
119 yigi+=wave[i]*samples[s];
120 }
121
122 if(gi2<=0) chi2=chi2_best;
123 else chi2=yi2-yigi*yigi/gi2;
124
125 if(chi2<chi2_best)
126 {
127 chi2_best=chi2;
128 delay_best=d;
129 lambda=yigi/gi2;
130 }
131 }
132
133 if(delay_best<=-999) { return solution; }
134
135 float adc_reco = lambda*shape_max;
136
137 float time_reco = delay_best;
138 if(delay_best<adc_max) time_reco = delay_best;
139
140 solution.push_back(adc_reco);
141 solution.push_back(time_reco);
142
143 return solution;
144}
#define ATH_MSG_ERROR(x)
void GetShapeParMax(float &xmax, float &ymax, float x1, float y1, float x2, float y2, float x3, float y3) const
double chi2(TH1 *h0, TH1 *h1)
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space

◆ 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();
384 }
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)

◆ 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 {
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 asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ 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) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ 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_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: