ATLAS Offline Software
Loading...
Searching...
No Matches
LArSingleFloatSubsetCnv_p1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6
9
10void
12 SingleFloatTransType* transObj,
13 MsgStream & /*log*/) const
14{
15
16 // Copy basic metadata
17 transObj->setChannel (persObj->m_subset.m_channel);
18 transObj->setGroupingType (persObj->m_subset.m_groupingType);
19
20 transObj->initialize (persObj->m_subset.m_febIds, persObj->m_subset.m_gain);
21
22 unsigned int nfebids = persObj->m_subset.m_febIds.size();
23 const unsigned int nChannelsPerFeb = persObj->m_subset.subsetSize();
24 unsigned index =0;
25
26 auto subsetIt = transObj->subsetBegin();
27 for (unsigned int i = 0; i < nfebids; ++i, ++subsetIt){
28 // Loop over channels in feb
29 for (unsigned int j = 0; j < nChannelsPerFeb; ++j){
30 const float& data=persObj->m_values[index];
32 subsetIt->second[j].m_data=LArElecCalib::ERRORCODE;
33 else
34 subsetIt->second[j].m_data=data;
35 ++index;
36 }
37 }
38
39 unsigned int ncorrs = persObj->m_subset.m_corrChannels.size();
41 corrs.resize(ncorrs);
42
43 // Loop over corrections
44 for (unsigned int i = 0; i < ncorrs; ++i){
45 corrs[i].first = persObj->m_subset.m_corrChannels[i];
46 const float& data=persObj->m_values[index];
48 corrs[i].second.m_data=LArElecCalib::ERRORCODE;
49 else
50 corrs[i].second.m_data=data;
51 ++index;
52 }
53 transObj->insertCorrections (std::move (corrs));
54 return;
55}
56
57
58
59
60
61void
63 SingleFloatPersType* persObj,
64 MsgStream &log) const
65{
66 // Get the number of channels, corrections and the size of pedestal and pedestalrms
67 unsigned int ncorrs = transObj->correctionVecSize();
68 unsigned int nsubsetsNotEmpty = 0;
69 const unsigned int nChannelsPerFeb = transObj->channelVectorSize();
70
71 const auto subsetEnd = transObj->subsetEnd();
72 for (auto subsetIt = transObj->subsetBegin();
73 subsetIt != subsetEnd;
74 ++subsetIt)
75 {
76 unsigned int nfebChans = subsetIt->second.size();
77 if (nfebChans != 0 && nfebChans != nChannelsPerFeb) {
78 log << MSG::ERROR
79 << "LArSingleFloatSubsetCnv_p1::transToPers - found incorrect number of channels per feb: " << nfebChans
80 << endmsg;
81 return;
82 }
83 if (nfebChans) ++nsubsetsNotEmpty; // count number of non-empty subsets
84 }
85
86 // Reserve space in vectors
87 persObj->m_subset.m_febIds.reserve(nsubsetsNotEmpty);
88 persObj->m_subset.m_corrChannels.reserve(ncorrs);
89 persObj->m_values.reserve(ncorrs+nsubsetsNotEmpty*nChannelsPerFeb);
90
91 //Copy subsets
92 for (auto subsetIt = transObj->subsetBegin();
93 subsetIt != subsetEnd;
94 ++subsetIt)
95 {
96 unsigned int nfebChans = subsetIt->second.size();
97 if (nfebChans==0) continue;
98 unsigned int febid = subsetIt->first;
99 persObj->m_subset.m_febIds.push_back(febid);
100 for (unsigned int j=0; j<nfebChans;++j) //Loop over channels in FEB
101 persObj->m_values.push_back(subsetIt->second[j].m_data);
102 }
103
104 // Copy corrections
105 const auto corrEnd = transObj->correctionVecEnd();
106 for (auto corrIt = transObj->correctionVecBegin();
107 corrIt != corrEnd;
108 ++corrIt)
109 {
110 persObj->m_subset.m_corrChannels.push_back(corrIt->first);
111 persObj->m_values.push_back(corrIt->second.m_data);
112 }
113
114 // Copy the rest
115 persObj->m_subset.m_gain = transObj->gain();
116 persObj->m_subset.m_channel = transObj->channel();
117 persObj->m_subset.m_groupingType = transObj->groupingType();
118}
#define endmsg
Copies a single float from a persistent LAr calibration object, protected against roundoff errors.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
Defines a common ERRORCODE enum for LAr-Calibration objects.
LArConditionsSubset< LArSingleFloatP > SingleFloatTransType
LArSingleFloatSubset_p1 SingleFloatPersType
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 persToTrans(const SingleFloatPersType *persObj, SingleFloatTransType *transObj, MsgStream &log) const override
virtual void transToPers(const SingleFloatTransType *transObj, SingleFloatPersType *persObj, MsgStream &log) const override
LArConditionsSubset_p1 m_subset
Definition index.py:1