10 #include "BarrelMipCalib.h"
11 #include "StJanBarrelDbMaker.h"
12 #include "JanBarrelEvent.h"
14 #include "StEmcUtil/geometry/StEmcGeom.h"
16 #include "StMuDSTMaker/COMMON/StMuEvent.h"
17 #include "StMuDSTMaker/COMMON/StMuDst.h"
18 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
19 #include "StMuDSTMaker/COMMON/StMuPrimaryVertex.h"
20 #include "StMuDSTMaker/COMMON/StMuTrack.h"
21 #include "StThreeVectorF.hh"
22 #include "StThreeVectorD.hh"
28 mJanDbMaker=jdb; assert(mJanDbMaker);
29 muMaker=mumk; assert(muMaker);
32 memset(hA,0,
sizeof(hA));
35 hA[0]=
new TH1F(
"mipStat",
"Mip calib statistics; case",30,-0.5,29.5);
36 hA[1]=
new TH1F(
"mipZver",
"primary (smalest) vertez Z ; vertx Z (cm)",200,-200,200);
37 hA[2]=
new TH1F(
"mipTrPt",
"primTr pT; pT (GeV/c)",100,0,20);
38 hA[3]=
new TH1F(
"mipTrEta",
"primTr Eta ; pseudorapidity",100,-2,2);
39 hA[4]=
new TH1F(
"mipTrNff",
"primTr nFit/nPos ; nFit/nPos",20,0,1.1);
42 hA[5]=
new TH2F(
"mipTrRZ1",
"primTr punch BPRS ; Z @ BPRS (cm); phi @ BPRS (rad)",nx,-300,300,ny,0,2*C_PI);
43 hA[6]=
new TH2F(
"mipTrRZ21",
"primTr punch BTOW L=21, input; Z @ BTOW layer=21 (cm); phi @ BPRS (rad)",nx,-300,300,ny,0,2*C_PI);
44 hA[7]=
new TH2F(
"mipTrRZf",
"primTr in BPRS fiducial ; Z @ BPRS (cm); phi @ BPRS (rad)",nx,-300,300,ny,0,2*C_PI);
46 hA[8]=
new TH2F(
"mipDeDx",
"primTr TPC deDx; track momentum (GeV); TPC dEdX (keV)", 100,0,5,100,0, 20);
48 hA[9]=
new TH1F(
"rankZver",
"highest rank primary vertez Z ; vertx Z (cm)",200,-200,200);
50 hA[10]=
new TH1F(
"mipRxyTr",
"primTr Rxy of last point on the track; Rxy (cm)",220,0,220);
56 hA[12]=
new TH1F(
"mipTrTw",
"tower pointed by accepted prim track; BPRS softID",mxBtow,0.5, mxBtow+0.5);
58 hA[13]=
new TH1F(
"mipZverAc",
"primary vertez Z , accepted; vertx Z (cm)",200,-200,200);
59 hA[14]=
new TH1F(
"mipTrPtAc",
"primTr pT, accepted; pT (GeV/c)",100,0,20);
60 hA[15]=
new TH1F(
"mipTrPAc",
"primTr p, accepted; momentum (GeV)",100,0,20);
65 hA[17]=
new TH1F(
"mipTrZf",
"primTr in BPRS fiducial ; Z @ BPRS (cm)",1800,-300,300);
66 hA[18]=
new TH1F(
"mipTrRf",
"primTr in BPRS fiducial , z>0; phi @ BPRS (rad)",3600,0,2*C_PI);
68 hA[20]=
new TH1F(
"mipMaZ1",
"Z distance of track from both tower Z-edges; delZ (cm)", 250,-5,20);
69 hA[21]=
new TH1F(
"mipMaP1",
"R*phi distance of track from tower edge; delR*phi (cm)", 200,-10,10);
71 hA[22]=
new TH2F(
"mipBprsTr",
"ADC for BPRS pointed by TPC MIP track; BPRS softID; rawADC-ped",mxBtow,0.5,mxBtow+0.5, nb,adc1,adc2);
72 hA[23]=
new TH2F(
"mipBprsTrBt",
"ADC for BPRS pointed by TPC MIP track + BTOW=MIP; BPRS softID; rawADC-ped",mxBtow,0.5,mxBtow+0.5, nb,adc1,adc2);
74 hA[24]=
new TH2F(
"mipBtowTr",
"ADC for BTOW pointed by TPC track; BTOW softID; rawADC-ped",mxBtow,0.5,mxBtow+0.5, nb,adc1,adc2);
75 hA[25]=
new TH2F(
"mipBtowTrPr",
"ADC for BTOW pointed by TPC track+BPRS=MIP; BTOW softID; rawADC-ped",mxBtow,0.5,mxBtow+0.5, nb,adc1,adc2);
79 for(
int i=0;i<mxH;i++)
80 if(hA[i]) HList->Add(hA[i]);
92 int nPrimV=muMaker->
muDst()->numberOfPrimaryVertices();
98 bool fired=tic.nominal().isTrigger(trigID);
101 printf(
"\nmipCalib eventID %d nPrimV=%d =============\n", muEve->eventId(),nPrimV);
102 if(nPrimV<=0)
return;
113 for(
int iv=0;iv<nPrimV;iv++) {
116 if(V->ranking()<0.)
continue;
120 if(iv==0) hA[9]->Fill(r.z());
122 cout <<
"\nPrimary track " << nPrimTr <<
" momentum " << pr_track->p() << endl; cout <<
"\t flag=" << pr_track->flag() <<
" nHits=" << pr_track->nHits()<<
" vertID="<< pr_track->vertexIndex()<< endl;
123 cout <<
"\t primV("<<iv<<
") primDCA=" << pr_track->dca(iv) <<
", pT="<< pr_track->pt()<< endl;
124 if(pr_track->dca(iv).mag()>5) cout <<
"^^^^^ 3D DCA magnitude="<<pr_track->dca(iv).mag()<<endl;
125 cout <<
"\t first point " << pr_track->firstPoint() << endl;
126 cout <<
"\t last point " << pr_track->lastPoint() << endl;
130 printf(
"iv=%d Vz=%.2f +/-%.2f bestZ=%f\n",iv,r.z(),er.z() ,zVert );
132 if( fabs(zVert)< fabs(r.z()))
continue;
141 if(fabs(zVert) > cut_zVertex)
return;
144 printf(
"pick zVert=%f iV=%d\n", zVert,iVert);
147 Int_t nPrimTrAll=muMaker->
muDst()->GetNPrimaryTrack();
148 for(
int itr=0;itr<nPrimTrAll;itr++) {
151 if(pr_track->
flag()<=0)
continue;
152 if(pr_track->
flag() != 301)
continue;
155 hA[2]->Fill(pr_track->
pt());
156 if(pr_track->
pt()< cut_primPt)
continue;
159 hA[3]->Fill(pr_track->
eta());
160 if(fabs(pr_track->
eta())> cut_primEta)
continue;
163 float dedx=pr_track->
dEdx()*1e6;
164 float mom= pr_track->
p().mag();
166 hA[8]->Fill(mom,dedx);
168 if(dedx<1.5)
continue;
169 if(dedx>cut_dedx)
continue;
176 assert(globTr->
flag()>0);
179 if(nFF< cut_nFitFrac)
continue;
184 if(Rxy<cut_primRxy)
continue;
190 float RxyA[mxPL]={225.4, 248.4};
195 for(
int ipl=0;ipl<mxPL;ipl++) {
196 float Rbprs= RxyA[ipl];
199 printf(
" path ipl=%d =%f, 2=%f, period=%f, trR=%f\n",ipl, d2.first ,d2.second,TrkHlx.
period(),1./TrkHlx.curvature());
200 if(d2.first>=0 || d2.second<=0) {
201 LOG_WARN<< Form(
"extrapolateTrk , unexpected solution for track crossing BPRS\n d2.firts=%f, second=%f, track ignored", d2.first, d2.second)<<endm;
205 pos3D = TrkHlx.at(d2.second);
206 double xmagn = ::sqrt( pos3D.x()*pos3D.x() + pos3D.y()*pos3D.y() );
207 printf(
" punchBPRS x,y,z=%.1f, %.1f, %.1f, Rxy=%.1f eta=%.2f\n",pos3D.x(),pos3D.y(),pos3D.z(),xmagn, globTr->
eta());
210 int ierr= mJanDbMaker->mBprsGeom->getId(pos3D.phi(),pos3D.pseudoRapidity(),softIDx);
211 printf(
"hit tower id=%d, ierr=%d ipl=%d\n",softIDx, ierr,ipl);
213 posPhi=atan2(pos3D.y(),pos3D.x());
214 if(posPhi<0) posPhi+=2*C_PI;
215 hA[5+ipl]->Fill(pos3D.z(),posPhi);
217 assert(softIDx>0 && softIDx<=mxBtow);
221 if(!checkFiducial(pos3D.z(),posPhi,softIDx, Rbprs))
break;
226 if(softID!=softIDx) softID=-999;
228 if(!checkFiducial(pos3D.z(),posPhi,softIDx, Rbprs)) softID=-999;
233 if(softID<1)
continue;
237 hA[14]->Fill(pr_track->
pt());
239 hA[7]->Fill(pos3D.z(),posPhi);
240 hA[12]->Fill(softID);
245 for(
int j=0; j<mxBtow; j++) {
247 if(fullEve.statTile[ibp][j])
continue;
248 float adc=fullEve.adcTile[ibp][j];
250 if(adc>35 )
continue;
251 hA[16]->Fill(j+1,softID);
257 uint badPed[mxBTile];
259 for(
int ibp=0;ibp<mxBTile;ibp++) {
261 adc[ibp] =fullEve.adcTile [ibp][id0];
262 badPed[ibp]=fullEve.statTile[ibp][id0];
263 if( badPed[ibp])
continue;
265 mJanDbMaker->cut_mipAdcLH(ibp,softID,adcL,adcH);
266 if(adc[ibp]<adcL)
continue;
267 if(adc[ibp]>adcH)
continue;
273 hA[22]->Fill(softID,adc[kBPrs]);
276 hA[23]->Fill(softID,adc[kBPrs]);
282 hA[24]->Fill(softID,adc[kBTow]);
285 hA[25]->Fill(softID,adc[kBTow]);
289 if(isMip[kBPrs] && isMip[kBTow]) hA[0]->Fill(25);
294 if(nPrimTr<=0)
return;
298 if(nPrimTr>1) hA[0]->Fill(4);
303 int BarrelMipCalib::checkFiducial(
float zTr,
float phiTr,
int softID,
float Rxy){
305 float etaHalfWidth=0.05/2.;
306 const float con_phiHalfWidth=(11.1/225.4)/2.;
307 float cut_eps=cut_zMargin;
308 if((softID-1)%20==19) cut_eps=cut_zMargin/2.;
311 assert( mJanDbMaker->mBprsGeom->getEta(softID,etaTw)==0);
313 if(fabs(etaTw)<0.050) etaHalfWidth=(0.05-0.0035)/2.;
314 if(fabs(etaTw)>0.95) etaHalfWidth=(0.9835-0.95)/2.;
317 float thetaL=2.*atan(exp(-etaTw+etaHalfWidth));
318 float thetaH=2.*atan(exp(-etaTw-etaHalfWidth));
320 float zL=Rxy/tan(thetaL);
321 float zH=Rxy/tan(thetaH);
325 bool isInZ= (delZ1>cut_eps) && (delZ2>cut_eps);
326 printf(
"checkFiducial(zTr=%f phiTr=%f, id=%d Rxy=%f\n",zTr,phiTr,softID,Rxy);
327 printf(
" theta range (deg)=%.1f %.1f\n",thetaL/3.1416*180,thetaH/3.1416*180);
328 printf(
" etaTw=%f w2=%f zL=%f zH=%f delZ1=%f delZ2=%f isInZ=%d\n",etaTw,etaHalfWidth,zL,zH,delZ1, delZ2,isInZ);
336 assert( mJanDbMaker->mBprsGeom->getPhi(softID,phiTw)==0);
337 TVector2 uniTw; uniTw.SetMagPhi(1.,phiTw);
338 TVector2 uniTr; uniTr.SetMagPhi(1.,phiTr);
339 float delPhi=uniTw.DeltaPhi(uniTr);
341 bool isInPhi=(con_phiHalfWidth- fabs(delPhi)) *Rxy> cut_eps;
343 printf(
" phiTr=%f phiTw=%f delPhi=%f delRphi=%f isInPhi=%d\n", phiTr, phiTw,delPhi, delPhi*Rxy, isInPhi);
344 if(isInPhi) hA[21]->Fill(delPhi *Rxy);
346 return isInZ && isInPhi ;
358 int nPrimV=muMaker->
muDst()->numberOfPrimaryVertices();
361 printf(
"\nWARN-ALTERNATIVE CODE: mipCalib eventID %d nPrimV=%d =============\n", muEve->eventId(),nPrimV);
367 for(
int j=0; j<mxBtow; j++) {
368 if((j%20)!=pickBin-1)
continue;
369 if((j/20)%3)
continue;
372 if(fullEve.statTile[ibp][j])
continue;
373 float adc=fullEve.adcTile[ibp][j];
374 if(adc<10 )
continue;
375 if(adc>30 )
continue;
382 assert( mJanDbMaker->mBprsGeom->getPhi(myId0+1,phiTw)==0);
383 TVector2 uniTw; uniTw.SetMagPhi(1.,phiTw);
385 if(nPrimV<=0)
return;
396 for(
int iv=0;iv<nPrimV;iv++) {
399 if(V->ranking()<0.)
continue;
403 if(iv==0) hA[9]->Fill(r.z());
405 printf(
"iv=%d Vz=%.2f +/-%.2f bestZ=%f\n",iv,r.z(),er.z() ,zVert );
407 if( fabs(zVert)< fabs(r.z()))
continue;
416 if(fabs(zVert) > cut_zVertex)
return;
419 printf(
"pick zVert=%f iV=%d\n", zVert,iVert);
422 Int_t nPrimTrAll=muMaker->
muDst()->GetNPrimaryTrack();
423 for(
int itr=0;itr<nPrimTrAll;itr++) {
426 if(pr_track->
flag()<=0)
continue;
429 hA[2]->Fill(pr_track->
pt());
430 if(pr_track->
pt()< cut_primPt)
continue;
433 hA[3]->Fill(pr_track->
eta());
434 if(fabs(pr_track->
eta())> cut_primEta)
continue;
437 float dedx=pr_track->
dEdx()*1e6;
438 float mom= pr_track->
p().mag();
440 hA[8]->Fill(mom,dedx);
442 if(dedx<1.5)
continue;
443 if(dedx>cut_dedx)
continue;
450 assert(globTr->
flag()>0);
453 if(nFF< cut_nFitFrac)
continue;
459 float RxyA[mxPL]={225.4, 248.4};
464 for(
int ipl=0;ipl<1;ipl++) {
465 float Rbprs= RxyA[ipl];
468 printf(
" path ipl=%d =%f, 2=%f, period=%f, trR=%f\n",ipl, d2.first ,d2.second,TrkHlx.
period(),1./TrkHlx.curvature());
469 if(d2.first>=0 || d2.second<=0) {
470 LOG_WARN<< Form(
"extrapolateTrk , unexpected solution for track crossing BPRS\n d2.firts=%f, second=%f, track ignored", d2.first, d2.second)<<endm;
474 pos3D = TrkHlx.at(d2.second);
475 double xmagn = ::sqrt( pos3D.x()*pos3D.x() + pos3D.y()*pos3D.y() );
476 printf(
" punchBPRS x,y,z=%.1f, %.1f, %.1f, Rxy=%.1f eta=%.2f\n",pos3D.x(),pos3D.y(),pos3D.z(),xmagn, globTr->
eta());
478 posPhi=atan2(pos3D.y(),pos3D.x());
479 if(posPhi<0) posPhi+=2*C_PI;
480 hA[5+ipl]->Fill(pos3D.z(),posPhi);
482 TVector2 uniTr; uniTr.SetMagPhi(1.,posPhi);
483 float delPhi=uniTw.DeltaPhi(uniTr);
485 if(fabs(delPhi)>0.15)
continue;
489 if(softID<1)
continue;
493 hA[14]->Fill(pr_track->
pt());
495 hA[7]->Fill(pos3D.z(),posPhi);
496 hA[17]->Fill(pos3D.z());
497 if(pos3D.z()>0) hA[18]->Fill(posPhi);
502 if(nPrimTr<=0)
return;
506 if(nPrimTr>1) hA[0]->Fill(5);
static StMuPrimaryVertex * primaryVertex()
return pointer to current primary vertex
Int_t vertexIndex() const
Returns index of associated primary vertex.
Double_t pt() const
Returns pT at point of dca to primary vertex.
pair< double, double > pathLength(double r) const
path length at given r (cylindrical r)
UShort_t nHitsFit() const
Return total number of hits used in fit.
short flag() const
Returns flag, (see StEvent manual for type information)
const StThreeVectorF & p() const
Returns 3-momentum at dca to primary vertex.
Double_t eta() const
Returns pseudo rapidity at point of dca to primary vertex.
static TObjArray * primaryTracks()
returns pointer to a list of tracks belonging to the selected primary vertex
UShort_t nHitsPoss() const
Return number of possible hits on track.
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
const StThreeVectorF & lastPoint() const
Returns positions of last measured point.
Double_t dEdx() const
Returns measured dE/dx value.
const StMuTrack * globalTrack() const
Returns pointer to associated global track. Null pointer if no global track available.
double period() const
returns period length of helix
StPhysicalHelixD outerHelix() const
Returns outer helix (last measured point)
static void setVertexIndex(Int_t vtx_id)
Set the index number of the current primary vertex (used by both primaryTracks() functions and for St...
Collection of trigger ids as stored in MuDst.