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-2023 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
,
m_ntuplePtr
(0)
41
,
m_ntupleID
(
"h90"
)
42
,
m_ntupleLoc
(
"/FILE1/TileRec"
)
43
,
m_cellContainer
(
"TileCellIDC"
)
44
,
m_tileID
(0)
45
{
46
declareProperty
(
"TileCellIDC"
,
m_cellContainer
);
47
declareProperty
(
"NTupleLoc"
,
m_ntupleLoc
);
48
declareProperty
(
"NTupleID"
,
m_ntupleID
);
49
}
50
51
TileCellIDCToNtuple::~TileCellIDCToNtuple
()
52
{
53
}
54
55
// Alg standard interface function
56
StatusCode
TileCellIDCToNtuple::initialize
()
57
{
58
ATH_MSG_INFO
(
"Initialization started"
);
59
60
// retrieve TileID helper from det store
61
62
CHECK
(
detStore
()->retrieve(
m_tileID
) );
63
64
m_ntupleLoc
=
"/NTUPLES"
+
m_ntupleLoc
;
65
66
SmartDataPtr<NTuple::Directory> DirPtr(
ntupleSvc
(),
m_ntupleLoc
);
67
if
(!DirPtr) DirPtr=
ntupleSvc
()->createDirectory(
m_ntupleLoc
);
68
if
(!DirPtr) {
69
ATH_MSG_ERROR
(
"Invalid Ntuple Directory: "
);
70
return
StatusCode::FAILURE;
71
}
72
m_ntuplePtr
=
ntupleSvc
()->book(DirPtr.ptr(),
m_ntupleID
,
73
CLID_ColumnWiseTuple,
"TileCellIDC-Ntuple"
);
74
if
(!
m_ntuplePtr
) {
75
ATH_MSG_ERROR
(
"Failed to book ntuple: TileCellIDCNtuple"
);
76
return
StatusCode::FAILURE;
77
}
78
79
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/ncell"
,
m_nchan
,0,
max_chan
) );
80
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/totalE"
,
m_tolE
) );
81
82
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/energy"
,
m_nchan
,
m_energy
) );
83
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/enediff"
,
m_nchan
,
m_enediff
) );
84
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/time"
,
m_nchan
,
m_time
) );
85
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/quality"
,
m_nchan
,
m_quality
) );
86
87
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/detector"
,
m_nchan
,
m_detector
,0,3) );
88
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/side"
,
m_nchan
,
m_side
,-1,1) );
89
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/sample"
,
m_nchan
,
m_sample
,0,3) );
90
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/eta"
,
m_nchan
,
m_eta
,0,15) );
91
CHECK
(
m_ntuplePtr
->addItem(
"TileCell/phi"
,
m_nchan
,
m_phi
,0,63) );
92
93
ATH_MSG_INFO
(
"Initialization completed"
);
94
return
StatusCode::SUCCESS;
95
}
96
97
StatusCode
TileCellIDCToNtuple::execute
(
const
EventContext&
/*ctx*/
)
98
{
99
// step1: read Cells from TDS
100
const
TileCellIDC
* CellCnt;
101
CHECK
(
evtStore
()->retrieve(CellCnt,
m_cellContainer
) );
102
103
// step2: to fill items in ntuple
104
SelectAllObject<TileCellIDC>
selCells(CellCnt);
105
SelectAllObject<TileCellIDC>::const_iterator it=selCells.
begin
();
106
SelectAllObject<TileCellIDC>::const_iterator end=selCells.
end
();
107
m_nchan
=0;
108
m_tolE
=0.0;
109
for
(; it != end; ++it) {
110
const
TileCell
*cell = (*it);
111
m_tolE
+=cell->energy();
112
m_energy
[
m_nchan
]=cell->energy();
113
m_enediff
[
m_nchan
]=cell->eneDiff();
114
m_time
[
m_nchan
]=cell->time();
115
m_quality
[
m_nchan
]=cell->quality();
116
117
Identifier
id
=
m_tileID
->cell_id(cell->subcalo_hash());
118
m_detector
[
m_nchan
]=
m_tileID
->section(
id
);
119
m_side
[
m_nchan
]=
m_tileID
->side(
id
);
120
m_sample
[
m_nchan
]=
m_tileID
->sample(
id
);
121
m_eta
[
m_nchan
]=
m_tileID
->tower(
id
);
122
m_phi
[
m_nchan
]=
m_tileID
->module(
id
);
123
124
m_nchan
++;
125
126
if
(
m_nchan
>=
max_chan
)
break
;
127
}
128
129
// step3: coomit ntuple
130
CHECK
(
ntupleSvc
()->writeRecord(
m_ntuplePtr
) );
131
132
// Execution completed.
133
ATH_MSG_DEBUG
(
"execute() completed successfully"
);
134
return
StatusCode::SUCCESS;
135
}
136
137
StatusCode
TileCellIDCToNtuple::finalize
()
138
{
139
ATH_MSG_INFO
(
"finalize() successfully"
);
140
return
StatusCode::SUCCESS;
141
}
142
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
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 >::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
SelectAllObjectMT::end
const_iterator end()
Definition
SelectAllObjectMT.h:131
SelectAllObjectMT::begin
const_iterator begin()
Definition
SelectAllObjectMT.h:115
TileCellIDCToNtuple::m_ntupleID
std::string m_ntupleID
Definition
TileCellIDCToNtuple.h:51
TileCellIDCToNtuple::m_cellContainer
std::string m_cellContainer
Definition
TileCellIDCToNtuple.h:68
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:97
TileCellIDCToNtuple::m_time
NTuple::Array< float > m_time
Definition
TileCellIDCToNtuple.h:59
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::finalize
StatusCode finalize()
Definition
TileCellIDCToNtuple.cxx:137
TileCellIDCToNtuple::m_ntupleLoc
std::string m_ntupleLoc
Definition
TileCellIDCToNtuple.h:52
TileCellIDCToNtuple::initialize
StatusCode initialize()
Definition
TileCellIDCToNtuple.cxx:56
TileCellIDCToNtuple::~TileCellIDCToNtuple
virtual ~TileCellIDCToNtuple()
Definition
TileCellIDCToNtuple.cxx:51
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
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