BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcDedxCnv.cxx
Go to the documentation of this file.
1#ifndef DedxCnv_CXX
2#define DedxCnv_CXX 1
3
4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/DataObject.h"
6#include "GaudiKernel/ObjectVector.h"
7
8#include "TClonesArray.h"
9
11#include "DstEvent/DstEvent.h" //TDS object
12#include "DstEvent/DstMdcDedx.h" //TDS object
13#include "RootEventData/TMdcDedx.h" // standard root object
15
19
20
21// Instantiation of a static factory class used by clients to create
22// instances of this service
23//static CnvFactory<DedxCnv> s_factory;
24//const ICnvFactory& DedxCnvFactory = s_factory;
25
26MdcDedxCnv::MdcDedxCnv(ISvcLocator* svc)
27: RootEventBaseCnv(classID(), svc)
28{
29 // Here we associate this converter with the /Event path on the TDS.
30 MsgStream log(msgSvc(), "MdcDedxCnv");
31 //log << MSG::DEBUG << "Constructor called for " << objType() << endreq;
32 m_rootBranchname ="m_mdcDedxCol";
33 //declareObject(EventModel::Dst::DstDedxCol, objType(), m_rootTreename, m_rootBranchname);
34 m_adresses.push_back(&m_mdcDedxCol);
35 m_mdcDedxCol=0;
36}
37
38StatusCode MdcDedxCnv::TObjectToDataObject(DataObject*& refpObject) {
39 // creation of TDS object from root object
40
41 MsgStream log(msgSvc(), "MdcDedxCnv");
42 log << MSG::DEBUG << "MdcDedxCnv::TObjectToDataObject" << endreq;
43 StatusCode sc=StatusCode::SUCCESS;
44
45 // create the TDS location for the Dedx Collection
46 DstMdcDedxCol* mdcDedxTdsCol = new DstMdcDedxCol;
47 refpObject=mdcDedxTdsCol;
48
49
50 // now convert
51 if (!m_mdcDedxCol) return sc;
52 TIter mdcDedxIter(m_mdcDedxCol);
53 TMdcDedx *mdcDedxRoot = 0;
54 while ((mdcDedxRoot = (TMdcDedx*)mdcDedxIter.Next())) {
55
56 int trackId = mdcDedxRoot->trackId();
57 int particleId = mdcDedxRoot->particleId();
58 int status = mdcDedxRoot->status();
59 int truncAlg = mdcDedxRoot->truncAlg();
60 /*
61 double pb[5];
62 for ( int i = 0; i < 5; i++)
63 pb[i] = dedxRoot->prob(i);
64
65 double numSigmaE = dedxRoot->numSigmaE();
66 double numSigmaMu = dedxRoot->numSigmaMu();
67 double numSigmaPi = dedxRoot->numSigmaPi();
68 double numSigmaK = dedxRoot->numSigmaK();
69 double numSigmaP = dedxRoot->numSigmaP();
70 */
71 double chi[5];
72 chi[0] = mdcDedxRoot->chiE();
73 chi[1] = mdcDedxRoot->chiMu();
74 chi[2] = mdcDedxRoot->chiPi();
75 chi[3] = mdcDedxRoot->chiK();
76 chi[4] = mdcDedxRoot->chiP();
77 int numGoodHits = mdcDedxRoot->numGoodHits();
78 int numTotalHits = mdcDedxRoot->numTotalHits();
79
80 double probPH = mdcDedxRoot->probPH();
81 double normPH = mdcDedxRoot->normPH();
82 double errorPH = mdcDedxRoot->errorPH();
83 double twentyPH = mdcDedxRoot->twentyPH();
84 //double fracErrPH = dedxRoot-> fracErrPH();
85 //double minIronPH = dedxRoot->minIronPH();
86 //double corrPH = dedxRoot->corrPH();
87
88 DstMdcDedx *mdcDedxTds = new DstMdcDedx();
89 m_common.m_rootMdcDedxMap[mdcDedxRoot] = mdcDedxTds;
90
91 mdcDedxTds->setTrackId(trackId);
92 mdcDedxTds->setParticleId(particleId);
93 mdcDedxTds->setStatus (status);
94 mdcDedxTds->setTruncAlg(truncAlg);
95 /*
96 dedxTds->setProb(pb);
97 dedxTds->setNumSigmaE(numSigmaE);
98 dedxTds->setNumSigmaMu(numSigmaMu);
99 dedxTds->setNumSigmaPi(numSigmaPi);
100 dedxTds->setNumSigmaK(numSigmaK);
101 dedxTds->setNumSigmaP(numSigmaP);
102 */
103 mdcDedxTds->setChi(chi);
104
105 mdcDedxTds->setNumGoodHits( numGoodHits);
106 mdcDedxTds->setNumTotalHits( numTotalHits);
107
108 mdcDedxTds->setProbPH(probPH);
109 mdcDedxTds->setNormPH(normPH);
110 mdcDedxTds->setErrorPH(errorPH);
111 mdcDedxTds->setTwentyPH(twentyPH);
112 //dedxTds->setFracErrPH(fracErrPH);
113 //dedxTds->setMinIronPH(minIronPH);
114 //dedxTds->setCorrPH(corrPH);
115
116 mdcDedxTdsCol->push_back(mdcDedxTds);
117 //delete dedxTds;
118 // dedxTds = NULL;
119 }
120 //m_dedxCol->Delete();
121 delete m_mdcDedxCol;
122 m_mdcDedxCol = 0;
123 return StatusCode::SUCCESS;
124}
125
126StatusCode MdcDedxCnv::DataObjectToTObject(DataObject* obj,RootAddress* rootaddr) {
127
128 MsgStream log(msgSvc(), "MdcDedxCnv");
129 log << MSG::DEBUG << "MdcDedxCnv::DataObjectToTObject" << endreq;
130 StatusCode sc=StatusCode::SUCCESS;
131
132 DstMdcDedxCol * mdcDedxColTds=dynamic_cast<DstMdcDedxCol *> (obj);
133 if (!mdcDedxColTds) {
134 log << MSG::ERROR << "Could not downcast to MdcDedxCol" << endreq;
135 return StatusCode::FAILURE;
136 }
137
138 DataObject *evt;
139 m_eds->findObject(EventModel::Dst::Event,evt);
140 if (evt==NULL) {
141 log << MSG::ERROR << "Could not get DstEvent in TDS " << endreq;
142 return StatusCode::FAILURE;
143 }
144 DstEvent * devtTds=dynamic_cast<DstEvent *> (evt);
145 if (!devtTds) {
146 log << MSG::ERROR << "MdcDedxCnv:Could not downcast to TDS DstEvent" << endreq;
147 }
148 IOpaqueAddress *addr;
149
150 m_cnvSvc->getDstCnv()->createRep(evt,addr);
152
153 const TObjArray *m_mdcDedxCol = recEvt->getMdcDedxCol();
154 if (!m_mdcDedxCol) return sc;
155 recEvt->clearMdcDedxCol(); //necessary in case there is I/O at the same time since array is static
156 DstMdcDedxCol::const_iterator mdcDedxTds;
157
158 for (mdcDedxTds = mdcDedxColTds->begin(); mdcDedxTds != mdcDedxColTds->end(); mdcDedxTds++) {
159 Int_t trackId = (*mdcDedxTds)->trackId();
160 Int_t particleId = (*mdcDedxTds)->particleId();
161 Int_t status = (*mdcDedxTds)->status();
162 Int_t truncAlg =(*mdcDedxTds)->truncAlg();
163 /*
164 Double_t pb[5];
165 for (Int_t i = 0; i < 5; i++)
166 pb[i] = (*dedxTds)->prob(i);
167 */
168 Double_t chiE = (*mdcDedxTds)->chi(0);
169 Double_t chiMu = (*mdcDedxTds)->chi(1);
170 Double_t chiPi = (*mdcDedxTds)->chi(2);
171 Double_t chiK = (*mdcDedxTds)->chi(3);
172 Double_t chiP = (*mdcDedxTds)->chi(4);
173
174 Int_t numGoodHits = (*mdcDedxTds)->numGoodHits();
175 Int_t numTotalHits = (*mdcDedxTds)->numTotalHits();
176
177 Double_t probPH = (*mdcDedxTds)->probPH();
178 Double_t normPH = (*mdcDedxTds)->normPH();
179 Double_t errorPH = (*mdcDedxTds)->errorPH();
180 Double_t twentyPH =(*mdcDedxTds)->twentyPH();
181 //Double_t fracErrPH = (*dedxTds)-> fracErrPH();
182 //Double_t minIronPH = (*dedxTds)->minIronPH();
183 //Double_t corrPH = (*dedxTds)->corrPH();
184 log << MSG::INFO <<"check Reconstrunction root"<<" particle Id is : "<<particleId
185 <<"track id is : "<<trackId
186 <<" and status is : "<<status<<endreq;
187
188
189 TMdcDedx *mdcDedxRoot = new TMdcDedx();
190 //m_common.m_mdcDedxMap[(*mdcDedxTds)] = mdcDedxRoot;
191
192 mdcDedxRoot->setTrackId(trackId);
193 mdcDedxRoot->setParticleId(particleId);
194 mdcDedxRoot->setStatus (status);
195 mdcDedxRoot->setTruncAlg(truncAlg);
196 //dedxRoot->setProb(pb);
197 mdcDedxRoot->setChiE(chiE);
198 mdcDedxRoot->setChiMu(chiMu);
199 mdcDedxRoot->setChiPi(chiPi);
200 mdcDedxRoot->setChiK(chiK);
201 mdcDedxRoot->setChiP(chiP);
202
203 mdcDedxRoot->setNumGoodHits( numGoodHits);
204 mdcDedxRoot->setNumTotalHits( numTotalHits);
205
206 mdcDedxRoot->setProbPH(probPH);
207 mdcDedxRoot->setNormPH(normPH);
208 mdcDedxRoot->setErrorPH(errorPH);
209 mdcDedxRoot->setTwentyPH(twentyPH);
210 // dedxRoot->setFracErrPH(fracErrPH);
211 //dedxRoot->setMinIronPH(minIronPH);
212 //dedxRoot->setCorrPH(corrPH);
213 log << MSG::INFO << "check Reconstrunction root"<<" particle Id is : "<<particleId
214 <<"track id is : "<<trackId
215 <<" and status is : "<<status<<endreq;
216
217
218
219 recEvt->addMdcDedx(mdcDedxRoot);
220 }
221
222 return StatusCode::SUCCESS;
223}
224#endif
ObjectVector< DstMdcDedx > DstMdcDedxCol
Definition: DstMdcDedx.h:102
IMessageSvc * msgSvc()
static TDstEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition: DstCnv.h:36
void setChi(double *chi)
Definition: DstMdcDedx.h:77
void setTruncAlg(int trunc_alg)
Definition: DstMdcDedx.h:75
void setStatus(int status)
Definition: DstMdcDedx.h:74
void setTwentyPH(double twentyPH)
Definition: DstMdcDedx.h:86
void setNumGoodHits(int numGoodHits)
Definition: DstMdcDedx.h:81
void setProbPH(double probPH)
Definition: DstMdcDedx.h:83
void setNormPH(double normPH)
Definition: DstMdcDedx.h:84
void setParticleId(int particleId)
Definition: DstMdcDedx.h:73
void setTrackId(int trackId)
Definition: DstMdcDedx.h:72
void setNumTotalHits(int numTotalHits)
Definition: DstMdcDedx.h:82
void setErrorPH(double errorPH)
Definition: DstMdcDedx.h:85
MdcDedxCnv(ISvcLocator *svc)
Definition: MdcDedxCnv.cxx:26
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
Definition: MdcDedxCnv.cxx:38
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
Definition: MdcDedxCnv.cxx:126
Definition of a Root address, derived from IOpaqueAddress.
Definition: RootAddress.h:21
DstCnv * getDstCnv()
Definition: RootCnvSvc.h:148
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.
const TObjArray * getMdcDedxCol() const
retrieve the whole TObjArray of Dedx Data
Definition: TDstEvent.h:84
void clearMdcDedxCol()
clear the whole array
Definition: TDstEvent.h:93
void addMdcDedx(TMdcDedx *Track)
Add a Dedx into the TOF Data collection.
Definition: TDstEvent.cxx:163
void setChiP(const Double_t chiP)
Definition: TMdcDedx.h:59
void setNormPH(const Double_t normPH)
Definition: TMdcDedx.h:65
Int_t particleId() const
Definition: TMdcDedx.h:20
Double_t probPH() const
Definition: TMdcDedx.h:35
Double_t chiMu() const
Definition: TMdcDedx.h:27
void setChiE(const Double_t chiE)
Definition: TMdcDedx.h:55
Int_t status() const
Definition: TMdcDedx.h:21
void setChiMu(const Double_t chiMu)
Definition: TMdcDedx.h:56
Int_t numTotalHits() const
Definition: TMdcDedx.h:33
Double_t chiP() const
Definition: TMdcDedx.h:30
void setChiPi(const Double_t chiPi)
Definition: TMdcDedx.h:57
Int_t numGoodHits() const
Definition: TMdcDedx.h:32
void setNumTotalHits(const Int_t numTotalHits)
Definition: TMdcDedx.h:62
void setParticleId(const Int_t particleId)
Definition: TMdcDedx.h:48
void setProbPH(const Double_t probPH)
Definition: TMdcDedx.h:64
Double_t chiK() const
Definition: TMdcDedx.h:29
void setTwentyPH(const Double_t twentyPH)
Definition: TMdcDedx.h:67
void setTrackId(const Int_t trackId)
Definition: TMdcDedx.h:47
void setStatus(const Int_t status)
Definition: TMdcDedx.h:49
Int_t truncAlg() const
Definition: TMdcDedx.h:22
void setTruncAlg(const Int_t trunc_alg)
Definition: TMdcDedx.h:50
Double_t chiPi() const
Definition: TMdcDedx.h:28
Double_t errorPH() const
Definition: TMdcDedx.h:37
Int_t trackId() const
Definition: TMdcDedx.h:19
void setChiK(const Double_t chiK)
Definition: TMdcDedx.h:58
void setNumGoodHits(const Int_t numGoodHits)
Definition: TMdcDedx.h:61
Double_t twentyPH() const
Definition: TMdcDedx.h:38
Double_t chiE() const
Definition: TMdcDedx.h:26
Double_t normPH() const
Definition: TMdcDedx.h:36
void setErrorPH(const Double_t errorPH)
Definition: TMdcDedx.h:66
static std::map< const TObject *, const DstMdcDedx * > m_rootMdcDedxMap
Definition: commonData.h:154
_EXTERN_ std::string Event
Definition: EventModel.h:123