CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtRecDTagCnv Class Reference

#include <EvtRecDTagCnv.h>

+ Inheritance diagram for EvtRecDTagCnv:

Public Member Functions

virtual ~EvtRecDTagCnv ()
 
- Public Member Functions inherited from RootEventBaseCnv
 RootEventBaseCnv (const CLID &clid, ISvcLocator *svc)
 
virtual ~RootEventBaseCnv ()
 
virtual long repSvcType () const
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
void declareObject (const std::string &fullPath, const CLID &clid, const std::string &treename, const std::string &branchname)
 Store TDS path to link a particular converter to an object on the TDS.
 
virtual StatusCode createObj (IOpaqueAddress *addr, DataObject *&dat)
 Convert the persistent object to transient.
 
virtual StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress)
 Convert the transient object to the requested representation.
 
virtual StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Resolve the references of the converted object.
 
virtual StatusCode fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Resolve the references of the converted object.
 
virtual StatusCode DataObjectToTObject (DataObject *dat, RootAddress *addr)=0
 Do the concrete conversion from TDS to ROOT.
 
virtual StatusCode TObjectToDataObject (DataObject *&dat)=0
 Do the concrete conversion from ROOT to TDS.
 
TObject * getReadObject () const
 get the object to be read
 
- Public Member Functions inherited from Converter< Ty1, Ty2 >
destinationoperator (const source &) const
 

Static Public Member Functions

static const CLID & classID ()
 
- Static Public Member Functions inherited from RootEventBaseCnv
static const unsigned char storageType ()
 Storage type and class ID.
 

Protected Member Functions

 EvtRecDTagCnv (ISvcLocator *svc)
 
virtual StatusCode DataObjectToTObject (DataObject *obj, RootAddress *addr)
 transformation to root
 
virtual StatusCode TObjectToDataObject (DataObject *&obj)
 transformation from root
 
- Protected Member Functions inherited from Converter< Ty1, Ty2 >
virtual destinationconvert (const source &) const =0
 

Friends

class CnvFactory< EvtRecDTagCnv >
 

Additional Inherited Members

- Public Types inherited from Converter< Ty1, Ty2 >
typedef Ty1 source
 
typedef Ty2 destination
 
- Protected Attributes inherited from RootEventBaseCnv
RootCnvSvcm_cnvSvc
 
std::vector< RootCnvSvc::Leafm_leaves
 
RootInterfacem_rootInterface
 pointer to the RootInterface
 
IDataProviderSvc * m_eds
 pointer to eventdataservice
 
int m_branchNr
 the branchNr of this converter for writing
 
int m_branchNrDst
 
int m_branchNrMc
 
int m_branchNrRecon
 
int m_branchNrEvtRec
 
int m_branchNrEvtHeader
 
int m_branchNrEvtNavigator
 
TObject * m_objRead
 the object that was read
 
CLID CLID_top
 the CLID of the upper converter if any
 
TArrayS * m_branchNumbers
 array with number of branches for reading
 
std::string m_rootBranchname
 root branchname (may be concatenated of severals)
 
std::string m_rootTreename
 each converter knows it's treename
 
std::string m_currentFileName
 
std::vector< void * > m_adresses
 each converter knows the corresponding adresses
 
RootEvtSelectorm_evtsel
 

Detailed Description

Definition at line 14 of file EvtRecDTagCnv.h.

Constructor & Destructor Documentation

◆ ~EvtRecDTagCnv()

virtual EvtRecDTagCnv::~EvtRecDTagCnv ( )
inlinevirtual

Definition at line 21 of file EvtRecDTagCnv.h.

21{}

◆ EvtRecDTagCnv()

EvtRecDTagCnv::EvtRecDTagCnv ( ISvcLocator *  svc)
protected

Definition at line 24 of file EvtRecDTagCnv.cxx.

