1#ifndef CgemMcHitCnv_CXX
2#define CgemMcHitCnv_CXX 1
4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/DataObject.h"
6#include "GaudiKernel/ObjectVector.h"
8#include "TClonesArray.h"
11#include "EventModel/EventModel.h"
12#include "McTruth/McEvent.h"
13#include "McTruth/CgemMcHit.h"
14#include "RootEventData/TCgemMc.h"
15#include "RootEventData/TMcEvent.h"
16#include "RootCnvSvc/Mc/McCnv.h"
17#include "RootCnvSvc/Mc/CgemMcHitCnv.h"
18#include "RootCnvSvc/RootAddress.h"
29 MsgStream log(
msgSvc(),
"CgemMcHitCnv");
40 MsgStream log(
msgSvc(),
"CgemMcHitCnv");
41 log << MSG::DEBUG <<
"CgemMcHitCnv::TObjectToDataObject" << endreq;
42 StatusCode sc=StatusCode::SUCCESS;
45 CgemMcHitCol* cgemMcTdsCol =
new CgemMcHitCol;
46 refpObject=cgemMcTdsCol;
50 if (!m_cgemMcHitCol)
return sc;
51 TIter cgemMcIter(m_cgemMcHitCol);
53 while ((cgemMcRoot = (
TCgemMc*)cgemMcIter.Next()))
55 unsigned int ID_track = cgemMcRoot->
GetTrackID ();
56 unsigned int ID_layer = cgemMcRoot->
GetLayerID ();
58 unsigned int pdg_code = cgemMcRoot->
GetPDGCode ();
59 unsigned int ID_parent = cgemMcRoot->
GetParentID ();
81 CgemMcHit *cgemMcTds =
new CgemMcHit;
84 cgemMcTds->SetTrackID ( ID_track );
85 cgemMcTds->SetLayerID ( ID_layer );
87 cgemMcTds->SetPDGCode ( pdg_code );
88 cgemMcTds->SetParentID ( ID_parent );
90 cgemMcTds->SetTotalEnergyDeposit ( E_deposit );
91 cgemMcTds->SetPositionXOfPrePoint ( XYZ_pre_x );
92 cgemMcTds->SetPositionYOfPrePoint ( XYZ_pre_y );
93 cgemMcTds->SetPositionZOfPrePoint ( XYZ_pre_z );
94 cgemMcTds->SetPositionXOfPostPoint ( XYZ_post_x );
95 cgemMcTds->SetPositionYOfPostPoint ( XYZ_post_y );
96 cgemMcTds->SetPositionZOfPostPoint ( XYZ_post_z );
97 cgemMcTds->SetMomentumXOfPrePoint ( P_pre_x );
98 cgemMcTds->SetMomentumYOfPrePoint ( P_pre_y );
99 cgemMcTds->SetMomentumZOfPrePoint ( P_pre_z );
100 cgemMcTds->SetMomentumXOfPostPoint ( P_post_x );
101 cgemMcTds->SetMomentumYOfPostPoint ( P_post_y );
102 cgemMcTds->SetMomentumZOfPostPoint ( P_post_z );
103 cgemMcTds->SetCreatorProcess ( creatorProcess.Data());
106 for(
int j = 0; j < ID_Identifier.GetSize(); j++){
107 tmp[j] = ID_Identifier.GetAt(j);
109 cgemMcTds->AddIdentifier(tmp, ID_Identifier.GetSize());
111 cgemMcTdsCol->push_back(cgemMcTds);
114 delete m_cgemMcHitCol;
116 return StatusCode::SUCCESS;
121 MsgStream log(
msgSvc(),
"CgemMcHitCnv");
122 log << MSG::DEBUG <<
"CgemMcHitCnv::DataObjectToTObject" << endreq;
123 StatusCode sc=StatusCode::SUCCESS;
125 CgemMcHitCol * cgemMcHitCnvTds=
dynamic_cast<CgemMcHitCol *
> (obj);
126 if (!cgemMcHitCnvTds) {
127 log << MSG::ERROR <<
"Could not downcast to CgemMcHitCol" << endreq;
128 return StatusCode::FAILURE;
134 log << MSG::ERROR <<
"Could not get McEvent in TDS " << endreq;
135 return StatusCode::FAILURE;
139 log << MSG::ERROR <<
"CgemMcHitCnv:Could not downcast to TDS McEvent" << endreq;
141 IOpaqueAddress *addr;
147 if (!m_cgemMcHitCol)
return sc;
149 CgemMcHitCol::const_iterator cgemMcTds;
151 for (cgemMcTds = cgemMcHitCnvTds->begin(); cgemMcTds != cgemMcHitCnvTds->end(); cgemMcTds++)
153 unsigned int ID_track = (*cgemMcTds)->GetTrackID ();
154 unsigned int ID_layer = (*cgemMcTds)->GetLayerID ();
156 unsigned int pdg_code = (*cgemMcTds)->GetPDGCode ();
157 unsigned int ID_parent = (*cgemMcTds)->GetParentID ();
159 double E_deposit = (*cgemMcTds)->GetTotalEnergyDeposit ();
160 double XYZ_pre_x = (*cgemMcTds)->GetPositionXOfPrePoint ();
161 double XYZ_pre_y = (*cgemMcTds)->GetPositionYOfPrePoint ();
162 double XYZ_pre_z = (*cgemMcTds)->GetPositionZOfPrePoint ();
163 double XYZ_post_x = (*cgemMcTds)->GetPositionXOfPostPoint ();
164 double XYZ_post_y = (*cgemMcTds)->GetPositionYOfPostPoint ();
165 double XYZ_post_z = (*cgemMcTds)->GetPositionZOfPostPoint ();
166 double P_pre_x = (*cgemMcTds)->GetMomentumXOfPrePoint ();
167 double P_pre_y = (*cgemMcTds)->GetMomentumYOfPrePoint ();
168 double P_pre_z = (*cgemMcTds)->GetMomentumZOfPrePoint ();
169 double P_post_x = (*cgemMcTds)->GetMomentumXOfPostPoint ();
170 double P_post_y = (*cgemMcTds)->GetMomentumYOfPostPoint ();
171 double P_post_z = (*cgemMcTds)->GetMomentumZOfPostPoint ();
173 TArrayI ID_Identifier = (*cgemMcTds)->GetIdentifier ();
175 string creatorProcess = (*cgemMcTds)->GetCreatorProcess();
201 for(
int j = 0; j < ID_Identifier.GetSize(); j++){
202 tmp[j] = ID_Identifier.GetAt(j);
210 return StatusCode::SUCCESS;
CgemMcHitCnv(ISvcLocator *svc)
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to 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 GetPositionXOfPrePoint() const
Double_t GetMomentumYOfPostPoint() const
void AddIdentifier(Int_t f_ID_Identifier[2000], Int_t N_dim)
void SetMomentumZOfPrePoint(Double_t f_P_pre_z)
Double_t GetMomentumYOfPrePoint() const
Double_t GetPositionYOfPrePoint() const
UInt_t GetPDGCode() const
Double_t GetPositionZOfPostPoint() const
void SetMomentumYOfPostPoint(Double_t f_P_post_y)
void SetPositionZOfPostPoint(Double_t f_XYZ_post_z)
Double_t GetPositionZOfPrePoint() const
void SetMomentumXOfPrePoint(Double_t f_P_pre_x)
void SetCreatorProcess(std::string creatorProcess)
void SetParentID(UInt_t f_ID_parent)
void SetPositionXOfPrePoint(Double_t f_XYZ_pre_x)
Double_t GetMomentumZOfPostPoint() const
void SetTrackID(UInt_t f_ID_track)
UInt_t GetTrackID() const
void SetPositionZOfPrePoint(Double_t f_XYZ_pre_z)
void SetMomentumYOfPrePoint(Double_t f_P_pre_y)
void SetLayerID(UInt_t f_ID_layer)
void SetPDGCode(UInt_t f_pdg_code)
void SetPositionYOfPrePoint(Double_t f_XYZ_pre_y)
Double_t GetMomentumXOfPostPoint() const
UInt_t GetLayerID() const
Double_t GetMomentumZOfPrePoint() const
Double_t GetPositionYOfPostPoint() const
void SetPositionYOfPostPoint(Double_t f_XYZ_post_y)
Double_t GetPositionXOfPostPoint() const
Double_t GetTotalEnergyDeposit() const
void SetPositionXOfPostPoint(Double_t f_XYZ_post_x)
UInt_t GetParentID() const
void SetMomentumXOfPostPoint(Double_t f_P_post_x)
void SetMomentumZOfPostPoint(Double_t f_P_post_z)
Double_t GetMomentumXOfPrePoint() const
TArrayI GetIdentifier() const
void SetTotalEnergyDeposit(Double_t f_E_deposit)
TString GetCreatorProcess() const
const TObjArray * getCgemMcHitCol() const
void addCgemMc(TCgemMc *mcHit)
Cgem.
static std::map< const TObject *, const CgemMcHit * > m_rootCgemMcHitMap
_EXTERN_ std::string Event