1#ifndef RecMdcDedxCnv_CXX
2#define RecMdcDedxCnv_CXX 1
3#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/DataObject.h"
5#include "GaudiKernel/ObjectVector.h"
6#include "TClonesArray.h"
35 MsgStream log(
msgSvc(),
"RecMdcDedxCnv");
46 MsgStream log(
msgSvc(),
"RecMdcDedxCnv");
47 log << MSG::DEBUG <<
"RecMdcDedxCnv::TObjectToDataObject" << endreq;
48 StatusCode sc=StatusCode::SUCCESS;
52 refpObject=recMdcDedxCol;
54 if (!m_recMdcDedxCol)
return sc;
57 IDataProviderSvc* dataSvc = 0;
58 sc = serviceLocator()->getService(
"EventDataSvc",
59 IDataProviderSvc::interfaceID(), (IInterface*&)dataSvc);
60 if ( sc.isFailure() ) {
61 log << MSG::FATAL <<
"Could not get EventDataSvc in RecMdcDedxCnv" << endreq;
66 SmartDataPtr<RecMdcDedxHitCol> recMdcDedxHitCol(dataSvc,
"/Event/Recon/RecMdcDedxHitCol");
67 if (!recMdcDedxHitCol) {
68 log << MSG::FATAL <<
"Could not find RecMdcDedxHitCol" << endreq;
69 return( StatusCode::FAILURE);
78 log << MSG::INFO <<
"Could not find RecMdcTrackCol" << endreq;
79 SmartDataPtr<DstMdcTrackCol> dstMdcTrackCol(dataSvc,
"/Event/Dst/DstMdcTrackCol");
80 if (!dstMdcTrackCol) {
81 log << MSG::INFO <<
"Could not find DstMdcTrackCol" << endreq;
85 DstMdcTrackCol::iterator iter_mdc = dstMdcTrackCol->begin();
87 for (;iter_mdc != dstMdcTrackCol->end(); iter_mdc++, trackID++) {
89 *recMdcTrack = **iter_mdc;
90 (*mdcTrackCol).push_back(recMdcTrack);
92 <<
" Mdc Track ID = " << trackID
93 <<
" Mdc Track Nster = " << (*iter_mdc)->
nster()
102 if (!mdcKalTrackCol) {
103 log << MSG::INFO <<
"Could not find RecMdcKalTrackCol" << endreq;
104 SmartDataPtr<DstMdcKalTrackCol> dstMdcKalTrackCol(dataSvc,
"/Event/Dst/DstMdcKalTrackCol");
105 if(!dstMdcKalTrackCol) {
106 log << MSG::INFO <<
"Could not find DstMdcKalTrackCol" << endreq;
110 DstMdcKalTrackCol::iterator iter_mdc = dstMdcKalTrackCol->begin();
112 for (;iter_mdc != dstMdcKalTrackCol->end(); iter_mdc++, trackID++) {
114 *recMdcKalTrack = **iter_mdc;
115 (*mdcKalTrackCol).push_back(recMdcKalTrack);
117 <<
" MdcKalTrack ID = " << trackID
118 <<
" MdcKalTrack Nster = " << (*iter_mdc)->
nster()
119 <<
" MdcKalTrack poca = " << (*iter_mdc)->poca()
129 TIter dedxIter(m_recMdcDedxCol);
131 while ((recMdcDedxRoot = (
TRecMdcDedx*)dedxIter.Next())) {
132 double dedxHit = recMdcDedxRoot->
dedxHit();
133 double dedxEsat = recMdcDedxRoot->
dedxEsat();
134 double dedxNoRun = recMdcDedxRoot->
dedxNoRun();
135 double dedxMoment = recMdcDedxRoot->
dedxMoment();
137 int trackId = recMdcDedxRoot->
trackId();
138 int particleId = recMdcDedxRoot->
particleId();
139 int status = recMdcDedxRoot->
status();
140 int truncAlg = recMdcDedxRoot->
truncAlg();
151 chi[0] = recMdcDedxRoot->
chiE();
152 chi[1] = recMdcDedxRoot->
chiMu();
153 chi[2] = recMdcDedxRoot->
chiPi();
154 chi[3] = recMdcDedxRoot->
chiK();
155 chi[4] = recMdcDedxRoot->
chiP();
159 double probPH = recMdcDedxRoot->
probPH();
160 double normPH = recMdcDedxRoot->
normPH();
161 double errorPH = recMdcDedxRoot->
errorPH();
162 double twentyPH = recMdcDedxRoot->
twentyPH();
163 double dedxExpect[5],sigmaDedx[5],pidProb[5];
165 for (
int i=0; i<5; i++){
166 dedxExpect[i] = recMdcDedxRoot->
dedxExpect(i);
167 sigmaDedx[i] = recMdcDedxRoot->
sigmaDedx(i);
168 pidProb[i] = recMdcDedxRoot->
pidProb(i);}
170 log << MSG::DEBUG<<
"TObjectToDataObject: check Reconstrunction of dE/dx root::"<<
" trackId: "<<trackId<<
" particleId: "<<particleId<<
" status: "<<status<<
" truncAlg: "<<truncAlg<<
" chi[2]: "<<chi[2]<<
" numTotalHits: "<<numTotalHits<<
" probPH: "<<probPH<<
" errorPH: "<<errorPH<<
" dedxExpect[2]: "<<dedxExpect[2]<<endreq;
205 RecMdcDedxHitCol::iterator
iter = recMdcDedxHitCol->begin();
206 for (;
iter != recMdcDedxHitCol->end();
iter++){
207 if((*iter)->getTrkId() == trackId){
208 SmartRef<RecMdcDedxHit> refDedxHit(*
iter);
209 theDedxHitRefVec.push_back(refDedxHit);
215 for(
int ii=0; ii <nhits ; ii++){
222 int mdcTrackId = recMdcDedxRoot->
mdcTrackId();
224 if ( mdcTrackId >= 0 ) {
226 dynamic_cast<RecMdcTrack*
>(mdcTrackCol->containedObject(mdcTrackId)));
230 if ( mdcKalTrackId >= 0 ) {
232 dynamic_cast<RecMdcKalTrack*
>(mdcKalTrackCol->containedObject(mdcKalTrackId)));
235 recMdcDedxCol->push_back(recMdcDedx);
240 delete m_recMdcDedxCol;
243 return StatusCode::SUCCESS;
248 MsgStream log(
msgSvc(),
"RecMdcDedxCnv");
249 log << MSG::DEBUG <<
"RecMdcDedxCnv::DataObjectToTObject" << endreq;
250 StatusCode sc=StatusCode::SUCCESS;
253 if (!recMdcDedxCol) {
254 log << MSG::ERROR <<
"Could not downcast to RecMdcDedxCol" << endreq;
255 return StatusCode::FAILURE;
261 log << MSG::ERROR <<
"Could not get RecEvent in TDS " << endreq;
262 return StatusCode::FAILURE;
266 log << MSG::ERROR <<
"RecMdcDedxCnv:Could not downcast to TDS RecEvent" << endreq;
269 IOpaqueAddress *addr;
274 if (!m_recMdcDedxCol)
return sc;
279 RecMdcTrackCol::iterator recMdcTrackColbegin, recMdcTrackColend;
280 RecMdcKalTrackCol::iterator recMdcKalTrackColbegin, recMdcKalTrackColend;
282 IDataProviderSvc* dataSvc = 0;
283 sc = serviceLocator()->getService(
"EventDataSvc",
284 IDataProviderSvc::interfaceID(), (IInterface*&)dataSvc);
285 if ( sc.isFailure() ) {
286 log << MSG::FATAL <<
"Could not get EventDataSvc in RecMdcDedxCnv" << endreq;
290 if (!recMdcTrackCol) {
291 log << MSG::ERROR <<
"Could not downcast to RecMdcTrackCol" << endreq;
292 return StatusCode::FAILURE;
295 recMdcTrackColbegin = recMdcTrackCol->begin();
296 recMdcTrackColend = recMdcTrackCol->end();
300 if (!recMdcKalTrackCol) {
301 log << MSG::ERROR <<
"Could not downcast to RecMdcKalTrackCol" << endreq;
302 return StatusCode::FAILURE;
305 recMdcKalTrackColbegin = recMdcKalTrackCol->begin();
306 recMdcKalTrackColend = recMdcKalTrackCol->end();
310 RecMdcDedxCol::const_iterator recMdcDedx;
312 for (recMdcDedx = recMdcDedxCol->begin(); recMdcDedx != recMdcDedxCol->end(); recMdcDedx++) {
313 Int_t trackId = (*recMdcDedx)->trackId();
314 Int_t particleId = (*recMdcDedx)->particleId();
315 Int_t status = (*recMdcDedx)->status();
316 Int_t truncAlg = (*recMdcDedx)->truncAlg();
320 Double_t dedxHit = (*recMdcDedx)->getDedxHit();
321 Double_t dedxEsat = (*recMdcDedx)->getDedxEsat();
322 Double_t dedxNoRun = (*recMdcDedx)->getDedxNoRun();
323 Double_t dedxMoment = (*recMdcDedx)->getDedxMoment();
326 Double_t chiE = (*recMdcDedx)->chi(0);
327 Double_t chiMu = (*recMdcDedx)->chi(1);
328 Double_t chiPi = (*recMdcDedx)->chi(2);
329 Double_t chiK = (*recMdcDedx)->chi(3);
330 Double_t chiP = (*recMdcDedx)->chi(4);
332 Int_t numGoodHits = (*recMdcDedx)->numGoodHits();
333 Int_t numTotalHits = (*recMdcDedx)->numTotalHits();
335 Double_t probPH = (*recMdcDedx)->probPH();
336 Double_t normPH = (*recMdcDedx)->normPH();
337 Double_t errorPH = (*recMdcDedx)->errorPH();
338 Double_t twentyPH = (*recMdcDedx)->twentyPH();
342 double dedxExpect[5],sigmaDedx[5],pidProb[5],chi[5];
343 for (
int i=0; i<5; i++){
344 chi[i] = (*recMdcDedx)->chi(i);
345 dedxExpect[i] = (*recMdcDedx)->getDedxExpect(i);
346 sigmaDedx[i] = (*recMdcDedx)->getSigmaDedx(i);
347 pidProb[i] = (*recMdcDedx)->getPidProb(i);
350 log << MSG::DEBUG<<
"DataObjectToTObject: check Reconstrunction of dE/dx::"<<
" trackId: "<<trackId<<
" particleId: "<<particleId<<
" status: "<<status<<
" truncAlg: "<<truncAlg<<
" chiPi: "<<chiPi<<
" numTotalHits: "<<numTotalHits<<
" probPH: "<<probPH<<
" errorPH: "<<errorPH<<
" dedxExpect[2]: "<<dedxExpect[2]<<endreq;
376 recMdcDedxRoot->
setChi(chi);
387 if ( (*recMdcDedx)->isMdcTrackValid() ) {
388 RecMdcTrackCol::iterator it = find(recMdcTrackColbegin, recMdcTrackColend, (*recMdcDedx)->getMdcTrack());
395 if ( (*recMdcDedx)->isMdcKalTrackValid() ) {
396 RecMdcKalTrackCol::iterator it = find(recMdcKalTrackColbegin, recMdcKalTrackColend, (*recMdcDedx)->getMdcKalTrack());
403 log << MSG::INFO<<
"check Reconstrunction root"<<
" particle Id is : "<<particleId
404 <<
"track id is : "<<trackId
405 <<
" and status is : "<<status<<endreq;
413 return StatusCode::SUCCESS;
SmartRefVector< RecMdcDedxHit > DedxHitRefVec
ObjectVector< RecMdcDedx > RecMdcDedxCol
ObjectVector< RecMdcKalTrack > RecMdcKalTrackCol
ObjectVector< RecMdcTrack > RecMdcTrackCol
void setTruncAlg(int trunc_alg)
void setStatus(int status)
void setTwentyPH(double twentyPH)
void setNumGoodHits(int numGoodHits)
void setProbPH(double probPH)
void setNormPH(double normPH)
void setParticleId(int particleId)
void setTrackId(int trackId)
void setNumTotalHits(int numTotalHits)
void setErrorPH(double errorPH)
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
static int wire(const Identifier &id)
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
RecMdcDedxCnv(ISvcLocator *svc)
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
void setMdcTrack(RecMdcTrack *trk)
DedxHitRefVec getVecDedxHits() const
void setVecDedxHits(const DedxHitRefVec &vecdedxhit)
void setDedxNoRun(double dedx_norun)
void setMdcKalTrack(RecMdcKalTrack *trk)
void setDedxMoment(double dedx_momentum)
void setDedxExpect(double *dedx_exp)
void setSigmaDedx(double *sigma_dedx)
void setDedxEsat(double dedx_esat)
void setDedxHit(double dedx_hit)
void setPidProb(double *pid_prob)
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 setNumTotalHits(const Int_t numTotalHits)
Double_t dedxExpect(int pid) const
Double_t dedxMoment() const
void setProbPH(const Double_t probPH)
void setPidProb(double *pid_prob)
void setDedxHit(const Double_t dedx_hit)
Double_t sigmaDedx(int pid) const
void setTruncAlg(const Int_t trunc_alg)
void setSigmaDedx(double *sigma_dedx)
void setParticleId(const Int_t particleId)
Double_t pidProb(int pid) const
void setMdcTrackId(const int mdcTrackId)
void setTwentyPH(const Double_t twentyPH)
void setDedxMoment(const Double_t dedx_momentum)
Int_t numGoodHits() const
void setChiE(const Double_t chiE)
Int_t mdcKalTrackId() const
void setDedxEsat(const Double_t dedx_esat)
void setErrorPH(const Double_t errorPH)
Int_t numTotalHits() const
Double_t dedxEsat() const
void setMdcKalTrackId(const int mdcKalTrackId)
void setStatus(const Int_t status)
void setChiPi(const Double_t chiPi)
void setTrackId(const Int_t trackId)
void setNormPH(const Double_t normPH)
Double_t dedxNoRun() const
void setChiP(const Double_t chiP)
Double_t twentyPH() const
void setDedxNoRun(const Double_t dedx_norun)
void setDedxExpect(double *dedx_exp)
void setChiMu(const Double_t chiMu)
void setChiK(const Double_t chiK)
void setNumGoodHits(const Int_t numGoodHits)
void clearRecMdcDedxCol()
clear the whole array
void addRecMdcDedx(TRecMdcDedx *Track)
Add a Dedx into the TOF Data collection.
const TObjArray * getRecMdcDedxCol() const
retrieve the whole TObjArray of Dedx Data
static std::map< const TObject *, const RecMdcDedx * > m_rootRecMdcDedxMap
_EXTERN_ std::string RecMdcTrackCol
_EXTERN_ std::string Event
_EXTERN_ std::string RecMdcKalTrackCol