BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TrigDataCnv.cxx
Go to the documentation of this file.
1#ifndef TrigDataCnv_CXX
2#define TrigDataCnv_CXX 1
3
4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/DataObject.h"
6
7#include "TClonesArray.h"
8
10#include "TrigEvent/TrigEvent.h" //TDS object
11#include "TrigEvent/TrigData.h" //TDS object
12#include "RootEventData/TTrigData.h" // standard root object
17
18
19// Instantiation of a static factory class used by clients to create
20// instances of this service
21
22TrigDataCnv::TrigDataCnv(ISvcLocator* svc)
23: RootEventBaseCnv(classID(), svc)
24{
25 // Here we associate this converter with the /Event path on the TDS.
26 MsgStream log(msgSvc(), "TrigDataCnv");
27 //log << MSG::DEBUG << "Constructor called for " << objType() << endreq;
28 m_rootBranchname ="m_trigData";
29 //declareObject(EventModel::MC::TrigDataCol, objType(), m_rootTreename, m_rootBranchname);
30 m_adresses.push_back(&m_trigData);
31 m_trigData=0;
32}
33
34StatusCode TrigDataCnv::TObjectToDataObject(DataObject*& refpObject) {
35 // creation of TDS object from root object
36
37 MsgStream log(msgSvc(), "TrigDataCnv");
38 log << MSG::DEBUG << "TrigDataCnv::TObjectToDataObject" << endreq;
39 StatusCode sc=StatusCode::SUCCESS;
40
41 // create the TDS location for the trigger data
42 TrigData* trigDataTds = new TrigData;
43 refpObject=trigDataTds;
44
45
46 // now convert
47 if(!m_trigData) return sc;
48
49 const int* trigCond = m_trigData->getTrigCondition();
50 const int* trigChan = m_trigData->getTrigChannel();
51 int timewindow = m_trigData->getTimeWindow();
52 int timing = m_trigData->getTimingType();
53 bool prescale = m_trigData->getPreScale();
54
55 trigDataTds->setTrigCondition(trigCond);
56 trigDataTds->setTrigChannel(trigChan);
57 trigDataTds->setTimeWindow(timewindow);
58 trigDataTds->setTimingType(timing);
59 trigDataTds->setPreScale(prescale);
60
61 delete m_trigData;
62 m_trigData = 0;
63
64 return StatusCode::SUCCESS;
65}
66
67StatusCode TrigDataCnv::DataObjectToTObject(DataObject* obj,RootAddress* rootaddr) {
68
69 MsgStream log(msgSvc(), "TrigDataCnv");
70 log << MSG::DEBUG << "TrigDataCnv::DataObjectToTObject" << endreq;
71 StatusCode sc=StatusCode::SUCCESS;
72
73 TrigData * trigDataCnvTds=dynamic_cast<TrigData*> (obj);
74 if (!trigDataCnvTds) {
75 log << MSG::ERROR << "Could not downcast to TrigData" << endreq;
76 return StatusCode::FAILURE;
77 }
78
79 DataObject *evt;
80 m_eds->findObject(EventModel::Trig::Event,evt);
81 if (evt==NULL) {
82 log << MSG::ERROR << "Could not get TrigEvent in TDS " << endreq;
83 return StatusCode::FAILURE;
84 }
85
86 TrigEvent * devtTds=dynamic_cast<TrigEvent *> (evt);
87 if (!devtTds) {
88 log << MSG::ERROR << "TrigDataCnv:Could not downcast to TDS TrigEvent" << endreq;
89 }
90
91 IOpaqueAddress *addr;
92 m_cnvSvc->getTrigCnv()->createRep(evt,addr);
93
95
96 const TObject *ttrigData = TrigEvt->getTrigData();
97 if (!ttrigData) return sc;
98
99 const int* trigCond = trigDataCnvTds->getTrigCondition();
100 const int* trigChan = trigDataCnvTds->getTrigChannel();
101 int timewindow = trigDataCnvTds->getTimeWindow();
102 int timing = trigDataCnvTds->getTimingType();
103 bool prescale = trigDataCnvTds->getPreScale();
104
105 TTrigData *trigDataRoot = new TTrigData();
106
107 trigDataRoot->setTrigCondition(trigCond);
108 trigDataRoot->setTrigChannel(trigChan);
109 trigDataRoot->setTimeWindow(timewindow);
110 trigDataRoot->setTimingType(timing);
111 trigDataRoot->setPreScale(prescale);
112
113 TrigEvt->addTrigData(trigDataRoot);
114
115 return StatusCode::SUCCESS;
116}
117#endif
IMessageSvc * msgSvc()
#define NULL
Definition of a Root address, derived from IOpaqueAddress.
Definition: RootAddress.h:21
TrigCnv * getTrigCnv()
Definition: RootCnvSvc.h:157
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.
int getTimingType() const
Definition: TTrigData.h:34
int getTimeWindow() const
Definition: TTrigData.h:33
bool getPreScale() const
Definition: TTrigData.h:35
void setTimeWindow(int i)
Definition: TTrigData.h:24
void setPreScale(bool i)
Definition: TTrigData.h:26
int getTrigCondition(int i) const
Definition: TTrigData.h:29
int getTrigChannel(int i) const
Definition: TTrigData.h:31
void setTrigCondition(int i, int j)
Definition: TTrigData.h:20
void setTrigChannel(int i, int j)
Definition: TTrigData.h:22
void setTimingType(int i)
Definition: TTrigData.h:25
const TTrigData * getTrigData() const
Definition: TTrigEvent.cxx:50
void addTrigData(TTrigData *trigData)
TrigData.
Definition: TTrigEvent.cxx:45
static TTrigEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition: TrigCnv.h:35
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
Definition: TrigDataCnv.cxx:67
TrigDataCnv(ISvcLocator *svc)
Definition: TrigDataCnv.cxx:22
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
Definition: TrigDataCnv.cxx:34
void setTimingType(int i)
Definition: TrigData.h:29
void setPreScale(bool i)
Definition: TrigData.h:30
const int getTimeWindow() const
Definition: TrigData.h:37
const int getTimingType() const
Definition: TrigData.h:38
const int getTrigCondition(int i) const
Definition: TrigData.h:33
void setTrigCondition(int i, int j)
Definition: TrigData.h:24
const int getTrigChannel(int i) const
Definition: TrigData.h:35
void setTimeWindow(int i)
Definition: TrigData.h:28
const bool getPreScale() const
Definition: TrigData.h:39
void setTrigChannel(int i, int j)
Definition: TrigData.h:26
_EXTERN_ std::string Event
Definition: EventModel.h:66