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

reconstruction of a suitable event phase More...

#include <TBPhaseRec.h>

Inheritance diagram for TBPhaseRec:
Collaboration diagram for TBPhaseRec:

Public Member Functions

 TBPhaseRec (const std::string &name, ISvcLocator *pSvcLocator)
 
virtual ~TBPhaseRec ()
 
virtual StatusCode initialize () override
 
virtual StatusCode execute () override
 
virtual StatusCode finalize () override
 
StatusCode getnewcalib ()
 
virtual StatusCode sysInitialize () override
 Override sysInitialize. More...
 
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies. More...
 
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 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 Attributes

static const int unknown = -99999
 

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

float computePhase (int tdcIndex)
 
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

std::vector< std::string > m_tdcNames
 
std::vector< float > m_tdcToTime
 
std::vector< float > m_tdcwac
 
std::vector< float > m_tdcMin
 
float m_delta
 
int m_timeBins
 
std::string m_TBPhaseKey
 
bool m_neverReturnFailure
 
std::string m_calib_filename
 
unsigned int m_runnumber
 
float m_guardValue
 
int m_nTDC
 
std::vector< int > m_tdcRaw
 
std::vector< float > m_phaseReco
 
DataObjIDColl m_extendedExtraObjects
 
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

reconstruction of a suitable event phase

Author
Michel Lefebvre lefeb.nosp@m.vre@.nosp@m.uvic..nosp@m.ca
Date
August 13, 2004

June 30, 2004 - implementation based on a first draft from Marco Delmastro

Definition at line 21 of file TBPhaseRec.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ TBPhaseRec()

TBPhaseRec::TBPhaseRec ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 24 of file TBPhaseRec.cxx.

25  :
26  AthAlgorithm(name,pSvcLocator)
27  , m_delta(25.0*ns)
28  , m_timeBins(25)
29  , m_TBPhaseKey("TBPhase")
30  , m_neverReturnFailure(false)
31  , m_guardValue(-1.) // in TDC counts
32  , m_nTDC(0)
33  {
34  // job options
35  declareProperty("CalibFileName",m_calib_filename="");
36  m_tdcNames.resize(0);
37  m_tdcToTime.resize(0);
38  m_tdcwac.resize(0);
39  m_tdcMin.resize(0);
40  declareProperty("TDCNames", m_tdcNames);
41  declareProperty("TDCToTime", m_tdcToTime);
42  declareProperty("TDCwac", m_tdcwac);
43  declareProperty("TDCMin", m_tdcMin);
44  declareProperty("TTCClockPeriod", m_delta);
45  declareProperty("TimeBins", m_timeBins);
46  declareProperty("TBPhaseKey", m_TBPhaseKey);
47  declareProperty("NeverReturnFailure", m_neverReturnFailure);
48  declareProperty("GuardCutValue", m_guardValue);
49  m_runnumber = 0;
50 }

◆ ~TBPhaseRec()

TBPhaseRec::~TBPhaseRec ( )
virtual

Definition at line 52 of file TBPhaseRec.cxx.

53 { }

Member Function Documentation

◆ computePhase()

float TBPhaseRec::computePhase ( int  tdcIndex)
private

Definition at line 349 of file TBPhaseRec.cxx.

349  {
350 
351  float phaseReco = m_tdcToTime[tdcIndex] * ((float)m_tdcRaw[tdcIndex] - m_tdcwac[tdcIndex]);
352  if (m_tdcToTime[tdcIndex] > 0.) {
353  if ((float)m_tdcRaw[tdcIndex] < m_tdcwac[tdcIndex]) phaseReco += m_delta;
354  } else {
355  if ((float)m_tdcRaw[tdcIndex] > m_tdcwac[tdcIndex]) phaseReco += m_delta;
356  }
357 
358  return phaseReco ;
359 }

◆ declareGaudiProperty() [1/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< Algorithm > >::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< Algorithm > >::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< Algorithm > >::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< Algorithm > >::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< Algorithm > >::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< Algorithm > >::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< Algorithm > >::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< Algorithm > >::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< Algorithm > >::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< Algorithm > >::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< Algorithm > >::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< Algorithm > >::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< Algorithm > >::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; }

