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-2024 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
,
m_ntuplePtr
(0)
44
,
m_ntupleID
(
"h110"
)
45
,
m_ntupleLoc
(
"/FILE1/TileRec"
)
46
,
m_scinCells
(true)
47
,
m_cellContainer
(
"MBTSContainer"
)
// "TileCellContainerKey";
48
,
m_tileID
(0)
49
,
m_tileTBID
(0)
50
{
51
declareProperty
(
"TileCellContainer"
,
m_cellContainer
);
52
declareProperty
(
"NTupleLoc"
,
m_ntupleLoc
);
53
declareProperty
(
"NTupleID"
,
m_ntupleID
);
54
declareProperty
(
"ScinCells"
,
m_scinCells
);
55
}
56
57
TileCellToNtuple::~TileCellToNtuple
()
58
{
59
}
60
61
// Alg standard interface function
62
StatusCode
TileCellToNtuple::initialize
()
63
{
64
ATH_MSG_INFO
(
"Initialization started"
);
65
66
// retrieve TileID helper from det store
67
CHECK
(
detStore
()->retrieve(
m_tileID
) );
68
CHECK
(
detStore
()->retrieve(
m_tileTBID
) );
69
70
m_ntupleLoc
=
"/NTUPLES"
+
m_ntupleLoc
;
71
72
SmartDataPtr<NTuple::Directory> DirPtr(
ntupleSvc
(),
m_ntupleLoc
);
73
if
(!DirPtr) DirPtr =
ntupleSvc
()->createDirectory(
m_ntupleLoc
);
74
if
(!DirPtr) {
75
ATH_MSG_ERROR
(
"Invalid Ntuple Directory: "
);
76
return
StatusCode::FAILURE;
77
}
78
m_ntuplePtr
=
ntupleSvc
()->book(DirPtr.ptr(),
m_ntupleID
,
79
CLID_ColumnWiseTuple,
"TileCell-Ntuple"
);
80
if
(!
m_ntuplePtr
) {
81
ATH_MSG_ERROR
(
"Failed to book ntuple: TileCellNtuple"
);
82
return
StatusCode::FAILURE;
83
}
84
85
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/ncell"
,
m_nchan
, 0,
max_chan
) );
86
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/totalE"
,
m_tolE
) );
87
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/energy"
,
m_nchan
,
m_energy
) );
88
89
if
(!
m_scinCells
)
90
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/enediff"
,
m_nchan
,
m_enediff
) );
91
92
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/time"
,
m_nchan
,
m_time
) );
93
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/quality"
,
m_nchan
,
m_quality
) );
94
95
if
(
m_scinCells
) {
96
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/type"
,
m_nchan
,
m_type
, -1, 6) );
97
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/module"
,
m_nchan
,
m_module
, 0, 7) );
98
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/channel"
,
m_nchan
,
m_channel
, 0, 15) );
99
}
else
{
100
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/detector"
,
m_nchan
,
m_detector
, 0, 3) );
101
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/side"
,
m_nchan
,
m_side
, -1, 1) );
102
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/sample"
,
m_nchan
,
m_sample
, 0, 3) );
103
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/eta"
,
m_nchan
,
m_eta
, 0, 15) );
104
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/phi"
,
m_nchan
,
m_phi
, 0, 63) );
105
}
106
107
ATH_MSG_INFO
(
"Initialization completed"
);
108
return
StatusCode::SUCCESS;
109
}
110
111
StatusCode
TileCellToNtuple::execute
(
const
EventContext&
/*ctx*/
)
112
{
113
m_nchan
=0;
114
m_tolE
=0.0;
115
116
if
(
m_scinCells
) {
117
118
// step1: read Cells from TDS
119
const
TileCellContainer
* CellCnt =
nullptr
;
120
CHECK
(
evtStore
()->retrieve(CellCnt,
m_cellContainer
) );
121
122
// step2: to fill items in ntuple
123
TileCellContainer::const_iterator
it = CellCnt->
begin
();
124
TileCellContainer::const_iterator
end = CellCnt->
end
();
125
for
(; it != end; ++it) {
126
const
TileCell
*cell = (
const
TileCell
*)(*it);
127
m_tolE
+=cell->energy();
128
m_energy
[
m_nchan
]=cell->energy();
129
m_time
[
m_nchan
]=cell->time();
130
m_quality
[
m_nchan
]=cell->quality();
131
132
Identifier
id
=cell->ID();
133
m_type
[
m_nchan
]=
m_tileTBID
->type(
id
);
134
m_channel
[
m_nchan
]=
m_tileTBID
->channel(
id
);
135
m_module
[
m_nchan
]=
m_tileTBID
->module(
id
);
136
137
m_nchan
++;
138
139
if
(
m_nchan
>=
max_chan
)
break
;
140
}
141
142
}
else
{
143
144
145
146
147
// step1: read Cells from TDS
148
const
CaloCellContainer
* CellCnt =
nullptr
;
149
CHECK
(
evtStore
()->retrieve(CellCnt,
m_cellContainer
) );
150
151
// step2: to fill items in ntuple
152
CaloCellContainer::const_iterator
it = CellCnt->
beginConstCalo
(
CaloCell_ID::TILE
);
153
CaloCellContainer::const_iterator
end = CellCnt->
endConstCalo
(
CaloCell_ID::TILE
);
154
for
(; it != end; ++it) {
155
const
TileCell
*cell = (
const
TileCell
*)(*it);
156
m_tolE
+=cell->energy();
157
m_energy
[
m_nchan
]=cell->energy();
158
m_enediff
[
m_nchan
]=cell->eneDiff();
159
m_time
[
m_nchan
]=cell->time();
160
m_quality
[
m_nchan
]=cell->quality();
161
162
Identifier
id
=
m_tileID
->cell_id(cell->subcalo_hash());
163
m_detector
[
m_nchan
]=
m_tileID
->section(
id
);
164
m_side
[
m_nchan
]=
m_tileID
->side(
id
);
165
m_sample
[
m_nchan
]=
m_tileID
->sample(
id
);
166
m_eta
[
m_nchan
]=
m_tileID
->tower(
id
);
167
m_phi
[
m_nchan
]=
m_tileID
->module(
id
);
168
169
m_nchan
++;
170
171
if
(
m_nchan
>=
max_chan
)
break
;
172
}
173
}
174
175
// step3: commit ntuple
176
CHECK
(
ntupleSvc
()->writeRecord(
m_ntuplePtr
) );
177
178
// Execution completed.
179
ATH_MSG_DEBUG
(
"execute() completed successfully"
);
180
return
StatusCode::SUCCESS;
181
}
182
183
StatusCode
TileCellToNtuple::finalize
()
184
{
185
ATH_MSG_INFO
(
"finalize() successfully"
);
186
return
StatusCode::SUCCESS;
187
}
188
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
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 >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
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:838
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_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:57
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:183
TileCellToNtuple::m_module
NTuple::Array< int > m_module
Definition
TileCellToNtuple.h:72
TileCellToNtuple::m_scinCells
bool m_scinCells
Definition
TileCellToNtuple.h:54
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_cellContainer
std::string m_cellContainer
Definition
TileCellToNtuple.h:74
TileCellToNtuple::m_phi
NTuple::Array< int > m_phi
Definition
TileCellToNtuple.h:68
TileCellToNtuple::initialize
StatusCode initialize()
Definition
TileCellToNtuple.cxx:62
TileCellToNtuple::m_ntupleID
std::string m_ntupleID
Definition
TileCellToNtuple.h:52
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:111
TileCellToNtuple::m_ntupleLoc
std::string m_ntupleLoc
Definition
TileCellToNtuple.h:53
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