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