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

#include <RawDataMcParticleCnv.h>

+ Inheritance diagram for RawDataMcParticleCnv:

Public Member Functions

StatusCode initialize ()
 
virtual long repSvcType () const
 
StatusCode createObj (IOpaqueAddress *pAddr, DataObject *&pObj)
 
virtual StatusCode updateObj (IOpaqueAddress *pAddr, DataObject *pObj)
 override the RawDataBaseCnv version
 
virtual StatusCode createRep (DataObject *pObj, IOpaqueAddress *&pAddr)
 Convert the transient object to the requested representation.
 
- Public Member Functions inherited from RawDataBaseCnv
 RawDataBaseCnv (ISvcLocator *svc)
 
 RawDataBaseCnv (unsigned char storageType, const CLID &clid, ISvcLocator *svc)
 
virtual ~RawDataBaseCnv ()
 
virtual long repSvcType () const
 
StatusCode initialize ()
 
virtual StatusCode finalize ()
 
void declareObject (const std::string &fullPath, const CLID &clid, const std::string &bank, long par=0)
 Store TDS path to link a particular converter to an object on the TDS.
 
virtual StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress)
 Convert the transient object to the requested representation.
 
virtual StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Resolve the references of the converted object.
 
virtual StatusCode updateRep (IOpaqueAddress *pAddress, DataObject *pObject)
 Update the converted representation of a transient object.
 
virtual StatusCode updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Update the references of an already converted object.
 
- Public Member Functions inherited from Converter< Ty1, Ty2 >
destinationoperator (const source &) const
 

Static Public Member Functions

static const CLID & classID ()
 
static const unsigned char storageType ()
 
- Static Public Member Functions inherited from RawDataBaseCnv
static const long storageType ()
 
static const CLID & classID ()
 

Protected Member Functions

 RawDataMcParticleCnv (ISvcLocator *svc)
 
- Protected Member Functions inherited from Converter< Ty1, Ty2 >
virtual destinationconvert (const source &) const =0
 

Friends

class CnvFactory< RawDataMcParticleCnv >
 

Additional Inherited Members

- Public Types inherited from Converter< Ty1, Ty2 >
typedef Ty1 source
 
typedef Ty2 destination
 
- Protected Attributes inherited from RawDataBaseCnv
IRawDataCnvSvcm_CnvSvc
 Pointer to event conversion service interface.
 
std::vector< IRawDataCnvSvc::Leafm_leaves
 Leaf objects giving the locations of the objects in the data store.
 

Detailed Description

Definition at line 32 of file RawDataMcParticleCnv.h.

Constructor & Destructor Documentation

◆ RawDataMcParticleCnv()

RawDataMcParticleCnv::RawDataMcParticleCnv ( ISvcLocator *  svc)
protected

Definition at line 32 of file RawDataMcPaticleCnv.cxx.

32 :
34{
35 //init();
36}
unsigned const long PACKEDRAWEVENT_StorageType
Definition: ClassID_temp.h:17
static const CLID & classID()

Member Function Documentation

◆ classID()

const CLID & RawDataMcParticleCnv::classID ( )
static

Definition at line 40 of file RawDataMcPaticleCnv.cxx.

41{
42 return CLID_McParticleCol;
43}
const CLID & CLID_McParticleCol
Definition: EventModel.cxx:207

Referenced by PackedRawDataCnvSvc::addConverters().

◆ createObj()

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

Definition at line 110 of file RawDataMcPaticleCnv.cxx.

111{
112 //MsgStream log(msgSvc(), "RawDataMcParticleCnv");
113
114 //This converter will create an empty McParticleCol on the TDS
115 McParticleCol *mcParticleCol = new McParticleCol;
116 pObj = mcParticleCol;
117
118 RAWEVENT *evt = m_inputSvc->currentEvent();
119 if (evt == NULL) {
120 //log << MSG::ERROR << "RawDataCnv has no event!" << endreq;
121 return StatusCode::FAILURE;
122 }
123
124 const BufferHolder& mcParBuf = evt->getMcParBuf();
125 if (mcParBuf.nBuf() == 0) {
126 //cerr << "no McParticle Data Buffer found!!!" << endl;
127 return StatusCode::FAILURE;
128 }
129 uint32_t* buf = mcParBuf(0);
130
131 uint32_t nParticle = (buf[0] >> 16);
132 //uint32_t nVertex = (buf[0] & 0xFFFF);
133 double* vPointer = (double*)(buf + nParticle*11 + 1);
134
135 for (uint32_t i = 0; i < nParticle; i++) {
136 McParticle* mcPar = new McParticle;
137 m_mcParticleBuilder.unPack((buf+1+i*11), vPointer, mcPar);
138 mcParticleCol->push_back(mcPar);
139 }
140
141 // Get primary McParticles
142 SmartRefVector<McParticle> primaryParticleCol;
143 McParticleCol::iterator iter_particle = mcParticleCol->begin();
144 for ( ; iter_particle != mcParticleCol->end(); iter_particle++) {
145 if ((*iter_particle)->primaryParticle()) {
146 McParticle* mcPart = (McParticle*)(*iter_particle);
147 primaryParticleCol.push_back(mcPart);
148 }
149 }
150
151 if (primaryParticleCol.empty()) {
152 //log << MSG::WARNING << "createObj error: no primary particle found!" << endreq;
153 }
154
155 // Add mother particle recursively
156 SmartRefVector<McParticle>::iterator iter_primary = primaryParticleCol.begin();
157 //std::cout << "primaryParticleCol.size() = " << primaryParticleCol.size() << std::endl;
158 for ( ; iter_primary != primaryParticleCol.end(); iter_primary++) {
159
160 if (!(*iter_primary)->leafParticle())
161 addMother((*iter_primary), mcParticleCol);
162 }
163
164 return StatusCode::SUCCESS;
165}
#define NULL
uint32_t nBuf() const
Definition: BufferHolder.h:15
virtual RAWEVENT * currentEvent()=0
virtual void unPack(uint32_t *buf, double *vPointer, McParticle *mcPar)
const BufferHolder & getMcParBuf() const
Definition: RAWEVENT.h:105
ObjectList< McParticle > McParticleCol
Definition: McParticle.h:205

