BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
RawDataMcParticleCnv Class Reference

#include <RawDataMcParticleCnv.hpp>

Inheritance diagram for RawDataMcParticleCnv:

Public Member Functions

 RawDataMcParticleCnv (ISvcLocator *svc)
StatusCode createObj (IOpaqueAddress *pAddr, DataObject *&pObj)
StatusCode createRep (DataObject *, IOpaqueAddress *&)
void addMother (McParticle *currentParticle, McParticleCol *particleCol)
Public Member Functions inherited from RawDataBaseCnv
StatusCode initialize ()
long repSvcType () const
const long storageType ()
Public Member Functions inherited from Converter< Ty1, Ty2 >
destinationoperator (const source &) const
destinationoperator (const source &) const
destinationoperator (const source &) const

Static Public Member Functions

static const CLID & classID ()

Additional Inherited Members

Public Types inherited from Converter< Ty1, Ty2 >
typedef Ty1 source
typedef Ty2 destination
typedef Ty1 source
typedef Ty2 destination
typedef Ty1 source
typedef Ty2 destination
Protected Member Functions inherited from RawDataBaseCnv
 RawDataBaseCnv (long storageType, const CLID &clid, ISvcLocator *svc)
 RawDataBaseCnv (ISvcLocator *svc, const CLID &clid)
Protected Member Functions inherited from Converter< Ty1, Ty2 >
virtual destinationconvert (const source &) const =0
virtual destinationconvert (const source &) const =0
virtual destinationconvert (const source &) const =0
Protected Attributes inherited from RawDataBaseCnv
std::vector< IRawDataCnvSvc::Leafm_leaves
IRawDataCnvSvcm_cnvSvc
IRawDataInputSvcm_inputSvc

Detailed Description

Definition at line 13 of file RawDataMcParticleCnv.hpp.

Constructor & Destructor Documentation

◆ RawDataMcParticleCnv()

RawDataMcParticleCnv::RawDataMcParticleCnv ( ISvcLocator * svc)
inline

Definition at line 18 of file RawDataMcParticleCnv.hpp.

18: RawDataBaseCnv( svc, classID() ) {}
RawDataBaseCnv(long storageType, const CLID &clid, ISvcLocator *svc)
static const CLID & classID()

Member Function Documentation

◆ addMother()

void RawDataMcParticleCnv::addMother ( McParticle * currentParticle,
McParticleCol * particleCol )
inline

Definition at line 105 of file RawDataMcParticleCnv.hpp.

105 {
106
107 if ( currentParticle->leafParticle() ) return;
108
109 bool found = false;
110 McParticleCol::iterator iter = particleCol->begin();
111 // std::cout << "particleCol->size() = " << particleCol->size() << std::endl;
112 for ( ; iter != particleCol->end(); iter++ )
113 {
114 if ( currentParticle->vertexIndex1() == ( *iter )->vertexIndex0() )
115 {
116 found = true;
117 ( *iter )->setMother( currentParticle );
118 currentParticle->addDaughter( *iter );
119 addMother( ( *iter ), particleCol );
120 }
121 }
122
123 if ( !found )
124 std::cout << "RawDataMcParticleCnv::addMother: inconsistency was found!" << std::endl;
125 }
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
void addMother(McParticle *currentParticle, McParticleCol *particleCol)

Referenced by addMother(), and createObj().

◆ classID()

const CLID & RawDataMcParticleCnv::classID ( )
inlinestatic

Definition at line 20 of file RawDataMcParticleCnv.hpp.

20{ return CLID_McParticleCol; }
const CLID & CLID_McParticleCol

Referenced by RawDataCnvSvc::addConverters(), RawDataCnvSvc::createConverter(), and RawDataMcParticleCnv().

◆ createObj()

StatusCode RawDataMcParticleCnv::createObj ( IOpaqueAddress * pAddr,
DataObject *& pObj )
inline

Definition at line 22 of file RawDataMcParticleCnv.hpp.

22 {
23 // MsgStream log(msgSvc(), "RawDataMcParticleCnv");
24
25 // This converter will create an empty McParticleCol on the TDS
26 McParticleCol* mcParticleCol = new McParticleCol;
27 pObj = mcParticleCol;
28
29 RAWEVENT* evt = m_inputSvc->currentEvent();
30 if ( evt == NULL )
31 {
32 // log << MSG::ERROR << "RawDataCnv has no event!" << endmsg;
33 return StatusCode::FAILURE;
34 }
35
36 const BufferHolder& mcParBuf = evt->getMcParBuf();
37 if ( mcParBuf.nBuf() == 0 )
38 {
39 // cerr << "no McParticle Data Buffer found!!!" << endl;
40 return StatusCode::FAILURE;
41 }
42 uint32_t* buf = mcParBuf( 0 );
43
44 uint32_t nParticle = ( buf[0] >> 16 );
45 // uint32_t nVertex = (buf[0] & 0xFFFF);
46 double* vPointer = (double*)( buf + nParticle * 11 + 1 );
47
48 for ( uint32_t i = 0; i < nParticle; i++ )
49 {
50 McParticle* mcPar = new McParticle;
51 m_mcParticleBuilder.unPack( ( buf + 1 + i * 11 ), vPointer, mcPar );
52 mcParticleCol->push_back( mcPar );
53 }
54
55 // Get primary McParticles
56 SmartRefVector<McParticle> primaryParticleCol;
57 McParticleCol::iterator iter_particle = mcParticleCol->begin();
58 for ( ; iter_particle != mcParticleCol->end(); iter_particle++ )
59 {
60 if ( ( *iter_particle )->primaryParticle() )
61 {
62 McParticle* mcPart = (McParticle*)( *iter_particle );
63 primaryParticleCol.push_back( mcPart );
64 }
65 }
66
67 if ( primaryParticleCol.empty() )
68 {
69 // log << MSG::WARNING << "createObj error: no primary particle found!" << endmsg;
70 }
71
72 // Add mother particle recursively
73 SmartRefVector<McParticle>::iterator iter_primary = primaryParticleCol.begin();
74 // std::cout << "primaryParticleCol.size() = " << primaryParticleCol.size() << std::endl;
75 for ( ; iter_primary != primaryParticleCol.end(); iter_primary++ )
76 {
77
78 if ( !( *iter_primary )->leafParticle() ) addMother( ( *iter_primary ), mcParticleCol );
79 }
80
81 return StatusCode::SUCCESS;
82 }
ObjectList< McParticle > McParticleCol
IRawDataInputSvc * m_inputSvc

◆ createRep()

StatusCode RawDataMcParticleCnv::createRep ( DataObject * ,
IOpaqueAddress *&  )
inline

Definition at line 84 of file RawDataMcParticleCnv.hpp.

84 {
85 // convert PixelRaw in the container into ByteStream
86 // MsgStream log(msgSvc(), "RawDataMcParticleCnv");
87
88 WriteRawEvent*& re = m_cnvSvc->getRawEvent();
89 if ( re == 0 )
90 {
91 // log << " get RawEvent failed !" << endmsg;
92 return StatusCode::FAILURE;
93 }
94
95 SmartDataPtr<McParticleCol> mcParticleCol( dataProvider(), EventModel::MC::McParticleCol );
96 if ( mcParticleCol == 0 )
97 {
98 // log << "no McParticleCol found" << endmsg;
99 return StatusCode::FAILURE;
100 }
101
102 return m_mcParticleBuilder.pack( mcParticleCol, re );
103 }
eformat::write::FullEventFragment WriteRawEvent
IRawDataCnvSvc * m_cnvSvc

The documentation for this class was generated from the following file: