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