BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
EmcMcHitCnv Class Reference

#include <EmcMcHitCnv.h>

+ Inheritance diagram for EmcMcHitCnv:

Public Member Functions

virtual ~EmcMcHitCnv ()
 
- Public Member Functions inherited from RootEventBaseCnv
 RootEventBaseCnv (const CLID &clid, ISvcLocator *svc)
 
virtual ~RootEventBaseCnv ()
 
virtual long repSvcType () const
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
void declareObject (const std::string &fullPath, const CLID &clid, const std::string &treename, const std::string &branchname)
 Store TDS path to link a particular converter to an object on the TDS.
 
virtual StatusCode createObj (IOpaqueAddress *addr, DataObject *&dat)
 Convert the persistent object to transient.
 
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 fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Resolve the references of the converted object.
 
TObject * getReadObject () const
 get the object to be read
 
- Public Member Functions inherited from Converter< Ty1, Ty2 >
destinationoperator (const source &) const
 

Static Public Member Functions

static const CLID & classID ()
 
- Static Public Member Functions inherited from RootEventBaseCnv
static const unsigned char storageType ()
 Storage type and class ID.
 

Protected Member Functions

 EmcMcHitCnv (ISvcLocator *svc)
 
virtual StatusCode DataObjectToTObject (DataObject *obj, RootAddress *addr)
 transformation to root
 
virtual StatusCode TObjectToDataObject (DataObject *&obj)
 transformation from root
 
- Protected Member Functions inherited from Converter< Ty1, Ty2 >
virtual destinationconvert (const source &) const =0
 

Friends

class CnvFactory< EmcMcHitCnv >
 

Additional Inherited Members

- Public Types inherited from Converter< Ty1, Ty2 >
typedef Ty1 source
 
typedef Ty2 destination
 
- Protected Attributes inherited from RootEventBaseCnv
RootCnvSvcm_cnvSvc
 
std::vector< RootCnvSvc::Leafm_leaves
 
RootInterfacem_rootInterface
 pointer to the RootInterface
 
IDataProviderSvc * m_eds
 pointer to eventdataservice
 
int m_branchNr
 the branchNr of this converter for writing
 
int m_branchNrDst
 
int m_branchNrMc
 
int m_branchNrRecon
 
int m_branchNrEvtRec
 
int m_branchNrEvtHeader
 
int m_branchNrEvtNavigator
 
TObject * m_objRead
 the object that was read
 
CLID CLID_top
 the CLID of the upper converter if any
 
TArrayS * m_branchNumbers
 array with number of branches for reading
 
std::string m_rootBranchname
 root branchname (may be concatenated of severals)
 
std::string m_rootTreename
 each converter knows it's treename
 
std::string m_currentFileName
 
std::vector< void * > m_adresses
 each converter knows the corresponding adresses
 
RootEvtSelectorm_evtsel
 

Detailed Description

Definition at line 19 of file EmcMcHitCnv.h.

Constructor & Destructor Documentation

◆ ~EmcMcHitCnv()

virtual EmcMcHitCnv::~EmcMcHitCnv ( )
inlinevirtual

Definition at line 29 of file EmcMcHitCnv.h.

29{ };

◆ EmcMcHitCnv()

EmcMcHitCnv::EmcMcHitCnv ( ISvcLocator * svc)
protected

Definition at line 28 of file EmcMcHitCnv.cxx.

30{
31 // Here we associate this converter with the /Event path on the TDS.
32 MsgStream log(msgSvc(), "EmcMcHitCnv");
33 // log << MSG::DEBUG << "Constructor called for " << objType() << endreq;
34 m_rootBranchname ="m_emcMcHitCol";
35 //declareObject(EventModel::MC::EmcMcHitCol, objType(), m_rootTreename, m_rootBranchname);
36 m_adresses.push_back(&m_emcMcHitCol);
37 m_emcMcHitCol=0;
38}
IMessageSvc * msgSvc()
static const CLID & classID()
Definition EmcMcHitCnv.h:24
std::vector< void * > m_adresses
each converter knows the corresponding adresses
std::string m_rootBranchname
root branchname (may be concatenated of severals)
RootEventBaseCnv(const CLID &clid, ISvcLocator *svc)

