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"
47 Gaudi::svcLocator()->service(
"MessageSvc",
msgSvc);
48 MsgStream log(
msgSvc,
"WrMdcCalib");
49 log << MSG::INFO <<
"WrMdcCalib::initialize()" << endreq;
52 m_mdcGeomSvc = mdcGeomSvc;
53 m_mdcFunSvc = mdcFunSvc;
54 m_mdcUtilitySvc = mdcUtilitySvc;
64 m_fdWire =
new TFolder(
"WireCor",
"WireCor");
65 m_hlist->Add(m_fdWire);
67 m_fdResiWire =
new TFolder(
"ResiWire",
"ResiWire");
68 m_hlist->Add(m_fdResiWire);
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();
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]);
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]);
84 m_hdwxtot =
new TH1F(
"dwXtot",
"", 100, -0.5, 0.5);
85 m_fdResiWire->Add(m_hdwxtot);
87 m_hddwx =
new TH1F(
"ddwX",
"", 100, -0.5, 0.5);
88 m_fdResiWire->Add(m_hddwx);
90 m_hdwytot =
new TH1F(
"dwYtot",
"", 100, -0.5, 0.5);
91 m_fdResiWire->Add(m_hdwytot);
93 m_hddwy =
new TH1F(
"ddwY",
"", 100, -0.5, 0.5);
94 m_fdResiWire->Add(m_hddwy);
96 m_hLrResiSum =
new TH1F(
"LrResiSum",
"", 200, -0.5, 0.5);
97 m_fdResiWire->Add(m_hLrResiSum);
99 m_hLrResiSub =
new TH1F(
"LrResiSub",
"", 200, -0.5, 0.5);
100 m_fdResiWire->Add(m_hLrResiSub);
105 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
106 MsgStream log(
msgSvc,
"WrMdcCalib");
107 log << MSG::DEBUG <<
"WrMdcCalib::fillHist()" << endreq;
112 bool esCutFg =
event->getEsCutFlag();
113 if( ! esCutFg )
return -1;
134 ntrk =
event->getNTrk();
135 log << MSG::DEBUG <<
"number of tracks: " << ntrk << endreq;
137 for(i=0; i<ntrk; i++){
138 rectrk =
event -> getRecTrk(i);
139 nhit = rectrk -> getNHits();
142 double dr = rectrk->
getDr();
143 if(fabs(dr) > m_param.
drCut)
continue;
146 double dz = rectrk->
getDz();
147 if(fabs(dz) > m_param.
dzCut)
continue;
150 double p = rectrk -> getP();
151 if((fabs(p) < m_param.
pCut[0]) || (fabs(p) > m_param.
pCut[1]))
continue;
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;
161 for(lay=0; lay<
MdcCalNLayer; lay++)
if(fgHitLay[lay]) nhitlay++;
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();
176 if(1 != stat)
continue;
178 if( (fabs(doca) < m_docaMin[lay]) ||
179 (fabs(doca) > m_docaMax[lay]) ||
180 (fabs(resi) > m_param.
resiCut[lay]) ){
185 if( ! fgHitLay[1] )
continue;
186 }
else if(42 == lay){
187 if( ! fgHitLay[41] )
continue;
189 if( (!fgHitLay[lay-1]) && (!fgHitLay[lay+1]) )
continue;
194 m_hleft[wir] ->
Fill(resi);
196 m_hright[wir] ->
Fill(resi);
199 std::cout <<
"wir: " << wir << std::endl;
212 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
213 MsgStream log(
msgSvc,
"WrMdcCalib");
214 log << MSG::INFO <<
"WrMdcCalib::updateConst()" << endreq;
221 int nwire = m_mdcGeomSvc -> getWireSize();
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];
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();
256 entry_l = m_hleft[i] -> GetEntries();
257 mean_l = m_hleft[i] -> GetMean();
259 entry_r = m_hright[i] -> GetEntries();
260 mean_r = m_hright[i] -> GetMean();
262 dwphi = 0.5 * (mean_l - mean_r);
266 if(0 == m_param.
fgWireCal[i]) dwphi = 0.0;
268 resiLrSum = 0.5 * (mean_l + mean_r);
269 m_hLrResiSum->Fill(resiLrSum);
270 m_hLrResiSub->Fill(dwphi);
272 wpos[0] = pWire -> Backward().x();
273 wpos[1] = pWire -> Backward().y();
274 wpos[3] = pWire -> Forward().x();
275 wpos[4] = pWire -> Forward().y();
277 xx = 0.5 * (wpos[0] + wpos[3]);
278 yy = 0.5 * (wpos[1] + wpos[4]);
279 rr = sqrt( (xx * xx) + (yy * yy) );
281 if( yy >= 0 ) wphi = acos(xx / rr);
282 else wphi =
PI2 - acos(xx / rr);
284 dx = -1.0 * dwphi *
sin(wphi);
285 dy = dwphi *
cos(wphi);
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;
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;
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];
316 for(k=0; k<6; k++) fdw << setw(15) << ddw[i][k];
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]);
double sin(const BesAngle a)
double cos(const BesAngle a)
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 const MdcGeoWire *const Wire(unsigned id)=0
virtual const int getWireSize()=0
int fgCalib[MdcCalNLayer]
double resiCut[MdcCalNLayer]
int fgWireCal[MdcCalTotCell]
virtual void printCut() const =0
virtual void initialize(TObjArray *hlist, IMdcGeomSvc *mdcGeomSvc, IMdcCalibFunSvc *mdcFunSvc, IMdcUtilitySvc *mdcUtilitySvc)=0
virtual int updateConst(MdcCalibConst *calconst)=0
virtual int fillHist(MdcCalEvent *event)=0
int updateConst(MdcCalibConst *calconst)
void initialize(TObjArray *hlist, IMdcGeomSvc *mdcGeomSvc, IMdcCalibFunSvc *mdcFunSvc, IMdcUtilitySvc *mdcUtilitySvc)
int fillHist(MdcCalEvent *event)