ATLAS Offline Software
TileRawChannelToNtuple.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //*****************************************************************************
6 // Filename : TileRawChannelToNtuple.cxx
7 // Author : Zhifang
8 // Created : Nov, 2002
9 //
10 // DESCRIPTION:
11 // Implement the algorithm
12 //
13 // HISTORY:
14 //
15 // BUGS:
16 //
17 //*****************************************************************************
18 
19 //Gaudi Includes
21 #include "GaudiKernel/INTupleSvc.h"
22 #include "GaudiKernel/IDataProviderSvc.h"
23 #include "GaudiKernel/SmartDataPtr.h"
24 
25 //Atlas include
28 #include "StoreGate/ReadHandle.h"
29 
30 // Calo include
31 #include "CaloIdentifier/TileID.h"
32 
33 //TileCalo include
37 
38 const int max_chan=12288;
39 
40 
41 // Alg standard interface function
43 {
44 
45  ATH_MSG_INFO( "Initialization started" );
46 
47  // retrieve TileID helper from det store
48 
51 
52  m_ntupleLoc="/NTUPLES" + m_ntupleLoc;
53 
54  SmartDataPtr<NTuple::Directory> DirPtr(ntupleSvc(), m_ntupleLoc);
55  if(!DirPtr) DirPtr = ntupleSvc()->createDirectory(m_ntupleLoc);
56  if(!DirPtr) {
57  ATH_MSG_ERROR( "Invalid Ntuple Directory: " );
58  return StatusCode::FAILURE;
59  }
60  m_ntuplePtr=ntupleSvc()->book(DirPtr.ptr(), m_ntupleID,
61  CLID_ColumnWiseTuple, "TileRC-Ntuple");
62  if(!m_ntuplePtr) {
63 
64  std::string ntupleCompleteID=m_ntupleLoc+"/"+m_ntupleID;
65 
66  NTuplePtr nt(ntupleSvc(),ntupleCompleteID);
67  if (!nt) {
68  ATH_MSG_ERROR( "Failed to book or to retrieve ntuple "
69  << ntupleCompleteID );
70  return StatusCode::FAILURE;
71  } else {
72  ATH_MSG_INFO( "Reaccessing ntuple " << ntupleCompleteID );
73  m_ntuplePtr = nt;
74  }
75  }
76 
77  ATH_CHECK( m_ntuplePtr->addItem("TileRC/nchan",m_nchan,0,max_chan) );
78  ATH_CHECK( m_ntuplePtr->addItem("TileRC/totalE",m_tolE) );
79 
80  ATH_CHECK( m_ntuplePtr->addItem("TileRC/energy",m_nchan,m_energy) );
81  ATH_CHECK( m_ntuplePtr->addItem("TileRC/time",m_nchan,m_time) );
82  ATH_CHECK( m_ntuplePtr->addItem("TileRC/quality",m_nchan,m_quality) );
83 
84  ATH_CHECK( m_ntuplePtr->addItem("TileRC/detector",m_nchan,m_detector,0,3) );
85  ATH_CHECK( m_ntuplePtr->addItem("TileRC/side",m_nchan,m_side,-1,1) );
86  ATH_CHECK( m_ntuplePtr->addItem("TileRC/sample",m_nchan,m_sample,-1,3) );
87  ATH_CHECK( m_ntuplePtr->addItem("TileRC/eta",m_nchan,m_eta,-1,15) );
88  ATH_CHECK( m_ntuplePtr->addItem("TileRC/phi",m_nchan,m_phi,0,63) );
89  ATH_CHECK( m_ntuplePtr->addItem("TileRC/pmt",m_nchan,m_pmt,-1,1) );
90  ATH_CHECK( m_ntuplePtr->addItem("TileRC/channel",m_nchan,m_channel,0,47) );
91  ATH_CHECK( m_ntuplePtr->addItem("TileRC/gain",m_nchan,m_gain,0,2) );
92 
93  ATH_CHECK(m_cablingSvc.retrieve());
95 
96  ATH_MSG_INFO( "Initialization completed" );
97  return StatusCode::SUCCESS;
98 }
99 
101 {
102 
103  // step1: read RCs from TDS
105  ATH_CHECK( rawChannelContainer.isValid() );
106 
107  // step2: to fill items in ntuple
111  m_nchan=0;
112  m_tolE=0.0;
113  for(; it != end; ++it) {
114  m_tolE+=(*it)->amplitude();
115  m_energy[m_nchan]=(*it)->amplitude();
116  m_time[m_nchan]=(*it)->time();
117  m_quality[m_nchan]=(*it)->quality();
118 
119  HWIdentifier hwid=(*it)->adc_HWID();
120 
121  Identifier id=(*it)->adc_ID();
122  if (id.is_valid() ) {
123 
125  m_side[m_nchan]=m_tileID->side(id);
127  m_eta[m_nchan]=m_tileID->tower(id);
129  m_pmt[m_nchan]=m_tileID->pmt(id);
131  m_gain[m_nchan]=m_tileHWID->adc(hwid);
132 
133  } else {
134 
135  m_detector[m_nchan]=(m_tileHWID->ros(hwid)+1)/2;
136  m_side[m_nchan]=(m_tileHWID->ros(hwid)%2)*2-1;
137  m_sample[m_nchan]=-1;
138  m_eta[m_nchan]=-1;
139  m_phi[m_nchan]=m_tileHWID->drawer(hwid);
140  m_pmt[m_nchan]=-1;
142  m_gain[m_nchan]=m_tileHWID->adc(hwid);
143  }
144 
145  m_nchan++;
146 
147  if (m_nchan >= max_chan) break;
148  }
149 
150  // step3: commit ntuple
151  ATH_CHECK( ntupleSvc()->writeRecord(m_ntuplePtr) );
152 
153  // Execution completed.
154  ATH_MSG_DEBUG( "execute() completed successfully" );
155  return StatusCode::SUCCESS;
156 }
157 
159 {
160  ATH_MSG_INFO( "finalize() successfully" );
161  return StatusCode::SUCCESS;
162 }
163 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TileRawChannelToNtuple::m_sample
NTuple::Array< int > m_sample
Definition: TileRawChannelToNtuple.h:80
TileRawChannelToNtuple::m_side
NTuple::Array< int > m_side
Definition: TileRawChannelToNtuple.h:79
AthCheckMacros.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SelectAllObjectMT::end
const_iterator end()
Definition: SelectAllObjectMT.h:131
TileRawChannelToNtuple::m_ntuplePtr
NTuple::Tuple * m_ntuplePtr
Definition: TileRawChannelToNtuple.h:69
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
Tile_Base_ID::pmt
int pmt(const Identifier &id) const
Definition: Tile_Base_ID.cxx:180
Tile_Base_ID::side
int side(const Identifier &id) const
Definition: Tile_Base_ID.cxx:153
skel.it
it
Definition: skel.GENtoEVGEN.py:407
Tile_Base_ID::sample
int sample(const Identifier &id) const
Definition: Tile_Base_ID.cxx:171
TileRawChannelToNtuple.h
Tile_Base_ID::tower
int tower(const Identifier &id) const
Definition: Tile_Base_ID.cxx:165
TileRawChannelToNtuple::m_detector
NTuple::Array< int > m_detector
Definition: TileRawChannelToNtuple.h:78
TileRawChannelToNtuple::m_cablingSvc
ServiceHandle< TileCablingSvc > m_cablingSvc
Name of Tile cabling service.
Definition: TileRawChannelToNtuple.h:66
HWIdentifier
Definition: HWIdentifier.h:13
TileRawChannelToNtuple::execute
StatusCode execute() override
Definition: TileRawChannelToNtuple.cxx:100
TileHWID::channel
int channel(const HWIdentifier &id) const
extract channel field from HW identifier
Definition: TileHWID.h:189
TileID.h
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:92
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
TileRawChannelToNtuple::m_ntupleID
Gaudi::Property< std::string > m_ntupleID
Definition: TileRawChannelToNtuple.h:57
TileHWID::ros
int ros(const HWIdentifier &id) const
extract ros field from HW identifier
Definition: TileHWID.h:167
TileRawChannelContainer.h
TileHWID::adc
int adc(const HWIdentifier &id) const
extract adc field from HW identifier
Definition: TileHWID.h:193
SelectAllObjectMT::begin
const_iterator begin()
Definition: SelectAllObjectMT.h:115
SelectAllObjectMT
Definition: SelectAllObjectMT.h:11
max_chan
const int max_chan
Definition: TileRawChannelToNtuple.cxx:38
TileHWID.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TileRawChannelToNtuple::m_ntupleLoc
Gaudi::Property< std::string > m_ntupleLoc
Definition: TileRawChannelToNtuple.h:54
Tile_Base_ID::module
int module(const Identifier &id) const
Definition: Tile_Base_ID.cxx:159
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
TileRawChannelToNtuple::m_phi
NTuple::Array< int > m_phi
Definition: TileRawChannelToNtuple.h:82
TileRawChannelToNtuple::m_rawChannelContainerKey
SG::ReadHandleKey< TileRawChannelContainer > m_rawChannelContainerKey
Definition: TileRawChannelToNtuple.h:60
TileRawChannelToNtuple::m_nchan
NTuple::Item< int > m_nchan
Definition: TileRawChannelToNtuple.h:71
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
SelectAllObjectMT::const_iterator
Definition: SelectAllObjectMT.h:22
errorcheck.h
Helpers for checking error return status codes and reporting errors.
TileRawChannelToNtuple::m_time
NTuple::Array< float > m_time
Definition: TileRawChannelToNtuple.h:75
RunTileCalibRec.rawChannelContainer
rawChannelContainer
Definition: RunTileCalibRec.py:321
TileRawChannelToNtuple::m_tolE
NTuple::Item< double > m_tolE
Definition: TileRawChannelToNtuple.h:72
TileRawChannelToNtuple::m_gain
NTuple::Array< int > m_gain
Definition: TileRawChannelToNtuple.h:85
TileRawChannelToNtuple::m_tileID
const TileID * m_tileID
Definition: TileRawChannelToNtuple.h:87
TileRawChannelToNtuple::m_quality
NTuple::Array< float > m_quality
Definition: TileRawChannelToNtuple.h:76
TileHWID::drawer
int drawer(const HWIdentifier &id) const
extract drawer field from HW identifier
Definition: TileHWID.h:171
TileRawChannelToNtuple::finalize
StatusCode finalize() override
Definition: TileRawChannelToNtuple.cxx:158
TileRawChannelToNtuple::m_energy
NTuple::Array< float > m_energy
Definition: TileRawChannelToNtuple.h:74
TileRawChannelToNtuple::initialize
StatusCode initialize() override
Definition: TileRawChannelToNtuple.cxx:42
TileRawChannelToNtuple::m_eta
NTuple::Array< int > m_eta
Definition: TileRawChannelToNtuple.h:81
SelectAllObject.h
Tile_Base_ID::section
int section(const Identifier &id) const
Definition: Tile_Base_ID.cxx:147
beamspotnt.nt
def nt
Definition: bin/beamspotnt.py:1062
ReadHandle.h
Handle class for reading from StoreGate.
TileRawChannelToNtuple::m_pmt
NTuple::Array< int > m_pmt
Definition: TileRawChannelToNtuple.h:83
ntupleSvc
INTupleSvc * ntupleSvc()
Definition: ServiceAccessor.h:14
TileRawChannelToNtuple::m_tileHWID
const TileHWID * m_tileHWID
Definition: TileRawChannelToNtuple.h:88
TileRawChannelToNtuple::m_channel
NTuple::Array< int > m_channel
Definition: TileRawChannelToNtuple.h:84
Identifier
Definition: IdentifierFieldParser.cxx:14