◆ execute()

StatusCode TBPhaseRec::execute ( )
overridevirtual

Definition at line 130 of file TBPhaseRec.cxx.

131 {
132  ATH_MSG_VERBOSE ( "In execute()" );
133  const EventContext& ctx = Gaudi::Hive::currentContext();
134 
135  // Get run number...
136  unsigned int thisrun=ctx.eventID().run_number();
137 
138  // ... and get new calib constants (only if calibration constant file has been specified!)
139  if( thisrun != m_runnumber && m_calib_filename != "" ) {
140  m_runnumber= thisrun;
141  if ( getnewcalib() == StatusCode::FAILURE ) {
142  setFilterPassed(false);
143  return StatusCode::SUCCESS;
144  }
145  }
146 
147  TBTDCRawCont * tdcRawCont;
148  StatusCode sc = evtStore()->retrieve(tdcRawCont, "TDCRawCont");
149  if (sc.isFailure()) {
150  ATH_MSG_ERROR ( "TBObjectReco: Retrieval of TDCRawCont failed" );
151  if (!m_neverReturnFailure) {
152  setFilterPassed(false);
153  }
154  return StatusCode::SUCCESS;
155  }
156 
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++) {
162  m_phaseReco[k] = unknown;
163  m_tdcRaw[k] = 0;
164  tdcQuality[k] = 0.;
165  tdcdTtoWAC[k] = 0.;
166  }
167 
168  // Loop over TDC's
169  int tdcFound = 0;
170  int tdcFoundAndOK = 0;
171  for (const TBTDCRaw* tdcRaw : *tdcRawCont) {
172  std::string tdcName = tdcRaw->getDetectorName();
173  int tdcIndex = 0;
174  for (; tdcIndex < m_nTDC; tdcIndex++) {
175  if (tdcName == m_tdcNames[tdcIndex]) break;
176  }
177  if (tdcIndex < m_nTDC) { // found the sought tdc
178  tdcFound++;
179 
180  // get the raw tdc value
181  m_tdcRaw[tdcIndex] = tdcRaw->getTDC();
182 
183  if (m_tdcRaw[tdcIndex] <= 0 || tdcRaw->isOverflow() || tdcRaw->isUnderThreshold()) {
184  // bad tdc
185  if (m_tdcRaw[tdcIndex] <= 0)
186  ATH_MSG_DEBUG ( "Bad TDC" << tdcIndex << "; value = " << m_tdcRaw[tdcIndex] );
187  if (tdcRaw->isOverflow())
188  ATH_MSG_DEBUG ( "Bad TDC" << tdcIndex << " is overflow" );
189  if (tdcRaw->isUnderThreshold())
190  ATH_MSG_DEBUG ( "Bad TDC" << tdcIndex << " is underthreshold" );
191  } else {
192  // found andvalid tdc
193  tdcFoundAndOK++;
194 
195  // compute a quality factor used to decide which tdc to use for the phase
196  // lowest distance (tdc units) to tdcMin or tdcMax or tdcwac
197 
198  float dTotdcMin = fabs(m_tdcRaw[tdcIndex] - m_tdcMin[tdcIndex]);
199  float tdcMax = m_tdcMin[tdcIndex] + m_delta/fabs(m_tdcToTime[tdcIndex]);
200  float dTotdcMax = fabs(m_tdcRaw[tdcIndex] - tdcMax);
201  float dTotdcwac = fabs(m_tdcRaw[tdcIndex] - m_tdcwac[tdcIndex]);
202  float dtemp = (dTotdcMin < dTotdcMax) ? dTotdcMin : dTotdcMax;
203  tdcQuality[tdcIndex] = (dtemp < dTotdcwac) ? dtemp : dTotdcwac;
204  tdcdTtoWAC[tdcIndex] = m_tdcRaw[tdcIndex] - m_tdcwac[tdcIndex];
205 
207  ( "TDC" << tdcIndex << " value = " << m_tdcRaw[tdcIndex]
208  << "; tdc quality"
209  << ": to tdcMin = " << dTotdcMin
210  << "; to tdcMax = " << dTotdcMax
211  << "; to tdcwac = " << dTotdcwac
212  << "; final = " << tdcQuality[tdcIndex] );
213 
214  // compute the phase
215  m_phaseReco[tdcIndex] = computePhase(tdcIndex);
216 
218  ( "TDC" << tdcIndex << " value = " << m_tdcRaw[tdcIndex]
219  << "; reconstructed phase = " << m_phaseReco[tdcIndex]/ns << " ns"
220  );
221  }
222 
223  if (tdcFound == m_nTDC) break ; // exit container loop if all TDCs found
224  }
225  }
226 
227  if (tdcFound == 0 || tdcFoundAndOK == 0) {
228  // Check if this is a random trigger and set tdc=12.5 ns
229  // retrieve Event Info
230  const TBEventInfo* theEventInfo;
231  StatusCode checkOut = evtStore()->retrieve(theEventInfo,"TBEventInfo");
232  if ( checkOut.isFailure() )
233  {
234  ATH_MSG_ERROR ( "cannot retrieve TBEventInfo from StoreGate" );
235  setFilterPassed(false);
236  return StatusCode::SUCCESS;
237  }
238  else
239  {
240  ATH_MSG_DEBUG ( "TBEventInfo object found in TDS" );
241  }
242  int evtType = theEventInfo->getEventType();
243  ATH_MSG_DEBUG ( "Event Type found " << evtType );
244  if (evtType != 1) { // Not a physics trigger found
245  float phase = 12.5;
246  short phaseInd = (short)floor(phase/m_delta * (float)m_timeBins);
247  float tdc_to_wac = 100.;
248  TBPhase* theTBPhase = new TBPhase(phase, phaseInd, tdc_to_wac);
249  sc = evtStore()->record(theTBPhase, m_TBPhaseKey);
250  if (sc.isFailure( )) {
251  ATH_MSG_FATAL ( "Cannot record TBPhase" );
252  setFilterPassed(false); // always return failure for this one!
253  return StatusCode::SUCCESS;
254  }
255  return StatusCode::SUCCESS;
256  }
257  if (tdcFound == 0) {
258  ATH_MSG_ERROR ( "no TDCs found in StoreGate" );
259  } else {
260  ATH_MSG_ERROR ( "no valid TDC data found" );
261  }
262  if (!m_neverReturnFailure) {
263  setFilterPassed(false);
264  }
265  return StatusCode::SUCCESS;
266  }
267  if (tdcFound < m_nTDC || tdcFoundAndOK < m_nTDC) {
268  if (tdcFound < m_nTDC) {
269  ATH_MSG_WARNING ( "not all the requested TDCs were found in StoreGate" );
270  } else {
271  ATH_MSG_WARNING ( "not all the requested TDCs contained valid data" );
272  }
273  }
274 
275  // choose/compute best phase, compute corresponding best phaseind, create TBPhase instance
276  int tdcBestIndex = 0;
277  float QMax = 0.;
278  for (int k = 0; k < m_nTDC; k++) {
279  if (tdcQuality[k] > QMax) {
280  QMax = tdcQuality[k];
281  tdcBestIndex = k;
282  }
283  }
284  float bestPhase = m_phaseReco[tdcBestIndex];
285 
287  ( "best quality for TDC" << tdcBestIndex
288  << ", with reconstructed phase = " << bestPhase/ns << " ns" );
289 
290  // If the tdc is working properly and if the TBPhaseRec jobOptions correctly calibrate the tdc,
291  // then this timeSampleShift should be zero always.
292  int timeSampleShift = (int)floor(bestPhase/m_delta);
293  if (timeSampleShift != 0) {
295  ( "TBPhaseRec time sample shift non zero: " << timeSampleShift );
296  }
297 
298  // the phase is between 0 and the ttcClockPeriod
299  float phase = bestPhase - timeSampleShift*m_delta; // "wrapped around" phase in case of shift
300 
301  // the phase index must be between 0 and m_timeBins-1
302  short phaseInd = (short)floor(phase/m_delta * (float)m_timeBins);
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 << "]" );
308  if (!m_neverReturnFailure) {
309  setFilterPassed(false);
310  }
311  return StatusCode::SUCCESS;
312  }
313 
314  // guard region cut
315  if ( m_guardValue > 0. && fabs(tdcdTtoWAC[tdcBestIndex]) < m_guardValue ) {
317  ( "Phase " << phase/ns << " ns "
318  << "has TDC-WAC " << tdcdTtoWAC[tdcBestIndex]
319  << " inside the guard region [0," << m_guardValue << "]" );
320  if (!m_neverReturnFailure) {
321  setFilterPassed(false);
322  }
323  return StatusCode::SUCCESS;
324  }
325 
327  ( "Phase = " << phase/ns << " ns; "
328  << "phase index = " << phaseInd );
329 
330  // create and store the TBPhase
331  // TBPhase* theTBPhase = new TBPhase(phase, phaseInd);
332  TBPhase* theTBPhase = new TBPhase(phase, phaseInd, tdcdTtoWAC[tdcBestIndex] );
333 
334  sc = evtStore()->record(theTBPhase, m_TBPhaseKey);
335  if (sc.isFailure( )) {
336  ATH_MSG_FATAL ( "Cannot record TBPhase" );
337  setFilterPassed(false); // always return failure for this one!
338  return StatusCode::SUCCESS;
339  }
340 
341  return StatusCode::SUCCESS;
342 
343 }

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::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

