ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArCellRec
src
LArCelldeadOTXTool.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
#include "
LArCelldeadOTXTool.h
"
6
7
#include "
CaloEvent/CaloCell.h
"
8
#include "
CaloEvent/CaloCellContainer.h
"
9
#include "
LArElecCalib/LArProvenance.h
"
10
11
StatusCode
LArCelldeadOTXTool::initialize
() {
12
13
ATH_CHECK
(
m_SCKey
.initialize());
14
ATH_CHECK
(
m_factors
.initialize());
15
16
if
(
m_testMode
) {
17
ATH_MSG_WARNING
(
18
"Test mode activated with additional debug output. Makes only sense if we try to patch a FEB that is actually there, so we have a reference"
);
19
}
20
21
return
StatusCode::SUCCESS;
22
}
23
24
StatusCode
LArCelldeadOTXTool::process
(
CaloCellContainer
* cellCollection,
const
EventContext& ctx)
const
{
25
26
ATH_MSG_VERBOSE
(
" in process..."
);
27
if
(!cellCollection) {
28
ATH_MSG_ERROR
(
"Cell Correction tool receives invalid cell Collection"
);
29
return
StatusCode::FAILURE;
30
}
31
32
if
(!(cellCollection->
hasCalo
(
CaloCell_ID::LAREM
) ||
33
cellCollection->
hasCalo
(
CaloCell_ID::LARHEC
) ||
34
cellCollection->
hasCalo
(
CaloCell_ID::LARFCAL
))) {
35
ATH_MSG_VERBOSE
(
"No LAr cell in CellContainer. Do nothing"
);
36
return
StatusCode::SUCCESS;
37
}
38
39
SG::ReadCondHandle<LArDeadOTXCorrFactors>
scToDeadHdl{
m_factors
,ctx};
40
const
LArDeadOTXCorrFactors::payload_t
& scToDead=scToDeadHdl->get();
41
if
(scToDead.empty()) {
42
return
StatusCode::SUCCESS;
// No dead FEBs, do nothing
43
}
44
45
// get SuperCellContainer
46
SG::ReadHandle<LArRawSCContainer>
scHdl(
m_SCKey
, ctx);
47
if
(!scHdl.
isValid
()) {
48
if
(msgLvl(MSG::WARNING) &&
m_nWarnings
< 5) {
49
ATH_MSG_WARNING
(
"Do not have SuperCell container no patching !!!!"
);
50
++
m_nWarnings
;
51
}
52
return
StatusCode::SUCCESS;
53
}
54
55
const
unsigned
int
bcid = ctx.eventID().bunch_crossing_id();
56
57
// get the SC, container is unordered, so have to loop
58
const
LArRawSCContainer
* scells = scHdl.
cptr
();
59
for
(
const
auto
*
sc
: *scells) {
60
if
(!
sc
)
61
continue
;
62
const
HWIdentifier
scHwid =
sc
->hardwareID();
63
auto
itr = scToDead.find(scHwid);
64
if
(itr == scToDead.end())
65
continue
;
// This SC is not connected to any deadFEB cell
66
67
const
std::vector<unsigned short>& bcids =
sc
->bcids();
68
const
std::vector<int>& energies =
sc
->energies();
69
const
std::vector<bool>& satur =
sc
->satur();
70
71
// Look for bcid:
72
float
scEne = 0;
73
const
size_t
nBCIDs = bcids.size();
74
size_t
i = 0;
75
for
(i = 0; i < nBCIDs && bcids[i] != bcid; i++)
76
;
77
78
if
(
ATH_LIKELY
(!satur[i]))
79
scEne = energies[i];
80
if
(scEne <
m_scCut
) {
81
ATH_MSG_VERBOSE
(
"SuperCell value "
<< scEne <<
" below threshold, ignoring"
);
82
continue
;
83
}
84
float
cellESum = 0;
85
float
patchEneSum = 0;
86
for
(
const
auto
& [
h
, convFactor] : itr->second) {
// Loop over all deadFEB cells connected to this SC
87
CaloCell
* cell = cellCollection->
findCell
(
h
);
88
if
(cell) {
89
const
float
patchEne = scEne * convFactor;
// Convert ET (coming from LATOMEs) into Energy
90
if
(
m_testMode
) {
91
cellESum += cell->energy();
92
patchEneSum += patchEne;
93
}
94
ATH_MSG_DEBUG
(
"Cell id 0x"
<< std::hex << cell->ID().get_identifier32().get_compact() <<
" Replacing energy "
<< cell->energy() <<
" "
<< patchEne
95
<<
", SCene="
<< scEne);
96
cell->setEnergy(patchEne);
97
cell->setProvenance(cell->provenance() |
LArProv::PATCHED
);
98
}
// end if cell obj found
99
}
// end loop over all deadFEB cells connected to this SC
100
if
(
m_testMode
) {
101
const
float
ratio = patchEneSum != 0 ? cellESum / patchEneSum : 0;
102
ATH_MSG_DEBUG
(
"ESums="
<< cellESum <<
"/"
<< patchEneSum <<
"="
<< ratio);
103
std::scoped_lock l(
m_mtx
);
104
auto
& entry = m_testMap[scEne];
105
entry.first += ratio;
106
entry.second++;
107
}
// end if testMode
108
}
// End loop over SuperCell container
109
110
return
StatusCode::SUCCESS;
111
}
112
113
114
StatusCode
LArCelldeadOTXTool::finalize
() {
115
if
(
m_testMode
) {
116
ATH_MSG_INFO
(
"Test mode for cell-patching:"
);
117
std::vector<std::pair<float, float> > avgList;
118
for
(
auto
& [scEne, entry] : m_testMap) {
119
avgList.emplace_back(scEne, entry.first / entry.second);
120
}
121
auto
ordering = [](
const
std::pair<float, float>&
a
, std::pair<float, float>& b) {
return
(
a
.first < b.first); };
122
std::sort
(avgList.begin(), avgList.end(), ordering);
123
for
(
auto
& p : avgList) {
124
ATH_MSG_INFO
(
"SCEne="
<< p.first <<
"Avg patching ratio="
<< p.second);
125
}
126
}
127
return
StatusCode::SUCCESS;
128
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
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
ATH_LIKELY
#define ATH_LIKELY(x)
Definition
AthUnlikelyMacros.h:16
CaloCellContainer.h
CaloCell.h
LArCelldeadOTXTool.h
a
static Double_t a
Definition
LArPhysWaveHECTool.cxx:38
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
LArProvenance.h
h
Header file for AthHistogramAlgorithm.
CaloCellContainer
Container class for CaloCell.
Definition
CaloCellContainer.h:55
CaloCellContainer::findCell
const CaloCell * findCell(const IdentifierHash theHash) const
fast find method given identifier hash.
Definition
CaloCellContainer.cxx:345
CaloCellContainer::hasCalo
bool hasCalo(const CaloCell_ID::SUBCALO caloNum) const
tell wether it has been filled with cells (maybe none) of a given calo
Definition
CaloCellContainer.cxx:209
CaloCell_Base_ID::LAREM
@ LAREM
Definition
CaloCell_Base_ID.h:45
CaloCell_Base_ID::LARFCAL
@ LARFCAL
Definition
CaloCell_Base_ID.h:45
CaloCell_Base_ID::LARHEC
@ LARHEC
Definition
CaloCell_Base_ID.h:45
CaloCell
Data object for each calorimeter readout cell.
Definition
CaloCell.h:57
HWIdentifier
Definition
HWIdentifier.h:13
LArCelldeadOTXTool::m_mtx
std::mutex m_mtx
Definition
LArCelldeadOTXTool.h:36
LArCelldeadOTXTool::m_SCKey
SG::ReadHandleKey< LArRawSCContainer > m_SCKey
Definition
LArCelldeadOTXTool.h:30
LArCelldeadOTXTool::m_testMode
Gaudi::Property< bool > m_testMode
Definition
LArCelldeadOTXTool.h:33
LArCelldeadOTXTool::finalize
virtual StatusCode finalize() override final
Definition
LArCelldeadOTXTool.cxx:114
LArCelldeadOTXTool::process
virtual StatusCode process(CaloCellContainer *cellCollection, const EventContext &ctx) const override final
Definition
LArCelldeadOTXTool.cxx:24
LArCelldeadOTXTool::initialize
virtual StatusCode initialize() override final
Definition
LArCelldeadOTXTool.cxx:11
LArCelldeadOTXTool::m_nWarnings
std::atomic< int > m_nWarnings
Definition
LArCelldeadOTXTool.h:38
LArCelldeadOTXTool::m_scCut
Gaudi::Property< int > m_scCut
Definition
LArCelldeadOTXTool.h:32
LArCelldeadOTXTool::m_factors
SG::ReadCondHandleKey< LArDeadOTXCorrFactors > m_factors
Definition
LArCelldeadOTXTool.h:31
LArDeadOTXCorrFactors::payload_t
std::map< HWIdentifier, std::vector< std::pair< IdentifierHash, float > > > payload_t
Definition
LArDeadOTXCorrFactors.h:19
LArRawSCContainer
Container class for LArRawSC.
Definition
LArRawSCContainer.h:17
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
LArProv::PATCHED
@ PATCHED
Definition
LArProvenance.h:21
std::sort
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Definition
DVL_algorithms.h:554
Generated on
for ATLAS Offline Software by
1.17.0