ATLAS Offline Software
LArOFCBinSubsetCnv_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 
7 void
9  OFCBinTransType* transObj,
10  MsgStream & /*log*/) const
11 {
12  // Copy basic metadata
13  transObj->setChannel (persObj->m_subset.m_channel);
14  transObj->setGroupingType (persObj->m_subset.m_groupingType);
15  transObj->initialize (persObj->m_subset.m_febIds, persObj->m_subset.m_gain);
16 
17  // Copy conditions
18  unsigned int nfebids = persObj->m_subset.m_febIds.size();
19  const unsigned int nChannelsPerFeb = persObj->m_subset.subsetSize();
20  unsigned index =0;
21 
22  auto subsetIt = transObj->subsetBegin();
23  for (unsigned int i = 0; i < nfebids; ++i, ++subsetIt){
24  // Loop over channels in feb
25  for (unsigned int j = 0; j < nChannelsPerFeb; ++j){
26  (*subsetIt).second[j].m_bin=persObj->m_values[index];
27  // std::cout << "WL Data: FEB=" << std::hex << febid << std::dec << " [" << i << "] Channel="
28  // << j << " Payload= <<
29  ++index;
30  }
31  }
32 
33  unsigned int ncorrs = persObj->m_subset.m_corrChannels.size();
35  corrs.resize(ncorrs);
36 
37  // Loop over corrections
38  for (unsigned int i = 0; i < ncorrs; ++i){
39  corrs[i].first = persObj->m_subset.m_corrChannels[i];
40  corrs[i].second.m_bin=persObj->m_values[index];
41  ++index;
42  }
43  transObj->insertCorrections (std::move (corrs));
44 
45 }
46 
47 
48 
49 
50 
51 void
53  OFCBinPersType* persObj,
54  MsgStream &log) const
55 {
56  // Get the number of channels, corrections and the size of pedestal and pedestalrms
57  unsigned int ncorrs = transObj->correctionVecSize();
58  const unsigned int nChannelsPerFeb = transObj->channelVectorSize();
59  unsigned int nsubsetsNotEmpty = 0;
60 
61  const auto subsetEnd = transObj->subsetEnd();
62  for (auto subsetIt = transObj->subsetBegin();
63  subsetIt != subsetEnd;
64  ++subsetIt)
65  {
66  unsigned int nfebChans = (*subsetIt).second.size();
67  if (nfebChans != 0 && nfebChans != nChannelsPerFeb) {
68  log << MSG::ERROR
69  << "LArOFCBinSubsetCnv_p1::transToPers - found incorrect number of channels per feb: " << nfebChans
70  << endmsg;
71  return;
72  }
73  if (nfebChans) ++nsubsetsNotEmpty; // count number of non-empty subsets
74  }
75 
76  // Reserve space in vectors
77  persObj->m_subset.m_febIds.reserve(nsubsetsNotEmpty);
78  persObj->m_subset.m_corrChannels.reserve(ncorrs);
79  persObj->m_values.reserve(ncorrs+nsubsetsNotEmpty*nChannelsPerFeb);
80 
81  //Copy subsets
82  for (auto subsetIt = transObj->subsetBegin();
83  subsetIt != subsetEnd;
84  ++subsetIt)
85  {
86  unsigned int nfebChans = (*subsetIt).second.size();
87  if (nfebChans==0) continue;
88  unsigned int febid = (*subsetIt).first;
89  persObj->m_subset.m_febIds.push_back(febid);
90  for (unsigned int j=0; j<nfebChans;++j) //Loop over channels in FEB
91  persObj->m_values.push_back((*subsetIt).second[j].m_bin);
92  }
93 
94  // Copy corrections
95  const auto corrEnd = transObj->correctionVecEnd();
96  for (auto corrIt = transObj->correctionVecBegin();
97  corrIt != corrEnd;
98  ++corrIt)
99  {
100  persObj->m_subset.m_corrChannels.push_back(corrIt->first);
101  persObj->m_values.push_back(corrIt->second.m_bin);
102  }
103 
104  // Copy the rest
105  persObj->m_subset.m_gain = transObj->gain();
106  persObj->m_subset.m_channel = transObj->channel();
107  persObj->m_subset.m_groupingType = transObj->groupingType();
108 }
LArConditionsSubset::setGroupingType
void setGroupingType(unsigned int type)
set the type of grouping - defined in LArConditionsContainerBase.h
Definition: LArConditionsSubset.h:575
LArConditionsSubset_p1::m_channel
unsigned int m_channel
Definition: LArConditionsSubset_p1.h:79
LArConditionsSubset_p1::m_corrChannels
std::vector< unsigned int > m_corrChannels
Definition: LArConditionsSubset_p1.h:76
index
Definition: index.py:1
LArOFCBinSubsetCnv_p1::persToTrans
virtual void persToTrans(const OFCBinPersType *persObj, OFCBinTransType *transObj, MsgStream &log) const override
Definition: LArOFCBinSubsetCnv_p1.cxx:8
LArSingleIntSubset_p1
persistent class container of LArConditionsSubset for LArSingleInt data.
Definition: LArSingleIntSubset_p1.h:30
LArConditionsSubset::channelVectorSize
unsigned channelVectorSize() const
Definition: LArConditionsSubset.h:608
LArConditionsSubset_p1::subsetSize
unsigned int subsetSize() const
Definition: LArConditionsSubset_p1.h:82
LArConditionsSubset_p1::m_gain
unsigned int m_gain
Definition: LArConditionsSubset_p1.h:78
LArConditionsSubset::correctionVecEnd
ConstCorrectionVecIt correctionVecEnd() const
Definition: LArConditionsSubset.h:472
LArOFCBinSubsetCnv_p1::transToPers
virtual void transToPers(const OFCBinTransType *transObj, OFCBinPersType *persObj, MsgStream &log) const override
Definition: LArOFCBinSubsetCnv_p1.cxx:52
LArConditionsSubset_p1::m_febIds
std::vector< unsigned int > m_febIds
Definition: LArConditionsSubset_p1.h:75
LArConditionsSubset::initialize
void initialize(const std::vector< FebId > &ids, unsigned int gain)
Initialize with set of FEB ids.
Definition: LArConditionsSubset.h:529
LArConditionsSubset::CorrectionVec
std::vector< CorrectionPair > CorrectionVec
Definition: LArConditionsSubset.h:144
lumiFormat.i
int i
Definition: lumiFormat.py:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
LArConditionsSubset_p1::m_groupingType
unsigned int m_groupingType
Definition: LArConditionsSubset_p1.h:80
LArConditionsSubset::channel
unsigned int channel() const
Access to the COOL channel number.
Definition: LArConditionsSubset.h:498
LArConditionsSubset::setChannel
void setChannel(unsigned int channel)
set the COOL channel number
Definition: LArConditionsSubset.h:567
LArConditionsSubset
template class for use for I/O of conditions data
Definition: LArConditionsSubset.h:122
LArConditionsSubset::gain
unsigned int gain() const
Access to gain.
Definition: LArConditionsSubset.h:490
DeMoScan.index
string index
Definition: DeMoScan.py:364
LArConditionsSubset::correctionVecSize
size_type correctionVecSize() const
Size of channel set.
Definition: LArConditionsSubset.h:481
LArSingleIntSubset_p1::m_subset
LArConditionsSubset_p1 m_subset
Definition: LArSingleIntSubset_p1.h:34
LArOFCBinSubsetCnv_p1.h
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
LArConditionsSubset::subsetBegin
ConstSubsetIt subsetBegin() const
Iterators over subset.
Definition: LArConditionsSubset.h:412
LArSingleIntSubset_p1::m_values
std::vector< int > m_values
Definition: LArSingleIntSubset_p1.h:35
LArConditionsSubset::subsetEnd
ConstSubsetIt subsetEnd() const
Definition: LArConditionsSubset.h:420
LArConditionsSubset::correctionVecBegin
ConstCorrectionVecIt correctionVecBegin() const
Iterators over channel set.
Definition: LArConditionsSubset.h:465
LArConditionsSubset::insertCorrections
void insertCorrections(CorrectionVec &&corrs)
Insert a group of corrections.
Definition: LArConditionsSubset.h:593
LArConditionsSubset::groupingType
unsigned int groupingType() const
Type of grouping - defined in LArConditionsContainerBase.h.
Definition: LArConditionsSubset.h:507