BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TreeOffEvtFilterCnv.cxx
Go to the documentation of this file.
2#include "CalibData/Ets/OffEvtFilterCal.h"
3#include "CalibDataSvc/IInstrumentName.h"
4#include "CalibMySQLCnvSvc/TreeAddress.h"
5#include "GaudiKernel/MsgStream.h"
6#include "TBuffer.h"
7#include "TDirectory.h"
8#include "TFile.h"
9#include "TObject.h"
10#include "TTree.h"
11
12#include "GaudiKernel/DataObject.h"
13#include "GaudiKernel/GenericAddress.h"
14#include "GaudiKernel/IAddressCreator.h"
15#include "GaudiKernel/IConversionSvc.h"
16#include "GaudiKernel/IDataProviderSvc.h"
17#include "GaudiKernel/IOpaqueAddress.h"
18
19#include "CalibDataSvc/ICalibMetaCnvSvc.h"
20#include "CalibDataSvc/ICalibTreeSvc.h" //maybe
21using namespace std;
22// Temporary. Hope to find a better way to do this
23#include "CalibData/CalibModel.h"
24using namespace CalibData;
25
28
30
32
33StatusCode TreeOffEvtFilterCnv::i_createObj( IOpaqueAddress* addr, DataObject*& refpObject ) {
34
35 MsgStream log( msgSvc(), "TreeOffEvtFilterCnv" );
36 log << MSG::DEBUG << "SetProperty" << endmsg;
37 TreeAddress* add = dynamic_cast<TreeAddress*>( addr );
38 DatabaseRecord* records = add->pp();
39
40 TBufferFile* buf1 = new TBufferFile( TBuffer::kRead );
41 TBufferFile* buf2 = new TBufferFile( TBuffer::kRead );
42 buf1->SetBuffer( ( *records )["data"], 512000, kFALSE );
43 buf2->SetBuffer( ( *records )["oef"], 512000, kFALSE );
44
45 std::cout << " SftVer is " << ( *records )["SftVer"];
46 std::cout << " CalVerSft is " << ( *records )["CalParVer"];
47 std::cout << " File name is " << ( *records )["FileName"] << std::endl;
48
49 TTree* tree1 = new TTree();
50 tree1->Streamer( *buf1 );
51 TTree* tree2 = new TTree();
52 tree2->Streamer( *buf2 );
53
55 // Read in our object
56 int i, no;
57
58 // read Tree:data & oef ------------------------------------------------------------
59 int runFrom, runTo, eventFrom, eventTo;
60 tree1->SetBranchAddress( "runFrom", &runFrom );
61 tree1->SetBranchAddress( "runTo", &runTo );
62 tree1->SetBranchAddress( "eventFrom", &eventFrom );
63 tree1->SetBranchAddress( "eventTo", &eventTo );
64 tree1->GetEntry( 0 );
65 tmpObject->setRunFrom( runFrom );
66 tmpObject->setRunTo( runTo );
67 tmpObject->setEventFrom( eventFrom );
68 tmpObject->setEventTo( eventTo );
69 cout << "runFrom in OffEvtFilter is:" << runFrom << endl;
70 cout << "runTo in OffEvtFilter is:" << runTo << endl;
71 cout << "EventFrom in OffEvtFilter is:" << eventFrom << endl;
72 cout << "eventTo in OffEvtFilter is:" << eventTo << endl;
73
74 int flag;
75 double tBegin, tEnd;
76 tree2->SetBranchAddress( "tbegin", &tBegin );
77 tree2->SetBranchAddress( "tend", &tEnd );
78 tree2->SetBranchAddress( "flag", &flag );
79 no = tree2->GetEntries();
80 tmpObject->setNpar( no );
81 for ( i = 0; i < no; i++ )
82 {
83 tree2->GetEntry( i );
84 tmpObject->setFlag( flag );
85 tmpObject->setTBegin( tBegin );
86 tmpObject->setTEnd( tEnd );
87 cout << "OffEvtFilter:i:flag:tBegin:tEnd==" << i << ":" << flag << ":" << tBegin << ":"
88 << tEnd << endl;
89 }
90
91 refpObject = tmpObject;
92
93 delete tree1;
94 delete tree2;
95 return StatusCode::SUCCESS;
96}
IMessageSvc * msgSvc()
void setTEnd(const double tEnd)
void setTBegin(const double tBegin)
void setFlag(const int flag)
TreeCalBaseCnv(ISvcLocator *svc, const CLID &clid)
virtual StatusCode i_createObj(IOpaqueAddress *address, DataObject *&refpObject)
const CLID & objType() const
static const CLID & classID()
TreeOffEvtFilterCnv(ISvcLocator *svc)