66{
68
69
71 const ILArPedestal* larPedestal=nullptr;
73
74
75 ATH_MSG_DEBUG (
"Retrieving channel phases and amplituides " );
76 const ILArH6Oscillation* larH6Oscillations = nullptr;
78 unsigned int iHECChan(0);
79 std::vector<std::vector<short> > theSamples;
80 std::vector<float> thePedestals;
81 std::vector<double> theChannelAmplitudes;
82 std::vector<double> theChannelPhases;
83 std::vector<float> theRMSValues;
84
85
87
88 SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{
m_cablingKey};
89 const LArOnOffIdMapping*
cabling{*cablingHdl};
90 if(!cabling) {
92 return StatusCode::FAILURE;
93 }
94
95
96 for (
unsigned int i=0;
i<theDC.
size();
i++) {
97
98 const LArDigit *theDigit = theDC[
i];
99 const std::vector<short>& samples = theDigit->
samples();
100 const HWIdentifier chid = theDigit->
channelID();
102
103
104 const Identifier
id =
cabling->cnvToIdentifier(chid);
105 bool isHEC = false;
106
108 isHEC = true;
109 }
110
111 if ( isHEC) {
112 float DBpedestalRMS=larPedestal->
pedestalRMS(chid,gain);
114 ATH_MSG_DEBUG (
"No pedestal RMS found for this cell. Exiting ...." );
115 return StatusCode::FAILURE;
116 }
117 const double& DBchannelPhase=larH6Oscillations->
channelPhase(chid);
119
120 if( DBpedestalRMS > 0 && DBchannelAmplitude>0 ) {
121 theRMSValues.push_back(DBpedestalRMS);
122 theSamples.push_back(samples);
123 theChannelPhases.push_back(DBchannelPhase);
124 theChannelAmplitudes.push_back(DBchannelAmplitude);
125 float DBpedestal=larPedestal->
pedestal(chid,gain);
127 thePedestals.push_back(DBpedestal);
128 else {
129 ATH_MSG_DEBUG (
"No valid pedestal found for this cell. Exiting ...." );
130 return StatusCode::FAILURE;
131 }
132 iHECChan++;
133 }
134 }
135 }
136
138 double lchimin = -1;
139 int nTotSamples = 0;
140 for(
double myEventPhase = -
M_PI; myEventPhase<
M_PI; myEventPhase+=0.1) {
141 double lchitest = 0;
142 for (
unsigned int i=0;
i<iHECChan;
i++) {
143 unsigned int nSamples = theSamples[
i].size();
144 for(
unsigned int j=0;j<
nSamples;j++) {
145
146
147 if ( j == 0 || (std::abs(theSamples[i][j] - theSamples[i][0]) <=
m_nSigma*theRMSValues[i]
148 && ( j <= 0 || std::abs(theSamples[i][j-1] - theSamples[i][0]) <=
m_nSigma*theRMSValues[i])
149 && ( j >= nSamples-1 || std::abs(theSamples[i][j+1] - theSamples[i][0]) <=
m_nSigma*theRMSValues[i])) ) {
150
151 if ( lchimin < 0 )
152 nTotSamples ++;
153 lchitest +=
pow((theSamples[i][j] - thePedestals[i]
155 +theChannelPhases[i]+myEventPhase))
156 /theRMSValues[i],2);
157 }
158 }
159 }
160 if ( lchitest < lchimin || lchimin < 0 ) {
161 lchimin = lchitest;
163 }
164 }
165
166 ATH_MSG_DEBUG (
"Ending eventphase calculation. Phase = <" <<
m_eventPhase <<
">, Number of Channels used = <" << iHECChan <<
">, Average Number of Samples Used = <"
167 << (iHECChan > 0 ? (double)nTotSamples/iHECChan : 0)
168 << ">" );
169 return StatusCode::SUCCESS;
170}
#define ATH_CHECK
Evaluate an expression and check for errors.
constexpr int pow(int base, int exp) noexcept
size_type size() const noexcept
Returns the number of elements in the collection.
virtual const double & channelPhase(const HWIdentifier &id) const =0
virtual const double & channelAmplitude(const HWIdentifier &id) const =0
access to channel amplitude index by Identifier
virtual float pedestal(const HWIdentifier &id, int gain) const =0
virtual float pedestalRMS(const HWIdentifier &id, int gain) const =0
access to RMS of Pedestal index by Identifier, and gain setting
CaloGain::CaloGain gain() const
const std::vector< short > & samples() const
const HWIdentifier & channelID() const
retrieve(aClass, aKey=None)