ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TileCalorimeter
TileRec
src
TileCellIDCToNtuple.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 : TileCellIDCToNtuple.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
31
//TileCalo include
32
#include "
TileEvent/TileCellIDC.h
"
33
#include "
TileRec/TileCellIDCToNtuple.h
"
34
35
const
int
max_chan
=5216;
36
37
// Constructor & deconstructor
38
TileCellIDCToNtuple::TileCellIDCToNtuple
(
const
std::string& name, ISvcLocator* pSvcLocator)
39
:
AthAlgorithm
(name, pSvcLocator)
40
{
41
}
42
43
TileCellIDCToNtuple::~TileCellIDCToNtuple
()
44
{
45
}
46
47
// Alg standard interface function
48
StatusCode
TileCellIDCToNtuple::initialize
()
49
{
50
ATH_MSG_INFO
(
"Initialization started"
);
51
52
// retrieve TileID helper from det store
53
54
CHECK
(
detStore
()->retrieve(
m_tileID
) );
55
56
m_ntupleLoc
=
"/NTUPLES"
+
m_ntupleLoc
.value();
57
58
SmartDataPtr<NTuple::Directory> DirPtr(
ntupleSvc
(),
m_ntupleLoc
);
59
if
(!DirPtr) DirPtr=
ntupleSvc
()->createDirectory(
m_ntupleLoc
);
60
if
(!DirPtr) {
61
ATH_MSG_ERROR
(
"Invalid Ntuple Directory: "
);
62
return
StatusCode::FAILURE;
63
}
64
m_ntuplePtr
=
ntupleSvc
()->book(DirPtr.ptr(),
m_ntupleID
,
65
CLID_ColumnWiseTuple,
"TileCellIDC-Ntuple"
);
66
if
(!
m_ntuplePtr
) {
67
ATH_MSG_ERROR
(
"Failed to book ntuple: TileCellIDCNtuple"
);
68
return
StatusCode::FAILURE;
69
}
70
71
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/ncell"
,
m_nchan
,0,
max_chan
) );
72
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/totalE"
,
m_tolE
) );
73
74
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/energy"
,
m_nchan
,
m_energy
) );
75
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/enediff"
,
m_nchan
,
m_enediff
) );
76
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/time"
,
m_nchan
,
m_time
) );
77
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/quality"
,
m_nchan
,
m_quality
) );
78
79
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/detector"
,
m_nchan
,
m_detector
,0,3) );
80
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/side"
,
m_nchan
,
m_side
,-1,1) );
81
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/sample"
,
m_nchan
,
m_sample
,0,3) );
82
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/eta"
,
m_nchan
,
m_eta
,0,15) );
83
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/phi"
,
m_nchan
,
m_phi
,0,63) );
84
85
ATH_MSG_INFO
(
"Initialization completed"
);
86
return
StatusCode::SUCCESS;
87
}
88
89
StatusCode
TileCellIDCToNtuple::execute
(
const
EventContext&
/*ctx*/
)
90
{
91
// step1: read Cells from TDS
92
const
TileCellIDC
* CellCnt;
93
CHECK
(
evtStore
()->retrieve(CellCnt,
m_cellContainer
.value()) );
94
95
// step2: to fill items in ntuple
96
SelectAllObject<TileCellIDC>
selCells(CellCnt);
97
SelectAllObject<TileCellIDC>::const_iterator it=selCells.
begin
();
98
SelectAllObject<TileCellIDC>::const_iterator end=selCells.
end
();
99
m_nchan
=0;
100
m_tolE
=0.0;
101
for
(; it != end; ++it) {
102
const
TileCell
*cell = (*it);
103
m_tolE
+=cell->energy();
104
m_energy
[
m_nchan
]=cell->energy();
105
m_enediff
[
m_nchan
]=cell->eneDiff();
106
m_time
[
m_nchan
]=cell->time();
107
m_quality
[
m_nchan
]=cell->quality();
108
109
Identifier
id
=
m_tileID
->cell_id(cell->subcalo_hash());
110
m_detector
[
m_nchan
]=
m_tileID
->section(
id
);
111
m_side
[
m_nchan
]=
m_tileID
->side(
id
);
112
m_sample
[
m_nchan
]=
m_tileID
->sample(
id
);
113
m_eta
[
m_nchan
]=
m_tileID
->tower(
id
);
114
m_phi
[
m_nchan
]=
m_tileID
->module(
id
);
115
116
m_nchan
++;
117
118
if
(
m_nchan
>=
max_chan
)
break
;
119
}
120
121
// step3: coomit ntuple
122
CHECK
(
ntupleSvc
()->writeRecord(
m_ntuplePtr
) );
123
124
// Execution completed.
125
ATH_MSG_DEBUG
(
"execute() completed successfully"
);
126
return
StatusCode::SUCCESS;
127
}
128
129
StatusCode
TileCellIDCToNtuple::finalize
()
130
{
131
ATH_MSG_INFO
(
"finalize() successfully"
);
132
return
StatusCode::SUCCESS;
133
}
134
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
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
SelectAllObject
SelectAllObjectMT< DCC, OBJECT > SelectAllObject
Definition
SelectAllObject.h:11
ntupleSvc
INTupleSvc * ntupleSvc()
Definition
ServiceAccessor.h:14
max_chan
const int max_chan
Definition
TileCellIDCToNtuple.cxx:35
TileCellIDCToNtuple.h
TileCellIDC.h
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
SelectAllObjectMT::end
const_iterator end()
Definition
SelectAllObjectMT.h:131
SelectAllObjectMT::begin
const_iterator begin()
Definition
SelectAllObjectMT.h:115
TileCellIDCToNtuple::m_tolE
NTuple::Item< double > m_tolE
Definition
TileCellIDCToNtuple.h:55
TileCellIDCToNtuple::m_energy
NTuple::Array< float > m_energy
Definition
TileCellIDCToNtuple.h:57
TileCellIDCToNtuple::m_sample
NTuple::Array< int > m_sample
Definition
TileCellIDCToNtuple.h:64
TileCellIDCToNtuple::execute
StatusCode execute(const EventContext &ctx)
Execute method.
Definition
TileCellIDCToNtuple.cxx:89
TileCellIDCToNtuple::m_time
NTuple::Array< float > m_time
Definition
TileCellIDCToNtuple.h:59
TileCellIDCToNtuple::m_cellContainer
Gaudi::Property< std::string > m_cellContainer
Definition
TileCellIDCToNtuple.h:68
TileCellIDCToNtuple::m_phi
NTuple::Array< int > m_phi
Definition
TileCellIDCToNtuple.h:66
TileCellIDCToNtuple::m_nchan
NTuple::Item< int > m_nchan
Definition
TileCellIDCToNtuple.h:54
TileCellIDCToNtuple::m_ntuplePtr
NTuple::Tuple * m_ntuplePtr
Definition
TileCellIDCToNtuple.h:50
TileCellIDCToNtuple::m_eta
NTuple::Array< int > m_eta
Definition
TileCellIDCToNtuple.h:65
TileCellIDCToNtuple::m_ntupleLoc
Gaudi::Property< std::string > m_ntupleLoc
Definition
TileCellIDCToNtuple.h:52
TileCellIDCToNtuple::finalize
StatusCode finalize()
Definition
TileCellIDCToNtuple.cxx:129
TileCellIDCToNtuple::initialize
StatusCode initialize()
Definition
TileCellIDCToNtuple.cxx:48
TileCellIDCToNtuple::~TileCellIDCToNtuple
virtual ~TileCellIDCToNtuple()
Definition
TileCellIDCToNtuple.cxx:43
TileCellIDCToNtuple::m_tileID
const TileID * m_tileID
Definition
TileCellIDCToNtuple.h:69
TileCellIDCToNtuple::m_detector
NTuple::Array< int > m_detector
Definition
TileCellIDCToNtuple.h:62
TileCellIDCToNtuple::m_quality
NTuple::Array< float > m_quality
Definition
TileCellIDCToNtuple.h:60
TileCellIDCToNtuple::m_enediff
NTuple::Array< float > m_enediff
Definition
TileCellIDCToNtuple.h:58
TileCellIDCToNtuple::m_side
NTuple::Array< int > m_side
Definition
TileCellIDCToNtuple.h:63
TileCellIDCToNtuple::TileCellIDCToNtuple
TileCellIDCToNtuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition
TileCellIDCToNtuple.cxx:38
TileCellIDCToNtuple::m_ntupleID
Gaudi::Property< std::string > m_ntupleID
Definition
TileCellIDCToNtuple.h:51
TileCellIDC
Definition
TileCellIDC.h:13
TileCell
Definition
TileCell.h:57
Identifier
Definition
IdentifierFieldParser.cxx:14
Generated on
for ATLAS Offline Software by
1.17.0