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;
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;
157 for(lay=0; lay<
MdcCalNLayer; lay++)
if(fgHitLay[lay]) nhitlay++;
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();
172 if(1 != stat)
continue;
174 if( (fabs(doca) < m_docaMin[lay]) ||
175 (fabs(doca) > m_docaMax[lay]) ||
176 (fabs(resi) > m_param.
resiCut[lay]) ){
181 if( ! fgHitLay[1] )
continue;
182 }
else if(42 == lay){
183 if( ! fgHitLay[41] )
continue;
185 if( (!fgHitLay[lay-1]) && (!fgHitLay[lay+1]) )
continue;
190 m_hleft[wir] -> Fill(resi);
192 m_hright[wir] -> Fill(resi);
195 std::cout <<
"wir: " << wir << std::endl;
204 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
205 MsgStream log(
msgSvc,
"WrMdcCalib");
206 log << MSG::INFO <<
"WrMdcCalib::updateConst()" << endreq;
213 int nwire = m_mdcGeomSvc -> getWireSize();
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];
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();
248 entry_l = m_hleft[i] -> GetEntries();
249 mean_l = m_hleft[i] -> GetMean();
251 entry_r = m_hright[i] -> GetEntries();
252 mean_r = m_hright[i] -> GetMean();
254 dwphi = 0.5 * (mean_l - mean_r);
259 resiLrSum = 0.5 * (mean_l + mean_r);
260 m_hLrResiSum->Fill(resiLrSum);
261 m_hLrResiSub->Fill(dwphi);
263 wpos[0] = pWire -> Backward().x();
264 wpos[1] = pWire -> Backward().y();
265 wpos[3] = pWire -> Forward().x();
266 wpos[4] = pWire -> Forward().y();
268 xx = 0.5 * (wpos[0] + wpos[3]);
269 yy = 0.5 * (wpos[1] + wpos[4]);
270 rr = sqrt( (xx * xx) + (yy * yy) );
272 if( yy >= 0 ) wphi = acos(xx / rr);
273 else wphi =
PI2 - acos(xx / rr);
275 dx = -1.0 * dwphi *
sin(wphi);
276 dy = dwphi *
cos(wphi);
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;
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;
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];
307 for(k=0; k<6; k++) fdw << setw(15) << ddw[i][k];
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]);
double sin(const BesAngle a)
double cos(const BesAngle a)
virtual const MdcGeoWire *const Wire(unsigned id)=0
virtual const int getWireSize()=0
int fgCalib[MdcCalNLayer]
double resiCut[MdcCalNLayer]
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)