BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
TreeDedxSimDataCnv.cxx
Go to the documentation of this file.
1#include "GaudiKernel/MsgStream.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
24
25// Temporary. Hope to find a better way to do this
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 double betagamma[5000];
91 int totalNum;
92 int bgNum;
93 bin-> SetBranchAddress("totalNum", &totalNum);
94 bin-> SetBranchAddress("betagamma", betagamma);
95 bin-> SetBranchAddress("betagammaBounds", &bgNum);
96 bin->GetEntry(0);
97 //int tot=totalNum*2;
98 for(cnt=0; cnt<bgNum; cnt++){
99 hRange.push_back(betagamma[cnt]);
100 }
101 tmpObject->setRangeNo(bgNum);
102 tmpObject->setRange(&hRange);
103 tmpObject->setHistNo(totalNum);
104 tmpObject->setHist(&hist);
105 refpObject=tmpObject;
106
107 delete tree;
108 delete bin;
109
110 return StatusCode::SUCCESS;
111
112
113}
const CLID CLID_Dedx_Sim
Definition: CalibModel.h:61
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
IMessageSvc * msgSvc()
void setHistNo(const int No)
Definition: DedxSimData.h:42
void setRange(const vector< double > *hRange)
Definition: DedxSimData.cxx:42
void setHist(const vector< TH1F > *hist)
Definition: DedxSimData.cxx:37
void setRangeNo(const int No)
Definition: DedxSimData.h:46
virtual DatabaseRecord * pp()
Definition: TreeAddress.h:130
TreeDedxSimDataCnv(ISvcLocator *svc)
virtual StatusCode i_createObj(IOpaqueAddress *address, DataObject *&refpObject)
const CLID & objType() const
static const CLID & classID()