BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
HltRawCnv.cxx
Go to the documentation of this file.
1#ifndef HltRawCnv_CXX
2#define HltRawCnv_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#include "HltEvent/HltEvent.h" //TDS object
12#include "HltEvent/HltRaw.h" //TDS object
13#include "RootEventData/THltRaw.h" // standard root object
14#include "RootEventData/THltEvent.h"
15#include "RootCnvSvc/Hlt/HltCnv.h"
16#include "RootCnvSvc/Hlt/HltRawCnv.h"
17#include "RootCnvSvc/RootAddress.h"
18
19
20// Instantiation of a static factory class used by clients to create
21// instances of this service
22//static CnvFactory<HltRawCnv> s_factory;
23//const ICnvFactory& HltRawCnvFactory = s_factory;
24
25HltRawCnv::HltRawCnv(ISvcLocator* svc)
26: RootEventBaseCnv(classID(), svc)
27{
28 // Here we associate this converter with the /Event path on the TDS.
29 MsgStream log(msgSvc(), "HltRawCnv");
30 //log << MSG::DEBUG << "Constructor called for " << objType() << endreq;
31 m_rootBranchname ="m_hltRawCol";
32 //declareObject(EventModel::Hlt::HltRawCol, objType(), m_rootTreename, m_rootBranchname);
33 m_adresses.push_back(&m_hltRawCol);
34 m_hltRawCol=0;
35
36}
37
38StatusCode HltRawCnv::TObjectToDataObject(DataObject*& refpObject) {
39 // creation of TDS object from root object
40
41 MsgStream log(msgSvc(), "HltRawCnv");
42 log << MSG::DEBUG << "HltRawCnv::TObjectToDataObject" << endreq;
43 StatusCode sc=StatusCode::SUCCESS;
44
45 // create the TDS location for the HltRaw Collection
46 HltRawCol* hltRawTdsCol = new HltRawCol;
47 refpObject=hltRawTdsCol;
48// sc = m_eds->registerObject(EventModel::Hlt::HltRawCol, hltRawTdsCol);
49// if (sc.isFailure()) {
50// log << "Failed to register HltRaw Collection" << endreq;
51// return StatusCode::FAILURE;
52// }
53
54
55 // now convert
56 if (!m_hltRawCol) return sc;
57 TIter hltRawIter(m_hltRawCol);
58 THltRaw *hltRawRoot = 0;
59 while ((hltRawRoot = (THltRaw*)hltRawIter.Next())) {
60 unsigned int id = hltRawRoot->getIntId();
61 unsigned int time = hltRawRoot->getTimeChannel();
62 unsigned int charge = hltRawRoot->getChargeChannel();
63
64 HltRaw *hltRawTds = new HltRaw(id);
65 m_common.m_rootHltRawMap[hltRawRoot] = hltRawTds;
66
67 hltRawTds->setTimeChannel(time);
68 hltRawTds->setChargeChannel(charge);
69
70 hltRawTdsCol->push_back(hltRawTds);
71 }
72 //m_hltRawCol->Delete(); // wensp add 2005/12/30
73 delete m_hltRawCol;
74 m_hltRawCol = 0;
75 return StatusCode::SUCCESS;
76}
77
78StatusCode HltRawCnv::DataObjectToTObject(DataObject* obj,RootAddress* rootaddr) {
79
80 MsgStream log(msgSvc(), "HltRawCnv");
81 log << MSG::DEBUG << "HltRawCnv::DataObjectToTObject" << endreq;
82 StatusCode sc=StatusCode::SUCCESS;
83
84 HltRawCol * hltRawColTds=dynamic_cast<HltRawCol *> (obj);
85 if (!hltRawColTds) {
86 log << MSG::ERROR << "Could not downcast to HltRawCol" << endreq;
87 return StatusCode::FAILURE;
88 }
89
90 DataObject *evt;
91 m_eds->findObject(EventModel::Hlt::Event,evt);
92 if (evt==NULL) {
93 log << MSG::ERROR << "Could not get HltEvent in TDS " << endreq;
94 return StatusCode::FAILURE;
95 }
96 HltEvent * devtTds=dynamic_cast<HltEvent *> (evt);
97 if (!devtTds) {
98 log << MSG::ERROR << "HltRawCnv:Could not downcast to TDS HltEvent" << endreq;
99 }
100
101 IOpaqueAddress *addr;
102
103
104 m_cnvSvc->getHltCnv()->createRep(evt,addr);
105
106 //createRep(evt,addr);
107
109
110 const TObjArray *m_hltRawCol = recEvt->getHltRawCol();
111 if (!m_hltRawCol) return sc;
112 recEvt->clearHltRawCol(); //necessary in case there is I/O at the same time since array is static
113 HltRawCol::const_iterator hltRawTds;
114
115 for (hltRawTds = hltRawColTds->begin(); hltRawTds != hltRawColTds->end(); hltRawTds++) {
116 UInt_t time = (*hltRawTds)->getTimeChannel();
117 UInt_t charge = (*hltRawTds)->getChargeChannel();
118 UInt_t id = (*hltRawTds)->getIntId();
119
120 THltRaw *hltRawRoot = new THltRaw();
121 //m_common.m_hltRawMap[(*hltRawTds)] = hltRawRoot;
122
123 hltRawRoot->initialize(id, time ,charge);
124 recEvt->addHltRaw(hltRawRoot);
125 }
126
127 return StatusCode::SUCCESS;
128}
129
130#endif
131
132
133
134
135
136
137
138
139
140
Double_t time
ObjectVector< HltRaw > HltRawCol
static THltEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
HltRawCnv(ISvcLocator *svc)
Definition: HltRawCnv.cxx:25
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
Definition: HltRawCnv.cxx:78
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
Definition: HltRawCnv.cxx:38
void setChargeChannel(const unsigned int chargeChannel)
Definition: RawData.cxx:30
void setTimeChannel(const unsigned int timeChannel)
Definition: RawData.cxx:25
Definition of a Root address, derived from IOpaqueAddress.
IDataProviderSvc * m_eds
pointer to eventdataservice
std::vector< void * > m_adresses
each converter knows the corresponding adresses
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 * getHltRawCol() const
Definition: THltEvent.cxx:73
void addHltRaw(THltRaw *hltRaw)
HltRaw.
Definition: THltEvent.cxx:65
void initialize(UInt_t id, UInt_t time=0, UInt_t charge=0)
Definition: TRawData.cxx:34
UInt_t getIntId() const
Definition: TRawData.cxx:50
UInt_t getChargeChannel() const
Definition: TRawData.cxx:60
UInt_t getTimeChannel() const
Definition: TRawData.cxx:55
static std::map< const TObject *, const HltRaw * > m_rootHltRawMap
float charge