CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
RecCgemDedxCnv.cxx
Go to the documentation of this file.
1#ifndef RecCgemDedxCnv_CXX
2#define RecCgemDedxCnv_CXX 1
3#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/DataObject.h"
5#include "GaudiKernel/ObjectVector.h"
6#include "TClonesArray.h"
10
11#include "RootEventData/TRecCgemDedx.h" // standard root object
13
17
18#include <vector>
19
20using namespace std;
21
22// Instantiation of a static factory class used by clients to create
23// instances of this service
24//static CnvFactory<RecCgemDedxCnv> s_factory;
25//const ICnvFactory& RecCgemDedxCnvFactory = s_factory;
26
28: RootEventBaseCnv(classID(), svc)
29{
30
31 // Here we associate this converter with the /Event path on the TDS.
32 MsgStream log(msgSvc(), "RecCgemDedxCnv");
33 //log << MSG::DEBUG << "Constructor called for " << objType() << endreq;
34 //m_rootTreename ="Rec";
35 m_rootBranchname ="m_recCgemDedxCol";
36 // declareObject(EventModel::Recon::RecCgemDedxCol, objType(), m_rootTreename, m_rootBranchname);
37 m_adresses.push_back(&m_recCgemDedxCol);
38 m_recCgemDedxCol=0;
39}
40
41StatusCode RecCgemDedxCnv::TObjectToDataObject(DataObject*& refpObject) {
42 // creation of TDS object from root object
43 MsgStream log(msgSvc(), "RecCgemDedxCnv");
44 log << MSG::DEBUG << "RecCgemDedxCnv::TObjectToDataObject" << endreq;
45 StatusCode sc=StatusCode::SUCCESS;
46
47 // create the TDS location for the Dedx Collection
48 RecCgemDedxCol* recCgemDedxCol = new RecCgemDedxCol;
49 refpObject=recCgemDedxCol;
50
51
52 // now convert
53 if (!m_recCgemDedxCol) return sc;
54 TIter dedxIter(m_recCgemDedxCol);
55 TRecCgemDedx *recCgemDedxRoot = 0;
56 while ((recCgemDedxRoot = (TRecCgemDedx*)dedxIter.Next())) {
57 double dedxHit = recCgemDedxRoot->dedxHit();
58 double dedxEsat = recCgemDedxRoot->dedxEsat();
59 double dedxNoRun = recCgemDedxRoot->dedxNoRun();
60 double dedxMoment = recCgemDedxRoot->dedxMoment();
61
62 int trackId = recCgemDedxRoot->trackId();
63 int particleId = recCgemDedxRoot->particleId();
64 int status = recCgemDedxRoot->status();
65 int truncAlg = recCgemDedxRoot->truncAlg();
66 // double pb[5];
67 // for ( int i = 0; i < 5; i++)
68 // pb[i] = dedxRoot->prob(i);
69
70 // double numSigmaE = dedxRoot->numSigmaE();
71 // double numSigmaMu = dedxRoot->numSigmaMu();
72 // double numSigmaPi = dedxRoot->numSigmaPi();
73 // double numSigmaK = dedxRoot->numSigmaK();
74 // double numSigmaP = dedxRoot->numSigmaP();
75 double chi[5];
76 chi[0] = recCgemDedxRoot->chiE();
77 chi[1] = recCgemDedxRoot->chiMu();
78 chi[2] = recCgemDedxRoot->chiPi();
79 chi[3] = recCgemDedxRoot->chiK();
80 chi[4] = recCgemDedxRoot->chiP();
81 int numGoodHits = recCgemDedxRoot->numGoodHits();
82 int numTotalHits = recCgemDedxRoot->numTotalHits();
83
84 double probPH = recCgemDedxRoot->probPH();
85 double normPH = recCgemDedxRoot->normPH();
86 double errorPH = recCgemDedxRoot->errorPH();
87 double twentyPH = recCgemDedxRoot->twentyPH();
88 double dedxExpect[5],sigmaDedx[5],pidProb[5];
89 for (int i=0; i<5; i++){
90 dedxExpect[i] = recCgemDedxRoot->dedxExpect(i);
91 sigmaDedx[i] = recCgemDedxRoot->sigmaDedx(i);
92 pidProb[i] = recCgemDedxRoot->pidProb(i);}
93
94 RecCgemDedx *recCgemDedx = new RecCgemDedx();
95 m_common.m_rootRecCgemDedxMap[recCgemDedxRoot] = recCgemDedx;
96
97 recCgemDedx->setTrackId(trackId);
98 recCgemDedx->setParticleId(particleId);
99 recCgemDedx->setStatus (status);
100 recCgemDedx->setTruncAlg(truncAlg);
101 // dedxTds->setProb(pb);
102 // dedxTds->setNumSigmaE(numSigmaE);
103 // dedxTds->setNumSigmaMu(numSigmaMu);
104 // dedxTds->setNumSigmaPi(numSigmaPi);
105 // dedxTds->setNumSigmaK(numSigmaK);
106 // dedxTds->setNumSigmaP(numSigmaP);
107 recCgemDedx->setChi(chi);
108 recCgemDedx->setNumGoodHits( numGoodHits);
109 recCgemDedx->setNumTotalHits( numTotalHits);
110
111 recCgemDedx->setProbPH(probPH);
112 recCgemDedx->setNormPH(normPH);
113 recCgemDedx->setErrorPH(errorPH);
114 recCgemDedx->setTwentyPH(twentyPH);
115 //for (int i=0; i<5; i++){
116 recCgemDedx->setDedxExpect(dedxExpect);
117 recCgemDedx->setSigmaDedx(sigmaDedx);
118 recCgemDedx->setPidProb(pidProb);
119
120 recCgemDedx->setDedxHit(dedxHit);
121 recCgemDedx->setDedxEsat(dedxEsat);
122 recCgemDedx->setDedxNoRun(dedxNoRun);
123 recCgemDedx->setDedxMoment(dedxMoment);
124
125 //}
126
127
128
129 recCgemDedxCol->push_back(recCgemDedx);
130 //delete dedxTds;
131 // dedxTds = NULL;
132 }
133 //m_dedxCol->Delete();
134 delete m_recCgemDedxCol;
135 m_recCgemDedxCol = 0;
136
137 return StatusCode::SUCCESS;
138}
139
140
141StatusCode RecCgemDedxCnv::DataObjectToTObject(DataObject* obj,RootAddress* rootaddr) {
142 MsgStream log(msgSvc(), "RecCgemDedxCnv");
143 log << MSG::DEBUG << "RecCgemDedxCnv::DataObjectToTObject" << endreq;
144 StatusCode sc=StatusCode::SUCCESS;
145
146 RecCgemDedxCol * recCgemDedxCol=dynamic_cast<RecCgemDedxCol *> (obj);
147 if (!recCgemDedxCol) {
148 log << MSG::ERROR << "Could not downcast to RecCgemDedxCol" << endreq;
149 return StatusCode::FAILURE;
150 }
151
152 DataObject *evt;
153 m_eds->findObject(EventModel::Recon::Event,evt);
154 if (evt==NULL) {
155 log << MSG::ERROR << "Could not get RecEvent in TDS " << endreq;
156 return StatusCode::FAILURE;
157 }
158 ReconEvent * devtTds=dynamic_cast<ReconEvent *> (evt);
159 if (!devtTds) {
160 log << MSG::ERROR << "RecCgemDedxCnv:Could not downcast to TDS RecEvent" << endreq;
161 }
162 IOpaqueAddress *addr;
163
164 m_cnvSvc->getRecTrackCnv()->createRep(evt,addr);
166
167 const TObjArray *m_recCgemDedxCol = recEvt->getRecCgemDedxCol();
168 if (!m_recCgemDedxCol) return sc;
169 recEvt->clearRecCgemDedxCol(); //necessary in case there is I/O at the same time since array is static
170 RecCgemDedxCol::const_iterator recCgemDedx;
171
172 for (recCgemDedx = recCgemDedxCol->begin(); recCgemDedx != recCgemDedxCol->end(); recCgemDedx++) {
173 Int_t trackId = (*recCgemDedx)->trackId();
174 Int_t particleId = (*recCgemDedx)->particleId();
175 Int_t status = (*recCgemDedx)->status();
176 Int_t truncAlg = (*recCgemDedx)->truncAlg();
177 // Double_t pb[5];
178 // for (Int_t i = 0; i < 5; i++)
179 // pb[i] = (*dedxTds)->prob(i);
180 Double_t dedxHit = (*recCgemDedx)->getDedxHit();
181 Double_t dedxEsat = (*recCgemDedx)->getDedxEsat();
182 Double_t dedxNoRun = (*recCgemDedx)->getDedxNoRun();
183 Double_t dedxMoment = (*recCgemDedx)->getDedxMoment();
184
185
186 Double_t chiE = (*recCgemDedx)->chi(0);
187 Double_t chiMu = (*recCgemDedx)->chi(1);
188 Double_t chiPi = (*recCgemDedx)->chi(2);
189 Double_t chiK = (*recCgemDedx)->chi(3);
190 Double_t chiP = (*recCgemDedx)->chi(4);
191
192 Int_t numGoodHits = (*recCgemDedx)->numGoodHits();
193 Int_t numTotalHits = (*recCgemDedx)->numTotalHits();
194
195 Double_t probPH = (*recCgemDedx)->probPH();
196 Double_t normPH = (*recCgemDedx)->normPH();
197 Double_t errorPH = (*recCgemDedx)->errorPH();
198 Double_t twentyPH = (*recCgemDedx)->twentyPH();
199 //Double_t fracErrPH = (*dedxTds)-> fracErrPH();
200 //Double_t minIronPH = (*dedxTds)->minIronPH();
201 //Double_t corrPH = (*dedxTds)->corrPH();
202 double dedxExpect[5],sigmaDedx[5],pidProb[5],chi[5];
203 for (int i=0; i<5; i++){
204 chi[i] = (*recCgemDedx)->chi(i);
205 dedxExpect[i] = (*recCgemDedx)->getDedxExpect(i);
206 sigmaDedx[i] = (*recCgemDedx)->getSigmaDedx(i);
207 pidProb[i] = (*recCgemDedx)->getPidProb(i);
208 }
209
210
211 TRecCgemDedx *recCgemDedxRoot = new TRecCgemDedx();
212 //m_common.m_recCgemDedxMap[(*recCgemDedx)] = recCgemDedxRoot;
213 //std::cout<<"check write to Reconstrunction root particle Id is "<<dedxRoot->particleId()<<endl;
214 recCgemDedxRoot->setTrackId(trackId);
215 recCgemDedxRoot->setParticleId(particleId);
216 recCgemDedxRoot->setStatus (status);
217 recCgemDedxRoot->setTruncAlg(truncAlg);
218 log << MSG::INFO<<"check Reconstrunction root"<<" particle Id is : "<<particleId
219 <<"track id is : "<<trackId
220 <<" and status is : "<<status<<endreq;
221 //dedxRoot->setProb(pb);
222 recCgemDedxRoot->setChiE(chiE);
223 recCgemDedxRoot->setChiMu(chiMu);
224 recCgemDedxRoot->setChiPi(chiPi);
225 recCgemDedxRoot->setChiK(chiK);
226 recCgemDedxRoot->setChiP(chiP);
227
228 recCgemDedxRoot->setNumGoodHits( numGoodHits);
229 recCgemDedxRoot->setNumTotalHits( numTotalHits);
230
231 recCgemDedxRoot->setProbPH(probPH);
232 recCgemDedxRoot->setNormPH(normPH);
233 recCgemDedxRoot->setErrorPH(errorPH);
234 recCgemDedxRoot->setTwentyPH(twentyPH);
235 // for (int i=0; i<5; i++){
236 recCgemDedxRoot->setChi(chi);
237 recCgemDedxRoot->setDedxExpect(dedxExpect);
238 recCgemDedxRoot->setSigmaDedx(sigmaDedx);
239 recCgemDedxRoot->setPidProb(pidProb);
240
241 recCgemDedxRoot->setDedxHit(dedxHit);
242 recCgemDedxRoot->setDedxEsat(dedxEsat);
243 recCgemDedxRoot->setDedxNoRun(dedxNoRun);
244 recCgemDedxRoot->setDedxMoment(dedxMoment);
245
246 //}
247 log << MSG::INFO<<"check Reconstrunction root"<<" particle Id is : "<<particleId
248 <<"track id is : "<<trackId
249 <<" and status is : "<<status<<endreq;
250
251 // dedxRoot->setFracErrPH(fracErrPH);
252 //dedxRoot->setMinIronPH(minIronPH);
253 //dedxRoot->setCorrPH(corrPH);
254 recEvt->addRecCgemDedx(recCgemDedxRoot);
255 }
256
257 return StatusCode::SUCCESS;
258}
259
260#endif
ObjectVector< RecCgemDedx > RecCgemDedxCol
Definition: RecCgemDedx.h:120
IMessageSvc * msgSvc()
void setNumTotalHits(int numTotalHits)
Definition: DstCgemDedx.h:59
void setChi(double *chi)
Definition: DstCgemDedx.h:54
void setProbPH(double probPH)
Definition: DstCgemDedx.h:60
void setErrorPH(double errorPH)
Definition: DstCgemDedx.h:62
void setNormPH(double normPH)
Definition: DstCgemDedx.h:61
void setParticleId(int particleId)
Definition: DstCgemDedx.h:50
void setTwentyPH(double twentyPH)
Definition: DstCgemDedx.h:63
void setTrackId(int trackId)
Definition: DstCgemDedx.h:49
void setNumGoodHits(int numGoodHits)
Definition: DstCgemDedx.h:58
void setStatus(int status)
Definition: DstCgemDedx.h:51
void setTruncAlg(int trunc_alg)
Definition: DstCgemDedx.h:52
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
RecCgemDedxCnv(ISvcLocator *svc)
void setDedxHit(double dedx_hit)
Definition: RecCgemDedx.h:69
void setDedxExpect(double *dedx_exp)
Definition: RecCgemDedx.h:81
void setSigmaDedx(double *sigma_dedx)
Definition: RecCgemDedx.h:85
void setDedxMoment(double dedx_momentum)
Definition: RecCgemDedx.h:72
void setDedxNoRun(double dedx_norun)
Definition: RecCgemDedx.h:71
void setPidProb(double *pid_prob)
Definition: RecCgemDedx.h:89
void setDedxEsat(double dedx_esat)
Definition: RecCgemDedx.h:70
static TRecTrackEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition: RecTrackCnv.h:36
Definition of a Root address, derived from IOpaqueAddress.
Definition: RootAddress.h:21
RecTrackCnv * getRecTrackCnv()
Definition: RootCnvSvc.h:166
Base class for all Root Converters.
std::vector< void * > m_adresses
each converter knows the corresponding adresses
RootCnvSvc * m_cnvSvc
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.
Double_t dedxNoRun() const
Definition: TRecCgemDedx.h:45
void setDedxHit(const Double_t dedx_hit)
Definition: TRecCgemDedx.h:49
void setChiE(const Double_t chiE)
Definition: TRecCgemDedx.h:59
void setChiP(const Double_t chiP)
Definition: TRecCgemDedx.h:63
Double_t dedxEsat() const
Definition: TRecCgemDedx.h:44
void setChiPi(const Double_t chiPi)
Definition: TRecCgemDedx.h:61
Double_t twentyPH() const
Definition: TRecCgemDedx.h:37
Double_t chiK() const
Definition: TRecCgemDedx.h:28
void setChiMu(const Double_t chiMu)
Definition: TRecCgemDedx.h:60
Double_t chiP() const
Definition: TRecCgemDedx.h:29
void setDedxNoRun(const Double_t dedx_norun)
Definition: TRecCgemDedx.h:51
void setParticleId(const Int_t particleId)
Definition: TRecCgemDedx.h:55
Int_t numGoodHits() const
Definition: TRecCgemDedx.h:31
void setTrackId(const Int_t trackId)
Definition: TRecCgemDedx.h:54
void setNumGoodHits(const Int_t numGoodHits)
Definition: TRecCgemDedx.h:65
void setChiK(const Double_t chiK)
Definition: TRecCgemDedx.h:62
void setTruncAlg(const Int_t trunc_alg)
Definition: TRecCgemDedx.h:57
void setTwentyPH(const Double_t twentyPH)
Definition: TRecCgemDedx.h:71
Int_t particleId() const
Definition: TRecCgemDedx.h:20
Double_t chiE() const
Definition: TRecCgemDedx.h:25
Double_t normPH() const
Definition: TRecCgemDedx.h:35
Double_t dedxHit() const
Definition: TRecCgemDedx.h:43
Double_t errorPH() const
Definition: TRecCgemDedx.h:36
void setSigmaDedx(double *sigma_dedx)
Definition: TRecCgemDedx.h:81
void setDedxMoment(const Double_t dedx_momentum)
Definition: TRecCgemDedx.h:52
Int_t trackId() const
Definition: TRecCgemDedx.h:19
Int_t numTotalHits() const
Definition: TRecCgemDedx.h:32
Double_t dedxExpect(int pid) const
Definition: TRecCgemDedx.h:39
void setStatus(const Int_t status)
Definition: TRecCgemDedx.h:56
void setNumTotalHits(const Int_t numTotalHits)
Definition: TRecCgemDedx.h:66
Double_t chiPi() const
Definition: TRecCgemDedx.h:27
Double_t dedxMoment() const
Definition: TRecCgemDedx.h:46
Int_t status() const
Definition: TRecCgemDedx.h:21
Double_t pidProb(int pid) const
Definition: TRecCgemDedx.h:41
Double_t chiMu() const
Definition: TRecCgemDedx.h:26
Double_t sigmaDedx(int pid) const
Definition: TRecCgemDedx.h:40
void setPidProb(double *pid_prob)
Definition: TRecCgemDedx.h:85
void setErrorPH(const Double_t errorPH)
Definition: TRecCgemDedx.h:70
void setNormPH(const Double_t normPH)
Definition: TRecCgemDedx.h:69
void setDedxEsat(const Double_t dedx_esat)
Definition: TRecCgemDedx.h:50
Int_t truncAlg() const
Definition: TRecCgemDedx.h:22
void setProbPH(const Double_t probPH)
Definition: TRecCgemDedx.h:68
void setDedxExpect(double *dedx_exp)
Definition: TRecCgemDedx.h:77
void setChi(double *chi)
Definition: TRecCgemDedx.h:73
Double_t probPH() const
Definition: TRecCgemDedx.h:34
void clearRecCgemDedxCol()
clear the whole array
void addRecCgemDedx(TRecCgemDedx *Track)
Add a Dedx into the TOF Data collection.
const TObjArray * getRecCgemDedxCol() const
retrieve the whole TObjArray of Dedx Data
static std::map< const TObject *, const RecCgemDedx * > m_rootRecCgemDedxMap
Definition: commonData.h:282
_EXTERN_ std::string Event
Definition: EventModel.h:90