ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TileCalorimeter
TileRec
src
TileTTL1ToNtuple.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 : TileTTL1ToNtuple.cxx
7
// Author : Gia
8
// Created : March, 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
27
// Calo include
28
#include "
CaloIdentifier/CaloLVL1_ID.h
"
29
#include "
CaloIdentifier/TileTBID.h
"
30
31
//TileCalo include
32
#include "
TileEvent/TileTTL1Container.h
"
33
#include "
TileRec/TileTTL1ToNtuple.h
"
34
35
TileTTL1ToNtuple::TileTTL1ToNtuple
(
const
std::string& name, ISvcLocator* pSvcLocator)
36
:
AthAlgorithm
(name, pSvcLocator)
37
,
m_ntuplePtr
(0)
38
,
m_ntupleID
(
"h130"
)
39
,
m_ntupleLoc
(
"/FILE1/TileRec"
)
40
,
m_ttl1Container
(
"TileTTL1Cnt"
)
41
,
m_TT_ID
(0)
42
,
m_tileTBID
(0)
43
{
44
declareProperty
(
"TileTTL1Container"
,
m_ttl1Container
);
45
declareProperty
(
"NTupleLoc"
,
m_ntupleLoc
);
46
declareProperty
(
"NTupleID"
,
m_ntupleID
);
47
declareProperty
(
"CommitNtuple"
,
m_commitNtuple
=
true
);
48
declareProperty
(
"MaxLength"
,
m_maxLength
= 2048);
49
declareProperty
(
"NSamples"
,
m_nSamples
= 7);
50
51
}
52
53
TileTTL1ToNtuple::~TileTTL1ToNtuple
()
54
{
55
}
56
57
//****************************************************************************
58
//* Initialization
59
//****************************************************************************
60
61
StatusCode
TileTTL1ToNtuple::initialize
()
62
{
63
64
ATH_MSG_INFO
(
"Initialization started"
);
65
66
// retrieve TileID helper from det store
67
68
CHECK
(
detStore
()->retrieve(
m_TT_ID
) );
69
CHECK
(
detStore
()->retrieve(
m_tileTBID
) );
70
71
m_ntupleLoc
=
"/NTUPLES"
+
m_ntupleLoc
;
72
73
SmartDataPtr<NTuple::Directory> DirPtr(
ntupleSvc
(),
m_ntupleLoc
);
74
if
(!DirPtr) DirPtr=
ntupleSvc
()->createDirectory(
m_ntupleLoc
);
75
if
(!DirPtr) {
76
ATH_MSG_ERROR
(
"Invalid Ntuple Directory: "
);
77
return
StatusCode::FAILURE;
78
}
79
m_ntuplePtr
=
ntupleSvc
()->book(DirPtr.ptr(),
m_ntupleID
,
80
CLID_ColumnWiseTuple,
"TileTTL1-Ntuple"
);
81
if
(!
m_ntuplePtr
) {
82
83
std::string ntupleCompleteID=
m_ntupleLoc
+
"/"
+
m_ntupleID
;
84
85
NTuplePtr nt(
ntupleSvc
(),ntupleCompleteID);
86
if
(!nt) {
87
ATH_MSG_ERROR
(
"Failed to book or to retrieve ntuple "
88
<< ntupleCompleteID );
89
return
StatusCode::FAILURE;
90
}
else
{
91
ATH_MSG_INFO
(
"Reaccessing ntuple "
<< ntupleCompleteID );
92
m_ntuplePtr
= nt;
93
}
94
}
95
96
CHECK
(
m_ntuplePtr
->addItem(
"TileTTL1/nttl1"
,
m_nchan
,0,
m_maxLength
) );
97
CHECK
(
m_ntuplePtr
->addItem(
"TileTTL1/side"
,
m_nchan
,
m_side
,-1,1) );
98
CHECK
(
m_ntuplePtr
->addItem(
"TileTTL1/eta"
,
m_nchan
,
m_eta
,0,15) );
99
CHECK
(
m_ntuplePtr
->addItem(
"TileTTL1/phi"
,
m_nchan
,
m_phi
,0,63) );
100
CHECK
(
m_ntuplePtr
->addItem(
"TileTTL1/samples"
,
m_maxLength
,
m_nSamples
,
m_samples
) );
101
102
ATH_MSG_INFO
(
"Initialization completed"
);
103
return
StatusCode::SUCCESS;
104
}
105
106
//****************************************************************************
107
//* Execution
108
//****************************************************************************
109
110
StatusCode
TileTTL1ToNtuple::execute
(
const
EventContext&
/*ctx*/
)
111
{
112
113
// step1: read TileTTL1s from TDS
114
const
TileTTL1Container
* TTL1Cnt =
nullptr
;
115
CHECK
(
evtStore
()->retrieve(TTL1Cnt,
m_ttl1Container
) );
116
117
// step2: put items in ntuple
118
TileTTL1Container::const_iterator
it=TTL1Cnt->
begin
();
119
TileTTL1Container::const_iterator
end=TTL1Cnt->
end
();
120
121
m_nchan
=0;
122
for
(; it != end; ++it) {
123
124
if
(
m_nchan
>=
m_maxLength
) {
125
ATH_MSG_DEBUG
(
"Number of ttl1s exceeds maximum ("
126
<<
m_maxLength
<<
"), ignore all the rest"
);
127
break
;
128
}
129
130
const
TileTTL1
* cinp = (*it);
131
Identifier
id
=cinp->
TTL1_ID
();
132
133
if
(
m_tileTBID
->is_tiletb(
id
)) {
134
m_side
[
m_nchan
]=
m_tileTBID
->type(
id
);
135
m_eta
[
m_nchan
]=
m_tileTBID
->channel(
id
);
136
m_phi
[
m_nchan
]=
m_tileTBID
->module(
id
);
137
}
else
{
138
m_side
[
m_nchan
]=
m_TT_ID
->pos_neg_z(
id
);
139
m_eta
[
m_nchan
]=
m_TT_ID
->eta(
id
);
140
m_phi
[
m_nchan
]=
m_TT_ID
->phi(
id
);
141
}
142
143
std::vector<float> samples = cinp->
fsamples
();
144
samples.resize(
m_nSamples
);
145
for
(
int
i=0;i<
m_nSamples
;++i)
146
m_samples
[
m_nchan
][i] = samples[i];
147
148
if
(
msgLvl
(MSG::VERBOSE)) {
149
msg
(MSG::VERBOSE) <<
" ichan="
<<
static_cast<
int
>
(
m_nchan
) <<
" "
150
<<
m_side
[
m_nchan
] <<
" /"
<<
m_eta
[
m_nchan
] <<
" /"
151
<<
m_phi
[
m_nchan
] <<
" samples="
;
152
153
for
(
int
i = 0; i <
m_nSamples
; ++i)
154
msg
(MSG::VERBOSE) << samples[i] <<
" "
;
155
156
msg
(MSG::VERBOSE) <<
endmsg
;
157
}
158
m_nchan
++;
159
}
160
161
// step3: commit ntuple
162
if
(
m_commitNtuple
) {
163
ATH_MSG_DEBUG
(
"Committing Ntuple"
);
164
CHECK
(
ntupleSvc
()->writeRecord(
m_ntuplePtr
) );
165
}
166
167
// Execution completed.
168
ATH_MSG_DEBUG
(
"execute() completed successfully"
);
169
return
StatusCode::SUCCESS;
170
}
171
172
//****************************************************************************
173
//* Finalize
174
//****************************************************************************
175
176
StatusCode
TileTTL1ToNtuple::finalize
()
177
{
178
ATH_MSG_INFO
(
"finalize() completed successfully"
);
179
return
StatusCode::SUCCESS;
180
}
181
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
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
CaloLVL1_ID.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
ntupleSvc
INTupleSvc * ntupleSvc()
Definition
ServiceAccessor.h:14
TileTTL1Container
TileContainer< TileTTL1 > TileTTL1Container
Definition
TileContainer.h:65
TileTTL1Container.h
TileTTL1ToNtuple.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
AthCommonAlgorithm< Gaudi::Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition
AthCommonMsg.h:30
AthCommonAlgorithm< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition
AthCommonMsg.h:24
TileContainer< TileTTL1 >::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
TileTTL1ToNtuple::m_TT_ID
const CaloLVL1_ID * m_TT_ID
Definition
TileTTL1ToNtuple.h:68
TileTTL1ToNtuple::m_ntupleID
std::string m_ntupleID
Definition
TileTTL1ToNtuple.h:52
TileTTL1ToNtuple::m_eta
NTuple::Array< int > m_eta
Definition
TileTTL1ToNtuple.h:61
TileTTL1ToNtuple::m_tileTBID
const TileTBID * m_tileTBID
Definition
TileTTL1ToNtuple.h:69
TileTTL1ToNtuple::m_nSamples
int m_nSamples
Definition
TileTTL1ToNtuple.h:56
TileTTL1ToNtuple::m_commitNtuple
bool m_commitNtuple
Definition
TileTTL1ToNtuple.h:54
TileTTL1ToNtuple::m_samples
NTuple::Matrix< float > m_samples
Definition
TileTTL1ToNtuple.h:64
TileTTL1ToNtuple::m_ntuplePtr
NTuple::Tuple * m_ntuplePtr
Definition
TileTTL1ToNtuple.h:51
TileTTL1ToNtuple::m_side
NTuple::Array< int > m_side
Definition
TileTTL1ToNtuple.h:60
TileTTL1ToNtuple::m_ntupleLoc
std::string m_ntupleLoc
Definition
TileTTL1ToNtuple.h:53
TileTTL1ToNtuple::execute
StatusCode execute(const EventContext &ctx)
Execute method.
Definition
TileTTL1ToNtuple.cxx:110
TileTTL1ToNtuple::m_ttl1Container
std::string m_ttl1Container
Definition
TileTTL1ToNtuple.h:66
TileTTL1ToNtuple::m_maxLength
int m_maxLength
Definition
TileTTL1ToNtuple.h:55
TileTTL1ToNtuple::finalize
StatusCode finalize()
Definition
TileTTL1ToNtuple.cxx:176
TileTTL1ToNtuple::m_phi
NTuple::Array< int > m_phi
Definition
TileTTL1ToNtuple.h:62
TileTTL1ToNtuple::TileTTL1ToNtuple
TileTTL1ToNtuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition
TileTTL1ToNtuple.cxx:35
TileTTL1ToNtuple::~TileTTL1ToNtuple
virtual ~TileTTL1ToNtuple()
Definition
TileTTL1ToNtuple.cxx:53
TileTTL1ToNtuple::m_nchan
NTuple::Item< int > m_nchan
Definition
TileTTL1ToNtuple.h:58
TileTTL1ToNtuple::initialize
StatusCode initialize()
Definition
TileTTL1ToNtuple.cxx:61
TileTTL1
Definition
TileTTL1.h:26
TileTTL1::TTL1_ID
const Identifier & TTL1_ID() const
Definition
TileTTL1.cxx:66
TileTTL1::fsamples
const std::vector< float > & fsamples() const
Definition
TileTTL1.cxx:77
Identifier
Definition
IdentifierFieldParser.cxx:14
Generated on
for ATLAS Offline Software by
1.17.0