ATLAS Offline Software
Loading...
Searching...
No Matches
LArPedestalSubsetCnv_p2.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
8
9void
11 LArPedestalTransType* transObj,
12 MsgStream & log) const
13{
14 // Copy basic metadata
15 transObj->setChannel (persObj->m_subset.m_channel);
16 transObj->setGroupingType (persObj->m_subset.m_groupingType);
17
18 transObj->initialize (persObj->m_subset.m_febIds, persObj->m_subset.m_gain);
19
20 // Copy conditions
21 const unsigned int nfebids = persObj->m_subset.m_febIds.size();
22 const unsigned int nChannelsPerFeb = persObj->m_subset.subsetSize();
23 unsigned int pedestalIndex = 0;
24 // Loop over febs
25 auto subsetIt = transObj->subsetBegin();
26 for (unsigned int i = 0; i < nfebids; ++i, ++subsetIt){
27 // Loop over channels in feb
28 for (unsigned int j = 0; j < nChannelsPerFeb; ++j){
29 //Copy Pedestal
30 subsetIt->second[j].m_Pedestal=copyFloatPT(persObj->m_vPedestal[pedestalIndex]);
31 //Copy RMS
32 subsetIt->second[j].m_PedestalRMS=copyFloatPT(persObj->m_vPedestalRMS[pedestalIndex]);
33 ++pedestalIndex;
34 }//end loop over channel in feb
35 }//end loop over febs
36
37 // Copy corrections
38 unsigned int ncorrs = persObj->m_subset.m_corrChannels.size();
40 if (ncorrs) {
41 // corrs exist - resize vector
42 corrs.resize(ncorrs);
43 // Loop over corrections
44 for (unsigned int i = 0; i < ncorrs; ++i){
45 // check indexes
46 if (pedestalIndex >= persObj->m_vPedestal.size()) {
47 log << MSG::ERROR
48 << "LArPedestalSubsetCnv_p2::persToTrans - pedestal index too large: pedestal/size "
49 << pedestalIndex << " " << persObj->m_vPedestal.size() << endmsg;
50 return;
51 }
52
53 corrs[i].first = persObj->m_subset.m_corrChannels[i];
54 //Copy Pedestal
55 corrs[i].second.m_Pedestal=copyFloatPT(persObj->m_vPedestal[pedestalIndex]);
56 //Copy RMS
57 corrs[i].second.m_PedestalRMS=copyFloatPT(persObj->m_vPedestalRMS[pedestalIndex]);
58 ++pedestalIndex;
59 }//end loop over corrections
60 }//end if ncorrs
61 transObj->insertCorrections (std::move (corrs));
62
63}
64
65
66
67
68void
70 LArPedestalSubset_p2* persObj,
71 MsgStream &log) const
72{
73 // Copy conditions
74 // Get the number of channels, corrections and the size of pedestal and pedestalrms
75 const unsigned int ncorrs = transObj->correctionVecSize();
76 unsigned int nsubsetsNotEmpty = 0;
77 const unsigned int nChannelsPerFeb = transObj->channelVectorSize();
78 // Find the number of pedestals/pedestalrmss and check for sparse
79 // conditions, e.g. MC conditions
80 const auto subsetEnd = transObj->subsetEnd();
81 for (auto subsetIt = transObj->subsetBegin();
82 subsetIt != subsetEnd;
83 ++subsetIt)
84 {
85 unsigned int nfebChans = subsetIt->second.size();
86
87 if (nfebChans != 0 && nfebChans != nChannelsPerFeb) {
88 log << MSG::ERROR
89 << "LArPedestalSubsetCnv_p2::transToPers - found incorrect number of channels per feb: " << nfebChans
90 << endmsg;
91 return;
92 }
93 if (nfebChans) ++nsubsetsNotEmpty; // count number of non-empty subsets
94 }
95 // Reserve space in vectors
96 persObj->m_subset.m_febIds.reserve(nsubsetsNotEmpty);
97 persObj->m_subset.m_corrChannels.reserve(ncorrs);
98 persObj->m_vPedestal.reserve(ncorrs+nsubsetsNotEmpty*nChannelsPerFeb);
99 persObj->m_vPedestalRMS.reserve(ncorrs+nsubsetsNotEmpty*nChannelsPerFeb);
100
101 // Copy conditions in subset
102 for (auto subsetIt = transObj->subsetBegin();
103 subsetIt != subsetEnd;
104 ++subsetIt)
105 {
106 unsigned int nfebChans = subsetIt->second.size();
107 // skip subsets without any channels
108 if (nfebChans == 0) continue;
109
110 unsigned int febid = subsetIt->first;
111 persObj->m_subset.m_febIds.push_back(febid);
112 for (unsigned int j=0; j<nfebChans;++j) { //Loop over channels in FEB
113 persObj->m_vPedestal.push_back(subsetIt->second[j].m_Pedestal);
114 persObj->m_vPedestalRMS.push_back(subsetIt->second[j].m_PedestalRMS);
115 }//End loop over channels in feb
116 }//end loop over febs
117
118 // Copy corrections
119 const auto corrEnd = transObj->correctionVecEnd();
120 for (auto corrIt = transObj->correctionVecBegin();
121 corrIt != corrEnd;
122 ++corrIt)
123 {
124 // Save channel id in febid vector
125 persObj->m_subset.m_corrChannels.push_back(corrIt->first);
126 persObj->m_vPedestal.push_back(corrIt->second.m_Pedestal);
127 persObj->m_vPedestalRMS.push_back(corrIt->second.m_PedestalRMS);
128 }//End loop over corrections
129
130 // Copy the rest
131 persObj->m_subset.m_gain = transObj->gain();
132 persObj->m_subset.m_channel = transObj->channel();
133 persObj->m_subset.m_groupingType = transObj->groupingType();
134}
#define endmsg
Copies a single float from a persistent LAr calibration object, protected against roundoff errors.
float copyFloatPT(const float &pers)
This file defines the template class used for I/O of conditions data.
LArConditionsSubset< LArPedestalP1 > LArPedestalTransType
std::vector< unsigned int > m_febIds
std::vector< unsigned int > m_corrChannels
unsigned int subsetSize() const
void initialize(const std::vector< FebId > &ids, unsigned int gain)
Initialize with set of FEB ids.
ConstSubsetIt subsetEnd() const
unsigned channelVectorSize() const
ConstCorrectionVecIt correctionVecBegin() const
Iterators over channel set.
unsigned int groupingType() const
Type of grouping - defined in LArConditionsContainerBase.h.
ConstCorrectionVecIt correctionVecEnd() const
void setGroupingType(unsigned int type)
set the type of grouping - defined in LArConditionsContainerBase.h
ConstSubsetIt subsetBegin() const
Iterators over subset.
unsigned int gain() const
Access to gain.
size_type correctionVecSize() const
Size of channel set.
std::vector< CorrectionPair > CorrectionVec
unsigned int channel() const
Access to the COOL channel number.
void insertCorrections(CorrectionVec &&corrs)
Insert a group of corrections.
void setChannel(unsigned int channel)
set the COOL channel number
virtual void transToPers(const LArPedestalTransType *transObj, LArPedestalSubset_p2 *persObj, MsgStream &log) const override
virtual void persToTrans(const LArPedestalSubset_p2 *persObj, LArPedestalTransType *transObj, MsgStream &log) const override
persistent class container of LArConditionsSubset for LArPedestal data.
std::vector< float > m_vPedestalRMS
std::vector< float > m_vPedestal
LArConditionsSubset_p1 m_subset