1#ifndef RecEmcShowerCnv_CXX
2#define RecEmcShowerCnv_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"
43 MsgStream log(
msgSvc(),
"RecEmcShowerCnv");
55 MsgStream log(
msgSvc(),
"RecEmcShowerCnv");
56 log << MSG::DEBUG <<
"RecEmcShowerCnv::TObjectToDataObject" << endreq;
58 StatusCode sc=StatusCode::SUCCESS;
60 IDataProviderSvc* eventSvc;
61 Gaudi::svcLocator()->service(
"EventDataSvc", eventSvc);
63 SmartDataPtr<RecEmcHitCol> emcRecHitCol(eventSvc,
65 if(!emcRecHitCol) log << MSG::INFO <<
"can't retrieve RecEmcHitCol" << endreq;
67 SmartDataPtr<RecEmcClusterCol> emcRecClusterCol(eventSvc,
69 if(!emcRecClusterCol) log << MSG::INFO <<
"can't retrieve RecEmcClusterCol" << endreq;
73 refpObject=emcShowerTdsCol;
76 if (!m_recEmcShowerCol)
return sc;
77 TIter emcShowerIter(m_recEmcShowerCol);
79 while ((emcShowerRoot = (
TRecEmcShower*)emcShowerIter.Next())) {
80 int trackId = emcShowerRoot->
trackId();
81 int numHits = emcShowerRoot->
numHits();
82 int status = emcShowerRoot->
status();
83 int cellId = emcShowerRoot->
cellId();
84 int module = emcShowerRoot->
module();
85 double x = emcShowerRoot->
x();
86 double y = emcShowerRoot->
y();
87 double z = emcShowerRoot->
z();
88 double theta = emcShowerRoot->
theta();
89 double dtheta = emcShowerRoot->
dtheta();
90 double phi = emcShowerRoot->
phi();
91 double dphi = emcShowerRoot->
dphi();
93 double dE = emcShowerRoot->
dE();
94 double eSeed = emcShowerRoot->
eSeed();
95 double e3x3 = emcShowerRoot->
e3x3();
96 double e5x5 = emcShowerRoot->
e5x5();
97 double eall = emcShowerRoot->
eAll();
98 double elepton = emcShowerRoot->
eLepton();
101 double latMoment = emcShowerRoot->
latMoment();
102 double a20Moment = emcShowerRoot->
a20Moment();
103 double a42Moment = emcShowerRoot->
a42Moment();
105 HepSymMatrix matrix(3);
106 matrix[0][0]=emcShowerRoot->
err(0);
107 matrix[1][1]=emcShowerRoot->
err(1);
108 matrix[2][2]=emcShowerRoot->
err(2);
109 matrix[0][1]=emcShowerRoot->
err(3);
110 matrix[0][2]=emcShowerRoot->
err(4);
111 matrix[1][2]=emcShowerRoot->
err(5);
117 vector<Int_t> cellId3x3 = emcShowerRoot->
cellId3x3();
118 vector<Int_t>::iterator iCellId;
120 for(iCellId=cellId3x3.begin();
121 iCellId!=cellId3x3.end();
129 vector<Int_t> cellId5x5 = emcShowerRoot->
cellId5x5();
131 for(iCellId=cellId5x5.begin();
132 iCellId!=cellId5x5.end();
151 emcShowerTds->
setDE( dE );
157 emcShowerTds->
EAll(eall);
158 emcShowerTds->
ELepton(elepton);
173 map<Int_t, Double_t> cellIdMap=emcShowerRoot->
cellIdMap();
174 map<Int_t, Double_t>::iterator iCellIdMap;
175 for(iCellIdMap=cellIdMap.begin();
176 iCellIdMap!=cellIdMap.end();
181 RecEmcHitCol::iterator iHit;
182 for(iHit=emcRecHitCol->begin();
183 iHit!=emcRecHitCol->end();
186 RecEmcID idHit((*iHit)->getCellId());
191 emcShowerTds->
Insert(frac);
198 if(emcRecClusterCol) {
199 RecEmcClusterCol::iterator iCluster;
200 for(iCluster=emcRecClusterCol->begin();
201 iCluster!=emcRecClusterCol->end();
203 if(clusterId==(*iCluster)->getClusterId()) {
204 emcShowerTds->
Cluster(*iCluster);
211 emcShowerTdsCol->push_back(emcShowerTds);
217 delete m_recEmcShowerCol;
218 m_recEmcShowerCol = 0;
220 return StatusCode::SUCCESS;
225 MsgStream log(
msgSvc(),
"RecEmcShowerCnv");
226 log << MSG::DEBUG <<
"RecEmcShowerCnv::DataObjectToTObject" << endreq;
228 StatusCode sc=StatusCode::SUCCESS;
231 if (!emcShowerColTds) {
232 log << MSG::ERROR <<
"Could not downcast to RecEmcShowerCol" << endreq;
233 return StatusCode::FAILURE;
239 log << MSG::ERROR <<
"Could not get RecEvent in TDS " << endreq;
240 return StatusCode::FAILURE;
244 log << MSG::ERROR <<
"RecEmcShowerCnv:Could not downcast to TDS DstEvent" << endreq;
246 IOpaqueAddress *addr;
252 if (!m_emcShowerCol)
return sc;
254 RecEmcShowerCol::const_iterator emcShowerTds;
256 for (emcShowerTds = emcShowerColTds->begin(); emcShowerTds != emcShowerColTds->end(); emcShowerTds++) {
257 Int_t trackId = (*emcShowerTds)->trackId();
258 Int_t numHits = (*emcShowerTds)->numHits();
259 Int_t status =(*emcShowerTds)->status();
260 Int_t cellId =(*emcShowerTds)->getShowerId();
261 Int_t clusterId = (*emcShowerTds)->getClusterId();
262 Int_t module =(*emcShowerTds)->module();
263 Double_t
x = (*emcShowerTds)->x();
264 Double_t
y = (*emcShowerTds)->y();
265 Double_t z = (*emcShowerTds)->z();
266 Double_t theta = (*emcShowerTds)->theta();
267 Double_t dtheta =(*emcShowerTds)->dtheta();
268 Double_t phi =(*emcShowerTds)->phi();
269 Double_t dphi =(*emcShowerTds)->dphi();
270 Double_t
energy = (*emcShowerTds)->energy();
271 Double_t dE = (*emcShowerTds)->dE();
272 Double_t eSeed = (*emcShowerTds)->eSeed();
273 Double_t e3x3 = (*emcShowerTds)->e3x3();
274 Double_t e5x5 = (*emcShowerTds)->e5x5();
275 Double_t eall = (*emcShowerTds)->getEAll();
276 Double_t elepton = (*emcShowerTds)->getELepton();
277 Double_t
time = (Int_t)(*emcShowerTds)->time();
278 Double_t secondMoment = (*emcShowerTds)->secondMoment();
279 Double_t latMoment = (*emcShowerTds)->latMoment();
280 Double_t a20Moment = (*emcShowerTds)->a20Moment();
281 Double_t a42Moment = (*emcShowerTds)->a42Moment();
283 HepSymMatrix matrix = (*emcShowerTds)->errorMatrix();
286 err[0] = matrix[0][0];
287 err[1] = matrix[1][1];
288 err[2] = matrix[2][2];
289 err[3] = matrix[0][1];
290 err[4] = matrix[0][2];
291 err[5] = matrix[1][2];
293 map<Int_t, Double_t> cellIdMap;
294 RecEmcFractionMap::const_iterator pFractionMap;
296 for(pFractionMap=(*emcShowerTds)->Begin();
297 pFractionMap!=(*emcShowerTds)->End();
299 Int_t
id = pFractionMap->first;
300 Double_t frac = pFractionMap->second.getFraction();
304 vector<Int_t> cellId3x3;
307 for(ciCellId=id3x3.begin();
308 ciCellId!=id3x3.end();
310 Int_t
id = *ciCellId;
311 cellId3x3.push_back(
id);
314 vector<Int_t> cellId5x5;
316 for(ciCellId=id5x5.begin();
317 ciCellId!=id5x5.end();
319 Int_t
id = *ciCellId;
320 cellId5x5.push_back(
id);
333 emcShowerRoot->
setX(
x );
334 emcShowerRoot->
setY(
y );
335 emcShowerRoot->
setZ( z );
337 emcShowerRoot->
setDE( dE );
340 emcShowerRoot->
setPhi( phi );
341 emcShowerRoot->
setDphi( dphi );
343 emcShowerRoot->
setE3x3( e3x3 );
344 emcShowerRoot->
setE5x5( e5x5 );
345 emcShowerRoot->
setEAll( eall );
352 emcShowerRoot->
setErr( err );
361 return StatusCode::SUCCESS;
************Class m_ypar INTEGER m_KeyWgt INTEGER m_KeyIHVP INTEGER m_KeyGPS INTEGER m_IsBeamPolarized INTEGER m_EvtGenInterface DOUBLE PRECISION m_Emin DOUBLE PRECISION m_sphot DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_q2 DOUBLE PRECISION m_PolBeam2 DOUBLE PRECISION m_xErrPb *COMMON c_KK2f $ !CMS energy average $ !Spin Polarization vector first beam $ !Spin Polarization vector second beam $ !Beam energy spread[GeV] $ !minimum hadronization energy[GeV] $ !input READ never touch them !$ !debug facility $ !maximum weight $ !inverse alfaQED $ !minimum real photon energy
RecEmcIDVector::const_iterator ci_RecEmcIDVector
vector< RecEmcID > RecEmcIDVector
ObjectVector< RecEmcShower > RecEmcShowerCol
void setE3x3(double e3x3)
void setDtheta(double dt)
void setSecondMoment(double secondMoment)
void setA20Moment(double a20Moment)
void setPosition(const HepPoint3D &pos)
void setA42Moment(double a42Moment)
void setESeed(double eSeed)
void setTime(double time)
void setLatMoment(double latMoment)
void setErrorMatrix(const HepSymMatrix &error)
void setTrackId(int trackId)
void setE5x5(double e5x5)
RecEmcFrac Fraction(const RecEmcFrac &Fraction)
RecEmcShowerCnv(ISvcLocator *svc)
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
void CellId3x3(RecEmcIDVector &id3x3)
RecEmcEnergy EAll(RecEmcEnergy e)
RecEmcEnergy ELepton(RecEmcEnergy e)
void ClusterId(const RecEmcID id)
RecEmcID ShowerId(RecEmcID id)
void Cluster(RecEmcCluster *pCluster)
void Insert(const RecEmcFraction &aFraction)
void CellId5x5(RecEmcIDVector &id5x5)
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.
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 setDphi(const Double_t dpi)
void setTime(const Double_t time)
void setCellIdMap(const map< Int_t, Double_t > &cellIdMap)
void setY(const Double_t y)
void setX(const Double_t x)
Double_t err(Int_t i) const
void setELepton(const Double_t elepton)
void setDtheta(const Double_t dt)
Double_t a20Moment() const
void setA20Moment(const Double_t a20Moment)
Double_t latMoment() const
void setStatus(const Int_t st)
void setClusterId(const Int_t clusterId)
map< Int_t, Double_t > cellIdMap() const
void setModule(const Int_t mod)
void setTheta(const Double_t theta)
Double_t secondMoment() const
void setEnergy(const Double_t e)
void setSecondMoment(const Double_t secondMoment)
void setE3x3(const Double_t e3x3)
void setZ(const Double_t z)
void setCellId5x5(const vector< Int_t > &cellId5x5)
void setE5x5(const Double_t e5x5)
vector< Int_t > cellId5x5() const
void setCellId3x3(const vector< Int_t > &cellId3x3)
vector< Int_t > cellId3x3() const
void setEAll(const Double_t eall)
void setCellId(const Int_t id)
void setESeed(const Double_t eSeed)
void setNumHits(const Int_t hit)
Double_t a42Moment() const
void setErr(const Double_t err[6])
void setDE(const Double_t de)
void setA42Moment(const Double_t a42Moment)
void setPhi(const Double_t pi)
void setTrackId(const Int_t trackId)
void setLatMoment(const Double_t latMoment)
void clearEmcShowerCol()
clear the whole array (necessary because of the consts-s) */
void addEmcShower(TRecEmcShower *Track)
Add a TkrTrack into the Emc data collection */.
const TObjArray * getEmcShowerCol() const
retrieve the whole TObjArray of EmcShower Data
static std::map< const TObject *, const RecEmcShower * > m_rootRecEmcShowerMap
_EXTERN_ std::string RecEmcClusterCol
_EXTERN_ std::string RecEmcHitCol
_EXTERN_ std::string Event