CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcCalConstMgr.cxx
Go to the documentation of this file.
1#include "MdcCalibAlg/MdcCalConstMgr.h"
2
3#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/IMessageSvc.h"
5#include "GaudiKernel/StatusCode.h"
6#include "GaudiKernel/ISvcLocator.h"
7#include "GaudiKernel/Bootstrap.h"
8#include "GaudiKernel/SmartDataPtr.h"
9#include "GaudiKernel/IDataProviderSvc.h"
10#include "GaudiKernel/PropertyMgr.h"
11
12#include "TROOT.h"
13#include "TFile.h"
14#include "TTree.h"
15#include "TH1F.h"
16#include "TObjArray.h"
17
18#include <iostream>
19#include <iomanip>
20
22 // constructor
23}
24
26 // destructor
27}
28
29void MdcCalConstMgr::init(IMdcGeomSvc* mdcGeomSvc, IMdcCalibFunSvc* mdcFunSvc){
30 m_mdcGeomSvc = mdcGeomSvc;
31 m_mdcFunSvc = mdcFunSvc;
32}
33
34// read calibration data from TCDS
36 IMessageSvc* msgSvc;
37 Gaudi::svcLocator() -> service("MessageSvc", msgSvc);
38 MsgStream log(msgSvc, "MdcCalConstMgr");
39 log << MSG::INFO << "Read calibration data from TCDS by MdcCalibFunSvc"
40 << endreq;
41
42 int lay;
43 int wid;
44
45 int nlayer;
46 int nwire;
47
48 int key;
49 double val;
50
51 nlayer = m_mdcGeomSvc -> getLayerSize();
52 nwire = m_mdcGeomSvc -> getWireSize();
53
54// read XT data -----------------------------------------------------------
55 m_mdcFunSvc -> setXtBegin();
56 while( m_mdcFunSvc -> getNextXtpar(key, val) ){
57 calconst -> fillXtpar(key, val);
58 }
59
60// read T0 data -----------------------------------------------------------
61 double t0;
62 double delt0;
63 for(wid=0; wid<nwire; wid++){
64 t0 = m_mdcFunSvc -> getT0(wid);
65 delt0 = m_mdcFunSvc -> getDelT0(wid);
66 calconst -> fillT0(t0);
67 calconst -> fillDelT0(delt0);
68 }
69
70// read QT data -----------------------------------------------------------
71 double qtpar0;
72 double qtpar1;
73 for(lay=0; lay<nlayer; lay++){
74 qtpar0 = m_mdcFunSvc -> getQtpar(lay, 0);
75 qtpar1 = m_mdcFunSvc -> getQtpar(lay, 1);
76 calconst -> fillQtpar0(qtpar0);
77 calconst -> fillQtpar1(qtpar1);
78 }
79
80// read spatial resolution data -------------------------------------------
81 m_mdcFunSvc -> setSdBegin();
82 while( m_mdcFunSvc -> getNextSdpar(key, val) ){
83 calconst -> fillSdpar(key, val);
84 }
85}
86
87
88// write calibration data from TCDS
90
91}
92
93
94// read calibration data directly in run directory
96 IMessageSvc* msgSvc;
97 Gaudi::svcLocator() -> service("MessageSvc", msgSvc);
98 MsgStream log(msgSvc, "MdcCalConstMgr");
99 log << MSG::WARNING << "read calibration data directly from run directory"
100 << endreq;
101
102 TFile fconst("MdcCalibConst.root");
103 log << MSG::INFO << "open file" << endreq;
104
105// read xttree ------------------------------------------------------------
106 int i;
107 int key;
108 double xtpar;
109 int entry;
110 TTree* xttree = (TTree*)fconst.Get("XtTree");
111 xttree -> SetBranchAddress("xtkey", &key);
112 xttree -> SetBranchAddress("xtpar", &xtpar);
113 entry = (int)xttree -> GetEntries();
114 for(i=0; i<entry; i++){
115 xttree -> GetEntry(i);
116 calconst -> fillXtpar(key, xtpar);
117 }
118 log << MSG::INFO << "read XTtree" << endreq;
119
120// read t0tree ------------------------------------------------------------
121 double t0;
122 double delt0;
123 TTree* t0tree = (TTree*)fconst.Get("T0Tree");
124 t0tree -> SetBranchAddress("t0", &t0);
125 t0tree -> SetBranchAddress("delt0", &delt0);
126 entry = (int)t0tree -> GetEntries();
127 for(i=0; i<entry; i++){
128 t0tree -> GetEntry(i);
129 calconst -> fillT0(t0);
130 calconst -> fillDelT0(delt0);
131 }
132 log << MSG::INFO << "read XTtree" << endreq;
133
134// read qttree ------------------------------------------------------------
135 double qtpar0;
136 double qtpar1;
137 TTree* qttree = (TTree*)fconst.Get("QtTree");
138 qttree -> SetBranchAddress("qtpar0", &qtpar0);
139 qttree -> SetBranchAddress("qtpar1", &qtpar1);
140 entry = (int)qttree -> GetEntries();
141 for(i=0; i<entry; i++){
142 qttree -> GetEntry(i);
143 calconst -> fillQtpar0(qtpar0);
144 calconst -> fillQtpar1(qtpar1);
145 }
146
147// read sdtree ---------------------------------------------------------
148 double sdpar;
149 TTree* sdtree = (TTree*)fconst.Get("SdTree");
150 sdtree -> SetBranchAddress("sdkey", &key);
151 sdtree -> SetBranchAddress("sdpar", &sdpar);
152 entry = sdtree -> GetEntries();
153 for(i=0; i<entry; i++){
154 sdtree -> GetEntry(i);
155 calconst -> fillSdpar(key, sdpar);
156 }
157
158 fconst.Close();
159
160 log << MSG::INFO << "read MdcCalibConst over" << endreq;
161}
162
163
164// write calibration data directly in run directory
166 IMessageSvc* msgSvc;
167 Gaudi::svcLocator() -> service("MessageSvc", msgSvc);
168 MsgStream log(msgSvc, "MdcCalConstMgr");
169 log << MSG::INFO << "MdcCalConstMgr::wrtConst()" << endreq;
170
171 TFile fconst("MdcCalibConst_new.root", "recreate");
172
173// XT parameter tree -------------------------------------------------------
174 int i;
175 int key;
176 int entry;
177 double xtpar;
178 TTree* xttree = new TTree("XtTree", "XtTree");
179 xttree -> Branch("xtkey", &key, "key/I");
180 xttree -> Branch("xtpar", &xtpar, "xtpar/D");
181 calconst -> setXtBegin();
182 while( calconst -> getNextXtpar(key, xtpar) ){
183 xttree -> Fill();
184 }
185
186// T0 parameter tree -------------------------------------------------------
187 double t0;
188 double delt0;
189
190 TTree* t0tree = new TTree("T0Tree", "T0Tree");
191 t0tree -> Branch("t0", &t0, "t0/D");
192 t0tree -> Branch("delt0", &delt0, "delt0/D");
193 entry = calconst -> getT0Size();
194 for(i=0; i<entry; i++){
195 t0 = calconst -> getT0(i);
196 delt0 = calconst -> getDelT0(i);
197 t0tree -> Fill();
198 }
199
200// QT parameter tree -------------------------------------------------------
201 double qtpar0;
202 double qtpar1;
203
204 TTree* qttree = new TTree("QtTree", "QtTree");
205 qttree -> Branch("qtpar0", &qtpar0, "qtpar0/D");
206 qttree -> Branch("qtpar1", &qtpar1, "qtpar1/D");
207 entry = calconst -> getQtSize();
208 for(i=0; i<entry; i++){
209 qtpar0 = calconst -> getQtpar0(i);
210 qtpar1 = calconst -> getQtpar1(i);
211 qttree -> Fill();
212 }
213
214// Spacial Resolution parameter tree ---------------------------------------
215 double sdpar;
216
217 TTree* sdtree = new TTree("SdTree", "SdTree");
218 sdtree -> Branch("sdkey", &key, "key/I");
219 sdtree -> Branch("sdpar", &sdpar, "sdpar/D");
220 calconst -> setSdBegin();
221 while( calconst -> getNextSdpar(key, sdpar) ){
222 sdtree -> Fill();
223 }
224
225 xttree -> Write();
226 t0tree -> Write();
227 qttree -> Write();
228 sdtree -> Write();
229
230 delete xttree;
231 delete t0tree;
232 delete qttree;
233 delete sdtree;
234
235 fconst.Close();
236
237 log << MSG::INFO << "MdcCalibConst_new.root was written." << endreq;
238}
data SetBranchAddress("time",&time)
data GetEntry(0)
*************DOUBLE PRECISION m_pi *DOUBLE PRECISION m_HvecTau2 DOUBLE PRECISION m_HvClone2 DOUBLE PRECISION m_gamma1 DOUBLE PRECISION m_gamma2 DOUBLE PRECISION m_thet1 DOUBLE PRECISION m_thet2 INTEGER m_IFPHOT *COMMON c_Taupair $ !Spin Polarimeter vector first Tau $ !Spin Polarimeter vector second Tau $ !Clone Spin Polarimeter vector first Tau $ !Clone Spin Polarimeter vector second Tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !phi of HvecTau1 $ !theta of HvecTau1 $ !phi of HvecTau2 $ !theta of HvecTau2 $ !super key
Definition: Taupair.h:42
void wrtConst(MdcCalibConst *calconst)
void init(IMdcGeomSvc *mdcGeomSvc, IMdcCalibFunSvc *mdcFunSvc)
void rdConstTcds(MdcCalibConst *calconst)
void rdConst(MdcCalibConst *calconst)
void wrtConstTcds(MdcCalibConst *calconst)