ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TileCalorimeter
TileRec
src
TileMuonReceiverDecisionToNtuple.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 : TileMuonReceiverDecisionToNtuple.cxx
7
// Author : Joao Gentil Saraiva <jmendes@lxplus.cern.ch>
8
// Created : April 2014
9
//
10
// DESCRIPTION:
11
// Produce a simple output of a container into a ntuple
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
// TileCal include
29
//
30
#include "
TileEvent/TileContainer.h
"
31
32
// header
33
//
34
#include "
TileRec/TileMuonReceiverDecisionToNtuple.h
"
35
36
// set a limit to the dimension of nt vectors
37
//
38
//const int max_inputs=128; // this is the maximum possible number of inputs for the
39
// current configuration of tile-d trigger i.e. 1 input per EB module (2x64)
40
41
// Constructor
42
TileMuonReceiverDecisionToNtuple::TileMuonReceiverDecisionToNtuple
(
const
std::string& name, ISvcLocator* pSvcLocator)
43
:
AthAlgorithm
(name, pSvcLocator)
44
,
m_ntuplePtr
(0)
45
,
m_ntupleID
(
"TileMuRcvNt"
)
// usualy it is a number hxxx, but here we use a name
46
,
m_ntupleLoc
(
"/FILE1"
)
47
,
m_TileMuRcvContainer
(
"TileMuRcvCnt"
)
48
{
49
declareProperty
(
"TileMuonReceiverContainer"
,
m_TileMuRcvContainer
);
50
declareProperty
(
"NTupleLoc"
,
m_ntupleLoc
);
51
declareProperty
(
"NTupleID"
,
m_ntupleID
);
52
declareProperty
(
"NDecisionBits"
,
m_nBits
=4);
53
declareProperty
(
"NMaxTrigInputs"
,
m_nMaxTrigInputs
=128);
54
}
55
56
57
// Destructor
58
TileMuonReceiverDecisionToNtuple::~TileMuonReceiverDecisionToNtuple
()
59
{
60
}
61
62
63
64
// Initialize
65
//
66
StatusCode
TileMuonReceiverDecisionToNtuple::initialize
()
67
{
68
ATH_MSG_INFO
(
"TileMuonReceiverDecisionToNtuple::initialize begins"
);
69
70
m_ntupleLoc
=
"/NTUPLES"
+
m_ntupleLoc
;
71
72
SmartDataPtr<NTuple::Directory> DirPtr(
ntupleSvc
(),
m_ntupleLoc
);
73
74
if
(!DirPtr) DirPtr=
ntupleSvc
()->createDirectory(
m_ntupleLoc
);
75
if
(!DirPtr) {
76
ATH_MSG_ERROR
(
"Invalid Ntuple Directory: "
);
77
return
StatusCode::FAILURE;
78
}
79
80
m_ntuplePtr
=
ntupleSvc
()->book(DirPtr.ptr(),
m_ntupleID
,
81
CLID_ColumnWiseTuple,
"Tile Muon Receiver Ntuple"
);
82
// if(!m_ntuplePtr) {
83
84
// std::string ntupleCompleteID=m_ntupleLoc+"/"+m_ntupleID;
85
86
// NTuplePtr nt(ntupleSvc(),ntupleCompleteID);
87
// if (!nt) {
88
// ATH_MSG_ERROR( "Failed to book or to retrieve ntuple "
89
// << ntupleCompleteID );
90
// return StatusCode::FAILURE;
91
// } else {
92
// ATH_MSG_INFO( "Reaccessing ntuple " << ntupleCompleteID );
93
// m_ntuplePtr = nt;
94
// }
95
// }
96
97
//
98
// The container has an object for each module in a extended barrel partition. Are expected 128 entries per event.
99
//
100
// For each entry i will have :
101
// - thresholds (?) 4 (Global will be equal for all entries) | one vector for each event -> 128 id's
102
// - decision ... NTuple::Matrix ?
103
// - d6 energy, d6 time
104
// d5+d6 energy, d5+d6 time | one vector combines each qty for each id -> NTuple::Array for ech qty
105
// - id mod and part | id is a convoluted number combining part and mod eg 356 part:3 mod:56 -> NTuple::Array for ech qty
106
//
107
108
CHECK
(
m_ntuplePtr
->addItem(
"TileMuRcv/nTrigInputs"
,
m_nTrigInput
,0,
m_nMaxTrigInputs
) );
109
CHECK
(
m_ntuplePtr
->addItem(
"TileMuRcv/trigThr_Hi_D5andD6"
,
m_thershold_hi_d5andd6
) );
110
CHECK
(
m_ntuplePtr
->addItem(
"TileMuRcv/trigThr_Lo_D5andD6"
,
m_thershold_lo_d5andd6
) );
111
CHECK
(
m_ntuplePtr
->addItem(
"TileMuRcv/trigThr_Hi_D6"
,
m_thershold_hi_d6
) );
112
CHECK
(
m_ntuplePtr
->addItem(
"TileMuRcv/trigThr_Lo_D6"
,
m_thershold_lo_d6
) );
113
CHECK
(
m_ntuplePtr
->addItem(
"TileMuRcv/t_D5andD6"
,
m_nTrigInput
,
m_time_D5andD6
) );
114
CHECK
(
m_ntuplePtr
->addItem(
"TileMuRcv/t_D6"
,
m_nTrigInput
,
m_time_D6
) );
115
CHECK
(
m_ntuplePtr
->addItem(
"TileMuRcv/e_D5andD6"
,
m_nTrigInput
,
m_energy_D5andD6
) );
116
CHECK
(
m_ntuplePtr
->addItem(
"TileMuRcv/e_D6"
,
m_nTrigInput
,
m_energy_D6
) );
117
CHECK
(
m_ntuplePtr
->addItem(
"TileMuRcv/mod"
,
m_nTrigInput
,
m_module
) );
118
CHECK
(
m_ntuplePtr
->addItem(
"TileMuRcv/part"
,
m_nTrigInput
,
m_partition
) );
119
CHECK
(
m_ntuplePtr
->addItem(
"TileMuRcv/d_tile2tgcSL_bit0"
,
m_nTrigInput
,
m_trigbit0
) );
120
CHECK
(
m_ntuplePtr
->addItem(
"TileMuRcv/d_tile2tgcSL_bit1"
,
m_nTrigInput
,
m_trigbit1
) );
121
CHECK
(
m_ntuplePtr
->addItem(
"TileMuRcv/d_tile2tgcSL_bit2"
,
m_nTrigInput
,
m_trigbit2
) );
122
CHECK
(
m_ntuplePtr
->addItem(
"TileMuRcv/d_tile2tgcSL_bit3"
,
m_nTrigInput
,
m_trigbit3
) );
123
124
125
// ATH_MSG_INFO( "Initialization completed" );
126
return
StatusCode::SUCCESS;
127
}
128
129
// execute
130
StatusCode
TileMuonReceiverDecisionToNtuple::execute
(
const
EventContext&
/*ctx*/
)
131
{
132
// step1: read container and declare temporary vectors
133
//
134
const
TileMuonReceiverContainer
*TileMuRcvCnt =
nullptr
;
135
CHECK
(
evtStore
()->retrieve(TileMuRcvCnt,
m_TileMuRcvContainer
) );
136
137
// step2: to fill items in ntuple
138
//
139
TileMuonReceiverContainer::const_iterator
it = TileMuRcvCnt->
begin
();
140
TileMuonReceiverContainer::const_iterator
end = TileMuRcvCnt->
end
();
141
142
ATH_MSG_INFO
(
"Size of the container "
<< TileMuRcvCnt->
size
() );
143
144
if
(it!=end){
145
// the first entry in the container are the thresholds and was wrote like that to avoid
146
// replicating this information in every element of the collection so to avoid other errors
147
//
148
const
std::vector<float> & thresh = (*it)->GetThresholds();
149
++it;
150
151
if
(thresh.size()==4){
152
ATH_MSG_VERBOSE
(
" thresholds: "
<< thresh[0] <<
" "
<< thresh[1] <<
" "
<< thresh[2] <<
" "
<< thresh[3] );
153
m_thershold_hi_d5andd6
= thresh[0];
154
m_thershold_lo_d5andd6
= thresh[1];
155
m_thershold_hi_d6
= thresh[2];
156
m_thershold_lo_d6
= thresh[3];
157
}
else
{
158
ATH_MSG_WARNING
(
" unexpected thresholds vector size: "
<< thresh.size());
159
m_thershold_hi_d5andd6
= -1000.;
160
m_thershold_lo_d5andd6
= -1000.;
161
m_thershold_hi_d6
= -1000.;
162
m_thershold_lo_d6
= -1000.;
163
}
164
}
else
{
165
ATH_MSG_DEBUG
(
" no thresholds available"
);
166
m_thershold_hi_d5andd6
= -1000.;
167
m_thershold_lo_d5andd6
= -1000.;
168
m_thershold_hi_d6
= -1000.;
169
m_thershold_lo_d6
= -1000.;
170
}
171
172
m_nTrigInput
=0;
173
174
for
(; it != end; ++it) {
175
176
if
(
m_nTrigInput
>=
m_nMaxTrigInputs
) {
177
ATH_MSG_WARNING
(
" Number of input objects exceeds max size = "
<<
m_nMaxTrigInputs
);
178
break
;
179
}
180
181
const
TileMuonReceiverObj
* obj = (*it);
182
183
// going over the collection of inputs to the L1Muon
184
//
185
// (1) ID
186
187
int
id
= obj->GetID();
188
int
part =
id
/100;
189
int
module =
id
- 100*part;
190
m_partition
[
m_nTrigInput
] = part;
191
m_module
[
m_nTrigInput
] =
module
;
192
if
(
id
>0) {
193
ATH_MSG_DEBUG
(
" index: "
<<
m_nTrigInput
<<
" id: "
<<
id
<<
" - "
<< ((part<4)?
"EBA"
:
"EBC"
) <<
" "
<< module);
194
}
else
{
195
ATH_MSG_WARNING
(
" index: "
<<
m_nTrigInput
<<
" unexpected id: "
<<
id
);
196
}
197
198
// (2) Energy
199
200
const
std::vector<float> & ene = obj->GetEne();
201
202
if
(ene.size()==2){
203
ATH_MSG_VERBOSE
(
" energy: "
<< ene[0] <<
" "
<< ene[1]);
204
m_energy_D5andD6
[
m_nTrigInput
] = ene[0];
205
m_energy_D6
[
m_nTrigInput
] = ene[1];
206
}
else
{
207
ATH_MSG_WARNING
(
" unexpected energy vector size: "
<< ene.size());
208
m_energy_D5andD6
[
m_nTrigInput
] = -1000.;
209
m_energy_D6
[
m_nTrigInput
] = -1000.;
210
}
211
212
// (3) Time d6:t1+t2/2 d5+d6:t1+t2+t3+t4/4
213
214
const
std::vector<float> & time = obj->GetTime();
215
216
if
(time.size()==2){
217
ATH_MSG_VERBOSE
(
" time: "
<< time[0] <<
" "
<< time[1] );
218
m_time_D5andD6
[
m_nTrigInput
] = time[0];
219
m_time_D6
[
m_nTrigInput
] = time[1];
220
}
else
{
221
ATH_MSG_WARNING
(
" unexpected time vector size: "
<< time.size());
222
m_time_D5andD6
[
m_nTrigInput
] = -1000.;
223
m_time_D6
[
m_nTrigInput
] = -1000.;
224
}
225
226
// (4) decision
227
228
const
std::vector<bool> & decision = obj->GetDecision();
229
230
if
(decision.size()==4){
231
ATH_MSG_DEBUG
(
" decision: "
<< decision[0] <<
" "
<< decision[1] <<
" "
<< decision[2] <<
" "
<< decision[3]) ;
232
m_trigbit0
[
m_nTrigInput
] = decision[0];
// d5+d6 hi
233
m_trigbit1
[
m_nTrigInput
] = decision[1];
// d5+d6 lo
234
m_trigbit2
[
m_nTrigInput
] = decision[2];
// d6 hi
235
m_trigbit3
[
m_nTrigInput
] = decision[3];
// d6 lo is this right? Ie d6 lo is 0?
236
}
else
{
237
ATH_MSG_WARNING
(
" unexpected decision vector size: "
<< decision.size()) ;
238
m_trigbit0
[
m_nTrigInput
] =
false
;
239
m_trigbit1
[
m_nTrigInput
] =
false
;
240
m_trigbit2
[
m_nTrigInput
] =
false
;
241
m_trigbit3
[
m_nTrigInput
] =
false
;
242
}
243
244
m_nTrigInput
++;
245
}
246
247
ATH_MSG_INFO
(
" Number of inputs "
<<
m_nTrigInput
);
248
249
// step3: commit ntuple
250
//
251
CHECK
(
ntupleSvc
()->writeRecord(
m_ntuplePtr
) );
252
253
// Execution completed.
254
//
255
ATH_MSG_DEBUG
(
"execute() completed successfully"
);
256
return
StatusCode::SUCCESS;
257
}
258
259
// finalize
260
StatusCode
TileMuonReceiverDecisionToNtuple::finalize
()
261
{
262
ATH_MSG_INFO
(
"finalize() successfully"
);
263
return
StatusCode::SUCCESS;
264
}
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_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
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
ntupleSvc
INTupleSvc * ntupleSvc()
Definition
ServiceAccessor.h:14
TileContainer.h
TileMuonReceiverContainer
TileContainer< TileMuonReceiverObj > TileMuonReceiverContainer
Definition
TileContainer.h:71
TileMuonReceiverDecisionToNtuple.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
TileContainer< TileMuonReceiverObj >::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
DataVector< TELEMENT >::size
size_type size() const noexcept
TileMuonReceiverDecisionToNtuple::execute
StatusCode execute(const EventContext &ctx)
Execute method.
Definition
TileMuonReceiverDecisionToNtuple.cxx:130
TileMuonReceiverDecisionToNtuple::m_trigbit2
NTuple::Array< bool > m_trigbit2
Definition
TileMuonReceiverDecisionToNtuple.h:76
TileMuonReceiverDecisionToNtuple::m_TileMuRcvContainer
std::string m_TileMuRcvContainer
Definition
TileMuonReceiverDecisionToNtuple.h:82
TileMuonReceiverDecisionToNtuple::m_thershold_hi_d5andd6
NTuple::Item< float > m_thershold_hi_d5andd6
Definition
TileMuonReceiverDecisionToNtuple.h:69
TileMuonReceiverDecisionToNtuple::m_energy_D5andD6
NTuple::Array< float > m_energy_D5andD6
Definition
TileMuonReceiverDecisionToNtuple.h:64
TileMuonReceiverDecisionToNtuple::m_trigbit0
NTuple::Array< bool > m_trigbit0
Definition
TileMuonReceiverDecisionToNtuple.h:74
TileMuonReceiverDecisionToNtuple::m_thershold_lo_d6
NTuple::Item< float > m_thershold_lo_d6
Definition
TileMuonReceiverDecisionToNtuple.h:72
TileMuonReceiverDecisionToNtuple::m_time_D6
NTuple::Array< float > m_time_D6
Definition
TileMuonReceiverDecisionToNtuple.h:67
TileMuonReceiverDecisionToNtuple::m_trigbit1
NTuple::Array< bool > m_trigbit1
Definition
TileMuonReceiverDecisionToNtuple.h:75
TileMuonReceiverDecisionToNtuple::m_nMaxTrigInputs
int m_nMaxTrigInputs
Definition
TileMuonReceiverDecisionToNtuple.h:56
TileMuonReceiverDecisionToNtuple::m_ntupleID
std::string m_ntupleID
Definition
TileMuonReceiverDecisionToNtuple.h:53
TileMuonReceiverDecisionToNtuple::m_thershold_lo_d5andd6
NTuple::Item< float > m_thershold_lo_d5andd6
Definition
TileMuonReceiverDecisionToNtuple.h:70
TileMuonReceiverDecisionToNtuple::m_module
NTuple::Array< int > m_module
Definition
TileMuonReceiverDecisionToNtuple.h:62
TileMuonReceiverDecisionToNtuple::initialize
StatusCode initialize()
Definition
TileMuonReceiverDecisionToNtuple.cxx:66
TileMuonReceiverDecisionToNtuple::m_partition
NTuple::Array< int > m_partition
Definition
TileMuonReceiverDecisionToNtuple.h:61
TileMuonReceiverDecisionToNtuple::m_thershold_hi_d6
NTuple::Item< float > m_thershold_hi_d6
Definition
TileMuonReceiverDecisionToNtuple.h:71
TileMuonReceiverDecisionToNtuple::m_ntuplePtr
NTuple::Tuple * m_ntuplePtr
Definition
TileMuonReceiverDecisionToNtuple.h:52
TileMuonReceiverDecisionToNtuple::m_trigbit3
NTuple::Array< bool > m_trigbit3
Definition
TileMuonReceiverDecisionToNtuple.h:77
TileMuonReceiverDecisionToNtuple::m_nBits
int m_nBits
Definition
TileMuonReceiverDecisionToNtuple.h:57
TileMuonReceiverDecisionToNtuple::~TileMuonReceiverDecisionToNtuple
virtual ~TileMuonReceiverDecisionToNtuple()
Definition
TileMuonReceiverDecisionToNtuple.cxx:58
TileMuonReceiverDecisionToNtuple::m_ntupleLoc
std::string m_ntupleLoc
Definition
TileMuonReceiverDecisionToNtuple.h:54
TileMuonReceiverDecisionToNtuple::m_nTrigInput
NTuple::Item< int > m_nTrigInput
Definition
TileMuonReceiverDecisionToNtuple.h:60
TileMuonReceiverDecisionToNtuple::m_time_D5andD6
NTuple::Array< float > m_time_D5andD6
Definition
TileMuonReceiverDecisionToNtuple.h:66
TileMuonReceiverDecisionToNtuple::finalize
StatusCode finalize()
Definition
TileMuonReceiverDecisionToNtuple.cxx:260
TileMuonReceiverDecisionToNtuple::TileMuonReceiverDecisionToNtuple
TileMuonReceiverDecisionToNtuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition
TileMuonReceiverDecisionToNtuple.cxx:42
TileMuonReceiverDecisionToNtuple::m_energy_D6
NTuple::Array< float > m_energy_D6
Definition
TileMuonReceiverDecisionToNtuple.h:65
TileMuonReceiverObj
Definition
TileMuonReceiverObj.h:28
Generated on
for ATLAS Offline Software by
1.17.0