Member Function Documentation

◆ classID()

static const CLID & EmcMcHitCnv::classID ( )
inlinestatic

Definition at line 24 of file EmcMcHitCnv.h.

25 {
26 return CLID_EmcMcHitCol;
27 }
const CLID & CLID_EmcMcHitCol

◆ DataObjectToTObject()

StatusCode EmcMcHitCnv::DataObjectToTObject ( DataObject * obj,
RootAddress * addr )
protectedvirtual

transformation to root

Implements RootEventBaseCnv.

Definition at line 132 of file EmcMcHitCnv.cxx.

132 {
133
134 MsgStream log(msgSvc(), "EmcMcHitCnv");
135 log << MSG::DEBUG << "EmcMcHitCnv::DataObjectToTObject" << endreq;
136 StatusCode sc=StatusCode::SUCCESS;
137
138 EmcMcHitCol * emcMcHitCnvTds=dynamic_cast<EmcMcHitCol *> (obj);
139 if (!emcMcHitCnvTds) {
140 log << MSG::ERROR << "Could not downcast to EmcMcHitCol" << endreq;
141 return StatusCode::FAILURE;
142 }
143
144 DataObject *evt;
145 m_eds->findObject(EventModel::MC::Event,evt);
146 if (evt==NULL) {
147 log << MSG::ERROR << "Could not get McEvent in TDS " << endreq;
148 return StatusCode::FAILURE;
149 }
150 McEvent * devtTds=dynamic_cast<McEvent *> (evt);
151 if (!devtTds) {
152 log << MSG::ERROR << "EmcMcHitCnv:Could not downcast to TDS McEvent" << endreq;
153 }
154 IOpaqueAddress *addr;
155
156 m_cnvSvc->getMcCnv()->createRep(evt,addr);
158
159 const TObjArray *m_emcMcHitCol = McEvt->getEmcMcHitCol();
160 if (!m_emcMcHitCol) return sc;
161 McEvt->clearEmcMcHitCol(); //necessary in case there is I/O at the same time since array is static
162 EmcMcHitCol::const_iterator emcMcTds;
163
164 for (emcMcTds = emcMcHitCnvTds->begin(); emcMcTds != emcMcHitCnvTds->end(); emcMcTds++) {
165 UInt_t id = ((*emcMcTds)->identify()).get_value() ;
166 UInt_t trackIndex = (*emcMcTds) ->getTrackIndex();
167
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();
173
174 map<Int_t, Double_t> HitMap;
175 map<Identifier, Double_t>::iterator iHitMap;
176 for(iHitMap=TdshitMap.begin();
177 iHitMap!=TdshitMap.end();
178 iHitMap++) {
179
180 Int_t id(iHitMap->first.get_value());
181 pair<Int_t, Double_t> Hit(id, iHitMap->second);
182 HitMap.insert(Hit);
183
184 //RecEmcHitCol::iterator iHit;
185 //for(iHit=emcRecHitCol->begin();
186 // iHit!=emcRecHitCol->end();
187 // iHit++) {
188
189 // RecEmcID idHit((*iHit)->getCellId());
190
191 // if(id==idHit) {
192 // RecEmcFraction frac(*(*iHit));
193 // frac.Fraction(iHitMap->second);
194 // emcShowerTds->Insert(frac);
195 // break;
196 // }
197 //} //RecEmcHitCol
198 } //CellIdMap
199
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() ;
207
208 TEmcMc *emcMcRoot = new TEmcMc();
209 //m_common.m_emcMcHitMap[(*emcMcTds)] = emcMcRoot;
210
211 emcMcRoot->setId(id);
212 emcMcRoot->setHitMap(HitMap);
213
214 emcMcRoot->setHitEmc(hitEmc);
215 emcMcRoot->setPDGCode(PDGCode);
216 emcMcRoot->setPDGCharge(PDGCharge);
217 emcMcRoot->setTime(time);
218 //emcMcRoot->setHitMap(hitMap);
219
220 emcMcRoot->setTrackIndex(trackIndex);
221 emcMcRoot->setPositionX(xPosition);
222 emcMcRoot->setPositionY(yPosition);
223 emcMcRoot->setPositionZ(zPosition);
224 emcMcRoot->setPx(px);
225 emcMcRoot->setPy(py);
226 emcMcRoot->setPz(pz);
227 emcMcRoot->setDepositEnergy(depositEnergy);
228
229 McEvt->addEmcMc(emcMcRoot);
230 }
231
232 return StatusCode::SUCCESS;
233}
Double_t time
#define NULL
static TMcEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition McCnv.h:35
McCnv * getMcCnv()
Definition RootCnvSvc.h:156
RootCnvSvc * m_cnvSvc
IDataProviderSvc * m_eds
pointer to eventdataservice
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)
Convert the transient object to the requested representation.
void setPositionZ(Double_t positionZ)
Definition TEmcMc.h:72
void setTrackIndex(UInt_t trackIndex)
Definition TEmcMc.h:69
void setPDGCode(int PDGCode)
Definition TEmcMc.h:64
void setHitMap(std::map< Int_t, Double_t > hitMap)
Definition TEmcMc.h:62
void setHitEmc(int hitEmc)
Definition TEmcMc.h:63
void setPx(Double_t px)
Definition TEmcMc.h:73
void setPositionY(Double_t positionY)
Definition TEmcMc.h:71
void setPDGCharge(double PDGCharge)
Definition TEmcMc.h:65
void setPz(Double_t pz)
Definition TEmcMc.h:75
void setPositionX(Double_t positionX)
Definition TEmcMc.h:70
void setTime(double time)
Definition TEmcMc.h:66
void setId(UInt_t id)
Definition TEmcMc.h:68
void setDepositEnergy(Double_t depositEnergy)
Definition TEmcMc.h:76
void setPy(Double_t py)
Definition TEmcMc.h:74
void clearEmcMcHitCol()
Definition TMcEvent.h:41
const TObjArray * getEmcMcHitCol() const
Definition TMcEvent.h:38
void addEmcMc(TEmcMc *mcHit)
Emc.
Definition TMcEvent.cxx:113
_EXTERN_ std::string Event
Definition EventModel.h:39
ObjectVector< EmcMcHit > EmcMcHitCol
Definition EmcMcHit.h:132

