ATLAS Offline Software
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 
9 void
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 
68 void
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 }
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
LArPedestalSubsetCnv_p2::persToTrans
virtual void persToTrans(const LArPedestalSubset_p2 *persObj, LArPedestalTransType *transObj, MsgStream &log) const override
Definition: LArPedestalSubsetCnv_p2.cxx:10
LArConditionsSubset_p1::m_corrChannels
std::vector< unsigned int > m_corrChannels
Definition: LArConditionsSubset_p1.h:76
LArPedestalSubset_p2::m_vPedestalRMS
std::vector< float > m_vPedestalRMS
Definition: LArPedestalSubset_p2.h:36
copyFloatPT
float copyFloatPT(const float &pers)
Definition: CopyFloatWithErrorcode.h:21
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
LArPedestalSubset_p2::m_subset
LArConditionsSubset_p1 m_subset
Definition: LArPedestalSubset_p2.h:34
LArConditionsSubset::correctionVecEnd
ConstCorrectionVecIt correctionVecEnd() const
Definition: LArConditionsSubset.h:472
LArPedestalSubsetCnv_p2.h
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:92
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
LArPedestalSubset_p2::m_vPedestal
std::vector< float > m_vPedestal
Definition: LArPedestalSubset_p2.h:35
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.h
This file defines the template class used for I/O of conditions data.
LArPedestalSubset_p2
persistent class container of LArConditionsSubset for LArPedestal data.
Definition: LArPedestalSubset_p2.h:30
LArConditionsSubset::gain
unsigned int gain() const
Access to gain.
Definition: LArConditionsSubset.h:490
LArConditionsSubset::correctionVecSize
size_type correctionVecSize() const
Size of channel set.
Definition: LArConditionsSubset.h:481
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
LArConditionsSubset::subsetBegin
ConstSubsetIt subsetBegin() const
Iterators over subset.
Definition: LArConditionsSubset.h:412
LArConditionsSubset::subsetEnd
ConstSubsetIt subsetEnd() const
Definition: LArConditionsSubset.h:420
CopyFloatWithErrorcode.h
Copies a single float from a persistent LAr calibration object, protected against roundoff errors.
LArPedestalSubsetCnv_p2::transToPers
virtual void transToPers(const LArPedestalTransType *transObj, LArPedestalSubset_p2 *persObj, MsgStream &log) const override
Definition: LArPedestalSubsetCnv_p2.cxx:69
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