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