◆ TObjectToDataObject()

StatusCode EmcMcHitCnv::TObjectToDataObject ( DataObject *& obj)
protectedvirtual

transformation from root

Implements RootEventBaseCnv.

Definition at line 40 of file EmcMcHitCnv.cxx.

40 {
41 // creation of TDS object from root object
42
43 MsgStream log(msgSvc(), "EmcMcHitCnv");
44 log << MSG::DEBUG << "EmcMcHitCnv::TObjectToDataObject" << endreq;
45 StatusCode sc=StatusCode::SUCCESS;
46
47 // create the TDS location for the MdcMc Collection
48 EmcMcHitCol* emcMcTdsCol = new EmcMcHitCol;
49 refpObject=emcMcTdsCol;
50
51
52 // now convert
53 if (!m_emcMcHitCol) return sc;
54 TIter emcMcIter(m_emcMcHitCol);
55 TEmcMc *emcMcRoot = 0;
56 while ((emcMcRoot = (TEmcMc*)emcMcIter.Next())) {
57 // unsigned int id = emcMcRoot ->getId();
58 Identifier id ;
59 unsigned int id_root = emcMcRoot ->getId();
60 id = id_root;
61 unsigned int trackIndex = emcMcRoot ->getTrackIndex();
62
63 int hitEmc = emcMcRoot ->getHitEmc();
64 int PDGCode = emcMcRoot ->getPDGCode();
65 double PDGCharge = emcMcRoot ->getPDGCharge();
66 double time = emcMcRoot ->getTime();
67
68 double xPosition = emcMcRoot ->getPositionX() ;
69 double yPosition = emcMcRoot ->getPositionY() ;
70 double zPosition = emcMcRoot ->getPositionZ() ;
71 double px= emcMcRoot ->getPx() ;
72 double py = emcMcRoot ->getPy() ;
73 double pz = emcMcRoot ->getPz() ;
74 double depositEnergy = emcMcRoot ->getDepositEnergy() ;
75
76 EmcMcHit *emcMcTds = new EmcMcHit();
77 m_common.m_rootEmcMcHitMap[emcMcRoot] = emcMcTds;
78
79 emcMcTds->setIdentifier(id);
80
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();
87 iHitMap++) {
88
89 Identifier id(iHitMap->first);
90 pair<Identifier, Double_t> TdsHit(id, iHitMap->second);
91 TdshitMap.insert(TdsHit);
92
93 //RecEmcHitCol::iterator iHit;
94 //for(iHit=emcRecHitCol->begin();
95 // iHit!=emcRecHitCol->end();
96 // iHit++) {
97
98 // RecEmcID idHit((*iHit)->getCellId());
99
100 // if(id==idHit) {
101 // RecEmcFraction frac(*(*iHit));
102 // frac.Fraction(iHitMap->second);
103 // emcShowerTds->Insert(frac);
104 // break;
105 // }
106 //} //RecEmcHitCol
107 } //CellIdMap
108 emcMcTds->setHitMap(TdshitMap);
109
110 emcMcTds->setHitEmc(hitEmc);
111 emcMcTds->setPDGCode(PDGCode);
112 emcMcTds->setPDGCharge(PDGCharge);
113 emcMcTds->setTime(time);
114
115 emcMcTds->setTrackIndex(trackIndex);
116 emcMcTds->setPositionX(xPosition);
117 emcMcTds->setPositionY(yPosition);
118 emcMcTds->setPositionZ(zPosition);
119 emcMcTds->setPx(px);
120 emcMcTds->setPy(py);
121 emcMcTds->setPz(pz);
122 emcMcTds->setDepositEnergy(depositEnergy);
123
124 emcMcTdsCol->push_back(emcMcTds);
125 }
126 //m_emcMcHitCol->Delete(); // wensp add 2005/12/30
127 delete m_emcMcHitCol;
128 m_emcMcHitCol = 0;
129 return StatusCode::SUCCESS;
130}
void setPDGCode(int code)
Definition EmcMcHit.h:75
void setPositionX(double positionX)
Definition EmcMcHit.h:79
void setHitEmc(int is)
Definition EmcMcHit.h:74
void setPDGCharge(double charge)
Definition EmcMcHit.h:76
void setTime(double time)
Definition EmcMcHit.h:77
void setDepositEnergy(double depositEnergy)
Definition EmcMcHit.h:85
void setHitMap(std::map< Identifier, double > &hitMap)
Definition EmcMcHit.h:94
void setTrackIndex(unsigned int trackIndex)
Definition EmcMcHit.h:78
void setPz(double pz)
Definition EmcMcHit.h:84
void setIdentifier(Identifier &id)
Definition EmcMcHit.h:73
void setPx(double px)
Definition EmcMcHit.h:82
void setPositionY(double positionY)
Definition EmcMcHit.h:80
void setPositionZ(double positionZ)
Definition EmcMcHit.h:81
void setPy(double py)
Definition EmcMcHit.h:83
Double_t getPositionY() const
Definition TEmcMc.h:43
Double_t getPz() const
Definition TEmcMc.h:55
Double_t getPx() const
Definition TEmcMc.h:49
UInt_t getId() const
Definition TEmcMc.h:34
double getPDGCharge() const
Definition TEmcMc.h:28
int getPDGCode() const
Definition TEmcMc.h:25
UInt_t getTrackIndex() const
Definition TEmcMc.h:37
int getHitEmc() const
Definition TEmcMc.h:22
Double_t getPy() const
Definition TEmcMc.h:52
Double_t getPositionX() const
Definition TEmcMc.h:40
double getTime() const
Definition TEmcMc.h:31
Double_t getDepositEnergy() const
Definition TEmcMc.h:58
std::map< Int_t, Double_t > getHitMap() const
Definition TEmcMc.h:19
Double_t getPositionZ() const
Definition TEmcMc.h:46
static std::map< const TObject *, const EmcMcHit * > m_rootEmcMcHitMap
Definition commonData.h:167

Friends And Related Symbol Documentation

◆ CnvFactory< EmcMcHitCnv >

friend class CnvFactory< EmcMcHitCnv >
friend

Definition at line 9 of file EmcMcHitCnv.h.


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