133 const EventContext& ctx = Gaudi::Hive::currentContext();
136 unsigned int thisrun=ctx.eventID().run_number();
142 setFilterPassed(
false);
143 return StatusCode::SUCCESS;
148 StatusCode
sc =
evtStore()->retrieve(tdcRawCont,
"TDCRawCont");
149 if (
sc.isFailure()) {
150 ATH_MSG_ERROR (
"TBObjectReco: Retrieval of TDCRawCont failed" );
152 setFilterPassed(
false);
154 return StatusCode::SUCCESS;
157 std::vector<float> tdcQuality;
158 std::vector<float> tdcdTtoWAC;
159 tdcQuality.resize(
m_nTDC);
160 tdcdTtoWAC.resize(
m_nTDC);
161 for (
int k = 0; k <
m_nTDC; k++) {
170 int tdcFoundAndOK = 0;
171 for (
const TBTDCRaw* tdcRaw : *tdcRawCont) {
172 std::string tdcName = tdcRaw->getDetectorName();
174 for (; tdcIndex <
m_nTDC; tdcIndex++) {
181 m_tdcRaw[tdcIndex] = tdcRaw->getTDC();
183 if (
m_tdcRaw[tdcIndex] <= 0 || tdcRaw->isOverflow() || tdcRaw->isUnderThreshold()) {
187 if (tdcRaw->isOverflow())
189 if (tdcRaw->isUnderThreshold())
190 ATH_MSG_DEBUG (
"Bad TDC" << tdcIndex <<
" is underthreshold" );
200 float dTotdcMax = fabs(
m_tdcRaw[tdcIndex] - tdcMax);
202 float dtemp = (dTotdcMin < dTotdcMax) ? dTotdcMin : dTotdcMax;
203 tdcQuality[tdcIndex] = (dtemp < dTotdcwac) ? dtemp : dTotdcwac;
207 (
"TDC" << tdcIndex <<
" value = " <<
m_tdcRaw[tdcIndex]
209 <<
": to tdcMin = " << dTotdcMin
210 <<
"; to tdcMax = " << dTotdcMax
211 <<
"; to tdcwac = " << dTotdcwac
212 <<
"; final = " << tdcQuality[tdcIndex] );
218 (
"TDC" << tdcIndex <<
" value = " <<
m_tdcRaw[tdcIndex]
219 <<
"; reconstructed phase = " <<
m_phaseReco[tdcIndex]/ns <<
" ns"
223 if (tdcFound ==
m_nTDC) break ;
227 if (tdcFound == 0 || tdcFoundAndOK == 0) {
231 StatusCode checkOut =
evtStore()->retrieve(theEventInfo,
"TBEventInfo");
232 if ( checkOut.isFailure() )
234 ATH_MSG_ERROR (
"cannot retrieve TBEventInfo from StoreGate" );
235 setFilterPassed(
false);
236 return StatusCode::SUCCESS;
247 float tdc_to_wac = 100.;
250 if (
sc.isFailure( )) {
252 setFilterPassed(
false);
253 return StatusCode::SUCCESS;
255 return StatusCode::SUCCESS;
263 setFilterPassed(
false);
265 return StatusCode::SUCCESS;
269 ATH_MSG_WARNING (
"not all the requested TDCs were found in StoreGate" );
276 int tdcBestIndex = 0;
278 for (
int k = 0; k <
m_nTDC; k++) {
279 if (tdcQuality[k] > QMax) {
280 QMax = tdcQuality[k];
287 (
"best quality for TDC" << tdcBestIndex
288 <<
", with reconstructed phase = " << bestPhase/ns <<
" ns" );
292 int timeSampleShift = (int)floor(bestPhase/
m_delta);
293 if (timeSampleShift != 0) {
295 (
"TBPhaseRec time sample shift non zero: " << timeSampleShift );
299 float phase = bestPhase - timeSampleShift*
m_delta;
303 if (phaseInd < 0 || phaseInd >
m_timeBins - 1) {
305 (
"Phase " << phase/ns <<
" ns "
306 <<
"has phase index " << phaseInd
307 <<
" outside of the bounds [0," <<
m_timeBins-1 <<
"]" );
309 setFilterPassed(
false);
311 return StatusCode::SUCCESS;
317 (
"Phase " << phase/ns <<
" ns "
318 <<
"has TDC-WAC " << tdcdTtoWAC[tdcBestIndex]
319 <<
" inside the guard region [0," <<
m_guardValue <<
"]" );
321 setFilterPassed(
false);
323 return StatusCode::SUCCESS;
327 (
"Phase = " << phase/ns <<
" ns; "
328 <<
"phase index = " << phaseInd );
332 TBPhase* theTBPhase =
new TBPhase(phase, phaseInd, tdcdTtoWAC[tdcBestIndex] );
335 if (
sc.isFailure( )) {
337 setFilterPassed(
false);
338 return StatusCode::SUCCESS;
341 return StatusCode::SUCCESS;