◆ extraOutputDeps()

const DataObjIDColl & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 50 of file AthAlgorithm.cxx.

51 {
52  // If we didn't find any symlinks to add, just return the collection
53  // from the base class. Otherwise, return the extended collection.
54  if (!m_extendedExtraObjects.empty()) {
56  }
57  return Algorithm::extraOutputDeps();
58 }

◆ finalize()

StatusCode TBPhaseRec::finalize ( )
overridevirtual

Definition at line 345 of file TBPhaseRec.cxx.

345  {
346  return StatusCode::SUCCESS;
347 }

◆ getnewcalib()

StatusCode TBPhaseRec::getnewcalib ( )

Definition at line 363 of file TBPhaseRec.cxx.

363  {
364  //
365  // Get calib constant from an ASCII file with the following structure :
366  //
367  // runnumber
368  // tdcnumber TDCToTime TDCwac TDCMin
369  // ...
370 
371  ATH_MSG_INFO ( "Get TDC calibration constants for run " << m_runnumber);
372 
373  int tdcnumber= m_tdcNames.size();
374 
375  m_tdcToTime.clear(); m_tdcToTime.resize(tdcnumber);
376  m_tdcwac.clear(); m_tdcwac.resize(tdcnumber);
377  m_tdcMin.clear(); m_tdcMin.resize(tdcnumber);
378 
379  // find file in share directory
381 
382  std::ifstream calibfile;
383  calibfile.open(m_calib_filename.c_str());
384  if (!calibfile.good()) {
385  ATH_MSG_INFO ( "Problem with calibration file "<< m_calib_filename );
386  return StatusCode::FAILURE;
387  }
388 
389  int pos = -1 ;
390  int runnumber = 0, prevrunnumber = 0;
391 
392  /*
393 
394  Parsing of TDC calibration constants file
395 
396  Loop is exited when a run number bigger then the current is found: calibration constants of
397  previous available run will be used, last step is used only to define interval of validity
398  (TDC calibration constant obtained from a run are considered valid _from_ that run (included)
399  since the next one used for TDC calibration)
400 
401  If the calibration constants file has only one line, or provide calibration constants for run
402  numbers smaller than the current one, or a empty line is found, the last read TDC calibration
403  constants are used but a warning message is issued.
404 
405  */
406 
407  while ( !calibfile.eof() ) {
408  prevrunnumber = runnumber ;
409  runnumber = -1 ;
410  calibfile >> runnumber;
411  if ( runnumber==-1 ) { // reached an empty line
412  ATH_MSG_WARNING ( "Empty line found in " << m_calib_filename );
413  calibfile.clear();
414  runnumber = prevrunnumber ;
415  break ;
416  }
417  if ( runnumber > int(m_runnumber) ) break ;
418  pos = calibfile.tellg();
419  for(int j=0; j<tdcnumber+1; j++) calibfile.ignore(5000,'\n'); // discard next lines
420  }
421 
422  // this take care of the case in which only one line is present in the file,
423  // and the corresponding run number is greater than the current one
424  if ( pos == -1 ) {
425  pos = calibfile.tellg();
426  prevrunnumber = runnumber ;
427  }
428  // Now we should have found a good set of constant (the ones following pos)
429  ATH_MSG_DEBUG ( "Position in file stream = "<< pos );
430  calibfile.seekg(pos);
431 
432  ATH_MSG_INFO ( "TDC calibration constants obtained from run " << prevrunnumber );
433  if ( prevrunnumber != runnumber ) {
434  ATH_MSG_INFO ( "valid for run interval " << prevrunnumber << " - " << runnumber );
435  } else {
436  ATH_MSG_WARNING ( "TDC calibration constants could not be optimal... ");
437  }
438 
439  for(int j=0;j<tdcnumber;j++) {
440  int tdcn;
441  calibfile >> tdcn;
442  calibfile >> m_tdcToTime[j];
443  calibfile >> m_tdcwac[j];
444  calibfile >> m_tdcMin[j];
445  ATH_MSG_INFO ( " * TDC n. " << tdcn );
446  ATH_MSG_INFO ( " - TDCToTime = " << m_tdcToTime[j] );
447  ATH_MSG_INFO ( " - TDCwac = " << m_tdcwac[j] );
448  ATH_MSG_INFO ( " - TDCMin = " << m_tdcMin[j] );
449  }
450 
451  calibfile.close();
452 
453  return StatusCode::SUCCESS;
454 
455 }

