BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
WrMdcCalib Class Reference

#include <WrMdcCalib.h>

+ Inheritance diagram for WrMdcCalib:

Public Member Functions

 WrMdcCalib ()
 
 ~WrMdcCalib ()
 
void initialize (TObjArray *hlist, IMdcGeomSvc *mdcGeomSvc, IMdcCalibFunSvc *mdcFunSvc, IMdcUtilitySvc *mdcUtilitySvc)
 
void setParam (MdcCalParams &param)
 
int fillHist (MdcCalEvent *event)
 
int updateConst (MdcCalibConst *calconst)
 
void clear ()
 
- Public Member Functions inherited from MdcCalib
 MdcCalib ()
 
virtual ~MdcCalib ()
 
virtual void initialize (TObjArray *hlist, IMdcGeomSvc *mdcGeomSvc, IMdcCalibFunSvc *mdcFunSvc, IMdcUtilitySvc *mdcUtilitySvc)=0
 
virtual void setParam (MdcCalParams &param)=0
 
virtual int fillHist (MdcCalEvent *event)=0
 
virtual int updateConst (MdcCalibConst *calconst)=0
 
virtual void clear ()=0
 

Detailed Description

Definition at line 6 of file WrMdcCalib.h.

Constructor & Destructor Documentation

◆ WrMdcCalib()

WrMdcCalib::WrMdcCalib ( )

Definition at line 13 of file WrMdcCalib.cxx.

13 {
14 for(int lay=0; lay<MdcCalNLayer; lay++){
15 if(lay < 8){
16 m_docaMin[lay] = 1.2; // mm
17 m_docaMax[lay] = 4.8; // mm
18 } else{
19 m_docaMin[lay] = 1.6; // mm
20 m_docaMax[lay] = 6.4; // mm
21 }
22 }
23}
const int MdcCalNLayer
Definition: MdcCalParams.h:6

◆ ~WrMdcCalib()

WrMdcCalib::~WrMdcCalib ( )

Definition at line 25 of file WrMdcCalib.cxx.

25 {
26}

Member Function Documentation

◆ clear()

void WrMdcCalib::clear ( )
virtual

Implements MdcCalib.

Definition at line 28 of file WrMdcCalib.cxx.

28 {
29 for(int i=0; i<MdcCalTotCell; i++){
30 delete m_hleft[i];
31 delete m_hright[i];
32 }
33 delete m_hdwxtot;
34 delete m_hddwx;
35 delete m_hdwytot;
36 delete m_hddwy;
37 delete m_hLrResiSum;
38 delete m_hLrResiSub;
39 delete m_fdWire;
40 delete m_fdResiWire;
42}
const int MdcCalTotCell
Definition: MdcCalParams.h:9
virtual void clear()=0
Definition: MdcCalib.cxx:76

◆ fillHist()

int WrMdcCalib::fillHist ( MdcCalEvent event)
virtual

Implements MdcCalib.

Definition at line 103 of file WrMdcCalib.cxx.

