ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArCalibUtils
src
LArRampFCalCorr.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
//
7
// LArRampFCalCorr.cxx - Algorithm to normalize FCal Ramps and correct
8
// for baseplane faults.
9
//
10
// Author: Alan Robinson <fbfree@interchange.ubc.ca>
11
// Created: August 28, 2007
12
//
13
//***************************************************************************
14
15
#include "GaudiKernel/MsgStream.h"
16
#include "GaudiKernel/ISvcLocator.h"
17
18
#include "
Identifier/IdentifierHash.h
"
19
20
#include "
CaloIdentifier/CaloGain.h
"
21
22
#include "
LArCalibUtils/LArRampFCalCorr.h
"
23
#include "
LArIdentifier/LArOnlineID.h
"
24
#include "
LArRawConditions/LArRampComplete.h
"
25
26
#include "
StoreGate/StoreGateSvc.h
"
27
#include <cmath>
28
using
std::pow;
29
30
LArRampFCalCorr::LArRampFCalCorr
(
const
std::string& name,ISvcLocator* pSvcLocator)
31
:
AthAlgorithm
(name, pSvcLocator),
32
m_onlineHelper
(nullptr)
33
{
34
declareProperty
(
"Threshold"
,
m_threshold
= 1.0);
// Baseplane problem threshold at HIGH gain.
35
}
36
37
LArRampFCalCorr::~LArRampFCalCorr
() =
default
;
38
39
StatusCode
LArRampFCalCorr::initialize
(){
40
ATH_MSG_DEBUG
(
" in initialize() "
);
41
ATH_CHECK
(
detStore
()->retrieve(
m_onlineHelper
,
"LArOnlineID"
) );
42
return
StatusCode::SUCCESS;
43
}
44
45
StatusCode
LArRampFCalCorr::execute
(
const
EventContext&
/*ctx*/
) {
return
StatusCode::SUCCESS;}
46
47
StatusCode
LArRampFCalCorr::stop
(){
48
49
ATH_MSG_DEBUG
(
" in stop() "
);
50
51
const
LArRampComplete
* ramp =
nullptr
;
52
ATH_CHECK
(
detStore
()->retrieve(ramp) );
53
ATH_MSG_DEBUG
(
"found LarRampComplete"
);
54
55
HWIdentifier
chid;
56
std::vector<int> badChan;
57
int
channel{},
module
{};
58
int
slot = 0;
59
double
avg[3];
60
int
numChan[3];
61
// float gainRatio[3] = {1, 9.3, 93}; // Gain ratio high:medium:low
62
63
for
(
int
gain = 0 ; gain < 3 ; gain++ ){
// loop on possible gains
64
badChan.clear();
65
66
for
(
int
i=0; i<3; i++){
67
avg[i] = 0.; numChan[i] = 0;
68
}
69
70
// Flag bad channels
71
for
(
LArRampIt
it = ramp->
begin
(gain); it != ramp->
end
(gain); ++it) {
72
chid = it.channelId();
73
module
= LArRampFCalCorr::toMod(slot);
74
if
(it->m_vRamp.size() != 2 || !
m_onlineHelper
->isFCALchannel(chid)
75
|| module == -1)
continue
;
76
slot =
m_onlineHelper
->slot(chid);
77
channel =
m_onlineHelper
->channel(chid);
78
ATH_MSG_VERBOSE
( slot <<
" "
<< channel );
79
if
(it->m_vRamp[1] >
m_threshold
*std::pow(10.0,(
int
)gain)){
// Note: ramp contains inverse of slope. Therefore, baseplane problems have a high value.
80
ATH_MSG_DEBUG
(
"Bad chan: slot"
<< slot <<
" chan: "
<< channel
81
<<
" amp "
<< it->m_vRamp[1] );
82
badChan.push_back(channel);
// Record baseplane faults.
83
}
84
}
85
86
// Create normalization average
87
for
(
LArRampIt
it = ramp->
begin
(gain); it != ramp->
end
(gain); ++it) {
88
chid = it.channelId();
89
module
= LArRampFCalCorr::toMod(slot);
90
if
(it->m_vRamp.size() != 2 || !
m_onlineHelper
->isFCALchannel(chid)
91
|| module == -1)
continue
;
92
slot =
m_onlineHelper
->slot(chid);
93
channel =
m_onlineHelper
->channel(chid);
94
if
(std::find(badChan.begin(), badChan.end(), channel)==badChan.end()){
// If this calib line doen't have a baseplane fault.
95
avg[module] += 1.0 / it->m_vRamp[1];
96
numChan[module]++;
97
}
98
}
99
100
for
(
int
i=0; i<3; i++)
// Average slope over each module
101
if
(numChan[i] != 0 && avg[i] != 0.0)
102
avg[i] /= numChan[i];
// avg[i] *= gainRatio[gain] / numChan[i];
103
else
104
avg[i] = 1.0;
// avg[i] = gainRatio[gain];
105
106
ATH_MSG_DEBUG
(
"Averages modules 1: "
<< avg[0] <<
" 2: "
<< avg[1]
107
<<
" 3: "
<< avg[2] );
108
ATH_MSG_DEBUG
(
"NumChan modules 1: "
<< numChan[0] <<
" 2: "
<< numChan[1]
109
<<
" 3: "
<< numChan[2] );
110
111
// Apply corrections
112
for
(
LArRampIt
it = ramp->
begin
(gain); it != ramp->
end
(gain); ++it) {
113
chid = it.channelId();
114
module
= LArRampFCalCorr::toMod(slot);
115
if
(it->m_vRamp.size() == 2 &&
m_onlineHelper
->isFCALchannel(chid) && module != -1){
116
//LArRampP& rampP = const_cast<LArRampP&> (*it); // avoid direct use of payload object!
117
LArRampComplete::LArCondObj
& rampP =
const_cast<
LArRampComplete::LArCondObj
&
>
(*it);
118
slot =
m_onlineHelper
->slot(chid);
119
channel =
m_onlineHelper
->channel(chid);
120
if
(std::find(badChan.begin(), badChan.end(), channel)==badChan.end())
121
rampP.
m_vRamp
[1] *= avg[module];
// Normalize the ramp
122
else
if
(rampP.
m_vRamp
[1] >
m_threshold
*pow(10.,gain))
123
rampP.
m_vRamp
[1] = 1.0;
// Write default value
124
else
125
rampP.
m_vRamp
[1] *= 1.027 * avg[module];
// Correct the amplitude and normalize
126
}
else
127
ATH_MSG_DEBUG
(
"Channel 0x"
<< std::hex << chid << std::dec
128
<<
" Slot "
<< slot <<
" Chan "
<< channel
129
<<
" No normalization applied."
);
130
//larRampComplete->set(chid, gain, rampP.m_vRamp); // Rerecords all channels. Including those not normalized
131
}
132
}
// end loop over gains
133
ATH_MSG_INFO
(
"Completed LArRampFCalCorr"
);
134
135
return
StatusCode::SUCCESS;
136
}
137
138
// Map slot number to an FCal module
139
int
LArRampFCalCorr::toMod
(
int
& slot){
140
if
(slot == 9 || (slot > 0 && slot < 8))
141
return
0;
142
else
if
(slot >= 10 && slot < 14)
143
return
1;
144
else
if
(slot == 14 || slot == 15)
145
return
2;
146
else
return
-1;
147
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
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_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
CaloGain.h
IdentifierHash.h
LArOnlineID.h
LArRampComplete.h
LArRampFCalCorr.h
StoreGateSvc.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 >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
HWIdentifier
Definition
HWIdentifier.h:13
LArConditionsContainer::begin
ConstConditionsMapIterator begin(unsigned int gain) const
get iterator for all channels for a gain
LArConditionsContainer::end
ConstConditionsMapIterator end(unsigned int gain) const
end of all channels for this gain
LArConditionsContainer< LArRampP1 >::LArCondObj
LArRampP1 LArCondObj
Definition
LArConditionsContainer.h:69
LArRampComplete
Definition
LArRampComplete.h:50
LArRampFCalCorr::LArRampIt
LArRampComplete::ConstConditionsMapIterator LArRampIt
Definition
LArRampFCalCorr.h:31
LArRampFCalCorr::stop
StatusCode stop()
Definition
LArRampFCalCorr.cxx:47
LArRampFCalCorr::m_onlineHelper
const LArOnlineID * m_onlineHelper
Definition
LArRampFCalCorr.h:42
LArRampFCalCorr::~LArRampFCalCorr
~LArRampFCalCorr()
LArRampFCalCorr::toMod
static int toMod(int &slot)
Definition
LArRampFCalCorr.cxx:139
LArRampFCalCorr::LArRampFCalCorr
LArRampFCalCorr(const std::string &name, ISvcLocator *pSvcLocator)
Definition
LArRampFCalCorr.cxx:30
LArRampFCalCorr::initialize
StatusCode initialize()
Definition
LArRampFCalCorr.cxx:39
LArRampFCalCorr::m_threshold
float m_threshold
Definition
LArRampFCalCorr.h:44
LArRampFCalCorr::execute
StatusCode execute(const EventContext &ctx)
Execute method.
Definition
LArRampFCalCorr.cxx:45
LArRampP1::m_vRamp
std::vector< float > m_vRamp
Definition
LArRampP1.h:30
Generated on
for ATLAS Offline Software by
1.17.0