◆ initialize()

StatusCode TBPhaseRec::initialize ( )
overridevirtual

Definition at line 56 of file TBPhaseRec.cxx.

57 {
58  // check consistency of jobOptions, set defaults if required
59  float default_tdc2time = 0.050*ns;
60  float default_tdcwac = 0.;
61  float default_tdcMin = 0.;
62 
63  m_nTDC = m_tdcNames.size() ;
64  if ( m_nTDC == 0 ) {
65  ATH_MSG_ERROR ( "Empty list of TDC names" );
66  return StatusCode::FAILURE ;
67  }
68 
69  if (m_nTDC != (int)m_tdcToTime.size()) { // check consistency of joboption vectors
70  if (m_tdcToTime.size() == 0) {
71  m_tdcToTime.resize(m_nTDC) ;
72  for (int k = 0; k < m_nTDC; k++) m_tdcToTime[k] = default_tdc2time;
73  } else if (m_tdcToTime.size() == 1) {
74  m_tdcToTime.resize(m_nTDC);
75  float tdc2time = m_tdcToTime[0];
76  for (int k = 0; k < m_nTDC; k++) m_tdcToTime[k] = tdc2time;
77  } else {
78  ATH_MSG_FATAL ( "Nunber of TDCs not equal to nunber of tdc2time constants" );
79  return StatusCode::FAILURE ;
80  }
81  }
82 
83  if (m_nTDC != (int)m_tdcwac.size()) { // check consistency of joboption vectors
84  if (m_tdcwac.size() == 0) {
85  m_tdcwac.resize(m_nTDC) ;
86  for (int k = 0; k < m_nTDC; k++) m_tdcwac[k] = default_tdcwac;
87  } else if (m_tdcwac.size() == 1) {
88  m_tdcwac.resize(m_nTDC);
89  float tdcwac = m_tdcwac[0];
90  for (int k = 0; k < m_nTDC; k++) m_tdcwac[k] = tdcwac;
91  } else {
92  ATH_MSG_FATAL ( "Nunber of TDCs not equal to nuunber of wac constants" );
93  return StatusCode::FAILURE ;
94  }
95  }
96 
97  if (m_nTDC != (int)m_tdcMin.size()) { // check consistency of joboption vectors
98  if (m_tdcMin.size() == 0) {
99  m_tdcMin.resize(m_nTDC) ;
100  for (int k = 0; k < m_nTDC; k++) m_tdcMin[k] = default_tdcMin;
101  } else if (m_tdcMin.size() == 1) {
102  m_tdcMin.resize(m_nTDC);
103  float tdcMin = m_tdcMin[0];
104  for (int k = 0; k < m_nTDC; k++) m_tdcMin[k] = tdcMin;
105  } else {
106  ATH_MSG_FATAL ( "Nunber of TDCs not equal to nuunber of tdcMin constants" );
107  return StatusCode::FAILURE ;
108  }
109  }
110 
112  ( "TTCClockPeriod = " << m_delta/ns << " ns" );
113  for (int k = 0; k < m_nTDC; k++) {
115  ( "\042" + m_tdcNames[k] + "\042"
116  << " PhaseTDCToTime = " << m_tdcToTime[k]/ns << " ns/TDC"
117  << " PhaseTDCwac = " << m_tdcwac[k]
118  << " PhaseTDCMin = " << m_tdcMin[k] );
119  }
120 
121  m_phaseReco.resize(m_nTDC);
122  m_tdcRaw.resize(m_nTDC);
123 
124  if ( m_guardValue > 0. )
125  ATH_MSG_INFO ( " Cut events using guard value: " << m_guardValue );
126 
127  return StatusCode::SUCCESS ;
128 }

