CGEM BOSS 6.6.5.i
BESIII Offline Software System
Loading...
Searching...
No Matches
CgemDedxCnv.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/DstCgemDedx.h" //TDS object
13#include "RootEventData/TCgemDedx.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
26CgemDedxCnv::CgemDedxCnv(ISvcLocator* svc)
27: RootEventBaseCnv(classID(), svc)
28{
29 // Here we associate this converter with the /Event path on the TDS.
30 MsgStream log(msgSvc(), "CgemDedxCnv");
31 //log << MSG::DEBUG << "Constructor called for " << objType() << endreq;
32 m_rootBranchname ="m_cgemDedxCol";
33 //declareObject(EventModel::Dst::DstDedxCol, objType(), m_rootTreename, m_rootBranchname);
34 m_adresses.push_back(&m_cgemDedxCol);
35 m_cgemDedxCol=0;
36}
37
38StatusCode CgemDedxCnv::TObjectToDataObject(DataObject*& refpObject) {
39 // creation of TDS object from root object
40
41 MsgStream log(msgSvc(), "CgemDedxCnv");
42 log << MSG::DEBUG << "CgemDedxCnv::TObjectToDataObject" << endreq;
43 StatusCode sc=StatusCode::SUCCESS;
44
45 // create the TDS location for the Dedx Collection
46 DstCgemDedxCol* cgemDedxTdsCol = new DstCgemDedxCol;
47 refpObject=cgemDedxTdsCol;
48
49
50 // now convert
51 if (!m_cgemDedxCol) return sc;
52 TIter cgemDedxIter(m_cgemDedxCol);
53 TCgemDedx *cgemDedxRoot = 0;
54 while ((cgemDedxRoot = (TCgemDedx*)cgemDedxIter.Next())) {
55
56 int trackId = cgemDedxRoot->trackId();
57 int particleId = cgemDedxRoot->particleId();
58 int status = cgemDedxRoot->status();
59 int truncAlg = cgemDedxRoot->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] = cgemDedxRoot->chiE();
73 chi[1] = cgemDedxRoot->chiMu();
74 chi[2] = cgemDedxRoot->chiPi();
75 chi[3] = cgemDedxRoot->chiK();
76 chi[4] = cgemDedxRoot->chiP();
77 int numGoodHits = cgemDedxRoot->numGoodHits();
78 int numTotalHits = cgemDedxRoot->numTotalHits();
79
80 double probPH = cgemDedxRoot->probPH();
81 double normPH = cgemDedxRoot->normPH();
82 double errorPH = cgemDedxRoot->errorPH();
83 double twentyPH = cgemDedxRoot->twentyPH();
84 //double fracErrPH = dedxRoot-> fracErrPH();
85 //double minIronPH = dedxRoot->minIronPH();
86 //double corrPH = dedxRoot->corrPH();
87
88 DstCgemDedx *cgemDedxTds = new DstCgemDedx();
89 m_common.m_rootCgemDedxMap[cgemDedxRoot] = cgemDedxTds;
90
91 cgemDedxTds->setTrackId(trackId);
92 cgemDedxTds->setParticleId(particleId);
93 cgemDedxTds->setStatus (status);
94 cgemDedxTds->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 cgemDedxTds->setChi(chi);
104
105 cgemDedxTds->setNumGoodHits( numGoodHits);
106 cgemDedxTds->setNumTotalHits( numTotalHits);
107
108 cgemDedxTds->setProbPH(probPH);
109 cgemDedxTds->setNormPH(normPH);
110 cgemDedxTds->setErrorPH(errorPH);
111 cgemDedxTds->setTwentyPH(twentyPH);
112 //dedxTds->setFracErrPH(fracErrPH);
113 //dedxTds->setMinIronPH(minIronPH);
114 //dedxTds->setCorrPH(corrPH);
115
116 cgemDedxTdsCol->push_back(cgemDedxTds);
117 //delete dedxTds;
118 // dedxTds = NULL;
119 }
120 //m_dedxCol->Delete();
121 delete m_cgemDedxCol;
122 m_cgemDedxCol = 0;
123 return StatusCode::SUCCESS;
124}
125
126StatusCode CgemDedxCnv::DataObjectToTObject(DataObject* obj,RootAddress* rootaddr) {
127
128 MsgStream log(msgSvc(), "CgemDedxCnv");
129 log << MSG::DEBUG << "CgemDedxCnv::DataObjectToTObject" << endreq;
130 StatusCode sc=StatusCode::SUCCESS;
131
132 DstCgemDedxCol * cgemDedxColTds=dynamic_cast<DstCgemDedxCol *> (obj);
133 if (!cgemDedxColTds) {
134 log << MSG::ERROR << "Could not downcast to CgemDedxCol" << 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 << "CgemDedxCnv:Could not downcast to TDS DstEvent" << endreq;
147 }
148 IOpaqueAddress *addr;
149
150 m_cnvSvc->getDstCnv()->createRep(evt,addr);
152
153 const TObjArray *m_cgemDedxCol = recEvt->getCgemDedxCol();
154 if (!m_cgemDedxCol) return sc;
155 recEvt->clearCgemDedxCol(); //necessary in case there is I/O at the same time since array is static
156 DstCgemDedxCol::const_iterator cgemDedxTds;
157
158 for (cgemDedxTds = cgemDedxColTds->begin(); cgemDedxTds != cgemDedxColTds->end(); cgemDedxTds++) {
159 Int_t trackId = (*cgemDedxTds)->trackId();
160 Int_t particleId = (*cgemDedxTds)->particleId();
161 Int_t status = (*cgemDedxTds)->status();
162 Int_t truncAlg =(*cgemDedxTds)->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 = (*cgemDedxTds)->chi(0);
169 Double_t chiMu = (*cgemDedxTds)->chi(1);
170 Double_t chiPi = (*cgemDedxTds)->chi(2);
171 Double_t chiK = (*cgemDedxTds)->chi(3);
172 Double_t chiP = (*cgemDedxTds)->chi(4);
173
174 Int_t numGoodHits = (*cgemDedxTds)->numGoodHits();
175 Int_t numTotalHits = (*cgemDedxTds)->numTotalHits();
176
177 Double_t probPH = (*cgemDedxTds)->probPH();
178 Double_t normPH = (*cgemDedxTds)->normPH();
179 Double_t errorPH = (*cgemDedxTds)->errorPH();
180 Double_t twentyPH =(*cgemDedxTds)->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 TCgemDedx *cgemDedxRoot = new TCgemDedx();
190 //m_common.m_cgemDedxMap[(*cgemDedxTds)] = cgemDedxRoot;
191
192 cgemDedxRoot->setTrackId(trackId);
193 cgemDedxRoot->setParticleId(particleId);
194 cgemDedxRoot->setStatus (status);
195 cgemDedxRoot->setTruncAlg(truncAlg);
196 //dedxRoot->setProb(pb);
197 cgemDedxRoot->setChiE(chiE);
198 cgemDedxRoot->setChiMu(chiMu);
199 cgemDedxRoot->setChiPi(chiPi);
200 cgemDedxRoot->setChiK(chiK);
201 cgemDedxRoot->setChiP(chiP);
202
203 cgemDedxRoot->setNumGoodHits( numGoodHits);
204 cgemDedxRoot->setNumTotalHits( numTotalHits);
205
206 cgemDedxRoot->setProbPH(probPH);
207 cgemDedxRoot->setNormPH(normPH);
208 cgemDedxRoot->setErrorPH(errorPH);
209 cgemDedxRoot->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->addCgemDedx(cgemDedxRoot);
220 }
221
222 return StatusCode::SUCCESS;
223}
224#endif
ObjectVector< DstCgemDedx > DstCgemDedxCol
Definition DstCgemDedx.h:79
IMessageSvc * msgSvc()
CgemDedxCnv(ISvcLocator *svc)
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
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
static TDstEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition DstCnv.h:36
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.
void setParticleId(const Int_t particleId)
Definition TCgemDedx.h:48
Double_t errorPH() const
Definition TCgemDedx.h:37
Double_t chiK() const
Definition TCgemDedx.h:29
void setChiPi(const Double_t chiPi)
Definition TCgemDedx.h:57
void setTruncAlg(const Int_t trunc_alg)
Definition TCgemDedx.h:50
void setChiK(const Double_t chiK)
Definition TCgemDedx.h:58
void setChiE(const Double_t chiE)
Definition TCgemDedx.h:55
Double_t normPH() const
Definition TCgemDedx.h:36
Int_t trackId() const
Definition TCgemDedx.h:19
void setChiP(const Double_t chiP)
Definition TCgemDedx.h:59
Int_t particleId() const
Definition TCgemDedx.h:20
Double_t chiMu() const
Definition TCgemDedx.h:27
Double_t twentyPH() const
Definition TCgemDedx.h:38
Double_t probPH() const
Definition TCgemDedx.h:35
void setChiMu(const Double_t chiMu)
Definition TCgemDedx.h:56
Double_t chiE() const
Definition TCgemDedx.h:26
Double_t chiP() const
Definition TCgemDedx.h:30
Int_t status() const
Definition TCgemDedx.h:21
void setNumTotalHits(const Int_t numTotalHits)
Definition TCgemDedx.h:62
void setStatus(const Int_t status)
Definition TCgemDedx.h:49
void setTwentyPH(const Double_t twentyPH)
Definition TCgemDedx.h:67
void setProbPH(const Double_t probPH)
Definition TCgemDedx.h:64
Int_t numGoodHits() const
Definition TCgemDedx.h:32
Double_t chiPi() const
Definition TCgemDedx.h:28
void setTrackId(const Int_t trackId)
Definition TCgemDedx.h:47
void setNormPH(const Double_t normPH)
Definition TCgemDedx.h:65
Int_t numTotalHits() const
Definition TCgemDedx.h:33
void setNumGoodHits(const Int_t numGoodHits)
Definition TCgemDedx.h:61
Int_t truncAlg() const
Definition TCgemDedx.h:22
void setErrorPH(const Double_t errorPH)
Definition TCgemDedx.h:66
void clearCgemDedxCol()
clear the whole array
Definition TDstEvent.h:133
const TObjArray * getCgemDedxCol() const
retrieve the whole TObjArray of Dedx Data
Definition TDstEvent.h:124
void addCgemDedx(TCgemDedx *Track)
Add a Dedx into the TOF Data collection.
static std::map< const TObject *, const DstCgemDedx * > m_rootCgemDedxMap
Definition commonData.h:186
_EXTERN_ std::string Event
Definition EventModel.h:146