1#ifndef RecEmcClusterCnv_CXX
2#define RecEmcClusterCnv_CXX 1
4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/DataObject.h"
6#include "GaudiKernel/ObjectVector.h"
7#include "GaudiKernel/IDataProviderSvc.h"
8#include "GaudiKernel/Bootstrap.h"
10#include "TClonesArray.h"
12#include "EventModel/EventModel.h"
14#include "ReconEvent/ReconEvent.h"
15#include "EmcRecEventModel/RecEmcCluster.h"
17#include "RootEventData/TRecEmcCluster.h"
18#include "RootEventData/TRecTrackEvent.h"
20#include "RootCnvSvc/Rec/RecTrackCnv.h"
21#include "RootCnvSvc/Rec/RecEmcClusterCnv.h"
22#include "RootCnvSvc/RootAddress.h"
39 MsgStream log(
msgSvc(),
"RecEmcClusterCnv");
42 m_rootBranchname =
"m_recEmcClusterCol";
44 m_adresses.push_back(&m_recEmcClusterCol);
50 MsgStream log(
msgSvc(),
"RecEmcClusterCnv");
51 log << MSG::DEBUG <<
"RecEmcClusterCnv::TObjectToDataObject" << endreq;
53 StatusCode sc=StatusCode::SUCCESS;
55 IDataProviderSvc* eventSvc;
56 Gaudi::svcLocator()->service(
"EventDataSvc", eventSvc);
58 SmartDataPtr<RecEmcHitCol> emcRecHitCol(eventSvc,
60 if(!emcRecHitCol) log << MSG::INFO <<
"can't retrieve RecEmcHitCol" << endreq;
64 refpObject=emcClusterTdsCol;
67 if (!m_recEmcClusterCol)
return sc;
68 TIter emcClusterIter(m_recEmcClusterCol);
70 while ((emcClusterRoot = (
TRecEmcCluster*)emcClusterIter.Next())) {
78 vector<int> vecShowers = emcClusterRoot->
vecShowers();
79 vector<int>::iterator iVecShower;
80 vector<RecEmcID> vecShowerId;
81 for(iVecShower=vecShowers.begin();
82 iVecShower!=vecShowers.end();
85 vecShowerId.push_back(
id);
90 vector<Int_t> vecHits = emcClusterRoot->
vecHits();
91 vector<Int_t> vecSeeds = emcClusterRoot->
vecSeeds();
92 vector<Int_t>::iterator iVecHit;
95 for(iVecHit=vecHits.begin();
96 iVecHit!=vecHits.end();
101 RecEmcHitCol::iterator iHit;
102 for(iHit=emcRecHitCol->begin();
103 iHit!=emcRecHitCol->end();
106 RecEmcID idHit((*iHit)->getCellId());
111 emcClusterTds->
Insert(*(*iHit));
118 for(iVecHit=vecSeeds.begin();
119 iVecHit!=vecSeeds.end();
124 RecEmcHitCol::iterator iHit;
125 for(iHit=emcRecHitCol->begin();
126 iHit!=emcRecHitCol->end();
129 RecEmcID idHit((*iHit)->getCellId());
142 emcClusterTdsCol->push_back(emcClusterTds);
146 return StatusCode::SUCCESS;
151 MsgStream log(
msgSvc(),
"RecEmcClusterCnv");
152 log << MSG::DEBUG <<
"RecEmcClusterCnv::DataObjectToTObject" << endreq;
154 StatusCode sc=StatusCode::SUCCESS;
157 if (!emcClusterColTds) {
158 log << MSG::ERROR <<
"Could not downcast to RecEmcClusterCol" << endreq;
159 return StatusCode::FAILURE;
165 log << MSG::ERROR <<
"Could not get RecEvent in TDS " << endreq;
166 return StatusCode::FAILURE;
170 log << MSG::ERROR <<
"RecEmcClusterCnv:Could not downcast to TDS DstEvent" << endreq;
172 IOpaqueAddress *addr;
178 if (!m_emcClusterCol)
return sc;
183 RecEmcClusterCol::const_iterator emcClusterTds;
185 for(emcClusterTds = emcClusterColTds->begin();
186 emcClusterTds != emcClusterColTds->end();
190 vector<Int_t> vecHits;
191 RecEmcHitMap::const_iterator iHitMap;
192 for(iHitMap=(*emcClusterTds)->Begin();
193 iHitMap!=(*emcClusterTds)->End();
195 vecHits.push_back(iHitMap->first);
198 vector<Int_t> vecSeeds;
199 RecEmcHitMap::const_iterator iSeedMap;
200 for(iSeedMap=(*emcClusterTds)->BeginSeed();
201 iSeedMap!=(*emcClusterTds)->EndSeed();
203 vecSeeds.push_back(iSeedMap->first);
206 vector<RecEmcID> vecShowerId=(*emcClusterTds)->getShowerIdVec();
207 vector<RecEmcID>::iterator iShowerId;
208 vector<Int_t> vecShowers;
209 for(iShowerId=vecShowerId.begin();
210 iShowerId!=vecShowerId.end();
212 vecShowers.push_back(*iShowerId);
228 return StatusCode::SUCCESS;
ObjectVector< RecEmcCluster > RecEmcClusterCol
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
RecEmcClusterCnv(ISvcLocator *svc)
RecEmcID getClusterId() const
void Insert(const RecEmcHit &aHit)
void ShowerIdVec(const vector< RecEmcID > &showerIdVec)
void InsertSeed(const RecEmcHit &aSeed)
void ClusterId(const RecEmcID id)
static TRecTrackEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition of a Root address, derived from IOpaqueAddress.
RecTrackCnv * getRecTrackCnv()
Base class for all Root Converters.
IDataProviderSvc * m_eds
pointer to eventdataservice
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)
Convert the transient object to the requested representation.
void setVecSeeds(const vector< Int_t > &vecSeeds)
vector< Int_t > vecSeeds() const
void setVecShowers(const vector< Int_t > &vecShowers)
void setVecHits(const vector< Int_t > &vecHits)
vector< Int_t > vecHits() const
vector< Int_t > vecShowers() const
void setClusterId(const Int_t id)
void addEmcCluster(TRecEmcCluster *Track)
Add a TkrTrack into the Emc data collection */.
const TObjArray * getEmcClusterCol() const
retrieve the whole TObjArray of EmcCluster Data
void clearEmcClusterCol()
clear the whole array (necessary because of the consts-s) */
static std::map< const TObject *, const RecEmcCluster * > m_rootRecEmcClusterMap
_EXTERN_ std::string RecEmcHitCol
_EXTERN_ std::string Event