ATLAS Offline Software
Loading...
Searching...
No Matches
LArAutoCorrTotal.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
6
7#include <cassert>
8
10 const size_t nGains)
11 : m_onlineID(onlineID), m_cabling(cabling) {
12
13 assert(m_onlineID);
15
16 for (size_t i = 0; i < nGains; ++i) {
17 m_AutoCorrTotal[i].resize(onlineID->channelHashMax());
18 }
19}
20
22
23bool LArAutoCorrTotal::set(const IdentifierHash &hid, const int gain,
24 std::vector<float> &autocorrtotal) {
25 if (gain >= CaloGain::LARNGAIN || hid >= m_AutoCorrTotal[gain].size()) {
26 return false;
27 }
28
29 m_AutoCorrTotal[gain][hid].swap(autocorrtotal);
30 return true;
31}
32
33// *** compute AutoCorrTotal (nsamples-1 coeffs) for a given cell ***
34const std::vector<double>
35LArAutoCorrTotal::computeAutoCorr(const std::vector<float>& terms,
36 float Nminbias) const {
37
38 std::vector<double> vResult;
39 int tsize = int(sqrt(terms.size()));
40 int nsize_tot = (tsize - 1) * (tsize) / 2;
41 vResult.reserve(nsize_tot);
42 for (int i1 = 0; i1 < tsize - 1; i1++) {
43 for (int i2 = i1 + 1; i2 < tsize; i2++) {
44
45 int index = i1 * tsize - i1 * (i1 + 1) / 2 + i2 - (i1 + 1);
46
47 vResult.push_back((terms[index] + Nminbias * terms[nsize_tot + index]) /
48 sqrt((1. + Nminbias * terms[2 * nsize_tot + i1]) *
49 (1. + Nminbias * terms[2 * nsize_tot + i2])));
50 }
51 }
52 return (vResult);
53}
54
55// *** retrieve AutoCorrTotal (nsamples*(nsamples-1)/2 coeffs) for a given cell
56// ***
57const std::vector<double>
59 float Nminbias) const {
60 //FIXME we should check if the vector<float> of index "hid" exists before trying to compute it!
61 //but we already have resized the vector<vector<float>> to size channelHashMax in the ctor
62
63 return (this->computeAutoCorr(m_AutoCorrTotal[gain][hid], Nminbias));
64}
65
66const std::vector<double> LArAutoCorrTotal::autoCorrTotal(const HWIdentifier &hwid, int gain, float Nminbias) const {
67 const IdentifierHash hid = m_onlineID->channel_Hash(hwid);
68 return this->autoCorrTotal(hid, gain, Nminbias);
69}
70
71const std::vector<double> LArAutoCorrTotal::autoCorrTotal(const Identifier &offid, int gain, float Nminbias) const {
72 const HWIdentifier hwid = m_cabling->createSignalChannelID(offid);
73 return this->autoCorrTotal(hwid, gain, Nminbias);
74}
75
76const std::vector<double>
77LArAutoCorrTotal::computeRMS(const std::vector<float>& terms,
78 float Nminbias) const {
79
80 std::vector<double> vResult;
81 int tsize = int(sqrt(terms.size()));
82 vResult.reserve(tsize);
83 int nsize_tot = (tsize - 1) * (tsize) / 2;
84 for (int i = 0; i < tsize; i++) {
85 vResult.push_back(sqrt(1. + Nminbias * terms[2 * nsize_tot + i]));
86 }
87 return (vResult);
88}
89
90const std::vector<double> LArAutoCorrTotal::samplRMS(const IdentifierHash &hid,
91 int gain,
92 float Nminbias) const {
93 return (this->computeRMS(m_AutoCorrTotal[gain][hid], Nminbias));
94}
95
96const std::vector<double> LArAutoCorrTotal::samplRMS(const HWIdentifier &hwid,
97 int gain,
98 float Nminbias) const {
99 const IdentifierHash hid = m_onlineID->channel_Hash(hwid);
100 return this->samplRMS(hid, gain, Nminbias);
101}
102
103const std::vector<double> LArAutoCorrTotal::samplRMS(const Identifier &offid,
104 int gain,
105 float Nminbias) const {
106 const HWIdentifier hwid = m_cabling->createSignalChannelID(offid);
107 return this->samplRMS(hwid, gain, Nminbias);
108}
This is a "hash" representation of an Identifier.
const std::vector< double > autoCorrTotal(const IdentifierHash &hid, int gain, float Nminbias) const
const LArOnOffIdMapping * m_cabling
LArAutoCorrTotal()=delete
bool set(const IdentifierHash &hid, const int gain, std::vector< float > &autocorrtotal)
const std::vector< double > computeRMS(const std::vector< float > &terms, float Nminbias) const
std::array< vecAutoCorrTotal, CaloGain::LARNGAIN > m_AutoCorrTotal
const LArOnlineID_Base * m_onlineID
const std::vector< double > computeAutoCorr(const std::vector< float > &terms, float Nminbias) const
const std::vector< double > samplRMS(const IdentifierHash &hid, int gain, float Nminbias) const
Helper for the Liquid Argon Calorimeter cell identifiers.
size_type channelHashMax() const
Define channel hash tables max size.
@ LARNGAIN
Definition CaloGain.h:19
Definition index.py:1