1#ifndef McParticleCnv_CXX
2#define McParticleCnv_CXX 1
4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/DataObject.h"
6#include "GaudiKernel/ObjectVector.h"
8#include "TClonesArray.h"
29 MsgStream log(
msgSvc(),
"McParticleCnv");
40 MsgStream log(
msgSvc(),
"McParticleCnv");
41 log << MSG::DEBUG <<
"McParticleCnv::TObjectToDataObject" << endreq;
42 StatusCode sc=StatusCode::SUCCESS;
46 refpObject=mcParticleTdsCol;
50 if (!m_mcParticleCol)
return sc;
51 TIter mcParticleIter(m_mcParticleCol);
57 while ((mcParticleRoot = (
TMcParticle*)mcParticleIter.Next())) {
85 HepLorentzVector initialMomentum(xInitialMomentum, yInitialMomentum, zInitialMomentum, eInitialMomentum);
86 HepLorentzVector initialPosition(xInitialPosition, yInitialPosition, zInitialPosition, tInitialPosition);
88 HepLorentzVector finalPosition(xFinalPosition, yFinalPosition, zFinalPosition, tFinalPosition);
94 mothers.push_back(mother);
101 mcParticleTds->
initialize(particleID, statusFlags, initialMomentum, initialPosition);
108 mcParticleTds->
finalize(finalPosition);
110 mcParticleTdsCol->push_back(mcParticleTds);
114 McParticleCol::iterator
iter;
116 for (
iter = mcParticleTdsCol->begin();
iter != mcParticleTdsCol->end();
iter++,i++){
118 if(mothers[i] != -99 ){
119 McParticleCol::iterator mcParticleTds;
120 for (mcParticleTds = mcParticleTdsCol->begin(); mcParticleTds != mcParticleTdsCol->end(); mcParticleTds++) {
121 int trackIndex = (*mcParticleTds)->trackIndex();
122 if( trackIndex == mothers[i] ){
123 (*iter)->setMother(*mcParticleTds);
124 (*mcParticleTds)->addDaughter(*
iter);
130 (*iter)->setMother(*
iter);
134 delete m_mcParticleCol;
136 return StatusCode::SUCCESS;
141 MsgStream log(
msgSvc(),
"McParticleCnv");
142 log << MSG::DEBUG <<
"McParticleCnv::DataObjectToTObject" << endreq;
143 StatusCode sc=StatusCode::SUCCESS;
146 if (!mcParticleCnvTds) {
147 log << MSG::ERROR <<
"Could not downcast to McParticleCol" << endreq;
148 return StatusCode::FAILURE;
154 log << MSG::ERROR <<
"Could not get McEvent in TDS " << endreq;
155 return StatusCode::FAILURE;
159 log << MSG::ERROR <<
"McParticleCnv:Could not downcast to TDS McEvent" << endreq;
161 IOpaqueAddress *addr;
167 if (!m_mcParticleCol) {
return sc; }
170 McParticleCol::const_iterator mcParticleTds;
172 for (mcParticleTds = mcParticleCnvTds->begin(); mcParticleTds != mcParticleCnvTds->end(); mcParticleTds++) {
173 Int_t particleID = (*mcParticleTds)->particleProperty();
174 Int_t trackIndex = (*mcParticleTds)->trackIndex();
176 Int_t vertexIndex0 = (*mcParticleTds)->vertexIndex0();
177 Int_t vertexIndex1 = (*mcParticleTds)->vertexIndex1();
178 Int_t statusFlags = (*mcParticleTds)->statusFlags();
180 HepLorentzVector initialPosition = (*mcParticleTds)->initialPosition();
181 HepLorentzVector finalPosition = (*mcParticleTds)->finalPosition();
182 HepLorentzVector initialFourMomentum = (*mcParticleTds)->initialFourMomentum();
188 if(!(*mcParticleTds)->primaryParticle()) mother = ((*mcParticleTds)->mother()).trackIndex();
190 vector<Int_t> daughters;
191 SmartRefVector<McParticle> daughterList = (*mcParticleTds)->daughterList();
193 for (
int iPar = 0; iPar < daughterList.size(); iPar++) {
195 daughters.push_back(daughterList[iPar]->trackIndex());
247 return StatusCode::SUCCESS;
void setVertexIndex0(int index0)
methods for setting and getting vertex indexes
void initialize(StdHepId id, unsigned int statusBits, const HepLorentzVector &initialMomentum, const HepLorentzVector &initialPosition, const std::string process="")
Set the initial attributes of the McParticle.
void addStatusFlag(unsigned int flag)
add a new flag to the status flags
void finalize(const HepLorentzVector &finalPosition)
Set the final attributes of the McParticle.
void setVertexIndex1(int index1)
void setTrackIndex(int trackIndex)
static TMcEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
McParticleCnv(ISvcLocator *svc)
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
Definition of a Root address, derived from IOpaqueAddress.
Base class for all Root Converters.
std::vector< void * > m_adresses
each converter knows the corresponding adresses
IDataProviderSvc * m_eds
pointer to eventdataservice
std::string m_rootBranchname
root branchname (may be concatenated of severals)
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)
Convert the transient object to the requested representation.
void addMcParticle(TMcParticle *mcHit)
McParticle.
const TObjArray * getMcParticleCol() const
void clearMcParticleCol()
void setInitialPositionT(Double_t positionT)
void setFinalPositionZ(Double_t positionZ)
Double_t getInitialMomentumX() const
void setStatusFlags(UInt_t statusFlags)
Double_t getFinalPositionT() const
Double_t getFinalPositionX() const
Int_t getVertexIndex0() const
void setInitialPositionX(Double_t positionX)
void setFinalPositionY(Double_t positionY)
void setInitialPositionY(Double_t positionY)
void setMother(Int_t mother)
void setInitialMomentumZ(Double_t momentumZ)
Double_t getInitialPositionX() const
void setInitialPositionZ(Double_t positionZ)
Int_t getParticleID() const
void setVertexIndex1(Int_t vertexIndex1)
Double_t getInitialMomentumZ() const
Double_t getInitialMomentumY() const
void setInitialMomentumX(Double_t momentumX)
UInt_t getStatusFlags() const
void setTrackIndex(Int_t trackIndex)
vector< Int_t > getDaughters() const
void setFinalPositionT(Double_t positionT)
void setInitialMomentumE(Double_t momentumE)
void setVertexIndex0(Int_t vertexIndex0)
Double_t getInitialPositionZ() const
void setParticleID(Int_t particleID)
Double_t getInitialPositionT() const
Double_t getFinalPositionY() const
void setFinalPositionX(Double_t positionX)
Int_t getVertexIndex1() const
Int_t getTrackIndex() const
Double_t getFinalPositionZ() const
Double_t getInitialPositionY() const
void setInitialMomentumY(Double_t momentumY)
Double_t getInitialMomentumE() const
void setDaughters(vector< Int_t > &daughters)
static std::map< const TObject *, const McParticle * > m_rootMcParticleMap
_EXTERN_ std::string Event
ObjectList< McParticle > McParticleCol