103 {
104 IMessageSvc *msgSvc;
105 Gaudi::svcLocator() -> service("MessageSvc", msgSvc);
106 MsgStream log(msgSvc, "WrMdcCalib");
107 log << MSG::DEBUG << "WrMdcCalib::fillHist()" << endreq;
108
109 MdcCalib::fillHist(event);
110
111 // get EsTimeCol
112 bool esCutFg = event->getEsCutFlag();
113 if( ! esCutFg ) return -1;
114
115 int i;
116 int k;
117 int ntrk;
118 int nhit;
119 int stat;
120
121 int lay;
122 int cel;
123 int wir;
124 int lr;
125 double dmeas;
126 double doca;
127 double resi;
128
129 bool fgHitLay[MdcCalNLayer];
130
131 MdcCalRecTrk* rectrk;
132 MdcCalRecHit* rechit;
133
134 ntrk = event->getNTrk();
135 log << MSG::DEBUG << "number of tracks: " << ntrk << endreq;
136
137 for(i=0; i<ntrk; i++){
138 rectrk = event -> getRecTrk(i);
139 nhit = rectrk -> getNHits();
140
141 // dr cut
142 double dr = rectrk->getDr();
143 if(fabs(dr) > m_param.drCut) continue;
144
145 // dz cut
146 double dz = rectrk->getDz();
147 if(fabs(dz) > m_param.dzCut) continue;
148
149 for(lay=0; lay<MdcCalNLayer; lay++) fgHitLay[lay] = false;
150 for(k=0; k<nhit; k++){
151 rechit = rectrk -> getRecHit(k);
152 lay = rechit -> getLayid();
153 fgHitLay[lay] = true;
154 }
155
156 int nhitlay = 0;
157 for(lay=0; lay<MdcCalNLayer; lay++) if(fgHitLay[lay]) nhitlay++;
158 if(nhitlay < m_param.nHitLayCut) continue;
159
160 log << MSG::DEBUG << "number of hits: " << nhit << endreq;
161 for(k=0; k<nhit; k++){
162 rechit = rectrk -> getRecHit(k);
163 lay = rechit -> getLayid();
164 cel = rechit -> getCellid();
165 wir = m_mdcGeomSvc ->Wire(lay, cel)->Id();
166 lr = rechit -> getLR();
167 doca = rechit -> getDocaExc();
168 dmeas = rechit -> getDmeas();
169 resi = rechit -> getResiExc();
170 stat = rechit -> getStat();
171
172 if(1 != stat) continue;
173
174 if( (fabs(doca) < m_docaMin[lay]) ||
175 (fabs(doca) > m_docaMax[lay]) ||
176 (fabs(resi) > m_param.resiCut[lay]) ){
177 continue;
178 }
179
180 if(0 == lay){
181 if( ! fgHitLay[1] ) continue;
182 } else if(42 == lay){
183 if( ! fgHitLay[41] ) continue;
184 } else{
185 if( (!fgHitLay[lay-1]) && (!fgHitLay[lay+1]) ) continue;
186 }
187
188 if(wir < (m_mdcGeomSvc->getWireSize()) ){
189 if( 0 == lr ){
190 m_hleft[wir] -> Fill(resi);
191 }else if( 1 == lr ){
192 m_hright[wir] -> Fill(resi);
193 }
194 }else{
195 std::cout << "wir: " << wir << std::endl;
196 }
197 }
198 }
199 return 1;
200}
IMessageSvc * msgSvc()
virtual const MdcGeoWire *const Wire(unsigned id)=0
virtual const int getWireSize()=0
double dzCut
Definition: MdcCalParams.h:71
double drCut
Definition: MdcCalParams.h:70
double resiCut[MdcCalNLayer]
Definition: MdcCalParams.h:79
double getDz() const
Definition: MdcCalRecTrk.h:33
double getDr() const
Definition: MdcCalRecTrk.h:30
virtual int fillHist(MdcCalEvent *event)=0
Definition: MdcCalib.cxx:692
int Id(void) const
Definition: MdcGeoWire.h:127

◆ initialize()

void WrMdcCalib::initialize ( TObjArray *  hlist,
IMdcGeomSvc mdcGeomSvc,
IMdcCalibFunSvc mdcFunSvc,
IMdcUtilitySvc mdcUtilitySvc 
)
virtual

Implements MdcCalib.

Definition at line 44 of file WrMdcCalib.cxx.

