BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
RootOffEvtFilterCnv.cxx
Go to the documentation of this file.
2#include "CalibData/Ets/OffEvtFilterCal.h"
3#include "CalibDataSvc/IInstrumentName.h"
4#include "GaudiKernel/MsgStream.h"
5
6#include "TDirectory.h"
7#include "TFile.h"
8#include "TObject.h"
9#include "TTree.h"
10
11#include "GaudiKernel/DataObject.h"
12#include "GaudiKernel/GenericAddress.h"
13#include "GaudiKernel/IAddressCreator.h"
14#include "GaudiKernel/IConversionSvc.h"
15#include "GaudiKernel/IDataProviderSvc.h"
16#include "GaudiKernel/IOpaqueAddress.h"
17
18#include "CalibDataSvc/ICalibMetaCnvSvc.h"
19#include "CalibDataSvc/ICalibRootSvc.h" //maybe
20
21// Temporary. Hope to find a better way to do this
22#include "CalibData/CalibModel.h"
23using namespace CalibData;
24
27
29
31
32StatusCode RootOffEvtFilterCnv::i_createObj( const std::string& fname,
33 DataObject*& refpObject ) {
34
35 MsgStream log( msgSvc(), "RootOffEvtFilterCnv" );
36 log << MSG::DEBUG << "SetProperty " << fname << endmsg;
37
38 StatusCode sc = openRead( fname );
39 if ( !sc ) { log << MSG::ERROR << "unable to open files11" << endmsg; }
40
42 // Read in our object
43 int i;
44 int nentries;
45
46 // read TestCalibConst ------------------------------------------------------------
47
48 int no;
49 vector<double> TestCalibConst;
50 int runFrom, runTo, eventFrom, eventTo;
51 if ( m_inFile->Read( "data" ) )
52 {
53 TTree* tree = (TTree*)m_inFile->Get( "data" );
54 tree->SetBranchAddress( "runFrom", &runFrom );
55 tree->SetBranchAddress( "runTo", &runTo );
56 tree->SetBranchAddress( "eventFrom", &eventFrom );
57 tree->SetBranchAddress( "eventTo", &eventTo );
58
59 tree->GetEntry( 0 );
60 tmpObject->setRunFrom( runFrom );
61 tmpObject->setRunTo( runTo );
62 tmpObject->setEventFrom( eventFrom );
63 tmpObject->setEventTo( eventTo );
64 }
65
66 int flag;
67 double tBegin, tEnd;
68 TTree* tree2 = (TTree*)m_inFile->Get( "oef" );
69 tree2->SetBranchAddress( "flag", &flag );
70 tree2->SetBranchAddress( "tbegin", &tBegin );
71 tree2->SetBranchAddress( "tend", &tEnd );
72
73 no = tree2->GetEntries();
74 tmpObject->setNpar( no );
75 for ( i = 0; i < no; i++ )
76 {
77 tree2->GetEntry( i );
78 tmpObject->setFlag( flag );
79 tmpObject->setTBegin( tBegin );
80 tmpObject->setTEnd( tEnd );
81 }
82
83 refpObject = tmpObject;
84
85 return StatusCode::SUCCESS;
86}
87
88StatusCode RootOffEvtFilterCnv::createRoot( const std::string& fname,
89 CalibData::CalibBase1* pTDSObj ) {
90
91 MsgStream log( msgSvc(), "RootOffEvtFilterCnv" );
92
93 // Open the file, create the branch
94 StatusCode sc = openWrite( fname );
95 if ( !sc ) { log << MSG::ERROR << "unable to open files22" << endmsg; }
96 // write the Data in the TCDS to RootFile
97 /* CalibData::OffEvtFilter* tmpObject = dynamic_cast<CalibData::OffEvtFilter*>(pTDSObj);
98 int tmpNo;
99 double EsTimeCalibConst;
100 int i;
101
102 //TestCalibConst------------------------------------------------------------------
103 TTree *Testtree = new TTree("TestCalibConst", "TestCalibConst");
104 Testtree -> Branch("TestCalibConst", &EsTimeCalibConst, "EsTimeCalibConst/D");
105 tmpNo = tmpObject -> getTestCalibConstNo();
106 for(i=0; i<tmpNo; i++){
107 EsTimeCalibConst = tmpObject -> getTestCalibConst(i);
108 Testtree -> Fill();
109 }
110
111
112 Testtree -> Write();
113
114
115 delete Testtree;
116
117 closeWrite();*/
118 log << MSG::INFO << "successfully create RootFile" << endmsg;
119 return sc;
120}
Int_t nentries
IMessageSvc * msgSvc()
void setTEnd(const double tEnd)
void setTBegin(const double tBegin)
void setFlag(const int flag)
StatusCode openRead(const std::string &fname)
RootCalBaseCnv(ISvcLocator *svc, const CLID &clid)
virtual StatusCode openWrite(const std::string &fname)
virtual StatusCode createRoot(const std::string &fname, CalibData::CalibBase1 *pTDSObj)
RootOffEvtFilterCnv(ISvcLocator *svc)
const CLID & objType() const
static const CLID & classID()
virtual StatusCode i_createObj(const std::string &fname, DataObject *&refpObject)