2#define EmcMcHitCnv_CXX 1
4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/DataObject.h"
6#include "GaudiKernel/ObjectVector.h"
8#include "TClonesArray.h"
11#include "Identifier/Identifier.h"
13#include "EventModel/EventModel.h"
14#include "McTruth/McEvent.h"
15#include "McTruth/EmcMcHit.h"
16#include "RootEventData/TEmcMc.h"
17#include "RootEventData/TMcEvent.h"
18#include "RootCnvSvc/Mc/McCnv.h"
19#include "RootCnvSvc/Mc/EmcMcHitCnv.h"
20#include "RootCnvSvc/RootAddress.h"
32 MsgStream log(
msgSvc(),
"EmcMcHitCnv");
43 MsgStream log(
msgSvc(),
"EmcMcHitCnv");
44 log << MSG::DEBUG <<
"EmcMcHitCnv::TObjectToDataObject" << endreq;
45 StatusCode sc=StatusCode::SUCCESS;
48 EmcMcHitCol* emcMcTdsCol =
new EmcMcHitCol;
49 refpObject=emcMcTdsCol;
53 if (!m_emcMcHitCol)
return sc;
54 TIter emcMcIter(m_emcMcHitCol);
56 while ((emcMcRoot = (
TEmcMc*)emcMcIter.Next())) {
59 unsigned int id_root = emcMcRoot ->
getId();
71 double px= emcMcRoot ->
getPx() ;
72 double py = emcMcRoot ->
getPy() ;
73 double pz = emcMcRoot ->
getPz() ;
76 EmcMcHit *emcMcTds =
new EmcMcHit();
79 emcMcTds->setIdentifier(
id);
81 map<Int_t, Double_t> hitMap = emcMcRoot ->
getHitMap();
82 map<Identifier, Double_t> TdshitMap;
83 map<Int_t, Double_t> HitMap = emcMcRoot->
getHitMap();
84 map<Int_t, Double_t>::iterator iHitMap;
85 for(iHitMap=HitMap.begin();
86 iHitMap!=HitMap.end();
90 pair<Identifier, Double_t> TdsHit(
id, iHitMap->second);
91 TdshitMap.insert(TdsHit);
108 emcMcTds->setHitMap(TdshitMap);
110 emcMcTds->setHitEmc(hitEmc);
111 emcMcTds->setPDGCode(PDGCode);
112 emcMcTds->setPDGCharge(PDGCharge);
113 emcMcTds->setTime(
time);
115 emcMcTds->setTrackIndex(trackIndex);
116 emcMcTds->setPositionX(xPosition);
117 emcMcTds->setPositionY(yPosition);
118 emcMcTds->setPositionZ(zPosition);
122 emcMcTds->setDepositEnergy(depositEnergy);
124 emcMcTdsCol->push_back(emcMcTds);
127 delete m_emcMcHitCol;
129 return StatusCode::SUCCESS;
134 MsgStream log(
msgSvc(),
"EmcMcHitCnv");
135 log << MSG::DEBUG <<
"EmcMcHitCnv::DataObjectToTObject" << endreq;
136 StatusCode sc=StatusCode::SUCCESS;
138 EmcMcHitCol * emcMcHitCnvTds=
dynamic_cast<EmcMcHitCol *
> (obj);
139 if (!emcMcHitCnvTds) {
140 log << MSG::ERROR <<
"Could not downcast to EmcMcHitCol" << endreq;
141 return StatusCode::FAILURE;
147 log << MSG::ERROR <<
"Could not get McEvent in TDS " << endreq;
148 return StatusCode::FAILURE;
152 log << MSG::ERROR <<
"EmcMcHitCnv:Could not downcast to TDS McEvent" << endreq;
154 IOpaqueAddress *addr;
160 if (!m_emcMcHitCol)
return sc;
162 EmcMcHitCol::const_iterator emcMcTds;
164 for (emcMcTds = emcMcHitCnvTds->begin(); emcMcTds != emcMcHitCnvTds->end(); emcMcTds++) {
165 UInt_t
id = ((*emcMcTds)->identify()).get_value() ;
166 UInt_t trackIndex = (*emcMcTds) ->getTrackIndex();
168 int hitEmc = (*emcMcTds) ->getHitEmc();
169 int PDGCode = (*emcMcTds) ->getPDGCode();
170 double PDGCharge = (*emcMcTds) ->getPDGCharge();
171 double time = (*emcMcTds) ->getTime();
172 std::map<Identifier, Double_t> TdshitMap = (*emcMcTds)->getHitMap();
174 map<Int_t, Double_t> HitMap;
175 map<Identifier, Double_t>::iterator iHitMap;
176 for(iHitMap=TdshitMap.begin();
177 iHitMap!=TdshitMap.end();
180 Int_t id(iHitMap->first.get_value());
181 pair<Int_t, Double_t> Hit(
id, iHitMap->second);
200 Double_t xPosition = (*emcMcTds) ->getPositionX() ;
201 Double_t yPosition = (*emcMcTds) ->getPositionY() ;
202 Double_t zPosition = (*emcMcTds) ->getPositionZ() ;
203 Double_t px= (*emcMcTds) ->getPx() ;
204 Double_t py = (*emcMcTds) ->getPy() ;
205 Double_t pz = (*emcMcTds) ->getPz() ;
206 Double_t depositEnergy = (*emcMcTds) ->getDepositEnergy() ;
211 emcMcRoot->
setId(
id);
224 emcMcRoot->
setPx(px);
225 emcMcRoot->
setPy(py);
226 emcMcRoot->
setPz(pz);
232 return StatusCode::SUCCESS;
EmcMcHitCnv(ISvcLocator *svc)
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
static TMcEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition of a Root address, derived from IOpaqueAddress.
Base class for all Root Converters.
IDataProviderSvc * m_eds
pointer to eventdataservice
std::vector< void * > m_adresses
each converter knows the corresponding adresses
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.
Double_t getPositionY() const
void setPositionZ(Double_t positionZ)
void setTrackIndex(UInt_t trackIndex)
void setPDGCode(int PDGCode)
void setHitMap(std::map< Int_t, Double_t > hitMap)
double getPDGCharge() const
void setHitEmc(int hitEmc)
UInt_t getTrackIndex() const
void setPositionY(Double_t positionY)
void setPDGCharge(double PDGCharge)
Double_t getPositionX() const
Double_t getDepositEnergy() const
std::map< Int_t, Double_t > getHitMap() const
void setPositionX(Double_t positionX)
void setTime(double time)
Double_t getPositionZ() const
void setDepositEnergy(Double_t depositEnergy)
const TObjArray * getEmcMcHitCol() const
void addEmcMc(TEmcMc *mcHit)
Emc.
static std::map< const TObject *, const EmcMcHit * > m_rootEmcMcHitMap
_EXTERN_ std::string Event