ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TileCalorimeter
TileRecAlgs
src
MBTSTimeDiffEventInfoAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// Tile includes
6
#include "
MBTSTimeDiffEventInfoAlg.h
"
7
#include "
TileIdentifier/TileTBID.h
"
8
9
// Atlas includes
10
#include "
StoreGate/ReadHandle.h
"
11
#include "
StoreGate/WriteHandle.h
"
12
#include "
AthenaKernel/errorcheck.h
"
13
14
#include <memory>
15
16
using
xAOD::EventInfo
;
17
18
/*
19
We have actually about five almost-identical copies of the code below in our repository.
20
I am adding now the sixth because I need it fast. But we should try to clean that up.
21
My suggestion: Adopt the strategy used by LAr, put a object in SG containing MBTS times
22
(and counts, possibly energies) usable by all clients.
23
*/
24
25
StatusCode
MBTSTimeDiffEventInfoAlg::initialize
() {
26
if
(
m_minHitsPerSide
== 0u) {
27
m_minHitsPerSide
= 1;
//Avoid div-by-zero later
28
}
29
30
ATH_MSG_INFO
(
"Initializing. MBTS_Threshold="
<<
m_mbts_threshold
31
<<
", MinHitsPerSide="
<<
m_minHitsPerSide
32
<<
", TimeDiffThreshold="
<<
m_timeDiffThreshold
);
33
34
CHECK
(
detStore
()->retrieve(
m_tileTBID
));
35
36
ATH_CHECK
(
m_mbtsContainerKey
.initialize() );
37
ATH_CHECK
(
m_eventInfoKey
.initialize() );
38
ATH_CHECK
(
m_mbtsCollisionTimeKey
.initialize() );
39
ATH_CHECK
(
m_eventInfoDecorKey
.initialize() );
40
41
return
StatusCode::SUCCESS;
42
}
43
44
45
StatusCode
MBTSTimeDiffEventInfoAlg::execute
(
const
EventContext& ctx)
const
{
46
47
SG::ReadHandle<xAOD::EventInfo>
eventInfo(
m_eventInfoKey
, ctx);
48
49
float
eneA = 0.F;
50
float
eneC = 0.F;
51
float
timeA = 0.F;
52
float
timeC = 0.F;
53
unsigned
countA = 0;
54
unsigned
countC = 0;
55
56
SG::ReadHandle<TileCellContainer>
mbtsContainer (
m_mbtsContainerKey
, ctx);
57
ATH_CHECK
( mbtsContainer.
isValid
() );
58
59
for
(
const
TileCell
* mbtsCell : *mbtsContainer) {
60
61
if
(mbtsCell->energy() <
m_mbts_threshold
)
continue
;
62
//Got cell above threshold
63
64
const
uint8_t qbit1 = mbtsCell->qbit1();
65
const
Identifier
&
id
= mbtsCell->ID();
66
67
if
(
msgLvl
(MSG::VERBOSE)) {
68
msg
(MSG::VERBOSE) <<
"Working on MBTS cell side="
<<
m_tileTBID
->type(
id
)
69
<<
" module_id="
<<
m_tileTBID
->module(
id
)
70
<<
" channel_id="
<<
m_tileTBID
->channel(
id
)
71
<<
" Energy="
<< mbtsCell->energy()
72
<<
" Time="
<< mbtsCell->time()
73
<<
" Qbit1="
<< (int) qbit1
74
<<
" Q1Mask(BC|OF|AP|TM)=["
<< ((qbit1 &
TileCell::MASK_BADCH
) != 0)
75
<<
"|"
<< ((qbit1 &
TileCell::MASK_OVER
) != 0) <<
"|"
76
<< ((qbit1 &
TileCell::MASK_AMPL
) != 0) <<
"|"
77
<< ((qbit1 &
TileCell::MASK_TIME
) != 0) <<
"] "
78
// << " Q2Mask(BC|OF|AP|TM)=[" << (qbit2 & TileCell::MASK_BADCH)==1 << "|" << (qbit2 & TileCell::MASK_OVER)==1 << "|"
79
// << (qbit2 & TileCell::MASK_AMPL) << "|" << (qbit2 & TileCell::MASK_TIME) << "]"
80
<<
endmsg
;
81
}
82
83
//Accept only cells with time computed, not known to be bad and no overflow:
84
if
((qbit1 &
m_mask
) !=
m_pattern
) {
85
ATH_MSG_DEBUG
(
"Rejected based on quality bits"
);
86
continue
;
87
}
88
89
// MBTS Id type is "side" +/- 1
90
const
int
type_id =
m_tileTBID
->type(
id
);
91
if
(type_id == 1) {
//A-side
92
eneA += mbtsCell->energy();
93
timeA += mbtsCell->time();
94
countA++;
95
}
else
if
(type_id == -1) {
//C-side
96
eneC += mbtsCell->energy();
97
timeC += mbtsCell->time();
98
countC++;
99
}
else
{
100
ATH_MSG_WARNING
(
"Unexpected 'side' from MBTS identifier "
);
101
continue
;
102
}
103
}
//end loop over MBTS cells
104
105
if
(countA > 0) timeA /= countA;
106
if
(countC > 0) timeC /= countC;
107
108
if
(countA >
m_minHitsPerSide
&& countC >
m_minHitsPerSide
) {
109
ATH_MSG_DEBUG
(
"Got MBTS cells above threshold on both sides"
);
110
const
float
timediff = fabs(timeA - timeC);
111
ATH_MSG_DEBUG
(
"Time diff "
<< timediff <<
"("
<<
m_timeDiffThreshold
<<
")"
);
112
113
if
(eventInfo.
isValid
()) {
114
if
(timediff >
m_timeDiffThreshold
) {
115
ATH_MSG_DEBUG
(
"Event identified as background, set bit 'MBTSTimeDiffHalo' in EventInfo Background word"
);
116
117
if
(eventInfo->updateEventFlagBit(
EventInfo::Background
,
118
EventInfo::MBTSTimeDiffHalo
) ==
false
)
119
120
ATH_MSG_WARNING
(
"Failed to set EventInfo Background word!"
);
121
}
else
{
//end if above theshold
122
ATH_MSG_DEBUG
(
"Event identified as collision, set bit 'MBTSTimeDiffCol' in EventInfo Background word"
);
123
124
if
(eventInfo->updateEventFlagBit(
EventInfo::Background
,
125
EventInfo::MBTSTimeDiffCol
) ==
false
)
126
ATH_MSG_WARNING
(
"Failed to set EventInfo Background word!"
);
127
}
//end if below threshold
128
}
else
{
129
ATH_MSG_WARNING
(
" cannot retrieve EventInfo, will not set Tile information "
);
130
}
131
}
else
{
132
ATH_MSG_DEBUG
(
"Not enough hits above threshold to distinguish halo from collision event"
);
133
}
134
135
SG::WriteHandle<MBTSCollisionTime>
mbtsTime(
m_mbtsCollisionTimeKey
, ctx);
136
137
if
(mbtsTime.
record
(std::make_unique<MBTSCollisionTime>(countA, countC, eneA, eneC, timeA, timeC)).isFailure()) {
138
ATH_MSG_WARNING
(
"Cannot record MBTSCollisionTime "
);
139
}
else
{
140
ATH_MSG_DEBUG
(
"MBTSCollisionTime recorded in event store"
);
141
ATH_MSG_DEBUG
(
" countA="
<< countA
142
<<
" countC="
<< countC
143
<<
" eneA="
<< eneA
144
<<
" eneC="
<< eneC
145
<<
" timeA="
<< timeA
146
<<
" timeC="
<< timeC );
147
}
148
149
return
StatusCode::SUCCESS;
150
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x,...)
Definition
AthMsgStreamMacros.h:43
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x,...)
Definition
AthMsgStreamMacros.h:46
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
MBTSTimeDiffEventInfoAlg.h
ReadHandle.h
Handle class for reading from StoreGate.
WriteHandle.h
Handle class for recording to StoreGate.
TileTBID.h
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
MBTSTimeDiffEventInfoAlg::m_mbts_threshold
Gaudi::Property< float > m_mbts_threshold
Definition
MBTSTimeDiffEventInfoAlg.h:39
MBTSTimeDiffEventInfoAlg::m_tileTBID
const TileTBID * m_tileTBID
Definition
MBTSTimeDiffEventInfoAlg.h:47
MBTSTimeDiffEventInfoAlg::m_mask
const uint8_t m_mask
Definition
MBTSTimeDiffEventInfoAlg.h:49
MBTSTimeDiffEventInfoAlg::m_eventInfoDecorKey
SG::WriteDecorHandleKey< xAOD::EventInfo > m_eventInfoDecorKey
Definition
MBTSTimeDiffEventInfoAlg.h:45
MBTSTimeDiffEventInfoAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm execute once per event.
Definition
MBTSTimeDiffEventInfoAlg.cxx:45
MBTSTimeDiffEventInfoAlg::m_timeDiffThreshold
Gaudi::Property< float > m_timeDiffThreshold
Definition
MBTSTimeDiffEventInfoAlg.h:35
MBTSTimeDiffEventInfoAlg::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition
MBTSTimeDiffEventInfoAlg.h:43
MBTSTimeDiffEventInfoAlg::m_pattern
const uint8_t m_pattern
Definition
MBTSTimeDiffEventInfoAlg.h:50
MBTSTimeDiffEventInfoAlg::initialize
virtual StatusCode initialize() override
Algorithm initialize at begin of job.
Definition
MBTSTimeDiffEventInfoAlg.cxx:25
MBTSTimeDiffEventInfoAlg::m_mbtsCollisionTimeKey
SG::WriteHandleKey< MBTSCollisionTime > m_mbtsCollisionTimeKey
Definition
MBTSTimeDiffEventInfoAlg.h:44
MBTSTimeDiffEventInfoAlg::m_mbtsContainerKey
SG::ReadHandleKey< TileCellContainer > m_mbtsContainerKey
Definition
MBTSTimeDiffEventInfoAlg.h:42
MBTSTimeDiffEventInfoAlg::m_minHitsPerSide
Gaudi::Property< unsigned int > m_minHitsPerSide
Definition
MBTSTimeDiffEventInfoAlg.h:37
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
TileCell
Definition
TileCell.h:57
TileCell::MASK_AMPL
@ MASK_AMPL
Definition
TileCell.h:65
TileCell::MASK_TIME
@ MASK_TIME
Definition
TileCell.h:67
TileCell::MASK_OVER
@ MASK_OVER
Definition
TileCell.h:64
TileCell::MASK_BADCH
@ MASK_BADCH
Definition
TileCell.h:63
xAOD::EventInfo_v1::Background
@ Background
The beam background detectors.
Definition
EventInfo_v1.h:340
xAOD::EventInfo_v1::MBTSTimeDiffCol
@ MBTSTimeDiffCol
Definition
EventInfo_v1.h:355
xAOD::EventInfo_v1::MBTSTimeDiffHalo
@ MBTSTimeDiffHalo
Definition
EventInfo_v1.h:354
Identifier
Definition
IdentifierFieldParser.cxx:14
xAOD::EventInfo
EventInfo_v1 EventInfo
Definition of the latest event info version.
Definition
IEventInfoCnvTool.h:16
Generated on
for ATLAS Offline Software by
1.17.0