ATLAS Offline Software
TileHitCnv_p1.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // TileHitCnv_p1.cxx
8 // Implementation file for class TileHitCnv_p1
9 // Author: Author: Davide Costanzo
10 // Date: March 2007
12 
13 #include "TileSimEvent/TileHit.h"
15 #include <stdexcept>
16 
17 
18 void
19 TileHitCnv_p1::persToTrans(const TileHit_p1* persObj, TileHit* transObj, MsgStream &/*log*/) const
20 {
21  size_t sz = persObj->m_energy.size();
22  if (sz != persObj->m_time.size())
23  throw std::runtime_error ("TileHit_p1 vector size mismatch");
24 
25  *transObj = TileHit (Identifier(Identifier32(persObj->m_channelID)));
26  transObj->resize (sz);
27 
28  for (size_t i = 0; i < sz; i++) {
29  transObj->setEnergy (persObj->m_energy[i], i);
30  transObj->setTime (persObj->m_time[i], i);
31  }
32 }
33 
34 void
35 TileHitCnv_p1::transToPers(const TileHit* transObj, TileHit_p1* persObj, MsgStream &/*log*/) const
36 {
37  persObj->m_channelID = transObj->identify().get_identifier32().get_compact();
38 
39  size_t sz = transObj->size();
40  persObj->m_energy.resize (sz);
41  persObj->m_time.resize (sz);
42  for (size_t i = 0; i < sz; i++) {
43  persObj->m_energy[i] = transObj->energy(i);
44  persObj->m_time[i] = transObj->time(i);
45  }
46 }
TileHit::identify
Identifier identify(void) const
Return logical ID of the pmt.
Definition: TileSimEvent/TileSimEvent/TileHit.h:76
Identifier32
Definition: Identifier32.h:25
fitman.sz
sz
Definition: fitman.py:527
Identifier::get_identifier32
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
Identifier32::get_compact
value_type get_compact() const
Get the compact id.
Definition: Identifier32.h:44
TileHit::size
int size(void) const
Return length of energy/time vectors
Definition: TileSimEvent/TileSimEvent/TileHit.h:94
TileHitCnv_p1.h
TileHit_p1::m_time
std::vector< float > m_time
Definition: TileHit_p1.h:17
lumiFormat.i
int i
Definition: lumiFormat.py:85
TileHit::resize
void resize(int len)
Resize energy and time vectors in a hit
Definition: TileSimEvent/TileSimEvent/TileHit.h:67
TileHitCnv_p1::persToTrans
virtual void persToTrans(const TileHit_p1 *persObj, TileHit *transObj, MsgStream &log) const override
Definition: TileHitCnv_p1.cxx:19
TileHit::setEnergy
void setEnergy(float e, int ind=0)
Set energy of ind-th sub-hit in a hit
Definition: TileSimEvent/TileSimEvent/TileHit.h:63
TileHit_p1
Definition: TileHit_p1.h:9
TileHit.h
TileHit
Definition: TileSimEvent/TileSimEvent/TileHit.h:30
TileHit_p1::m_energy
std::vector< float > m_energy
Definition: TileHit_p1.h:16
TileHit_p1::m_channelID
unsigned int m_channelID
Definition: TileHit_p1.h:15
TileHit::energy
float energy(int ind=0) const
Return energy of ind-th sub-hit
Definition: TileSimEvent/TileSimEvent/TileHit.h:90
TileHit::setTime
void setTime(float t, int ind=0)
Set time of ind-th sub-hit in a hit
Definition: TileSimEvent/TileSimEvent/TileHit.h:65
TileHit::time
float time(int ind=0) const
Return time of ind-th sub-hit
Definition: TileSimEvent/TileSimEvent/TileHit.h:92
TileHitCnv_p1::transToPers
virtual void transToPers(const TileHit *transObj, TileHit_p1 *persObj, MsgStream &log) const override
Definition: TileHitCnv_p1.cxx:35
Identifier
Definition: IdentifierFieldParser.cxx:14