ATLAS Offline Software
LArPedestalSubsetCnv_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 
7 
8 void
10  LArPedestalTransType* transObj,
11  MsgStream & log) const
12 {
13  transObj->initialize (persObj->m_subset.m_febIds, persObj->m_subset.m_gain);
14 
15  // Copy conditions
16  unsigned int nfebids = persObj->m_subset.m_febIds.size();
17  unsigned int nPedestals = persObj->m_vPedestalSize;
18  unsigned int nPedestalRMSs = persObj->m_vPedestalRMSSize;
19  unsigned int pedestalIndex = 0;
20  unsigned int pedestalrmsIndex = 0;
21  const unsigned int nChannelsPerFeb = persObj->m_subset.subsetSize();
22  // Loop over febs
23  unsigned int ifebWithData = 0; // counter for febs with data
24 
25  auto subsetIt = transObj->subsetBegin();
26  for (unsigned int i = 0; i < nfebids; ++i, ++subsetIt){
27  // Set febid
28  unsigned int febid = subsetIt->first;
29  bool hasSparseData = false;
30  unsigned int chansSet = 0;
31  unsigned int chansOffset = 0;
32  if (ifebWithData < persObj->m_subset.m_febsWithSparseData.size() &&
33  febid == persObj->m_subset.m_febsWithSparseData[ifebWithData]) {
34  // Found feb with sparse data
35  hasSparseData = true;
36  ifebWithData++;
37  chansSet = persObj->m_subset.m_febsWithSparseData[ifebWithData];
38  chansOffset = 0;
39  ifebWithData++;
40  }
41 
42  // Loop over channels in feb - only some channels are filled
43  for (unsigned int j = 0; j < nChannelsPerFeb; ++j){
44 
45  bool copyChannel = true;
46  if (hasSparseData) {
47  if (!(chansSet & (1 << (j - chansOffset)))) {
48  // Channel is missing data - skip
49  copyChannel = false;
50  }
51  if (j%32 == 31 && j < nChannelsPerFeb-2) {
52  chansSet = persObj->m_subset.m_febsWithSparseData[ifebWithData];
53  chansOffset += 32;
54  ifebWithData++;
55  }
56  }
57  if (copyChannel) {
58 
59  // Channel has pedestals - loop over pedestals per channel
60  // and copy to the persistent object
61 
62  // check indexes
63  if (pedestalIndex >= persObj->m_vPedestal.size() ||
64  pedestalrmsIndex >= persObj->m_vPedestalRMS.size()) {
65  log << MSG::ERROR
66  << "LArPedestalSubsetCnv_p1::persToTrans - pedestal index too large: pedestal/size, pedestalrms/size "
67  << pedestalIndex << " " << persObj->m_vPedestal.size() << " "
68  << pedestalrmsIndex << " " << persObj->m_vPedestalRMS.size()
69  << endmsg;
70  return;
71  }
72 
73  // This channel has pedestals, resize vectors
74  //subsetIt->second[j].m_vPedestal.resize(nPedestals);
75  //subsetIt->second[j].m_vPedestalRMS.resize(nPedestalRMSs);
76  if (nPedestals)
77  subsetIt->second[j].m_Pedestal = persObj->m_vPedestal[pedestalIndex];
78  pedestalIndex+=nPedestals;
79 
80  if (nPedestalRMSs)
81  subsetIt->second[j].m_PedestalRMS = persObj->m_vPedestalRMS[pedestalrmsIndex];
82  pedestalrmsIndex+=nPedestalRMSs;
83  }//end if copychannel
84 
85  }//end loop over channels in feb
86  }// end loop over febs
87 
88  // Copy corrections
89 
90  unsigned int ncorrs = persObj->m_subset.m_corrChannels.size();
92  corrs.resize (ncorrs);
93  if (ncorrs) {
94  // Loop over corrections
95  for (unsigned int i = 0; i < ncorrs; ++i){
96  // check indexes
97  if (pedestalIndex >= persObj->m_vPedestal.size() ||
98  pedestalrmsIndex >= persObj->m_vPedestalRMS.size()) {
99  log << MSG::ERROR
100  << "LArPedestalSubsetCnv_p1::persToTrans - pedestal index too large: pedestal/size, pedestalrms/size "
101  << pedestalIndex << " " << persObj->m_vPedestal.size() << " "
102  << pedestalrmsIndex << " " << persObj->m_vPedestalRMS.size()
103  << endmsg;
104  return;
105  }
106  corrs[i].first = persObj->m_subset.m_corrChannels[i];
107 
108  if (nPedestals)
109  corrs[i].second.m_Pedestal = persObj->m_vPedestal[pedestalIndex];
110  pedestalIndex+=nPedestals;
111 
112 
113  if (nPedestalRMSs)
114  corrs[i].second.m_PedestalRMS = persObj->m_vPedestalRMS[pedestalrmsIndex];
115  pedestalrmsIndex+=nPedestalRMSs;
116 
117  }// end loop over corrections
118 
119  }//end if ncorr
120  transObj->insertCorrections (std::move (corrs));
121 
122  // Copy the rest
123  transObj->setChannel (persObj->m_subset.m_channel);
124  transObj->setGroupingType (persObj->m_subset.m_groupingType);
125 }
126 
127 
128 
129 
130 void
132  LArPedestalPersType* /*persObj*/,
133  MsgStream &log) const
134 {
135 
136  log << MSG::ERROR << "LArPedestalSubset_p1 is obsolete and can't be written out any more." << endmsg;
137  return;
138 }
139 
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
LArPedestalSubset_p1::m_subset
LArConditionsSubset_p1 m_subset
Definition: LArPedestalSubset_p1.h:35
LArConditionsSubset_p1::m_corrChannels
std::vector< unsigned int > m_corrChannels
Definition: LArConditionsSubset_p1.h:76
LArConditionsSubset_p1::m_febsWithSparseData
std::vector< unsigned int > m_febsWithSparseData
Definition: LArConditionsSubset_p1.h:77
LArPedestalSubset_p1::m_vPedestalSize
unsigned int m_vPedestalSize
Definition: LArPedestalSubset_p1.h:38
LArPedestalSubset_p1::m_vPedestalRMSSize
unsigned int m_vPedestalRMSSize
Definition: LArPedestalSubset_p1.h:39
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
LArPedestalSubsetCnv_p1::transToPers
virtual void transToPers(const LArPedestalTransType *transObj, LArPedestalPersType *persObj, MsgStream &log) const override
Definition: LArPedestalSubsetCnv_p1.cxx:131
LArPedestalSubset_p1::m_vPedestalRMS
std::vector< float > m_vPedestalRMS
Definition: LArPedestalSubset_p1.h:37
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::setChannel
void setChannel(unsigned int channel)
set the COOL channel number
Definition: LArConditionsSubset.h:567
LArPedestalSubsetCnv_p1.h
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.
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
LArPedestalSubsetCnv_p1::persToTrans
virtual void persToTrans(const LArPedestalPersType *persObj, LArPedestalTransType *transObj, MsgStream &log) const override
Definition: LArPedestalSubsetCnv_p1.cxx:9
LArConditionsSubset::subsetBegin
ConstSubsetIt subsetBegin() const
Iterators over subset.
Definition: LArConditionsSubset.h:412
LArPedestalSubset_p1::m_vPedestal
std::vector< float > m_vPedestal
Definition: LArPedestalSubset_p1.h:36
LArPedestalSubset_p1
persistent class container of LArConditionsSubset for LArPedestal data.
Definition: LArPedestalSubset_p1.h:30
LArConditionsSubset::insertCorrections
void insertCorrections(CorrectionVec &&corrs)
Insert a group of corrections.
Definition: LArConditionsSubset.h:593