11 MsgStream & log)
const
13 log<<MSG::DEBUG<<
"LArPhysWaveSubsetCNV_p1 begin persToTrans"<<
endmsg;
20 log<<MSG::DEBUG<<
"\t\tTotal febs:"<<nfebids<<
endmsg;
22 unsigned int waveIndex = 0;
23 unsigned int chIndex = 0;
25 unsigned int ifebWithData = 0;
28 for (
unsigned int i = 0; i < nfebids; ++i, ++subsetIt){
29 unsigned int febid = subsetIt->first;
31 bool hasSparseData =
false;
32 unsigned int chansSet = 0;
33 unsigned int chansOffset = 0;
43 log<<MSG::DEBUG<<
"\t\tsparse? "<< hasSparseData <<
endmsg;
45 for (
unsigned int j = 0; j < nChannelsPerFeb; ++j){
46 bool copyChannel =
true;
50 if (!(chansSet & (1 << (j - chansOffset)))) {
55 if (j%32 == 31 && j < nChannelsPerFeb-2) {
65 double time = persObj->
m_dt[chIndex];
66 unsigned int f = persObj->
m_flag[chIndex];
69 std::vector<double> val;
70 std::vector<double> err;
72 for (
unsigned int k = 0; k < persObj->
m_samples; ++k){
74 err.push_back(persObj->
m_vErrors[waveIndex]);
91 log<<MSG::DEBUG<<
"Total corrections:"<<ncorrs;
92 log<<MSG::DEBUG <<
"Corrections reading, ncorr=" << ncorrs <<
" waveIndex=" << waveIndex <<
" size=" << persObj->
m_vAmplitudes.size() <<
endmsg;
96 for (
unsigned int i = 0; i < ncorrs; ++i){
98 if (chIndex >= persObj->
m_dt.size()) {
99 log << MSG::ERROR <<
"LArPhysWaveSubsetCnv_p1::persToTrans - PhysWave index too large: WaveIndex/sizeInFile "
100 << chIndex <<
" " << persObj->
m_dt.size()<<
" "<<
endmsg;
108 double time = persObj->
m_dt[chIndex];
109 unsigned int f = persObj->
m_flag[chIndex];
112 std::vector<double> val;
113 std::vector<double> err;
114 std::vector<int> tri;
115 for (
unsigned int k = 0; k < persObj->
m_samples; ++k){
117 log << MSG::ERROR <<
"Persistent LArPhysWave object is inconsistent. i=" << i <<
" WaveIndes=" << waveIndex <<
" size=" << persObj->
m_vAmplitudes.size() <<
"samples=" << persObj->
m_samples <<
endmsg;
119 err.push_back(persObj->
m_vErrors[waveIndex]);
133 log<< MSG::DEBUG <<
"PhysWave successfully read."<<
endmsg;
143 MsgStream & log)
const
145 log<<MSG::DEBUG<<
"LArPhysWaveSubsetCNV_p1 begin transToPers"<<
endmsg;
149 log<<MSG::DEBUG<<
"total febs:"<<nfebs;
151 log<<MSG::DEBUG<<
"\t\ttotal corrections: "<<ncorrs<<
endmsg;
153 unsigned int nsubsetsNotEmpty = 0;
154 unsigned int nchans = 0;
157 bool haveSampleSize=
false;
159 std::vector<unsigned int> febsWithSparseData;
160 const auto subsetEnd = transObj->
subsetEnd();
162 subsetIt != subsetEnd;
165 unsigned int nfebChans = subsetIt->second.size();
167 if (nfebChans != 0 && nfebChans != nChannelsPerFeb) {
168 log << MSG::ERROR <<
"LArPhysWaveSubsetCnv_p1::transToPers - found incorrect number of channels per feb: " << nfebChans<<
endmsg;
172 if (nfebChans) ++nsubsetsNotEmpty;
174 bool isSparse =
false;
175 for (
unsigned int j = 0; j < nfebChans; ++j) {
179 if (!isSparse && PW.
isEmpty()) {
181 febsWithSparseData.push_back(subsetIt->first);
182 log<<MSG::DEBUG<<
"\t\tfebID: "<<subsetIt->first<<
" is sparse"<<
endmsg;
187 if (!haveSampleSize) {
193 log << MSG::ERROR <<
"Waves of unequal length found in same conditions channel. Truncating to the shorter of "
210 if (febsWithSparseData.size())
213 persObj->
m_dt.reserve(nchans);
217 persObj->
m_flag.reserve(nchans);
222 subsetIt != subsetEnd;
225 unsigned int nfebChans = subsetIt->second.size();
227 if (nfebChans == 0)
continue;
229 unsigned int febid = subsetIt->first;
233 if (counterSparse < (
int)febsWithSparseData.size() && febid == febsWithSparseData[counterSparse]){
239 unsigned int chansSet = 0;
240 unsigned int chansOffset = 0;
241 for (
unsigned int j = 0; j < nfebChans; ++j){
243 bool saveAmplitudes=
true;
246 if (!subsetIt->second[j].isEmpty()) {
248 assert (j >= chansOffset && (j - chansOffset) <= 31);
250 chansSet |= (1 << (j - chansOffset));
255 saveAmplitudes =
false;
260 if (j == (chansOffset + 31) || j == nfebChans-1 ) {
268 if (saveAmplitudes) {
273 std::vector<double> w=PW.
getWave();
276 for (
unsigned int k = 0; k< persObj->
m_samples; ++k){
298 std::vector<double> w=PW.
getWave();
305 for (
unsigned int k = 0; k< w.size(); ++k){
316 log<< MSG::DEBUG <<
"PhysWave successfully written down."<<
endmsg;
This file defines the template class used for I/O of conditions data.
LArPhysWaveSubset_p1 LArPWPersType
LArConditionsSubset< LArPhysWave > LArPWTransType
std::vector< unsigned int > m_febIds
std::vector< unsigned int > m_corrChannels
unsigned int subsetSize() const
std::vector< unsigned int > m_febsWithSparseData
unsigned int m_groupingType
size_type subsetSize() const
Size of subset.
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 transToPers(const LArPWTransType *transObj, LArPWPersType *persObj, MsgStream &log) const override
virtual void persToTrans(const LArPWPersType *persObj, LArPWTransType *transObj, MsgStream &log) const override
std::vector< int > m_timeOffset
std::vector< float > m_vAmplitudes
LArConditionsSubset_p1 m_subset
std::vector< unsigned > m_flag
std::vector< float > m_dt
std::vector< float > m_vErrors
std::vector< int > m_vTriggers
int getTimeOffset() const
const std::vector< int > & getTriggers() const
trigger vector
const std::vector< double > & getErrors() const
error vector
size_t getSize() const
number of time samples
bool isEmpty() const
is LArWave uninitialized?
const std::vector< double > & getWave() const
Wave parameters.
const double & getDt() const
delta time
unsigned getFlag() const
flag: ...