ATLAS Offline Software
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 
10 void
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];
31  if (data<=1.0+LArElecCalib::ERRORCODE)
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];
47  if (data<=1.0+LArElecCalib::ERRORCODE)
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 
61 void
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 }
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
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
LArConditionsSubset_p1::m_corrChannels
std::vector< unsigned int > m_corrChannels
Definition: LArConditionsSubset_p1.h:76
index
Definition: index.py:1
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
LArCalibErrorCode.h
Defines a common ERRORCODE enum for LAr-Calibration objects.
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
LArSingleFloatSubset_p1::m_values
std::vector< float > m_values
Definition: LArSingleFloatSubset_p1.h:35
LArSingleFloatSubsetCnv_p1.h
LArSingleFloatSubsetCnv_p1::persToTrans
virtual void persToTrans(const SingleFloatPersType *persObj, SingleFloatTransType *transObj, MsgStream &log) const override
Definition: LArSingleFloatSubsetCnv_p1.cxx:11
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:362
LArConditionsSubset::correctionVecSize
size_type correctionVecSize() const
Size of channel set.
Definition: LArConditionsSubset.h:481
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
LArSingleFloatSubset_p1::m_subset
LArConditionsSubset_p1 m_subset
Definition: LArSingleFloatSubset_p1.h:34
LArSingleFloatSubsetCnv_p1::transToPers
virtual void transToPers(const SingleFloatTransType *transObj, SingleFloatPersType *persObj, MsgStream &log) const override
Definition: LArSingleFloatSubsetCnv_p1.cxx:62
LArElecCalib::ERRORCODE
@ ERRORCODE
Definition: LArCalibErrorCode.h:17
LArConditionsSubset::subsetBegin
ConstSubsetIt subsetBegin() const
Iterators over subset.
Definition: LArConditionsSubset.h:412
LArSingleFloatSubset_p1
persistent class container of LArConditionsSubset for LArSingleFloat data.
Definition: LArSingleFloatSubset_p1.h:30
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.
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