◆ inputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< Algorithm > >::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.

◆ msg() [1/2]

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ msg() [2/2]

MsgStream& AthCommonMsg< Algorithm >::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< Algorithm >::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< Algorithm > >::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.

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

StatusCode AthAlgorithm::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, PyAthena::Alg, and AthHistogramAlgorithm.

Definition at line 66 of file AthAlgorithm.cxx.

66  {
68 
69  if (sc.isFailure()) {
70  return sc;
71  }
72  ServiceHandle<ICondSvc> cs("CondSvc",name());
73  for (auto h : outputHandles()) {
74  if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
75  // do this inside the loop so we don't create the CondSvc until needed
76  if ( cs.retrieve().isFailure() ) {
77  ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
78  return StatusCode::SUCCESS;
79  }
80  if (cs->regHandle(this,*h).isFailure()) {
81  sc = StatusCode::FAILURE;
82  ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
83  << " with CondSvc");
84  }
85  }
86  }
87  return sc;
88 }

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Algorithm > >::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< Algorithm > >::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_calib_filename

std::string TBPhaseRec::m_calib_filename
private

Definition at line 48 of file TBPhaseRec.h.

◆ m_delta

float TBPhaseRec::m_delta
private

Definition at line 43 of file TBPhaseRec.h.

◆ m_detStore

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

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

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

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 79 of file AthAlgorithm.h.

