CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
bak_RootCnvSvc-04-01-14/src/Rec/RecCgemClusterCnv.cxx
Go to the documentation of this file.
1#ifndef RECCGEMCLUSTERCNV_CXX
2#define RECCGEMCLUSTERCNV_CXX
3
4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/DataObject.h"
6#include "GaudiKernel/ObjectVector.h"
7
8#include "TClonesArray.h"
9
10#include "EventModel/EventModel.h"
11
12#include "ReconEvent/ReconEvent.h"
13#include "CgemRecEvent/RecCgemCluster.h"
14
15#include "RootEventData/TRecCgemCluster.h"
16#include "RootEventData/TRecTrackEvent.h"
17
18#include "RootCnvSvc/Rec/RecTrackCnv.h"
19#include "RootCnvSvc/Rec/RecCgemClusterCnv.h"
20#include "RootCnvSvc/RootAddress.h"
21
22#include <vector>
23
24using namespace std;
25
27 :RootEventBaseCnv(classID(), svc)
28{
29
30 MsgStream log(msgSvc(),"RecCgemClusterCnv");
31 log << MSG::INFO << " RecCgemClusterCnv ------ " << endreq;
32 m_rootBranchname = "m_recCgemClusterCol";
33 m_adresses.push_back(&m_recCgemClusterCol);
34 m_recCgemClusterCol = 0;
35}
36StatusCode RecCgemClusterCnv::TObjectToDataObject(DataObject*& refpObject)
37{
38 MsgStream log(msgSvc(),"RecCgemClusterCnv");
39 log << MSG::DEBUG << "RecCgemClusterCnv::TObjectToDataObject" << endreq;
40
41
42 RecCgemClusterCol* recCgemClusterCol = new RecCgemClusterCol;
43 refpObject = recCgemClusterCol;
44
45
46 //convert//
47 if (!m_recCgemClusterCol) return StatusCode::SUCCESS;
48 TIter cgemClusterIter(m_recCgemClusterCol);
49 TRecCgemCluster *recCgemClusterRoot = 0;
50 while ((recCgemClusterRoot = (TRecCgemCluster*)cgemClusterIter.Next()))
51 {
52 int clusterid = recCgemClusterRoot->getclusterid();
53 int layerid = recCgemClusterRoot->getlayerid();
54 int sheetid = recCgemClusterRoot->getsheetid();
55 int flag = recCgemClusterRoot->getflag();
56 double energydeposit = recCgemClusterRoot->getenergydeposit();
57 double recphi = recCgemClusterRoot->getrecphi();
58 //double recpositiony = recCgemClusterRoot->getrecpositiony();
59 double recv = recCgemClusterRoot->getrecv();
60
61 double recZ = recCgemClusterRoot->getRecZ();
62 int trkid = recCgemClusterRoot->getTrkId();
63 int clusterflag_first = recCgemClusterRoot->getclusterflagb();
64 int clusterflag_second = recCgemClusterRoot->getclusterflage();
65
66 RecCgemCluster* recCgemCluster = new RecCgemCluster();
67 m_common.m_rootRecCgemClusterMap[recCgemClusterRoot] = recCgemCluster;
68
69 recCgemCluster->setclusterid(clusterid);
70 recCgemCluster->setlayerid(layerid);
71 recCgemCluster->setsheetid(sheetid);
72 recCgemCluster->setflag(flag);
73 recCgemCluster->setenergydeposit(energydeposit);
74 recCgemCluster->setrecphi(recphi);
75 //recCgemCluster->setrecpositiony(recpositiony);
76 recCgemCluster->setrecv(recv);
77
78 recCgemCluster->setRecZ(recZ);
79 recCgemCluster->setTrkId(trkid);
80 recCgemCluster->setclusterflag(clusterflag_first,clusterflag_second);
81
82 recCgemClusterCol->push_back(recCgemCluster);
83 }
84 return StatusCode::SUCCESS;
85}
86StatusCode RecCgemClusterCnv::DataObjectToTObject(DataObject* obj,RootAddress* rootaddr)
87{
88 MsgStream log(msgSvc(), "RecCgemClusterCnv");
89 log << MSG::DEBUG << "RecCgemClusterCnv::DataObjectToTObject" << endreq;
90
91 RecCgemClusterCol * cgemClusterColTds=dynamic_cast<RecCgemClusterCol *> (obj);
92 if (!cgemClusterColTds) {
93 log << MSG::ERROR << "Could not downcast to RecCgemClusterCol" << endreq;
94 return StatusCode::FAILURE;
95 }
96
97 DataObject *evt;
98 m_eds->findObject(EventModel::Recon::Event,evt);
99 if (evt==NULL) {
100 log << MSG::ERROR << "Could not get ReconEvent in TDS " << endreq;
101 return StatusCode::FAILURE;
102 }
103
104 ReconEvent * devtTds=dynamic_cast<ReconEvent *> (evt);
105 if (!devtTds) {
106 log << MSG::ERROR << "RecCgemHitCnv:Could not downcast to TDS ReconEvent" << endreq;
107 }
108
109 IOpaqueAddress *addr;
110
111 m_cnvSvc->getRecTrackCnv()->createRep(evt,addr);
113
114 const TObjArray *m_recCgemClusterCol = recEvt->getRecCgemClusterCol();
115 if (!m_recCgemClusterCol) return StatusCode::SUCCESS;
116 recEvt->clearRecCgemClusterCol();
117
118 RecCgemClusterCol::const_iterator recCgemCluster;
119 for (recCgemCluster = cgemClusterColTds->begin(); recCgemCluster != cgemClusterColTds->end(); recCgemCluster++)
120 {
121 Int_t layerid = (*recCgemCluster)->getlayerid();
122 Int_t sheetid = (*recCgemCluster)->getsheetid();
123 Int_t clusterid = (*recCgemCluster)->getclusterid();
124 Int_t flag = (*recCgemCluster)->getflag();
125 Double_t energydeposit = (*recCgemCluster)->getenergydeposit();
126 Double_t recphi = (*recCgemCluster)->getrecphi();
127 //Double_t recpositiony = (*recCgemCluster)->getrecpositiony();
128 Double_t recv = (*recCgemCluster)->getrecv();
129
130 Int_t trkid = (*recCgemCluster)->getTrkId();
131 Double_t recZ = (*recCgemCluster)->getRecZ();
132 Int_t clusterflag_b = (*recCgemCluster)->getclusterflagb();
133 Int_t clusterflag_e = (*recCgemCluster)->getclusterflage();
134
135 TRecCgemCluster *recCgemClusterRoot = new TRecCgemCluster();
136
137 recCgemClusterRoot->setlayerid(layerid);
138 recCgemClusterRoot->setsheetid(sheetid);
139 recCgemClusterRoot->setclusterid(clusterid);
140 recCgemClusterRoot->setflag(flag);
141 recCgemClusterRoot->setenergydeposit(energydeposit);
142 recCgemClusterRoot->setrecphi(recphi);
143 //recCgemClusterRoot->setrecpositiony(recpositiony);
144 recCgemClusterRoot->setrecv(recv);
145
146 recCgemClusterRoot->setTrkId(trkid);
147 recCgemClusterRoot->setRecZ(recZ);
148 recCgemClusterRoot->setclusterflag(clusterflag_b,clusterflag_e);
149 Int_t stripid[2][2] = {-9999,-9999,-9999,-9999};
150 if(flag==0||flag==1){
151 stripid[flag][0] = clusterflag_b;
152 stripid[flag][1] = clusterflag_e;
153 }else if(flag==2||flag==3){
154 for(RecCgemClusterCol::const_iterator iter = cgemClusterColTds->begin(); iter != cgemClusterColTds->end(); iter++){
155 if((*iter)->getclusterid() == clusterflag_b || (*iter)->getclusterid() == clusterflag_e){
156 Int_t Flag = (*iter)->getflag();
157 if(Flag==0||Flag==1){
158 stripid[Flag][0] = (*iter)->getclusterflagb();
159 stripid[Flag][1] = (*iter)->getclusterflage();
160 }
161 }
162 }
163 }
164 recCgemClusterRoot->setstripid(stripid);
165
166 recEvt->addRecCgemCluster(recCgemClusterRoot);
167 }
168 return StatusCode::SUCCESS;
169}
170#endif
171
172
173
174
175
176
ObjectVector< RecCgemCluster > RecCgemClusterCol
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
virtual StatusCode TObjectToDataObject(DataObject *&obj)
Do the concrete conversion from ROOT to TDS.
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
Do the concrete conversion from TDS to ROOT.
static TRecTrackEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition of a Root address, derived from IOpaqueAddress.
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.
void clearRecCgemClusterCol()
clear the whole array(necessary because of the consts-s)
const TObjArray * getRecCgemClusterCol() const
retrive the whole TObjArray of RecCgemCluster Data
void addRecCgemCluster(TRecCgemCluster *Cluster)
Add a Rec Cgem Cluster into the Cgem data collection.
static std::map< const TObject *, const RecCgemCluster * > m_rootRecCgemClusterMap