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"
49 Gaudi::svcLocator()->service(
"MessageSvc",
msgSvc);
50 MsgStream log(
msgSvc,
"Wr2dMdcCalib");
51 log << MSG::INFO <<
"Wr2dMdcCalib::initialize()" << endreq;
54 m_mdcGeomSvc = mdcGeomSvc;
55 m_mdcFunSvc = mdcFunSvc;
56 m_mdcUtilitySvc = mdcUtilitySvc;
66 m_fdWire =
new TFolder(
"WireCor",
"WireCor");
67 m_hlist->Add(m_fdWire);
70 lay = m_mdcGeomSvc -> Wire(i) -> Layer();
71 cel = m_mdcGeomSvc -> Wire(i) -> Cell();
75 m_hl[i][
bin] =
new TH1F(hname,
"", 300, -1.5, 1.5);
76 m_fdWire->Add(m_hl[i][
bin]);
79 m_hr[i][
bin] =
new TH1F(hname,
"", 300, -1.5, 1.5);
80 m_fdWire->Add(m_hr[i][
bin]);
85 m_zwest[lay] = m_mdcGeomSvc->
Wire(lay, 0)->
Forward().z();
86 m_zeast[lay] = m_mdcGeomSvc->
Wire(lay, 0)->
Backward().z();
87 m_zwid[lay] = (m_zeast[lay] - m_zwest[lay]) / (
double)
MdcCalWrNBin;
90 m_zbinCen[lay][
bin] = ((double)
bin + 0.5) * m_zwid[lay] + m_zwest[lay];
97 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
98 MsgStream log(
msgSvc,
"Wr2dMdcCalib");
99 log << MSG::DEBUG <<
"Wr2dMdcCalib::fillHist()" << endreq;
104 bool esCutFg =
event->getEsCutFlag();
105 if( ! esCutFg )
return -1;
125 ntrk =
event->getNTrk();
126 log << MSG::DEBUG <<
"number of tracks: " << ntrk << endreq;
128 for(i=0; i<ntrk; i++){
129 rectrk =
event -> getRecTrk(i);
130 nhit = rectrk -> getNHits();
132 log << MSG::DEBUG <<
"number of hits: " << nhit << endreq;
133 for(k=0; k<nhit; k++){
134 rechit = rectrk -> getRecHit(k);
135 lay = rechit -> getLayid();
136 cel = rechit -> getCellid();
137 wir = m_mdcGeomSvc -> Wire(lay, cel) -> Id();
138 lr = rechit -> getLR();
139 doca = rechit -> getDocaInc();
140 dmeas = rechit -> getDmeas();
141 residual = rechit -> getResiInc();
142 zhit = rechit -> getZhit();
145 bin = (int)(zhit / m_zwid[lay]);
147 m_hl[wir][
bin] ->
Fill(residual);
149 m_hr[wir][
bin] ->
Fill(residual);
152 std::cout <<
"wir: " << wir << std::endl;
165 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
166 MsgStream log(
msgSvc,
"Wr2dMdcCalib");
167 log << MSG::INFO <<
"Wr2dMdcCalib::updateConst()" << endreq;
184 Double_t arglist[10];
186 TMinuit *gmtrw =
new TMinuit(5);
187 gmtrw -> SetPrintLevel(-1);
189 gmtrw -> SetErrorDef(1.0);
190 gmtrw -> mnparm(0,
"xf", 0.0, 0.01, 0, 0, ierflg);
191 gmtrw -> mnparm(1,
"yf", 0.0, 0.01, 0, 0, ierflg);
192 gmtrw -> mnparm(2,
"xb", 0.0, 0.01, 0, 0, ierflg);
193 gmtrw -> mnparm(3,
"yb", 0.0, 0.01, 0, 0, ierflg);
194 gmtrw -> mnparm(4,
"ten", 0.0, 0.1, 0, 0, ierflg);
196 gmtrw -> mnexcm(
"Set NOW", arglist, 0, ierflg);
203 double ten[] = {15, 15, 15, 16, 16, 17, 17, 18, 14, 14,
204 19, 19, 24, 24, 31, 31, 37, 37, 45, 45,
205 46, 47, 47, 47, 47, 48, 48, 48, 48, 49,
206 49, 49, 49, 50, 50, 50, 51, 51, 51, 52,
225 ofstream fwlog(
"logWireCor.txt");
226 ofstream fwpc(
"wireposCor.txt");
227 ofstream fwpcErr(
"wireposErr.txt");
229 fwpc << setw(5) <<
"wireId" << setw(15) <<
"dx_East(mm)"
230 << setw(15) <<
"dy_East(mm)" << setw(15) <<
"dz_East(mm)"
231 << setw(15) <<
"dx_West(mm)" << setw(15) <<
"dy_West(mm)"
232 << setw(15) <<
"dz_West(mm)" << endl;
235 for(k=0; k<5; k++) wparErr[k] = 999.0;
238 entryL = m_hl[i][
bin] -> GetEntries();
239 entryR = m_hr[i][
bin] -> GetEntries();
240 if((entryL < 100) && (entryR < 100)){
249 hcen = m_hl[i][
bin] -> GetMean();
251 m_hl[i][
bin] ->
Fit(
"gaus",
"Q",
"", hcen-1.5, hcen+1.5);
252 cenL[
bin] = m_hl[i][
bin]->GetFunction(
"gaus")->GetParameter(1);
253 errL[
bin] = m_hl[i][
bin]->GetFunction(
"gaus")->GetParameter(2);
257 errL[
bin] = m_hl[i][
bin] -> GetRMS();
260 hcen = m_hr[i][
bin] -> GetMean();
262 m_hr[i][
bin] ->
Fit(
"gaus",
"Q",
"", hcen-1.5, hcen+1.5);
263 cenR[
bin] = m_hr[i][
bin]->GetFunction(
"gaus")->GetParameter(1);
264 errR[
bin] = m_hr[i][
bin]->GetFunction(
"gaus")->GetParameter(2);
268 errR[
bin] = m_hr[i][
bin] -> GetRMS();
277 if(nFit < 8)
continue;
279 lay = m_mdcGeomSvc -> Wire(i) -> Layer();
280 cel = m_mdcGeomSvc -> Wire(i) -> Cell();
285 wpar[2] = m_mdcGeomSvc->
Wire(lay, 0)->
Forward().x();
286 wpar[3] = m_mdcGeomSvc->
Wire(lay, 0)->
Forward().y();
289 a = 9.47e-06 / (2 * wpar[4]);
290 dx = wpar[0] - wpar[2];
291 dy = wpar[1] - wpar[3];
293 length = sqrt(dx*dx + dz*dz);
299 + 0.5*(wpar[1]+wpar[3]) - a*length*length/4.0;
304 deldw = - (cenL[
bin]-cenR[
bin])/2.0;
305 delxw = -deldw * sinphiw;
306 delyw = deldw * cosphiw;
308 fwlog << setw(3) << lay << setw(4) << cel << setw(5) << i
310 << setw(15) << deldw << setw(15) << delxw
311 << setw(15) << delyw << endl;
320 arglist[1] = wpar[0];
321 gmtrw -> mnexcm(
"SET PARameter", arglist, 2, ierflg);
323 arglist[1] = wpar[1];
324 gmtrw -> mnexcm(
"SET PARameter", arglist, 2, ierflg);
326 arglist[1] = wpar[2];
327 gmtrw -> mnexcm(
"SET PARameter", arglist, 2, ierflg);
329 arglist[1] = wpar[3];
330 gmtrw -> mnexcm(
"SET PARameter", arglist, 2, ierflg);
332 arglist[1] = wpar[4];
333 gmtrw -> mnexcm(
"SET PARameter", arglist, 2, ierflg);
334 gmtrw -> mnexcm(
"FIX", arglist, 1, ierflg);
338 gmtrw -> mnexcm(
"MIGRAD", arglist, 2, ierflg);
339 gmtrw -> mnstat(fmin, edm, errdef, nvpar, nparx, istat);
341 if( (0==ierflg) && (3==istat) ){
342 gmtrw -> GetParameter(0, wpar[0], wparErr[0]);
343 gmtrw -> GetParameter(1, wpar[1], wparErr[1]);
344 gmtrw -> GetParameter(2, wpar[2], wparErr[2]);
345 gmtrw -> GetParameter(3, wpar[3], wparErr[3]);
346 gmtrw -> GetParameter(4, wpar[4], wparErr[4]);
348 gmtrw -> mnexcm(
"RELease", arglist, 1, ierflg);
350 fwlog << setw(5) << i << setw(15) << wpar[0] << setw(15) << wpar[1]
351 << setw(15) << wpar[2] << setw(15) << wpar[3] << endl;
352 fwpc << setw(5) << i << setw(15) << wpar[0] << setw(15) << wpar[1]
353 << setw(15) <<
"0" << setw(15) << wpar[2]
354 << setw(15) << wpar[3] << setw(15) <<
"0" << endl;
355 fwpcErr << setw(5) << i << setw(15) << wparErr[0] << setw(15) << wparErr[1]
356 << setw(15) << wparErr[2] << setw(15) << wparErr[3] << endl;
367 Double_t &
f, Double_t *par, Int_t iflag){
372 double a = 9.47e-06 / (2 * par[4]);
373 double dx = par[0] - par[2];
374 double dy = par[1] - par[3];
376 double length = sqrt(dx*dx + dz*dz);
378 Double_t chisq = 0.0;
385 + 0.5*(par[1] + par[3]) - a*length*length/4.0;
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)
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
*******INTEGER m_nBinMax INTEGER m_NdiMax !No of bins in histogram for cell exploration division $ !Last vertex $ !Last active cell $ !Last cell in buffer $ !No of sampling when dividing cell $ !No of function total $ !Flag for random ceel for $ !Flag for type of for WtMax $ !Flag which decides whether vertices are included in the sampling $ entire domain is hyp !Maximum effective eevents per bin
virtual const MdcGeoWire *const Wire(unsigned id)=0
int fgCalib[MdcCalNLayer]
virtual void printCut() const =0
virtual void initialize(TObjArray *hlist, IMdcGeomSvc *mdcGeomSvc, IMdcCalibFunSvc *mdcFunSvc, IMdcUtilitySvc *mdcUtilitySvc)=0
virtual int fillHist(MdcCalEvent *event)=0
HepPoint3D Forward(void) const
HepPoint3D Backward(void) const
static double zBIN[MdcCalWrNBin]
int fillHist(MdcCalEvent *event)
static void fcnWireParab(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
void initialize(TObjArray *hlist, IMdcGeomSvc *mdcGeomSvc, IMdcCalibFunSvc *mdcFunSvc, IMdcUtilitySvc *mdcUtilitySvc)
static double xBIN[MdcCalWrNBin]
static double zBINERR[MdcCalWrNBin]
static bool fgBIN[MdcCalWrNBin]
static double yBIN[MdcCalWrNBin]
int updateConst(MdcCalibConst *calconst)