CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
RootCnvSvc-04-01-15/src/Rec/RecCgemHitCnv.cxx
Go to the documentation of this file.
1#ifndef RecCgemHitCnv_CXX
2#define RecCgemHitCnv_CXX 1
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/RecCgemHit.h"
14#include "Identifier/Identifier.h"
15
16#include "RootEventData/TRecCgemHit.h" // standard root object
17#include "RootEventData/TRecTrackEvent.h"
18
19#include "RootCnvSvc/Rec/RecTrackCnv.h"
20#include "RootCnvSvc/Rec/RecCgemHitCnv.h"
21#include "RootCnvSvc/RootAddress.h"
22
23#include <vector>
24
25using namespace std;
26
27
28RecCgemHitCnv::RecCgemHitCnv(ISvcLocator* svc)
29: RootEventBaseCnv(classID(), svc)
30{
31
32 // Here we associate this converter with the /Event path on the TDS.
33 MsgStream log(msgSvc(), "RecCgemHitCnv");
34 //log << MSG::DEBUG << "Constructor called for " << objType() << endreq;
35 //m_rootTreename ="Rec";
36 m_rootBranchname ="m_recCgemHitCol";
37 //declareObject(EventModel::Recon::RecCgemHitCol, objType(), m_rootTreename, m_rootBranchname);
38 m_adresses.push_back(&m_recCgemHitCol);
39 m_recCgemHitCol=0;
40}
41
42StatusCode RecCgemHitCnv::TObjectToDataObject(DataObject*& refpObject) {
43 // creation of TDS object from root object
44 MsgStream log(msgSvc(), "RecCgemHitCnv");
45 log << MSG::DEBUG << "RecCgemHitCnv::TObjectToDataObject" << endreq;
46
47 // create the TDS location for the RecCgemHit Collection
48 RecCgemHitCol* recCgemHitCol = new RecCgemHitCol;
49 refpObject = recCgemHitCol;
50
51 // now convert
52 if (!m_recCgemHitCol) return StatusCode::SUCCESS;
53 TIter cgemHitIter(m_recCgemHitCol);
54 TRecCgemHit *recCgemHitRoot = 0;
55 while ((recCgemHitRoot = (TRecCgemHit*)cgemHitIter.Next())) {
56 int id = recCgemHitRoot->getId();
57 int trackId = recCgemHitRoot->getTrkId();
58 double chisqAdd = recCgemHitRoot->getChisqAdd();
59 int stat = recCgemHitRoot->getStat();
60// unsigned int cgemIdMSB=recCgemHitRoot->getCgemIdMSB();
61// unsigned int cgemIdLSB=recCgemHitRoot->getCgemIdLSB();
62 unsigned int cgemId=recCgemHitRoot->getCgemId();
63 double tdc = recCgemHitRoot->getTdc();
64 double adc = recCgemHitRoot->getAdc();
65 double doca = recCgemHitRoot->getDoca();
66 double entra = recCgemHitRoot->getEntra();
67 double zhit = recCgemHitRoot->getZhit();
68 double fltLen = recCgemHitRoot->getFltLen();
69
70 RecCgemHit *recCgemHit= new RecCgemHit();
71 m_common.m_rootRecCgemHitMap[recCgemHitRoot] = recCgemHit;
72
73 recCgemHit->setId( id );
74 recCgemHit->setTrkId( trackId );
75 recCgemHit->setChisqAdd( chisqAdd );
76 recCgemHit->setStat( stat );
77// recCgemHit->setCgemId( Identifier64(cgemIdMSB,cgemIdLSB) );
78 recCgemHit->setCgemId( Identifier(cgemId) );
79 recCgemHit->setTdc( tdc );
80 recCgemHit->setAdc( adc );
81 recCgemHit->setDoca( doca );
82 recCgemHit->setEntra( entra );
83 recCgemHit->setZhit( zhit );
84 recCgemHit->setFltLen( fltLen );
85
86 recCgemHitCol->push_back(recCgemHit);
87 }
88 return StatusCode::SUCCESS;
89}
90
91StatusCode RecCgemHitCnv::DataObjectToTObject(DataObject* obj,RootAddress* rootaddr) {
92
93 MsgStream log(msgSvc(), "RecCgemHitCnv");
94 log << MSG::DEBUG << "RecCgemHitCnv::DataObjectToTObject" << endreq;
95
96 RecCgemHitCol * cgemHitColTds=dynamic_cast<RecCgemHitCol *> (obj);
97 if (!cgemHitColTds) {
98 log << MSG::ERROR << "Could not downcast to RecCgemHitCol" << endreq;
99 return StatusCode::FAILURE;
100 }
101
102 DataObject *evt;
103 m_eds->findObject(EventModel::Recon::Event,evt);
104 if (evt==NULL) {
105 log << MSG::ERROR << "Could not get ReconEvent in TDS " << endreq;
106 return StatusCode::FAILURE;
107 }
108
109 ReconEvent * devtTds=dynamic_cast<ReconEvent *> (evt);
110 if (!devtTds) {
111 log << MSG::ERROR << "RecCgemHitCnv:Could not downcast to TDS ReconEvent" << endreq;
112 }
113
114 IOpaqueAddress *addr;
115
116 m_cnvSvc->getRecTrackCnv()->createRep(evt,addr);
118
119 const TObjArray *m_recCgemHitCol = recEvt->getRecCgemHitCol();
120 if (!m_recCgemHitCol) return StatusCode::SUCCESS;
121 recEvt->clearRecCgemHitCol(); //necessary in case there is I/O at the same time since array is static
122
123 RecCgemHitCol::const_iterator recCgemHit;
124 for (recCgemHit = cgemHitColTds->begin(); recCgemHit != cgemHitColTds->end(); recCgemHit++) {
125 Bool_t isGrouped =(*recCgemHit)->isGrouped();
126 Int_t id =(*recCgemHit)->getId();
127 Int_t trackId =(*recCgemHit)->getTrkId();
128 Double_t chisqAdd =(*recCgemHit)->getChisqAdd();
129 Int_t stat =(*recCgemHit)->getStat();
130// UInt_t cgemIdMSB =(*recCgemHit)->getCgemId().get_valueMSB();
131// UInt_t cgemIdLSB =(*recCgemHit)->getCgemId().get_valueLSB();
132 UInt_t cgemId =(*recCgemHit)->getCgemId().get_value();
133 Double_t tdc =(*recCgemHit)->getTdc();
134 Double_t adc =(*recCgemHit)->getAdc();
135 Double_t doca =(*recCgemHit)->getDoca();
136 Double_t entra =(*recCgemHit)->getEntra();
137 Double_t zhit =(*recCgemHit)->getZhit();
138 Double_t fltLen =(*recCgemHit)->getFltLen();
139
140 TRecCgemHit *recCgemHitRoot = new TRecCgemHit();
141 //m_common.m_recCgemHitMap[(*recCgemHit)] = recCgemHitRoot;
142
143 recCgemHitRoot->setIsGrouped( isGrouped );
144 recCgemHitRoot->setId( id );
145 recCgemHitRoot->setTrkId( trackId );
146 recCgemHitRoot->setChisqAdd( chisqAdd );
147 recCgemHitRoot->setStat( stat );
148// recCgemHitRoot->setCgemIdMSB( cgemIdMSB );
149// recCgemHitRoot->setCgemIdLSB( cgemIdLSB );
150 recCgemHitRoot->setCgemId( cgemId );
151 recCgemHitRoot->setTdc( tdc );
152 recCgemHitRoot->setAdc( adc );
153 recCgemHitRoot->setDoca( doca );
154 recCgemHitRoot->setEntra( entra );
155 recCgemHitRoot->setZhit( zhit );
156 recCgemHitRoot->setFltLen( fltLen );
157
158 recEvt->addRecCgemHit(recCgemHitRoot);
159 }
160 return StatusCode::SUCCESS;
161}
162#endif
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
bool isGrouped(void)
Definition: RecCgemHit.cxx:41
static TRecTrackEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition of a Root address, derived from IOpaqueAddress.
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)
Convert the transient object to the requested representation.
const TObjArray * getRecCgemHitCol() const
retrieve the whole TObjArray of RecCgemHit Data
void addRecCgemHit(TRecCgemHit *Hit)
Add a Rec Cgem Hit into the Cgem data collection.
void clearRecCgemHitCol()
clear the whole array (necessary because of the consts-s)
static std::map< const TObject *, const RecCgemHit * > m_rootRecCgemHitMap