26{
27 m_rootBranchname = "m_evtRecDTagCol";
28 m_adresses.push_back(&m_evtRecDTagCol);
29 m_evtRecDTagCol = 0;
30}
static const CLID & classID()
Definition: EvtRecDTagCnv.h:19
Base class for all Root Converters.
std::vector< void * > m_adresses
each converter knows the corresponding adresses
std::string m_rootBranchname
root branchname (may be concatenated of severals)

Member Function Documentation

◆ classID()

static const CLID & EvtRecDTagCnv::classID ( )
inlinestatic

Definition at line 19 of file EvtRecDTagCnv.h.

19{ return CLID_EvtRecDTagCol; }
const CLID & CLID_EvtRecDTagCol
Definition: EventModel.cxx:453

◆ DataObjectToTObject()

StatusCode EvtRecDTagCnv::DataObjectToTObject ( DataObject *  obj,
RootAddress addr 
)
protectedvirtual

transformation to root

Implements RootEventBaseCnv.

Definition at line 127 of file EvtRecDTagCnv.cxx.

127 {
128 MsgStream log(msgSvc(), "EvtRecDTagCnv");
129 log << MSG::DEBUG << "EvtRecDTagCnv::DataObjectToTObject" << endreq;
130
131 EvtRecDTagCol* evtRecDTagCol = dynamic_cast<EvtRecDTagCol*> (obj);
132 if ( ! evtRecDTagCol ) {
133 log << MSG::ERROR << "Could not downcast to EvtRecDTagCol" << endreq;
134 return StatusCode::FAILURE;
135 }
136
137 DataObject* evt;
138 m_eds->findObject(EventModel::EvtRec::Event, evt);
139 if ( evt == NULL ) {
140 log << MSG::ERROR << "Could not get EvtRecObject in TDS" << endreq;
141 return StatusCode::FAILURE;
142 }
143 EvtRecObject* devtTds = dynamic_cast<EvtRecObject*> (evt);
144 if ( ! devtTds ) {
145 log << MSG::ERROR << "EvtRecDTagCnv: Could not downcast to TDS EvtRecObject" << endreq;
146 }
147
148 IOpaqueAddress *addr;
149 m_cnvSvc->getEvtRecCnv()->createRep(evt, addr);
151
152 const TObjArray* m_evtRecDTagCol = recEvt->getEvtRecDTagCol();
153 if ( ! m_evtRecDTagCol ) return StatusCode::SUCCESS;
154
155 IDataProviderSvc* dataSvc = 0;
156 StatusCode sc = serviceLocator()->getService("EventDataSvc",
157 IDataProviderSvc::interfaceID(), (IInterface*&)dataSvc);
158 if ( sc.isFailure() ) {
159 log << MSG::FATAL << "Could not get EventDataSvc in EvtRecDTagCnv" << endreq;
160 return sc;
161 }
162
163 EvtRecTrackCol::iterator evtRecTrackColbegin, evtRecTrackColend;
164
165 SmartDataPtr<EvtRecTrackCol> evtRecTrackCol(dataSvc, EventModel::EvtRec::EvtRecTrackCol);
166 if ( ! evtRecTrackCol) {
167 log << MSG::INFO << "Could not find EvtRecTrackCol" << endreq;
168 }
169 else {
170 evtRecTrackColbegin = evtRecTrackCol->begin();
171 evtRecTrackColend = evtRecTrackCol->end();
172 }
173
174 // convert
175 recEvt->clearEvtRecDTagCol();
176 EvtRecDTagCol::const_iterator evtRecDTag = evtRecDTagCol->begin();
177
178 for ( ; evtRecDTag != evtRecDTagCol->end(); evtRecDTag++) {
179 EvtRecDTag* ptr = *evtRecDTag;
180 TEvtRecDTag* evtRecDTagRoot = new TEvtRecDTag();
181
182 // set ...
183 evtRecDTagRoot->setdecayMode( ptr->decayMode() );
184 evtRecDTagRoot->settype( ptr->type() );
185 evtRecDTagRoot->setbeamE( ptr->beamE() );
186 evtRecDTagRoot->setmass( ptr->mass() );
187 evtRecDTagRoot->setmBC( ptr->mBC() );
188 evtRecDTagRoot->setdeltaE( ptr->deltaE() );
189 evtRecDTagRoot->setcharge( ptr->charge() );
190 evtRecDTagRoot->setcharm( ptr->charm() );
191 evtRecDTagRoot->setnumOfChildren( ptr->numOfChildren() );
192
193 HepLorentzVector p4=ptr->p4();
194 evtRecDTagRoot->setpx(p4.x());
195 evtRecDTagRoot->setpy(p4.y());
196 evtRecDTagRoot->setpz(p4.z());
197 evtRecDTagRoot->setpe(p4.t());
198
199
200
201 SmartRefVector<EvtRecTrack> tracks=ptr->tracks();
202 // assert(evtRecTrackColbegin != evtRecTrackColend);
203 for(unsigned int i=0; i<tracks.size();i++){
204 EvtRecTrackCol::iterator it = find(evtRecTrackColbegin,
205 evtRecTrackColend, tracks[i]);
206 //assert(it != evtRecTrackColend);
207 evtRecDTagRoot->addTrack(it - evtRecTrackColbegin );
208 }
209
210
211 SmartRefVector<EvtRecTrack> showers=ptr->showers();
212 // assert(evtRecTrackColbegin != evtRecTrackColend);
213 for(unsigned int i=0; i<showers.size();i++){
214 EvtRecTrackCol::iterator it = find(evtRecTrackColbegin,
215 evtRecTrackColend, showers[i]);
216 //assert(it != evtRecTrackColend);
217 evtRecDTagRoot->addShower(it - evtRecTrackColbegin );
218 }
219
220
221 SmartRefVector<EvtRecTrack> otherTracks=ptr->otherTracks();
222 // assert(evtRecTrackColbegin != evtRecTrackColend);
223 for(unsigned int i=0; i<otherTracks.size();i++){
224 EvtRecTrackCol::iterator it = find(evtRecTrackColbegin,
225 evtRecTrackColend, otherTracks[i]);
226 //assert(it != evtRecTrackColend);
227 evtRecDTagRoot->addOtherTrack(it - evtRecTrackColbegin );
228 }
229
230 SmartRefVector<EvtRecTrack> otherShowers=ptr->otherShowers();
231 // assert(evtRecTrackColbegin != evtRecTrackColend);
232 for(unsigned int i=0; i<otherShowers.size();i++){
233 EvtRecTrackCol::iterator it = find(evtRecTrackColbegin,
234 evtRecTrackColend, otherShowers[i]);
235 //assert(it != evtRecTrackColend);
236 evtRecDTagRoot->addOtherShower(it - evtRecTrackColbegin );
237 }
238
239 SmartRefVector<EvtRecTrack> pionId=ptr->pionId();
240 // assert(evtRecTrackColbegin != evtRecTrackColend);
241 for(unsigned int i=0; i<pionId.size();i++){
242 EvtRecTrackCol::iterator it = find(evtRecTrackColbegin,
243 evtRecTrackColend, pionId[i]);
244 //assert(it != evtRecTrackColend);
245 evtRecDTagRoot->addPionId(it - evtRecTrackColbegin );
246 }
247
248 SmartRefVector<EvtRecTrack> kaonId=ptr->kaonId();
249 // assert(evtRecTrackColbegin != evtRecTrackColend);
250 for(unsigned int i=0; i<kaonId.size();i++){
251 EvtRecTrackCol::iterator it = find(evtRecTrackColbegin,
252 evtRecTrackColend, kaonId[i]);
253 //assert(it != evtRecTrackColend);
254 evtRecDTagRoot->addKaonId(it - evtRecTrackColbegin );
255 }
256
257
258 recEvt->addEvtRecDTag(evtRecDTagRoot);
259 }
260
261 return StatusCode::SUCCESS;
262}
ObjectVector< EvtRecDTag > EvtRecDTagCol
Definition: EvtRecDTag.h:234
IMessageSvc * msgSvc()
static TEvtRecObject * getWriteObject()
Definition: EvtRecCnv.h:26
SmartRefVector< EvtRecTrack > tracks()
Definition: EvtRecDTag.h:164
SmartRefVector< EvtRecTrack > showers()
Definition: EvtRecDTag.h:165
double mass() const
Definition: EvtRecDTag.h:155
SmartRefVector< EvtRecTrack > otherShowers()
Definition: EvtRecDTag.h:167
SmartRefVector< EvtRecTrack > kaonId()
Definition: EvtRecDTag.h:169
HepLorentzVector p4() const
Definition: EvtRecDTag.h:161
SmartRefVector< EvtRecTrack > otherTracks()
Definition: EvtRecDTag.h:166
SmartRefVector< EvtRecTrack > pionId()
Definition: EvtRecDTag.h:168
int numOfChildren() const
Definition: EvtRecDTag.h:160
double beamE() const
Definition: EvtRecDTag.h:154
SelType type() const
Definition: EvtRecDTag.h:153
int charge() const
Definition: EvtRecDTag.h:158
double deltaE() const
Definition: EvtRecDTag.h:157
int charm() const
Definition: EvtRecDTag.h:159
DecayMode decayMode() const
Definition: EvtRecDTag.h:152
double mBC() const
Definition: EvtRecDTag.h:156
EvtRecCnv * getEvtRecCnv()
Definition: RootCnvSvc.h:152
RootCnvSvc * m_cnvSvc
IDataProviderSvc * m_eds
pointer to eventdataservice
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)
Convert the transient object to the requested representation.
void setpz(Double_t pz)
Definition: TEvtRecDTag.h:47
void setpx(Double_t px)
Definition: TEvtRecDTag.h:45
void setpy(Double_t py)
Definition: TEvtRecDTag.h:46
void setnumOfChildren(Int_t numOfChildren)
Definition: TEvtRecDTag.h:44
void addTrack(Int_t track)
Definition: TEvtRecDTag.h:58
void setbeamE(Double_t beamE)
Definition: TEvtRecDTag.h:38
void addOtherTrack(Int_t track)
Definition: TEvtRecDTag.h:60
void addOtherShower(Int_t shower)
Definition: TEvtRecDTag.h:61
void setpe(Double_t pe)
Definition: TEvtRecDTag.h:48
void setmass(Double_t mass)
Definition: TEvtRecDTag.h:39
void addPionId(Int_t pionId)
Definition: TEvtRecDTag.h:62
void setcharge(Int_t charge)
Definition: TEvtRecDTag.h:42
void addShower(Int_t shower)
Definition: TEvtRecDTag.h:59
void setdeltaE(Double_t deltaE)
Definition: TEvtRecDTag.h:41
void setcharm(Int_t charm)
Definition: TEvtRecDTag.h:43
void addKaonId(Int_t kaonId)
Definition: TEvtRecDTag.h:63
void settype(Int_t type)
Definition: TEvtRecDTag.h:37
void setmBC(Double_t mBC)
Definition: TEvtRecDTag.h:40
void setdecayMode(Int_t decayMode)
Definition: TEvtRecDTag.h:36
void clearEvtRecDTagCol()
Definition: TEvtRecObject.h:69
const TObjArray * getEvtRecDTagCol() const
Definition: TEvtRecObject.h:66
void addEvtRecDTag(TEvtRecDTag *dtag)
_EXTERN_ std::string Event
Definition: EventModel.h:133
_EXTERN_ std::string EvtRecTrackCol
Definition: EventModel.h:135