◆ m_guardValue

float TBPhaseRec::m_guardValue
private

Definition at line 51 of file TBPhaseRec.h.

◆ m_neverReturnFailure

bool TBPhaseRec::m_neverReturnFailure
private

Definition at line 46 of file TBPhaseRec.h.

◆ m_nTDC

int TBPhaseRec::m_nTDC
private

Definition at line 57 of file TBPhaseRec.h.

◆ m_phaseReco

std::vector<float> TBPhaseRec::m_phaseReco
private

Definition at line 59 of file TBPhaseRec.h.

◆ m_runnumber

unsigned int TBPhaseRec::m_runnumber
private

Definition at line 49 of file TBPhaseRec.h.

◆ m_TBPhaseKey

std::string TBPhaseRec::m_TBPhaseKey
private

Definition at line 45 of file TBPhaseRec.h.

◆ m_tdcMin

std::vector<float> TBPhaseRec::m_tdcMin
private

Definition at line 42 of file TBPhaseRec.h.

◆ m_tdcNames

std::vector<std::string> TBPhaseRec::m_tdcNames
private

Definition at line 39 of file TBPhaseRec.h.

◆ m_tdcRaw

std::vector<int> TBPhaseRec::m_tdcRaw
private

Definition at line 58 of file TBPhaseRec.h.

◆ m_tdcToTime

std::vector<float> TBPhaseRec::m_tdcToTime
private

Definition at line 40 of file TBPhaseRec.h.

◆ m_tdcwac

std::vector<float> TBPhaseRec::m_tdcwac
private

Definition at line 41 of file TBPhaseRec.h.

◆ m_timeBins

int TBPhaseRec::m_timeBins
private

