BOSS 7.1.2
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 printCut () const
 
void clear ()
 
- Public Member Functions inherited from MdcCalib
 MdcCalib ()
 
virtual ~MdcCalib ()
 

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:80

◆ 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 // momentum cut
150 double p = rectrk -> getP();
151 if((fabs(p) < m_param.pCut[0]) || (fabs(p) > m_param.pCut[1])) continue;
152
153 for(lay=0; lay<MdcCalNLayer; lay++) fgHitLay[lay] = false;
154 for(k=0; k<nhit; k++){
155 rechit = rectrk -> getRecHit(k);
156 lay = rechit -> getLayid();
157 fgHitLay[lay] = true;
158 }
159
160 int nhitlay = 0;
161 for(lay=0; lay<MdcCalNLayer; lay++) if(fgHitLay[lay]) nhitlay++;
162 if(nhitlay < m_param.nHitLayCut) continue;
163
164 log << MSG::DEBUG << "number of hits: " << nhit << endreq;
165 for(k=0; k<nhit; k++){
166 rechit = rectrk -> getRecHit(k);
167 lay = rechit -> getLayid();
168 cel = rechit -> getCellid();
169 wir = m_mdcGeomSvc ->Wire(lay, cel)->Id();
170 lr = rechit -> getLR();
171 doca = rechit -> getDocaExc();
172 dmeas = rechit -> getDmeas();
173 resi = rechit -> getResiExc();
174 stat = rechit -> getStat();
175
176 if(1 != stat) continue;
177
178 if( (fabs(doca) < m_docaMin[lay]) ||
179 (fabs(doca) > m_docaMax[lay]) ||
180 (fabs(resi) > m_param.resiCut[lay]) ){
181 continue;
182 }
183
184 if(0 == lay){
185 if( ! fgHitLay[1] ) continue;
186 } else if(42 == lay){
187 if( ! fgHitLay[41] ) continue;
188 } else{
189 if( (!fgHitLay[lay-1]) && (!fgHitLay[lay+1]) ) continue;
190 }
191
192 if(wir < (m_mdcGeomSvc->getWireSize()) ){
193 if( 0 == lr ){
194 m_hleft[wir] -> Fill(resi);
195 }else if( 1 == lr ){
196 m_hright[wir] -> Fill(resi);
197 }
198 }else{
199 std::cout << "wir: " << wir << std::endl;
200 }
201 }
202 }
203 return 1;
204}
curve Fill()
IMessageSvc * msgSvc()
virtual const MdcGeoWire *const Wire(unsigned id)=0
virtual const int getWireSize()=0
double pCut[2]
double resiCut[MdcCalNLayer]
double getDz() const
double getDr() const
virtual int fillHist(MdcCalEvent *event)=0
Definition MdcCalib.cxx:730
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}
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)
virtual void initialize(TObjArray *hlist, IMdcGeomSvc *mdcGeomSvc, IMdcCalibFunSvc *mdcFunSvc, IMdcUtilitySvc *mdcUtilitySvc)=0
Definition MdcCalib.cxx:214

◆ printCut()

void WrMdcCalib::printCut ( ) const
virtual

Implements MdcCalib.

Definition at line 206 of file WrMdcCalib.cxx.

206 {
208}
virtual void printCut() const =0

◆ setParam()

void WrMdcCalib::setParam ( MdcCalParams & param)
inlinevirtual

Implements MdcCalib.

Definition at line 44 of file WrMdcCalib.h.

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

◆ updateConst()

int WrMdcCalib::updateConst ( MdcCalibConst * calconst)
virtual

Implements MdcCalib.

Definition at line 210 of file WrMdcCalib.cxx.

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

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