BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
RawDataMucMcHitCnv.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "Identifier/MucID.h"
4#include "RawDataCnv/EventManagement/McTruthDataStructure.h"
5#include "RawDataCnv/EventManagement/MucMcHitBuilder.h"
6
7#include "RawDataBaseCnv.h"
8
9extern const CLID& CLID_MucMcHitCol;
10
12private:
13 /// MucMcHitder for packing or unpacking data
14 MucMcHitBuilder m_mucMcHitBuilder;
15
16public:
17 RawDataMucMcHitCnv( ISvcLocator* svc ) : RawDataBaseCnv( svc, classID() ) {}
18
19 static const CLID& classID() { return CLID_MucMcHitCol; }
20
21 StatusCode createObj( IOpaqueAddress* pAddr, DataObject*& pObj ) {
22 // MsgStream log(msgSvc(), "RawDataMucMcHitCnv");
23
24 // This converter will create an empty MucMcHitCol on the TDS
25 MucMcHitCol* mucMcHitCol = new MucMcHitCol;
26 pObj = mucMcHitCol;
27
28 RAWEVENT* evt = m_inputSvc->currentEvent();
29 if ( evt == NULL )
30 {
31 // log << MSG::ERROR << "RawDataCnv has no event!" << endmsg;
32 return StatusCode::FAILURE;
33 }
34
35 assert( ( evt->getMucTruth().size() % 7 ) == 0 );
36
37 MucMcHit* mucMcHit;
38 MucTruth_t m_MucTruth;
39
40 std::vector<uint32_t>::const_iterator iter = evt->getMucTruth().begin();
41 std::vector<uint32_t>::const_iterator eiter = evt->getMucTruth().end();
42
43 for ( int mucMcHitId = 0; iter != eiter; mucMcHitId++ )
44 {
45 // retrieve the MucTruth data
46 m_mucMcHitBuilder.unPack( iter, eiter, m_MucTruth );
47 // construct the identifier
48 const Identifier ident = MucID::channel_id( m_MucTruth.partId, m_MucTruth.segId,
49 m_MucTruth.gapId, m_MucTruth.stripId );
50 // construct the MucMcHit
51 mucMcHit = new MucMcHit( ident, m_MucTruth.trackIndex % 1000,
52 m_MucTruth.x / ( m_mucMcHitBuilder.m_xCoeff * 1.0 ),
53 m_MucTruth.y / ( m_mucMcHitBuilder.m_yCoeff * 1.0 ),
54 m_MucTruth.z / ( m_mucMcHitBuilder.m_zCoeff * 1.0 ),
55 m_MucTruth.px / ( m_mucMcHitBuilder.m_pxCoeff * 1.0 ),
56 m_MucTruth.py / ( m_mucMcHitBuilder.m_pyCoeff * 1.0 ),
57 m_MucTruth.pz / ( m_mucMcHitBuilder.m_pzCoeff * 1.0 ) );
58 // And add the stuff to the container
59 mucMcHitCol->push_back( mucMcHit );
60 }
61
62 return StatusCode::SUCCESS;
63 }
64
65 StatusCode createRep( DataObject* pObj, IOpaqueAddress*& pAddr ) {
66 // convert PixelRaw in the container into ByteStream
67 // MsgStream log(msgSvc(), "RawDataMucMcHitCnv");
68
69 WriteRawEvent*& re = m_cnvSvc->getRawEvent();
70
71 if ( re == 0 )
72 {
73 // log << " get RawEvent failed !" << endmsg;
74 return StatusCode::FAILURE;
75 }
76
77 SmartDataPtr<MucMcHitCol> mcHitCol( dataProvider(), EventModel::MC::MucMcHitCol );
78
79 if ( mcHitCol == 0 )
80 {
81 // log << "no MucMcHitCol found" << endmsg;
82 return StatusCode::FAILURE;
83 }
84
85 StatusCode sc = m_mucMcHitBuilder.pack( mcHitCol, re );
86
87 return sc;
88 }
89};
const CLID & CLID_MucMcHitCol
ObjectVector< MucMcHit > MucMcHitCol
eformat::write::FullEventFragment WriteRawEvent
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
const CLID & CLID_MucMcHitCol
static Identifier channel_id(int barrel_ec, int segment, int layer, int channel)
For a single crystal.
Definition MucID.cxx:114
IRawDataCnvSvc * m_cnvSvc
IRawDataInputSvc * m_inputSvc
RawDataBaseCnv(long storageType, const CLID &clid, ISvcLocator *svc)
RawDataMucMcHitCnv(ISvcLocator *svc)
StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
static const CLID & classID()
StatusCode createRep(DataObject *pObj, IOpaqueAddress *&pAddr)