◆ createRep()

StatusCode RawDataMcParticleCnv::createRep ( DataObject *  pObject,
IOpaqueAddress *&  refpAddress 
)
virtual

Convert the transient object to the requested representation.

Reimplemented from RawDataBaseCnv.

Definition at line 167 of file RawDataMcPaticleCnv.cxx.

168{
169 // convert PixelRaw in the container into ByteStream
170 //MsgStream log(messageService(), "RawDataMcParticleCnv");
171
172 WriteRawEvent*& re = m_RawDataAccess->getRawEvent();
173 if (re == 0) {
174 //log << " get RawEvent failed !" << endreq;
175 return StatusCode::FAILURE;
176 }
177
178 SmartDataPtr<McParticleCol> mcParticleCol(dataProvider(), EventModel::MC::McParticleCol);
179 if (mcParticleCol == 0) {
180 //log << "no McParticleCol found" << endreq;
181 return StatusCode::FAILURE;
182 }
183
184 return m_mcParticleBuilder.pack(mcParticleCol, re);
185}
virtual StatusCode pack(McParticleCol *mcParticleCol, WriteRawEvent *&re)
virtual WriteRawEvent *& getRawEvent()
_EXTERN_ std::string McParticleCol
Definition: EventModel.h:41

◆ initialize()

StatusCode RawDataMcParticleCnv::initialize ( )

Definition at line 45 of file RawDataMcPaticleCnv.cxx.

46{
47
48 std::string PackedRawDataCnvSvc_Name("PackedRawDataCnvSvc");
49 std::string RawDataInputSvc_Name("RawDataInputSvc");
50 std::string RawDataMcParticleCnv_Name("RawDataMcParticleCnv");
51
52 // for Mutil-thread by tianhl
53 //ConversionSvc* pCnvSvc = 0;
54 //if (pCnvSvc = dynamic_cast<ConversionSvc*>(conversionSvc())){
55 SmartIF<IService> pCnvSvc(conversionSvc());
56 if (isGaudiThreaded(pCnvSvc->name())){
57 PackedRawDataCnvSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
58 RawDataInputSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
59 RawDataMcParticleCnv_Name += getGaudiThreadIDfromName(pCnvSvc->name());
60 }
61 //}
62
63 MsgStream log(messageService(), RawDataMcParticleCnv_Name.c_str());
64
65 StatusCode sc = RawDataBaseCnv::initialize();
66 if (StatusCode::SUCCESS != sc) {
67 log << MSG::ERROR << "RawDataBaseCnv: Cant initialize PackedRawDataCnvSvc" << endreq;
68 return sc;
69 }
70
71 // Check RawDataCnvSvc
72 IService* isvc = 0;
73 sc = serviceLocator()->service(PackedRawDataCnvSvc_Name.c_str(), isvc, true);
74 if (sc != StatusCode::SUCCESS) {
75 log << MSG::ERROR << "Cant get PackedRawDataCnvSvc" << endreq;
76 }
77
78 m_RawDataAccess = dynamic_cast<PackedRawDataCnvSvc*> (isvc);
79 if (m_RawDataAccess == 0 ) {
80 log << MSG::ERROR << "RawDataMcParticleCnv: Cant cast to RawDataCnvSvc " << endreq;
81 return StatusCode::FAILURE;
82 }
83
84 sc = serviceLocator()->getService(RawDataInputSvc_Name.c_str(), isvc);
85 if (sc != StatusCode::SUCCESS ) {
86 log << MSG::WARNING << "Cant get RawDataInputSvc " << endreq;
87 return sc ;
88 }
89
90 m_inputSvc = dynamic_cast<RawDataInputSvc*> (isvc);
91 if (m_inputSvc == 0 ) {
92 log << MSG::WARNING << "Cant cast to RawDataInputSvc " << endreq;
93 return StatusCode::FAILURE ;
94 }
95
96 return StatusCode::SUCCESS;
97}
StatusCode initialize()

◆ repSvcType()

virtual long RawDataMcParticleCnv::repSvcType ( ) const
inlinevirtual

Reimplemented from RawDataBaseCnv.

Definition at line 46 of file RawDataMcParticleCnv.h.

46 {
48 }

◆ storageType()

static const unsigned char RawDataMcParticleCnv::storageType ( )
inlinestatic

Definition at line 50 of file RawDataMcParticleCnv.h.

50 {
52 }

◆ updateObj()

StatusCode RawDataMcParticleCnv::updateObj ( IOpaqueAddress *  pAddr,
DataObject *  pObj 
)
virtual

override the RawDataBaseCnv version

Definition at line 100 of file RawDataMcPaticleCnv.cxx.

100 {
101 // Purpose and Method: This method does nothing other than announce it has
102 // been called.
103
104 //MsgStream log(msgSvc(), "RawDataMcParticleCnv");
105 //log << MSG::DEBUG << "RawDataMcParticleCnv::updateObj" << endreq;
106 return Converter::updateObj(pAddr, pObj);
107}

Friends And Related Function Documentation

◆ CnvFactory< RawDataMcParticleCnv >

friend class CnvFactory< RawDataMcParticleCnv >
friend

Definition at line 1 of file RawDataMcParticleCnv.h.


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