45 {
46 IMessageSvc *msgSvc;
47 Gaudi::svcLocator()->service("MessageSvc", msgSvc);
48 MsgStream log(msgSvc, "WrMdcCalib");
49 log << MSG::INFO << "WrMdcCalib::initialize()" << endreq;
50
51 m_hlist = hlist;
52 m_mdcGeomSvc = mdcGeomSvc;
53 m_mdcFunSvc = mdcFunSvc;
54 m_mdcUtilitySvc = mdcUtilitySvc;
55
56 MdcCalib::initialize(m_hlist, m_mdcGeomSvc, m_mdcFunSvc, m_mdcUtilitySvc);
57
58 int i;
59 int nwire;
60 int lay;
61 int cel;
62 char hname[200];
63
64 m_fdWire = new TFolder("WireCor", "WireCor");
65 m_hlist->Add(m_fdWire);
66
67 m_fdResiWire = new TFolder("ResiWire", "ResiWire");
68 m_hlist->Add(m_fdResiWire);
69
70 nwire = m_mdcGeomSvc -> getWireSize();
71 for(i=0; i<nwire; i++){
72 lay = m_mdcGeomSvc -> Wire(i) -> Layer();
73 cel = m_mdcGeomSvc -> Wire(i) -> Cell();
74
75 sprintf(hname, "h%04d_L%02d_%03d_Left", i, lay, cel);
76 m_hleft[i] = new TH1F(hname, hname, 300, -1.5, 1.5);
77 m_fdWire->Add(m_hleft[i]);
78
79 sprintf(hname, "h%04d_L%02d_%03d_Right", i, lay, cel);
80 m_hright[i] = new TH1F(hname, hname, 300, -1.5, 1.5);
81 m_fdWire->Add(m_hright[i]);
82 }
83
84 m_hdwxtot = new TH1F("dwXtot", "", 100, -0.5, 0.5);
85 m_fdResiWire->Add(m_hdwxtot);
86
87 m_hddwx = new TH1F("ddwX", "", 100, -0.5, 0.5);
88 m_fdResiWire->Add(m_hddwx);
89
90 m_hdwytot = new TH1F("dwYtot", "", 100, -0.5, 0.5);
91 m_fdResiWire->Add(m_hdwytot);
92
93 m_hddwy = new TH1F("ddwY", "", 100, -0.5, 0.5);
94 m_fdResiWire->Add(m_hddwy);
95
96 m_hLrResiSum = new TH1F("LrResiSum", "", 200, -0.5, 0.5);
97 m_fdResiWire->Add(m_hLrResiSum);
98
99 m_hLrResiSub = new TH1F("LrResiSub", "", 200, -0.5, 0.5);
100 m_fdResiWire->Add(m_hLrResiSub);
101}
virtual void initialize(TObjArray *hlist, IMdcGeomSvc *mdcGeomSvc, IMdcCalibFunSvc *mdcFunSvc, IMdcUtilitySvc *mdcUtilitySvc)=0
Definition: MdcCalib.cxx:202

◆ setParam()

void WrMdcCalib::setParam ( MdcCalParams param)
inlinevirtual

Implements MdcCalib.

Definition at line 43 of file WrMdcCalib.h.

43 {
44 MdcCalib::setParam(param);
45 m_param = param;
46}
virtual void setParam(MdcCalParams &param)=0
Definition: MdcCalib.h:293

◆ updateConst()

int WrMdcCalib::updateConst ( MdcCalibConst calconst)
virtual

Implements MdcCalib.

Definition at line 202 of file WrMdcCalib.cxx.