◆ TObjectToDataObject()

StatusCode EvtRecDTagCnv::TObjectToDataObject ( DataObject *&  obj)
protectedvirtual

transformation from root

Implements RootEventBaseCnv.

Definition at line 32 of file EvtRecDTagCnv.cxx.

32 {
33 // creation of TDS object from root object
34 MsgStream log(msgSvc(), "EvtRecDTagCnv");
35 log << MSG::DEBUG << "EvtRecDTagCnv::TObjectToDataObject" << endreq;
36
37 // create the TDS location for the EvtRecDTag Collection
38 EvtRecDTagCol* evtRecDTagCol = new EvtRecDTagCol;
39 refpObject = evtRecDTagCol;
40
41 if ( ! m_evtRecDTagCol ) return StatusCode::SUCCESS;
42
43 IDataProviderSvc* dataSvc = 0;
44 StatusCode sc = serviceLocator()->getService("EventDataSvc",
45 IDataProviderSvc::interfaceID(), (IInterface*&)dataSvc);
46 if ( sc.isFailure() ) {
47 log << MSG::FATAL << "Could not get EventDataSvc in EvtRecDTagCnv" << endreq;
48 return sc;
49 }
50
51 SmartDataPtr<EvtRecTrackCol> evtRecTrackCol(dataSvc, EventModel::EvtRec::EvtRecTrackCol);
52 if ( ! evtRecTrackCol) {
53 log << MSG::INFO << "Could not find EvtRecTrackCol" << endreq;
54 }
55
56 // convert
57 TIter evtRecDTagIter(m_evtRecDTagCol);
58 TEvtRecDTag* evtRecDTagRoot = 0;
59 while ( (evtRecDTagRoot = (TEvtRecDTag*)evtRecDTagIter.Next() ) ) {
60 EvtRecDTag* evtRecDTag = new EvtRecDTag();
61 m_common.m_rootEvtRecDTagMap[evtRecDTagRoot] = evtRecDTag;
62
63 // set ....
64 evtRecDTag->setdecayMode( (EvtRecDTag::DecayMode)evtRecDTagRoot->decayMode() );
65 evtRecDTag->settype( (EvtRecDTag::SelType)evtRecDTagRoot->type() );
66 evtRecDTag->setbeamE( evtRecDTagRoot->beamE() );
67 evtRecDTag->setmass( evtRecDTagRoot->mass() );
68 evtRecDTag->setmBC( evtRecDTagRoot->mBC() );
69 evtRecDTag->setdeltaE( evtRecDTagRoot->deltaE() );
70 evtRecDTag->setcharge( evtRecDTagRoot->charge() );
71 evtRecDTag->setcharm( evtRecDTagRoot->charm() );
72 evtRecDTag->setnumOfChildren( evtRecDTagRoot->numOfChildren() );
73
74 HepLorentzVector p4(evtRecDTagRoot->px(),evtRecDTagRoot->py(),evtRecDTagRoot->pz(),evtRecDTagRoot->pe());
75 evtRecDTag->setp4(p4);
76
77
78 const std::vector<int>& tracks=evtRecDTagRoot->tracks();
79 const std::vector<int>& showers=evtRecDTagRoot->showers();
80 const std::vector<int>& otherTracks=evtRecDTagRoot->otherTracks();
81 const std::vector<int>& otherShowers=evtRecDTagRoot->otherShowers();
82 const std::vector<int>& pionId=evtRecDTagRoot->pionId();
83 const std::vector<int>& kaonId=evtRecDTagRoot->kaonId();
84
85 for(unsigned int i=0; i<tracks.size();i++)
86 evtRecDTag->addTrack(
87 dynamic_cast<EvtRecTrack*>(evtRecTrackCol->containedObject(tracks[i]))
88 );
89
90 for(unsigned int i=0; i<showers.size();i++)
91 evtRecDTag->addShower(
92 dynamic_cast<EvtRecTrack*>(evtRecTrackCol->containedObject(showers[i]))
93 );
94
95
96 for(unsigned int i=0; i<otherTracks.size();i++)
97 evtRecDTag->addOtherTrack(
98 dynamic_cast<EvtRecTrack*>(evtRecTrackCol->containedObject(otherTracks[i]))
99 );
100
101
102 for(unsigned int i=0; i<otherShowers.size();i++)
103 evtRecDTag->addOtherShower(
104 dynamic_cast<EvtRecTrack*>(evtRecTrackCol->containedObject(otherShowers[i]))
105 );
106
107 for(unsigned int i=0; i<pionId.size();i++)
108 evtRecDTag->addPionId(
109 dynamic_cast<EvtRecTrack*>(evtRecTrackCol->containedObject(pionId[i]))
110 );
111
112 for(unsigned int i=0; i<kaonId.size();i++)
113 evtRecDTag->addKaonId(
114 dynamic_cast<EvtRecTrack*>(evtRecTrackCol->containedObject(kaonId[i]))
115 );
116
117
118
119 evtRecDTagCol->push_back(evtRecDTag);
120 }
121
122 delete m_evtRecDTagCol;
123 m_evtRecDTagCol = 0;
124 return StatusCode::SUCCESS;
125}
void addOtherTrack(const SmartRef< EvtRecTrack > track)
Definition: EvtRecDTag.h:187
void settype(SelType type)
Definition: EvtRecDTag.h:173
void setdecayMode(DecayMode decayMode)
Definition: EvtRecDTag.h:172
void setp4(HepLorentzVector p4)
Definition: EvtRecDTag.h:181
void setmass(double mass)
Definition: EvtRecDTag.h:175
void addOtherShower(const SmartRef< EvtRecTrack > shower)
Definition: EvtRecDTag.h:189
void addKaonId(const SmartRef< EvtRecTrack > kaonId)
Definition: EvtRecDTag.h:193
void setdeltaE(double deltaE)
Definition: EvtRecDTag.h:177
void setcharm(int charm)
Definition: EvtRecDTag.h:179
void setmBC(double mBC)
Definition: EvtRecDTag.h:176
void setcharge(int charge)
Definition: EvtRecDTag.h:178
void addPionId(const SmartRef< EvtRecTrack > pionId)
Definition: EvtRecDTag.h:191
void setbeamE(double beamE)
Definition: EvtRecDTag.h:174
void addShower(const SmartRef< EvtRecTrack > shower)
Definition: EvtRecDTag.h:185
void setnumOfChildren(int numOfChildren)
Definition: EvtRecDTag.h:180
void addTrack(const SmartRef< EvtRecTrack > track)
Definition: EvtRecDTag.h:183
Double_t pe() const
Definition: TEvtRecDTag.h:26
const std::vector< Int_t > & otherShowers() const
Definition: TEvtRecDTag.h:32
Int_t charm() const
Definition: TEvtRecDTag.h:21
Double_t py() const
Definition: TEvtRecDTag.h:24
Double_t px() const
Definition: TEvtRecDTag.h:23
Double_t mass() const
Definition: TEvtRecDTag.h:17
Int_t type() const
Definition: TEvtRecDTag.h:15
Double_t beamE() const
Definition: TEvtRecDTag.h:16
const std::vector< Int_t > & showers() const
Definition: TEvtRecDTag.h:30
Double_t deltaE() const
Definition: TEvtRecDTag.h:19
Int_t numOfChildren() const
Definition: TEvtRecDTag.h:22
const std::vector< Int_t > & otherTracks() const
Definition: TEvtRecDTag.h:31
Int_t decayMode() const
Definition: TEvtRecDTag.h:14
Double_t mBC() const
Definition: TEvtRecDTag.h:18
const std::vector< Int_t > & kaonId() const
Definition: TEvtRecDTag.h:34
Int_t charge() const
Definition: TEvtRecDTag.h:20
const std::vector< Int_t > & tracks() const
Definition: TEvtRecDTag.h:29
Double_t pz() const
Definition: TEvtRecDTag.h:25
const std::vector< Int_t > & pionId() const
Definition: TEvtRecDTag.h:33
static std::map< const TObject *, const EvtRecDTag * > m_rootEvtRecDTagMap
Definition: commonData.h:323

Friends And Related Function Documentation

◆ CnvFactory< EvtRecDTagCnv >

friend class CnvFactory< EvtRecDTagCnv >
friend

Definition at line 9 of file EvtRecDTagCnv.h.


The documentation for this class was generated from the following files: