ATLAS Offline Software
Loading...
Searching...
No Matches
TileRawChannelCnv_p1.cxx
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
5*/
6
7// TileRawChannelCnv_p1.cxx
8// Implementation file for class TileRawChannelCnv_p1
9// Author: Alexander Solodkov <Sanya.Solodkov@cern.ch>
10// Date: June 2009
12
15//#include "iostream"
16
17void
18TileRawChannelCnv_p1::persToTrans(const TileRawChannel_p1* persObj, TileRawChannel* transObj, MsgStream &log) const
19{
20 unsigned int length = persObj->m_length;
21 unsigned int l1 = length & 0xFF;
22 unsigned int l2 = (length >> 8) & 0xFF;
23 unsigned int l3 = (length >> 16) & 0xFF;
24 unsigned int l4 = (length >> 24) & 0xFF;
25
26 std::vector<float>::const_iterator it = persObj->m_data.begin();
27
28 std::vector<float> amplitude;
29 if (l1>0) {
30 amplitude.assign (it, it+l1);
31 it += l1;
32 } else {
33 amplitude.push_back( 0.0 );
34 }
35
36 std::vector<float> time;
37 if (l2>0) {
38 time.assign (it, it+l2);
39 it += l2;
40 } else {
41 time.push_back( 0.0 );
42 }
43
44 std::vector<float> quality;
45 if (l3>0) {
46 quality.assign (it, it+l3);
47 it += l3;
48 } else {
49 quality.push_back( 0.0 );
50 }
51
52 float pedestal = 0;
53 if (l4>0)
54 pedestal = (*it++);
55
56 if (it != persObj->m_data.end()) {
57 log << MSG::ERROR << "TileRawChannelCnv_p1::persToTrans wrong size of data vector: "
58 << persObj->m_data.size() << MSG::hex << "0x" << persObj->m_length << MSG::dec << endmsg;
59 }
60
62 std::move(amplitude),
63 std::move(time),
64 std::move(quality),
65 pedestal);
66}
67
68
69void
70TileRawChannelCnv_p1::transToPers(const TileRawChannel* transObj, TileRawChannel_p1* persObj, MsgStream &/*log*/) const
71{
72 persObj->m_channelID = transObj->adc_HWID().get_identifier32().get_compact();
73
74 unsigned int l1 = transObj->size(); if (l1>0xFF) l1=0xFF;
75 unsigned int l2 = transObj->sizeTime(); if (l2>0xFF) l2=0xFF;
76 unsigned int l3 = transObj->sizeQuality(); if (l3>0xFF) l3=0xFF;
77 unsigned int l4 = 1;
78
79 if (l1==1 && transObj->amplitude(0)==0.0) l1=0;
80 if (l2==1 && transObj->time(0)==0.0) l2=0;
81 if (l3==1 && transObj->quality(0)==0.0) l3=0;
82 if ( transObj->pedestal()==0.0) l4=0;
83
84 persObj->m_length = (l4<<24 | l3<<16 | l2<<8 | l1);
85
86 if (persObj->m_length) {
87
88 persObj->m_data.reserve(l1+l2+l3+l4);
89
90 for (unsigned int i=0; i<l1; ++i) {
91 persObj->m_data.push_back( transObj->amplitude(i) );
92 }
93
94 for (unsigned int i=0; i<l2; ++i) {
95 persObj->m_data.push_back( transObj->time(i) );
96 }
97
98 for (unsigned int i=0; i<l3; ++i) {
99 persObj->m_data.push_back( transObj->quality(i) );
100 }
101
102 if (l4>0) {
103 persObj->m_data.push_back( transObj->pedestal() );
104 }
105
106 } else {
107 persObj->m_data.clear();
108 }
109
110// if (l1==0 || l2==0 || l3==0 || l4==0)
111// std::cout << "id=0x" << std::hex << persObj->m_channelID
112// << " length=0x" << persObj->m_length << std::dec
113// << " amp=" <<transObj->m_amplitude[0]
114// << " time="<<transObj->m_time[0]
115// << " qual="<<transObj->m_quality[0]
116// << " ped=" <<transObj->m_pedestal
117// << std::endl;
118}
#define endmsg
double length(const pvec &v)
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
virtual void transToPers(const TileRawChannel *transObj, TileRawChannel_p1 *persObj, MsgStream &log) const override
Method creating the persistent representation TileRawChannel_p1 from its transient representation Til...
virtual void persToTrans(const TileRawChannel_p1 *persObj, TileRawChannel *transObj, MsgStream &log) const override
Method creating the transient representation TileRawChannel from its persistent representation TileRa...
unsigned int m_channelID
std::vector< float > m_data
float pedestal(void) const
float time(int ind=0) const
float quality(int ind=0) const
int size() const
int sizeTime() const
float amplitude(int ind=0) const
int sizeQuality() const
HWIdentifier adc_HWID(void) const
Definition TileRawData.h:53