ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TileCalorimeter
TileRec
src
TileCellToNtuple.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
//*****************************************************************************
6
// Filename : TileCellToNtuple.cxx
7
// Author : Zhifang
8
// Created : Jan, 2003
9
//
10
// DESCRIPTION:
11
// Implement the algorithm
12
//
13
// HISTORY:
14
//
15
// BUGS:
16
//
17
//*****************************************************************************
18
19
//Gaudi Includes
20
#include "GaudiKernel/INTupleSvc.h"
21
#include "GaudiKernel/IDataProviderSvc.h"
22
#include "GaudiKernel/SmartDataPtr.h"
23
24
//Atlas include
25
#include "
AthenaKernel/errorcheck.h
"
26
#include "
EventContainers/SelectAllObject.h
"
27
28
// Calo include
29
#include "
CaloIdentifier/TileID.h
"
30
#include "
CaloIdentifier/TileTBID.h
"
31
#include "
CaloEvent/CaloCellContainer.h
"
32
33
//TileCalo include
34
#include "
TileEvent/TileCell.h
"
35
#include "
TileEvent/TileCellContainer.h
"
36
#include "
TileRec/TileCellToNtuple.h
"
37
38
const
int
max_chan
=5216;
39
40
// Constructor & deconstructor
41
TileCellToNtuple::TileCellToNtuple
(
const
std::string& name, ISvcLocator* pSvcLocator)
42
:
AthAlgorithm
(name, pSvcLocator)
43
{
44
}
45
46
TileCellToNtuple::~TileCellToNtuple
()
47
{
48
}
49
50
// Alg standard interface function
51
StatusCode
TileCellToNtuple::initialize
()
52
{
53
ATH_MSG_INFO
(
"Initialization started"
);
54
55
// retrieve TileID helper from det store
56
CHECK
(
detStore
()->retrieve(
m_tileID
) );
57
CHECK
(
detStore
()->retrieve(
m_tileTBID
) );
58
59
m_ntupleLoc
=
"/NTUPLES"
+
m_ntupleLoc
.value();
60
61
SmartDataPtr<NTuple::Directory> DirPtr(
ntupleSvc
(),
m_ntupleLoc
);
62
if
(!DirPtr) DirPtr =
ntupleSvc
()->createDirectory(
m_ntupleLoc
);
63
if
(!DirPtr) {
64
ATH_MSG_ERROR
(
"Invalid Ntuple Directory: "
);
65
return
StatusCode::FAILURE;
66
}
67
m_ntuplePtr
=
ntupleSvc
()->book(DirPtr.ptr(),
m_ntupleID
,
68
CLID_ColumnWiseTuple,
"TileCell-Ntuple"
);
69
if
(!
m_ntuplePtr
) {
70
ATH_MSG_ERROR
(
"Failed to book ntuple: TileCellNtuple"
);
71
return
StatusCode::FAILURE;
72
}
73
74
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/ncell"
,
m_nchan
, 0,
max_chan
) );
75
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/totalE"
,
m_tolE
) );
76
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/energy"
,
m_nchan
,
m_energy
) );
77
78
if
(!
m_scinCells
)
79
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/enediff"
,
m_nchan
,
m_enediff
) );
80
81
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/time"
,
m_nchan
,
m_time
) );
82
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/quality"
,
m_nchan
,
m_quality
) );
83
84
if
(
m_scinCells
) {
85
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/type"
,
m_nchan
,
m_type
, -1, 6) );
86
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/module"
,
m_nchan
,
m_module
, 0, 7) );
87
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/channel"
,
m_nchan
,
m_channel
, 0, 15) );
88
}
else
{
89
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/detector"
,
m_nchan
,
m_detector
, 0, 3) );
90
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/side"
,
m_nchan
,
m_side
, -1, 1) );
91
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/sample"
,
m_nchan
,
m_sample
, 0, 3) );
92
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/eta"
,
m_nchan
,
m_eta
, 0, 15) );
93
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/phi"
,
m_nchan
,
m_phi
, 0, 63) );
94
}
95
96
ATH_MSG_INFO
(
"Initialization completed"
);
97
return
StatusCode::SUCCESS;
98
}
99
100
StatusCode
TileCellToNtuple::execute
(
const
EventContext&
/*ctx*/
)
101
{
102
m_nchan
=0;
103
m_tolE
=0.0;
104
105
if
(
m_scinCells
) {
106
107
// step1: read Cells from TDS
108
const
TileCellContainer
* CellCnt =
nullptr
;
109
CHECK
(
evtStore
()->retrieve(CellCnt,
m_cellContainer
.value()) );
110
111
// step2: to fill items in ntuple
112
TileCellContainer::const_iterator
it = CellCnt->
begin
();
113
TileCellContainer::const_iterator
end = CellCnt->
end
();
114
for
(; it != end; ++it) {
115
const
TileCell
*cell = (
const
TileCell
*)(*it);
116
m_tolE
+=cell->energy();
117
m_energy
[
m_nchan
]=cell->energy();
118
m_time
[
m_nchan
]=cell->time();
119
m_quality
[
m_nchan
]=cell->quality();
120
121
Identifier
id
=cell->ID();
122
m_type
[
m_nchan
]=
m_tileTBID
->type(
id
);
123
m_channel
[
m_nchan
]=
m_tileTBID
->channel(
id
);
124
m_module
[
m_nchan
]=
m_tileTBID
->module(
id
);
125
126
m_nchan
++;
127
128
if
(
m_nchan
>=
max_chan
)
break
;
129
}
130
131
}
else
{
132
133
134
135
136
// step1: read Cells from TDS
137
const
CaloCellContainer
* CellCnt =
nullptr
;
138
CHECK
(
evtStore
()->retrieve(CellCnt,
m_cellContainer
.value()) );
139
140
// step2: to fill items in ntuple
141
CaloCellContainer::const_iterator
it = CellCnt->
beginConstCalo
(
CaloCell_ID::TILE
);
142
CaloCellContainer::const_iterator
end = CellCnt->
endConstCalo
(
CaloCell_ID::TILE
);
143
for
(; it != end; ++it) {
144
const
TileCell
*cell = (
const
TileCell
*)(*it);
145
m_tolE
+=cell->energy();
146
m_energy
[
m_nchan
]=cell->energy();
147
m_enediff
[
m_nchan
]=cell->eneDiff();
148
m_time
[
m_nchan
]=cell->time();
149
m_quality
[
m_nchan
]=cell->quality();
150
151
Identifier
id
=
m_tileID
->cell_id(cell->subcalo_hash());
152
m_detector
[
m_nchan
]=
m_tileID
->section(
id
);
153
m_side
[
m_nchan
]=
m_tileID
->side(
id
);
154
m_sample
[
m_nchan
]=
m_tileID
->sample(
id
);
155
m_eta
[
m_nchan
]=
m_tileID
->tower(
id
);
156
m_phi
[
m_nchan
]=
m_tileID
->module(
id
);
157
158
m_nchan
++;
159
160
if
(
m_nchan
>=
max_chan
)
break
;
161
}
162
}
163
164
// step3: commit ntuple
165
CHECK
(
ntupleSvc
()->writeRecord(
m_ntuplePtr
) );
166
167
// Execution completed.
168
ATH_MSG_DEBUG
(
"execute() completed successfully"
);
169
return
StatusCode::SUCCESS;
170
}
171
172
StatusCode
TileCellToNtuple::finalize
()
173
{
174
ATH_MSG_INFO
(
"finalize() successfully"
);
175
return
StatusCode::SUCCESS;
176
}
177
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x,...)
Definition
AthMsgStreamMacros.h:43
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x,...)
Definition
AthMsgStreamMacros.h:47
ATH_MSG_INFO
#define ATH_MSG_INFO(x,...)
Definition
AthMsgStreamMacros.h:45
CaloCellContainer.h
TileTBID.h
errorcheck.h
Helpers for checking error return status codes and reporting errors.
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
SelectAllObject.h
ntupleSvc
INTupleSvc * ntupleSvc()
Definition
ServiceAccessor.h:14
TileCellContainer.h
max_chan
const int max_chan
Definition
TileCellIDCToNtuple.cxx:35
TileCellToNtuple.h
TileCell.h
TileCellContainer
TileContainer< TileCell > TileCellContainer
Definition
TileContainer.h:64
TileID.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
Definition
AthCommonDataStore.h:85
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
CaloCellContainer
Container class for CaloCell.
Definition
CaloCellContainer.h:55
CaloCellContainer::beginConstCalo
CaloCellContainer::const_iterator beginConstCalo(CaloCell_ID::SUBCALO caloNum) const
get const iterators on cell of just one calo
Definition
CaloCellContainer.cxx:119
CaloCellContainer::endConstCalo
CaloCellContainer::const_iterator endConstCalo(CaloCell_ID::SUBCALO caloNum) const
Definition
CaloCellContainer.cxx:133
CaloCell_Base_ID::TILE
@ TILE
Definition
CaloCell_Base_ID.h:45
TileContainer< TileCell >::const_iterator
DataModel_detail::const_iterator< DataVector > const_iterator
Definition
DataVector.h:861
DataVector< TELEMENT >::end
const_iterator end() const noexcept
DataVector< TELEMENT >::begin
const_iterator begin() const noexcept
TileCellToNtuple::m_tileTBID
const TileTBID * m_tileTBID
Definition
TileCellToNtuple.h:77
TileCellToNtuple::m_channel
NTuple::Array< int > m_channel
Definition
TileCellToNtuple.h:71
TileCellToNtuple::m_ntupleID
Gaudi::Property< std::string > m_ntupleID
Definition
TileCellToNtuple.h:52
TileCellToNtuple::m_ntupleLoc
Gaudi::Property< std::string > m_ntupleLoc
Definition
TileCellToNtuple.h:53
TileCellToNtuple::m_eta
NTuple::Array< int > m_eta
Definition
TileCellToNtuple.h:67
TileCellToNtuple::TileCellToNtuple
TileCellToNtuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition
TileCellToNtuple.cxx:41
TileCellToNtuple::~TileCellToNtuple
virtual ~TileCellToNtuple()
Definition
TileCellToNtuple.cxx:46
TileCellToNtuple::m_time
NTuple::Array< float > m_time
Definition
TileCellToNtuple.h:61
TileCellToNtuple::m_side
NTuple::Array< int > m_side
Definition
TileCellToNtuple.h:65
TileCellToNtuple::m_type
NTuple::Array< int > m_type
Definition
TileCellToNtuple.h:70
TileCellToNtuple::m_quality
NTuple::Array< float > m_quality
Definition
TileCellToNtuple.h:62
TileCellToNtuple::finalize
StatusCode finalize()
Definition
TileCellToNtuple.cxx:172
TileCellToNtuple::m_module
NTuple::Array< int > m_module
Definition
TileCellToNtuple.h:72
TileCellToNtuple::m_nchan
NTuple::Item< int > m_nchan
Definition
TileCellToNtuple.h:56
TileCellToNtuple::m_energy
NTuple::Array< float > m_energy
Definition
TileCellToNtuple.h:59
TileCellToNtuple::m_phi
NTuple::Array< int > m_phi
Definition
TileCellToNtuple.h:68
TileCellToNtuple::initialize
StatusCode initialize()
Definition
TileCellToNtuple.cxx:51
TileCellToNtuple::m_scinCells
Gaudi::Property< bool > m_scinCells
Definition
TileCellToNtuple.h:54
TileCellToNtuple::m_cellContainer
Gaudi::Property< std::string > m_cellContainer
Definition
TileCellToNtuple.h:74
TileCellToNtuple::m_sample
NTuple::Array< int > m_sample
Definition
TileCellToNtuple.h:66
TileCellToNtuple::m_tolE
NTuple::Item< double > m_tolE
Definition
TileCellToNtuple.h:57
TileCellToNtuple::m_enediff
NTuple::Array< float > m_enediff
Definition
TileCellToNtuple.h:60
TileCellToNtuple::m_tileID
const TileID * m_tileID
Definition
TileCellToNtuple.h:76
TileCellToNtuple::execute
StatusCode execute(const EventContext &ctx)
Execute method.
Definition
TileCellToNtuple.cxx:100
TileCellToNtuple::m_detector
NTuple::Array< int > m_detector
Definition
TileCellToNtuple.h:64
TileCellToNtuple::m_ntuplePtr
NTuple::Tuple * m_ntuplePtr
Definition
TileCellToNtuple.h:51
TileCell
Definition
TileCell.h:57
Identifier
Definition
IdentifierFieldParser.cxx:14
Generated on
for ATLAS Offline Software by
1.17.0