ATLAS Offline Software
CBNTAA_TBTDCRaw.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "CBNTAA_TBTDCRaw.h"
6 #include "TBEvent/TBTDCRawCont.h"
7 #include <vector>
8 
9 CBNTAA_TBTDCRaw::CBNTAA_TBTDCRaw(const std::string & name, ISvcLocator * pSvcLocator) : CBNT_TBRecBase(name, pSvcLocator)
10 {
11  declareProperty("NeverReturnFailure", m_neverReturnFailure=false);
12  declareProperty("ContainerKey1",m_containerKey1="TDCRawCont");
13  m_tdc=NULL;
14  m_underThreshold=NULL;
15 }
16 
18 {//Clean up arrays of ntuple entries (if they have been booked)
19  if (m_tdc)
20  delete m_tdc;
21  if (m_underThreshold)
22  delete m_underThreshold;
23 }
24 
26 {
27  ATH_MSG_DEBUG ( "in initialize()" );
28 
29  addBranch("TBTDCRaw",m_tdc);
30  addBranch("TBTDCRaw_underThreshold",m_underThreshold);
31 
32  return StatusCode::SUCCESS;
33 
34 }
35 
37 {
38  const TBTDCRawCont * tdcCont;
39  StatusCode sc = evtStore()->retrieve(tdcCont,m_containerKey1);
40  if (sc.isFailure())
41  {
42  ATH_MSG_ERROR ( "\033[31m" << " Cannot read TBTDCRawCont from StoreGate! key= " << m_containerKey1 << "\033[0m" );
44  return StatusCode::SUCCESS;
45  } else {
46  return StatusCode::FAILURE;
47  }
48  }
49  else
50  {
51  ATH_MSG_DEBUG ( "\033[31m" << "Going over TBTDCRawCont channels ..."<< "\033[0m" );
52 
53  const unsigned nTDC = (TBTDCRawCont::size_type)tdcCont->size();
54  m_tdc->resize(nTDC);
55  m_underThreshold->resize(nTDC);
56 
57  unsigned NtupleVectorIndex = 0;
58  for (const TBTDCRaw* tdc : *tdcCont) {
59  (*m_tdc)[NtupleVectorIndex] = tdc->getTDC();
60  (*m_underThreshold)[NtupleVectorIndex] = tdc->isUnderThreshold();
61  }
62  }
63 
64  return StatusCode::SUCCESS;
65 }
66 
68 {
69  if (m_tdc)
70  m_tdc->clear();
71  if (m_underThreshold)
72  m_underThreshold->clear();
73 
74  return StatusCode::SUCCESS;
75 }
76 
78 {
79  ATH_MSG_DEBUG ( "in finalize()" );
80  return StatusCode::SUCCESS;
81 }
82 
83 std::string CBNTAA_TBTDCRaw::add_name(const char* base, const std::string& extension) {
84  std::string retval(base);
85  for (unsigned i=0;i<extension.size();i++) {
86  const char& ch=extension[i];
87  if (ch=='=' || ch==':' || ch=='/')
88  continue; //Inore these characters
89  else if (ch=='-')
90  retval.append("m");//replace by letter m
91  else if (ch=='+')
92  retval.append("p");//replace by letter p
93  else
94  retval.append(1,ch);
95  }
96  return retval;
97 }
base
std::string base
Definition: hcg.cxx:78
TBTDCRaw
Definition: TBTDCRaw.h:21
CBNTAA_TBTDCRaw::m_containerKey1
std::string m_containerKey1
Definition: CBNTAA_TBTDCRaw.h:39
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
CBNTAA_TBTDCRaw::CBNT_finalize
virtual StatusCode CBNT_finalize() override
Definition: CBNTAA_TBTDCRaw.cxx:77
CBNTAA_TBTDCRaw::~CBNTAA_TBTDCRaw
virtual ~CBNTAA_TBTDCRaw()
Definition: CBNTAA_TBTDCRaw.cxx:17
CBNTAA_TBTDCRaw::CBNT_initialize
virtual StatusCode CBNT_initialize() override
Definition: CBNTAA_TBTDCRaw.cxx:25
CBNTAA_TBTDCRaw::CBNT_clear
virtual StatusCode CBNT_clear() override
Definition: CBNTAA_TBTDCRaw.cxx:67
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
CBNTAA_TBTDCRaw::CBNTAA_TBTDCRaw
CBNTAA_TBTDCRaw(const std::string &name, ISvcLocator *pSvcLocator)
Definition: CBNTAA_TBTDCRaw.cxx:9
LArCellBinning_test.retval
def retval
Definition: LArCellBinning_test.py:112
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
TBTDCRawCont.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
CBNT_TBRecBase
Definition: CBNT_TBRecBase.h:21
lumiFormat.i
int i
Definition: lumiFormat.py:92
CBNTAA_TBTDCRaw::CBNT_execute
virtual StatusCode CBNT_execute() override
Definition: CBNTAA_TBTDCRaw.cxx:36
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
CBNT_TBRecBase::addBranch
void addBranch(const std::string &branchname, T &obj, const std::string &leaflist)
Definition: CBNT_TBRecBase.h:44
TBTDCRawCont
Definition: TBTDCRawCont.h:21
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
CBNTAA_TBTDCRaw.h
CBNTAA_TBTDCRaw::m_underThreshold
std::vector< bool > * m_underThreshold
Definition: CBNTAA_TBTDCRaw.h:38
CBNTAA_TBTDCRaw::add_name
std::string add_name(const char *base, const std::string &extension)
Definition: CBNTAA_TBTDCRaw.cxx:83
CBNTAA_TBTDCRaw::m_neverReturnFailure
bool m_neverReturnFailure
Definition: CBNTAA_TBTDCRaw.h:35
DataVector< TBTDCRaw >::size_type
BASE::size_type size_type
Definition: DataVector.h:813
CBNTAA_TBTDCRaw::m_tdc
std::vector< unsigned int > * m_tdc
Definition: CBNTAA_TBTDCRaw.h:37
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.