Definition at line 44 of file TBPhaseRec.h.

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.

◆ unknown

const int TBPhaseRec::unknown = -99999
static

Definition at line 33 of file TBPhaseRec.h.


The documentation for this class was generated from the following files:
TBTDCRaw
Definition: TBTDCRaw.h:21
ReadOfcFromCool.phase
phase
Definition: ReadOfcFromCool.py:127
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
TBPhaseRec::m_tdcMin
std::vector< float > m_tdcMin
Definition: TBPhaseRec.h:42
xAOD::short
short
Definition: Vertex_v1.cxx:165
TBPhaseRec::m_timeBins
int m_timeBins
Definition: TBPhaseRec.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
TBPhaseRec::m_delta
float m_delta
Definition: TBPhaseRec.h:43
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
Definition: PathResolver.cxx:251
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
TBPhaseRec::m_guardValue
float m_guardValue
Definition: TBPhaseRec.h:51
AthCommonDataStore< AthCommonMsg< Algorithm > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
AthCommonDataStore< AthCommonMsg< Algorithm > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
TBEventInfo::getEventType
int getEventType() const
Definition: TBEventInfo.h:66
TBPhaseRec::m_tdcRaw
std::vector< int > m_tdcRaw
Definition: TBPhaseRec.h:58
TBPhaseRec::getnewcalib
StatusCode getnewcalib()
Definition: TBPhaseRec.cxx:363
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
TBPhaseRec::m_tdcwac
std::vector< float > m_tdcwac
Definition: TBPhaseRec.h:41
TBPhaseRec::m_calib_filename
std::string m_calib_filename
Definition: TBPhaseRec.h:48
TBPhaseRec::m_TBPhaseKey
std::string m_TBPhaseKey
Definition: TBPhaseRec.h:45
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
TBPhaseRec::unknown
static const int unknown
Definition: TBPhaseRec.h:33
IDTPMcnv.htype
htype
Definition: IDTPMcnv.py:27
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
AthCommonDataStore
Definition: AthCommonDataStore.h:52
AthAlgorithm::sysInitialize
virtual StatusCode sysInitialize() override
Override sysInitialize.
Definition: AthAlgorithm.cxx:66
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
AthCommonDataStore< AthCommonMsg< Algorithm > >::outputHandles
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
Return this algorithm's output handles.
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
TBPhaseRec::m_runnumber
unsigned int m_runnumber
Definition: TBPhaseRec.h:49
TBPhaseRec::m_nTDC
int m_nTDC
Definition: TBPhaseRec.h:57
TBPhaseRec::m_neverReturnFailure
bool m_neverReturnFailure
Definition: TBPhaseRec.h:46
TBTDCRawCont
Definition: TBTDCRawCont.h:21
AthCommonDataStore< AthCommonMsg< Algorithm > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
DeMoScan.runnumber
runnumber
Definition: DeMoScan.py:266
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
TBPhaseRec::m_tdcNames
std::vector< std::string > m_tdcNames
Definition: TBPhaseRec.h:39
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
TBPhaseRec::m_tdcToTime
std::vector< float > m_tdcToTime
Definition: TBPhaseRec.h:40
TBPhaseRec::m_phaseReco
std::vector< float > m_phaseReco
Definition: TBPhaseRec.h:59
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
AthAlgorithm::m_extendedExtraObjects
DataObjIDColl m_extendedExtraObjects
Definition: AthAlgorithm.h:79
a
TList * a
Definition: liststreamerinfos.cxx:10
TBPhase
Definition: TBPhase.h:22
h
TBEventInfo
Definition: TBEventInfo.h:27
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
TBPhaseRec::computePhase
float computePhase(int tdcIndex)
Definition: TBPhaseRec.cxx:349
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:623
python.SystemOfUnits.ns
int ns
Definition: SystemOfUnits.py:130
AthAlgorithm::AthAlgorithm
AthAlgorithm()
Default constructor:
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
LHEF::Writer
Pythia8::Writer Writer
Definition: Prophecy4fMerger.cxx:12
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
readCCLHist.float
float
Definition: readCCLHist.py:83
fitman.k
k
Definition: fitman.py:528
ServiceHandle< ICondSvc >