BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
RootDedxSimDataCnv.cxx
Go to the documentation of this file.
1// $Header:
2// /bes/bes/BossCvs/Calibration/CalibSvc/CalibROOTCnv/src/cnv/RootDedxSimDataCnv.cxx,v 1.6
3// 2016/09/14 05:32:44 zhaog Exp $
5#include "CalibData/Dedx/DedxSimData.h"
6#include "CalibDataSvc/IInstrumentName.h"
7#include "GaudiKernel/MsgStream.h"
8
9#include "TDirectory.h"
10#include "TFile.h"
11#include "TObject.h"
12#include "TROOT.h"
13#include "TTree.h"
14
15#include "GaudiKernel/DataObject.h"
16#include "GaudiKernel/GenericAddress.h"
17#include "GaudiKernel/IAddressCreator.h"
18#include "GaudiKernel/IConversionSvc.h"
19#include "GaudiKernel/IDataProviderSvc.h"
20#include "GaudiKernel/IOpaqueAddress.h"
21
22#include "CalibDataSvc/ICalibMetaCnvSvc.h"
23#include "CalibDataSvc/ICalibRootSvc.h" //maybe
24// #include "CalibData/CalibTime.h"
25// #include "commonRootData/idents/CalXtalId.h"
26// #include "idents/CalXtalId.h"
27
28// Temporary. Hope to find a better way to do this
29#include "CalibData/CalibModel.h"
30using namespace CalibData;
31// static CnvFactory<RootDedxSimDataCnv> TofCalib_factory;
32// const ICnvFactory& RootDedxSimDataCnvFactory = TofCalib_factory;
33
36
37const CLID& RootDedxSimDataCnv::objType() const { return CLID_Dedx_Sim; }
38
40
41StatusCode RootDedxSimDataCnv::i_createObj( const std::string& fname,
42 DataObject*& refpObject ) {
43
44 MsgStream log( msgSvc(), "RootDedxSimDataCnv" );
45 log << MSG::DEBUG << "SetProperty" << endmsg;
46
48
49 TH1F* h1 = new TH1F();
50 // open the file
51 StatusCode sc = openRead( fname );
52 if ( !sc ) { log << MSG::ERROR << "unable to open files" << endmsg; }
53
54 std::vector<TH1F> hist;
55 std::vector<double> hRange;
56 // Read in the object
57 int cnt;
58 TTree* tree = (TTree*)m_inFile->Get( "TH1F_Col" );
59 tree->SetBranchAddress( "TH1F_Col", &h1 );
60 int entries = tree->GetEntries();
61 for ( cnt = 0; cnt < entries; cnt++ )
62 {
63 tree->GetEntry( cnt );
64 gROOT->cd();
65 TH1F* h2 = new TH1F();
66 h2 = (TH1F*)h1->Clone();
67 hist.push_back( *h2 );
68 }
69 // tmpObject->setHist(&hist);
70 int ver;
71 double betagamma[5000];
72 int totalNum;
73 int bgNum;
74 int thetaNum;
75 TTree* bin = (TTree*)m_inFile->Get( "bin" );
76 if ( bin->FindBranch( "version" ) ) bin->SetBranchAddress( "version", &ver );
77 else ver = 0;
78 if ( bin->FindBranch( "thetaNum" ) ) bin->SetBranchAddress( "thetaNum", &thetaNum );
79 else thetaNum = 16;
80 bin->SetBranchAddress( "totalNum", &totalNum );
81 bin->SetBranchAddress( "betagamma", betagamma );
82 bin->SetBranchAddress( "betagammaBounds", &bgNum );
83 bin->GetEntry( 0 );
84
85 // int tot=totalNum*2;
86 for ( cnt = 0; cnt < bgNum; cnt++ ) { hRange.push_back( betagamma[cnt] ); }
87
88 tmpObject->setVersion( ver );
89 tmpObject->setRangeNo( bgNum );
90 tmpObject->setRange( &hRange );
91 tmpObject->setThetaNo( thetaNum );
92 tmpObject->setHistNo( totalNum );
93 tmpObject->setHist( &hist );
94 refpObject = tmpObject;
95
96 return StatusCode::SUCCESS;
97}
98
99StatusCode RootDedxSimDataCnv::createRoot( const std::string& fname,
100 CalibData::CalibBase1* pTDSObj ) {
101 MsgStream log( msgSvc(), "RootDedxSimDataCnv" );
102
103 // Open the file, create the branch
104 StatusCode sc = openWrite( fname );
105 if ( !sc ) { log << MSG::ERROR << "unable to open files" << endmsg; }
106 // write the Data in the TCDS to RootFile
107 /* int i;
108 int j;
109 CalibData::TofCalibData* btof = dynamic_cast<CalibData::TofCalibData*>(pTDSObj);
110
111 // write btoftree----------------------------------------------------------------
112 double cnvP1[10];
113 double cnvP2[10];
114 double cnvW[4];
115 double cnvAtten[8];
116 double cnvQ;
117 double cnvSpeed[2];
118 TTree *btoftree = new TTree("BarTofPar", "BarTofPar");
119 btoftree -> Branch("Atten0",&cnvAtten[0], "Atten0/D");
120 btoftree -> Branch("Atten1",&cnvAtten[1], "Atten1/D");
121 btoftree -> Branch("Atten2",&cnvAtten[2], "Atten2/D");
122 btoftree -> Branch("Atten3",&cnvAtten[3], "Atten3/D");
123 btoftree -> Branch("Atten4",&cnvAtten[4], "Atten4/D");
124 btoftree -> Branch("Atten5",&cnvAtten[5], "Atten5/D");
125 btoftree -> Branch("Atten6",&cnvAtten[6], "Atten6/D");
126 btoftree -> Branch("Atten7",&cnvAtten[7], "Atten7/D");
127 btoftree -> Branch("Q0",&cnvQ, "Q0/D");
128 btoftree -> Branch("Speed0",&cnvSpeed[0], "Speed0/D");
129 btoftree -> Branch("Speed1",&cnvSpeed[1], "Speed1/D");
130 btoftree -> Branch("P0",&cnvP1[0], "P0/D");
131 btoftree -> Branch("P1",&cnvP1[1], "P1/D");
132 btoftree -> Branch("P2",&cnvP1[2], "P2/D");
133 btoftree -> Branch("P3",&cnvP1[3], "P3/D");
134 btoftree -> Branch("P4",&cnvP1[4], "P4/D");
135 btoftree -> Branch("P5",&cnvP1[5], "P5/D");
136 btoftree -> Branch("P6",&cnvP1[6], "P6/D");
137 btoftree -> Branch("P7",&cnvP1[7], "P7/D");
138 btoftree -> Branch("P8",&cnvP1[8], "P8/D");
139 btoftree -> Branch("P9",&cnvP1[9], "P9/D");
140 btoftree -> Branch("P10",&cnvP2[0], "P10/D");
141 btoftree -> Branch("P11",&cnvP2[1], "P11/D");
142 btoftree -> Branch("P12",&cnvP2[2], "P12/D");
143 btoftree -> Branch("P13",&cnvP2[3], "P13/D");
144 btoftree -> Branch("P14",&cnvP2[4], "P14/D");
145 btoftree -> Branch("P15",&cnvP2[5], "P15/D");
146 btoftree -> Branch("P16",&cnvP2[6], "P16/D");
147 btoftree -> Branch("P17",&cnvP2[7], "P17/D");
148 btoftree -> Branch("P18",&cnvP2[8], "P17/D");
149 btoftree -> Branch("P19",&cnvP2[9], "P17/D");
150 btoftree -> Branch("W0",&cnvW[0], "W0/D");
151 btoftree -> Branch("W1",&cnvW[1], "W1/D");
152 btoftree -> Branch("W2",&cnvW[2], "W2/D");
153 btoftree -> Branch("W3",&cnvW[3], "W3/D");
154
155 for(i=0; i<176; i++){
156 cnvAtten[0] = btof->getBTofAtten(i,0);
157 cnvAtten[1] = btof->getBTofAtten(i,1);
158 cnvAtten[2] = btof->getBTofAtten(i,2);
159 cnvQ = btof->getBTofQ(i);
160 cnvSpeed[0] = btof->getBTofSpeed(i,0);
161 cnvSpeed[1] = btof->getBTofSpeed(i,1);
162 for(j=0;j<10;j++){
163 cnvP1[j] = btof->getBTofPleft(i,j);
164 cnvP2[j] = btof->getBTofPright(i,j);
165 }
166 for(j=0;j<4;j++){
167 cnvW[j]=btof->getBTofW(i,j);
168 }
169 btoftree -> Fill();
170 }
171
172 //write etoftree----------------------------------------------------------------
173 double ecnvP[8];
174 double ecnvAtten[5];
175 double ecnvSpeed[3];
176 TTree *etoftree = new TTree("EndTofPar", "EndTofPar");
177 etoftree -> Branch("Atten0",&ecnvAtten[0], "Atten0/D");
178 etoftree -> Branch("Atten1",&ecnvAtten[1], "Atten1/D");
179 etoftree -> Branch("Atten2",&ecnvAtten[2], "Atten2/D");
180 etoftree -> Branch("Atten3",&ecnvAtten[3], "Atten3/D");
181 etoftree -> Branch("Atten4",&ecnvAtten[4], "Atten4/D");
182 etoftree -> Branch("Speed0",&ecnvSpeed[0], "Speed0/D");
183 etoftree -> Branch("Speed1",&ecnvSpeed[1], "Speed1/D");
184 etoftree -> Branch("P0",&ecnvP[0], "P0/D");
185 etoftree -> Branch("P1",&ecnvP[1], "P1/D");
186 etoftree -> Branch("P2",&ecnvP[2], "P2/D");
187 etoftree -> Branch("P3",&ecnvP[3], "P3/D");
188 etoftree -> Branch("P4",&ecnvP[4], "P4/D");
189 etoftree -> Branch("P5",&ecnvP[5], "P5/D");
190 etoftree -> Branch("P6",&ecnvP[6], "P6/D");
191 etoftree -> Branch("P7",&ecnvP[7], "P7/D");
192
193 for(i=0; i<96; i++){
194 ecnvAtten[0] = btof->getETofAtten(i,0);
195 ecnvAtten[1] = btof->getETofAtten(i,1);
196 ecnvAtten[2] = btof->getETofAtten(i,2);
197 ecnvSpeed[0] = btof->getETofSpeed(i,0);
198 ecnvSpeed[1] = btof->getETofSpeed(i,1);
199 for(j=0;j<8;j++){
200 ecnvP[j] = btof->getETofP(i,j);
201 }
202 etoftree -> Fill();
203 }
204 // write all the trees
205 btoftree -> Write();
206 etoftree -> Write();
207 delete btoftree;
208 delete etoftree;
209 closeWrite();
210 log<<MSG::INFO<<"successfully create RootFile"<<endmsg;
211 */
212 return sc;
213}
*******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 setHist(const vector< TH1F > *hist)
void setRange(const vector< double > *hRange)
StatusCode openRead(const std::string &fname)
RootCalBaseCnv(ISvcLocator *svc, const CLID &clid)
virtual StatusCode openWrite(const std::string &fname)
virtual StatusCode i_createObj(const std::string &fname, DataObject *&refpObject)
static const CLID & classID()
virtual StatusCode createRoot(const std::string &fname, CalibData::CalibBase1 *pTDSObj)
const CLID & objType() const
RootDedxSimDataCnv(ISvcLocator *svc)