ATLAS Offline Software
Loading...
Searching...
No Matches
LArAutoCorrAlgToDB.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
7 NAME: LArAutoCorrAlgToDB.cxx
8 PACKAGE: LArCalorimeter/LArCalibUtils
9
10 AUTHORS: P. Strizenec, based on Tool by G. Unal
11
12 PURPOSE: write LArAutoCorr in Database from LArAutoCorrTotal conditions object
13
14********************************************************************/
15
16// Include files
20
21
22LArAutoCorrAlgToDB::LArAutoCorrAlgToDB(const std::string& name, ISvcLocator* pSvcLocator)
23 : AthAlgorithm(name, pSvcLocator),
24 m_onlineHelper(nullptr)
25{
26 declareProperty("GroupingType", m_groupingType="ExtendedFeedThrough");
27 declareProperty("OutAutoCorrKey", m_acContName="LArPhysAutoCorr");
28 declareProperty("isSC",m_isSC=false);
29 declareProperty("NMinbias", m_nMinbias);
30}
31
32
34= default;
35
36//----------------------------------------------------------------------------
38{
39 StatusCode sc;
40 if ( m_isSC ) {
41 const LArOnline_SuperCellID* ll;
42 sc = detStore()->retrieve(ll, "LArOnline_SuperCellID");
43 if (sc.isFailure()) {
44 ATH_MSG_ERROR( "Could not get LArOnlineID helper !" );
45 return StatusCode::FAILURE;
46 }
47 else {
48 m_onlineHelper = static_cast<const LArOnlineID_Base*>(ll);
49 ATH_MSG_DEBUG("Found the LArOnlineID helper");
50 }
51 m_nGains=1;
52 } else { // m_isSC
53 const LArOnlineID* ll;
54 sc = detStore()->retrieve(ll, "LArOnlineID");
55 if (sc.isFailure()) {
56 ATH_MSG_ERROR( "Could not get LArOnlineID helper !" );
57 return StatusCode::FAILURE;
58 }
59 else {
60 m_onlineHelper = static_cast<const LArOnlineID_Base*>(ll);
61 ATH_MSG_DEBUG(" Found the LArOnlineID helper. ");
62 }
64 }
65
66 ATH_CHECK( m_autocorrKey.initialize() );
67 return StatusCode::SUCCESS;
68}
69
70//---------------------------------------------------------------------------
72
73 ATH_MSG_INFO ( ">>> stop()" );
74
75 // ReadHandle setup
77 const LArAutoCorrTotal *acTotal = *acHdl;
78 if(!acTotal) {
79 ATH_MSG_ERROR("Could not read LArAutoCorrTotal with key " <<m_autocorrKey.key()<<" from ConditionsStore");
80 return StatusCode::FAILURE;
81 }
82
83 auto larAutoCorrComplete = std::make_unique<LArAutoCorrComplete>();
84 // Initialize LArAutoCorrComplete
85 ATH_CHECK( larAutoCorrComplete->setGroupingType(m_groupingType,msg()) );
86 ATH_CHECK( larAutoCorrComplete->initialize() );
87
88 //Loop over gains
89 for (unsigned igain=0;igain<m_nGains;igain++) {
91 //Loop over cells
92 std::vector<HWIdentifier>::const_iterator it =m_onlineHelper->channel_begin();
93 std::vector<HWIdentifier>::const_iterator it_e =m_onlineHelper->channel_end();
94 unsigned nSkipped=0;
95 unsigned nDone=0;
96 for(;it!=it_e;++it) {
97
98 HWIdentifier chid = (*it);
99
100 const std::vector<double> AutoCorr = acTotal->autoCorrTotal(chid,igain,m_nMinbias);
101 // Not to process channels not existing in input elec. autocorr. DB
102 if(AutoCorr.size() < 2 || (AutoCorr[0]==0. && AutoCorr[1]==0.)) {
103 ++nSkipped;
104 continue;
105 }
106 const std::vector<double> rmsSampl = acTotal->samplRMS(chid,igain,m_nMinbias);
107 unsigned int nsamples_AC = (1+((int)(sqrt(1+8*AutoCorr.size()))))/2;
108
109 std::vector<float> cov;
110 unsigned int ntot = nsamples_AC*(nsamples_AC+1) / 2;
111 cov.resize(ntot,0.);
112
113 unsigned int k=0;
114 for (unsigned i=0;i<nsamples_AC;i++) {
115 for (unsigned j=i;j<nsamples_AC;j++,k++) {
116 double AC;
117 if (i==j) {
118 AC=1.;
119 }
120 else {
121 int i1=std::min(i,j);
122 int i2=std::max(i,j);
123 int index = i1*nsamples_AC - i1*(i1+1)/2 -(i1+1) + i2;
124 AC=AutoCorr[index];
125 }
126 AC = AC*rmsSampl[i]*rmsSampl[j];
127 cov[k] = AC;
128 }
129 }
130
131 larAutoCorrComplete->set(chid,gain,cov);
132 ++nDone;
133 }//end loop over all cells
134 ATH_MSG_INFO ( "Gain " << gain << ": " << nDone << " channels done, " << nSkipped << " channels skipped (no Elec Noise AC in input)" );
135 }//end loop over gains
136
137 // Record LArAutoCorrComplete
138 ATH_CHECK( detStore()->record(std::move(larAutoCorrComplete),m_acContName) );
139 ATH_MSG_INFO ( "Recorded LArAutCorrComplete object with key " << m_acContName );
142
143 return StatusCode::SUCCESS;
144}
145
146
147
148
149
150
151
152
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
MsgStream & msg() const
LArAutoCorrAlgToDB(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadCondHandleKey< LArAutoCorrTotal > m_autocorrKey
const LArOnlineID_Base * m_onlineHelper
const std::vector< double > autoCorrTotal(const IdentifierHash &hid, int gain, float Nminbias) const
const std::vector< double > samplRMS(const IdentifierHash &hid, int gain, float Nminbias) const
Helper for the Liquid Argon Calorimeter cell identifiers.
@ LARNGAIN
Definition CaloGain.h:19
-event-from-file
Definition index.py:1