202 {
203 IMessageSvc *msgSvc;
204 Gaudi::svcLocator() -> service("MessageSvc", msgSvc);
205 MsgStream log(msgSvc, "WrMdcCalib");
206 log << MSG::INFO << "WrMdcCalib::updateConst()" << endreq;
207
208 MdcCalib::updateConst(calconst);
209
210 int i;
211 int lay;
212 int cel;
213 int nwire = m_mdcGeomSvc -> getWireSize();
214 double dwphi; // wire derivation in phi direction
215 double resiLrSum; // to fill histogram
216 double wpos[6];
217 double xx;
218 double yy;
219 double rr;
220 double dx;
221 double dy;
222 double wphi;
223
224 Stat_t entry_l;
225 double mean_l;
226 Stat_t entry_r;
227 double mean_r;
228 const MdcGeoWire* pWire;
229
230 double ddw[MdcCalTotCell][6];
231 double dwinput[MdcCalTotCell][6];
232 string strtmp;
233 ifstream fwpinput(m_param.wpcFile.c_str());
234 for(i=0; i<7; i++) fwpinput >> strtmp;
235 for(i=0; i<nwire; i++){
236 fwpinput >> strtmp >> dwinput[i][0] >> dwinput[i][1] >> dwinput[i][2]
237 >> dwinput[i][3] >> dwinput[i][4] >> dwinput[i][5];
238 }
239 fwpinput.close();
240
241 std::cout << "totwire: " << nwire << std::endl;
242 for(i=0; i<nwire; i++){
243 pWire = m_mdcGeomSvc -> Wire(i);
244 lay = pWire -> Layer();
245 cel = pWire -> Cell();
246
247 if(1 == m_param.fgCalib[lay]){
248 entry_l = m_hleft[i] -> GetEntries();
249 mean_l = m_hleft[i] -> GetMean();
250
251 entry_r = m_hright[i] -> GetEntries();
252 mean_r = m_hright[i] -> GetMean();
253
254 dwphi = 0.5 * (mean_l - mean_r);
255 } else{
256 dwphi = 0.0;
257 }
258
259 resiLrSum = 0.5 * (mean_l + mean_r);
260 m_hLrResiSum->Fill(resiLrSum);
261 m_hLrResiSub->Fill(dwphi);
262
263 wpos[0] = pWire -> Backward().x(); // east end
264 wpos[1] = pWire -> Backward().y();
265 wpos[3] = pWire -> Forward().x(); // west end
266 wpos[4] = pWire -> Forward().y();
267
268 xx = 0.5 * (wpos[0] + wpos[3]);
269 yy = 0.5 * (wpos[1] + wpos[4]);
270 rr = sqrt( (xx * xx) + (yy * yy) );
271
272 if( yy >= 0 ) wphi = acos(xx / rr);
273 else wphi = PI2 - acos(xx / rr);
274
275 dx = -1.0 * dwphi * sin(wphi);
276 dy = dwphi * cos(wphi);
277
278 ddw[i][0] = dx;
279 ddw[i][1] = dy;
280 ddw[i][2] = 0.0;
281 ddw[i][3] = dx;
282 ddw[i][4] = dy;
283 ddw[i][5] = 0.0;
284 }
285
286 ofstream fwpc("WirePosCalib_new.txt");
287 fwpc << setw(5) << "wireId" << setw(15) << "dx_East(mm)"
288 << setw(15) << "dy_East(mm)" << setw(15) << "dz_East(mm)"
289 << setw(15) << "dx_West(mm)" << setw(15) << "dy_West(mm)"
290 << setw(15) << "dz_West(mm)" << endl;
291
292 ofstream fdw("dw.txt");
293 fdw << setw(5) << "wireId" << setw(15) << "ddx_East(mm)"
294 << setw(15) << "ddy_East(mm)" << setw(15) << "ddz_East(mm)"
295 << setw(15) << "ddx_West(mm)" << setw(15) << "ddy_West(mm)"
296 << setw(15) << "ddz_West(mm)" << endl;
297
298 int k;
299 double dwtot[6];
300 for(i=0; i<nwire; i++){
301 for(k=0; k<6; k++) dwtot[k] = dwinput[i][k] + ddw[i][k];
302 fwpc << setw(5) << i;
303 for(k=0; k<6; k++) fwpc << setw(15) << dwtot[k];
304 fwpc << endl;
305
306 fdw << setw(5) << i;
307 for(k=0; k<6; k++) fdw << setw(15) << ddw[i][k];
308 fdw << endl;
309 m_hdwxtot->Fill(dwtot[0]);
310 m_hddwx->Fill(ddw[i][0]);
311 m_hdwytot->Fill(dwtot[1]);
312 m_hddwy->Fill(ddw[i][1]);
313 }
314 fwpc.close();
315 fdw.close();
316 return 1;
317}
double sin(const BesAngle a)
Definition: BesAngle.h:210
double cos(const BesAngle a)
Definition: BesAngle.h:213
int fgCalib[MdcCalNLayer]
Definition: MdcCalParams.h:75
std::string wpcFile
Definition: MdcCalParams.h:83
virtual int updateConst(MdcCalibConst *calconst)=0
Definition: MdcCalib.cxx:1322
std::ifstream ifstream
Definition: bpkt_streams.h:44
std::ofstream ofstream
Definition: bpkt_streams.h:42

The documentation for this class was generated from the following files: