BOSS 7.0.2
BESIII Offline Software System
Loading...
Searching...
No Matches
TreeDedxSimDataCnv.cxx
Go to the documentation of this file.
1#include "GaudiKernel/MsgStream.h"
3#include "CalibData/Dedx/DedxSimData.h"
4#include "CalibDataSvc/IInstrumentName.h"
5#include "CalibMySQLCnv/TreeAddress.h"
6#include "TFile.h"
7#include "TTree.h"
8#include "TDirectory.h"
9#include "TObject.h"
10#include "TBuffer.h"
11#include "TBufferFile.h"
12#include "TROOT.h"
13
14#include "GaudiKernel/CnvFactory.h"
15#include "GaudiKernel/IOpaqueAddress.h"
16#include "GaudiKernel/DataObject.h"
17#include "GaudiKernel/IAddressCreator.h"
18#include "GaudiKernel/IDataProviderSvc.h"
19#include "GaudiKernel/IConversionSvc.h"
20#include "GaudiKernel/GenericAddress.h"
21
22#include "CalibDataSvc/ICalibTreeSvc.h" //maybe
23#include "CalibDataSvc/ICalibMetaCnvSvc.h"
24
25// Temporary. Hope to find a better way to do this
26#include "CalibData/CalibModel.h"
27using namespace CalibData;
28//static CnvFactory<TreeDedxSimDataCnv> DedxCal_factory;
29//const ICnvFactory& TreeDedxSimDataCnvFactory = DedxCal_factory;
30
31
32
35
36 }
37
38
39const CLID& TreeDedxSimDataCnv::objType() const {
40 return CLID_Dedx_Sim;
41}
42
44 return CLID_Dedx_Sim;
45}
46
47StatusCode TreeDedxSimDataCnv::i_createObj(IOpaqueAddress* addr,
48 DataObject*& refpObject) {
49
50 MsgStream log(msgSvc(), "TreeDedxSimDataCnv");
51
53 TreeAddress* add = dynamic_cast<TreeAddress*>(addr);
54 DatabaseRecord *records=add->pp();
55
56 TBufferFile *buf1 = new TBufferFile(TBuffer::kRead);
57 TBufferFile *buf2 = new TBufferFile(TBuffer::kRead);
58
59 buf1->SetBuffer((*records)["TH1F_Col"],51200000,kFALSE);
60 buf2->SetBuffer((*records)["bin"],512000,kFALSE);
61
62 std::cout<<" SftVer is "<<(*records)["SftVer"];
63 std::cout<<" CalVerSft is "<<(*records)["CalParVer"];
64 std::cout<<" File name is "<<(*records)["FileName"]<<std::endl;
65
66
67 //TClass *myclass=gROOT->GetClass("TTree");
68 //TTree *tree =(TTree*)buf1->ReadObject(myclass);
69 TTree* tree = new TTree();
70 tree->Streamer(*buf1);
71
72 TTree* bin = new TTree();
73 bin->Streamer(*buf2);
74
75 TH1F *h1=new TH1F();
76
77 std::vector<TH1F> hist;
78 std::vector<double> hRange;
79 // Read in the object
80 int cnt;
81 tree -> SetBranchAddress("TH1F_Col", &h1);
82 int entries=tree->GetEntries();
83 for(cnt=0; cnt<entries; cnt++){
84 tree -> GetEntry(cnt);
85 gROOT->cd();
86 TH1F *h2=new TH1F();
87 h2=(TH1F*)h1->Clone();
88 hist.push_back(*h2);
89 }
90 int ver;
91 double betagamma[5000];
92 int totalNum;
93 int bgNum;
94 int thetaNum;
95 if (bin->FindBranch("version")) bin->SetBranchAddress("version", &ver);
96 else ver = 0;
97 if (bin->FindBranch("thetaNum")) bin->SetBranchAddress("thetaNum", &thetaNum);
98 else thetaNum = 16;
99 bin-> SetBranchAddress("totalNum", &totalNum);
100 bin-> SetBranchAddress("betagamma", betagamma);
101 bin-> SetBranchAddress("betagammaBounds", &bgNum);
102 bin->GetEntry(0);
103 //int tot=totalNum*2;
104 for(cnt=0; cnt<bgNum; cnt++){
105 hRange.push_back(betagamma[cnt]);
106 }
107 tmpObject->setVersion(ver);
108 tmpObject->setRangeNo(bgNum);
109 tmpObject->setRange(&hRange);
110 tmpObject->setHistNo(totalNum);
111 tmpObject->setThetaNo(thetaNum);
112 tmpObject->setHist(&hist);
113 refpObject=tmpObject;
114
115 delete tree;
116 delete bin;
117
118 return StatusCode::SUCCESS;
119
120
121}
data SetBranchAddress("time",&time)
data GetEntry(0)
*******INTEGER m_nBinMax INTEGER m_NdiMax !No of bins in histogram for cell exploration division $ !Last vertex $ !Last active cell $ !Last cell in buffer $ !No of sampling when dividing cell $ !No of function total $ !Flag for random ceel for $ !Flag for type of for WtMax $ !Flag which decides whether vertices are included in the sampling $ entire domain is hyp !Maximum effective eevents per bin
Definition: FoamA.h:85
void setRange(const vector< double > *hRange)
Definition: DedxSimData.cxx:43
void setHist(const vector< TH1F > *hist)
Definition: DedxSimData.cxx:38
TreeDedxSimDataCnv(ISvcLocator *svc)
virtual StatusCode i_createObj(IOpaqueAddress *address, DataObject *&refpObject)
const CLID & objType() const
static const CLID & classID()