1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
20 /////////////////////////////////////////////////////
21 // Segmentation and Response classes version 01 //
22 /////////////////////////////////////////////////////
28 #include "AliMUONv01.h"
33 //___________________________________________
34 ClassImp(AliMUONsegmentationV01)
36 AliMUONsegmentationV01::AliMUONsegmentationV01()
44 void AliMUONsegmentationV01::SetSegRadii(Float_t r[4])
46 for (Int_t i=0; i<4; i++) {
48 printf("\n R %d %f",i,fRSec[i]);
53 void AliMUONsegmentationV01::SetPadDivision(Int_t ndiv[4])
56 // Defines the pad size perp. to the anode wire (y) for different sectors.
58 for (Int_t i=0; i<4; i++) {
60 printf("\n Ndiv %d %d",i,fNDiv[i]);
66 void AliMUONsegmentationV01::Init(AliMUONchamber*)
69 // Fill the arrays fCx (x-contour) and fNpx (ix-contour) for each sector
70 // These arrays help in converting from real to pad co-ordinates and
74 printf("\n Initialise segmentation v01");
75 fNpy=Int_t(fRSec[fNsec-1]/fDpy)+1;
79 for (Int_t i=fNsec-2; i>=0; i--){
80 fDpxD[i]=fDpxD[fNsec-1]/fNDiv[i];
81 printf("\n dx %d %f",i,fDpxD[i]);
86 // fill the arrays defining the pad segmentation boundaries
91 for(isec=0; isec<fNsec; isec++) {
93 // loop over pads along the aode wires
94 for (Int_t iy=1; iy<=fNpy; iy++) {
96 Float_t x=iy*fDpy-fDpy/2;
97 if (x > fRSec[isec]) {
101 ry=TMath::Sqrt(fRSec[isec]*fRSec[isec]-x*x);
103 dnx= Int_t((ry-fCx[isec-1][iy])/fDpxD[isec]);
104 if (TMath::Odd(dnx)) dnx--;
105 fNpx[isec][iy]=fNpx[isec-1][iy]+dnx;
106 fCx[isec][iy]=fCx[isec-1][iy]+dnx*fDpxD[isec];
108 dnx=Int_t(ry/fDpxD[isec]);
110 if (TMath::Odd(dnx)) dnx--;
111 fCx[isec][iy]=dnx*fDpxD[isec];
118 // for debugging only
119 for (Int_t iy=0; iy<fNpy; iy++) {
120 printf("\n iy %d",iy);
121 for(isec=0; isec<fNsec; isec++) {
125 printf("\n iy %d",iy);
126 for(isec=0; isec<fNsec; isec++) {
135 // for debugging only
136 for (Int_t ix=1; ix<100; ix++) {
137 for (Int_t iy=1; iy<100; iy++) {
138 GetPadCxy(ix,iy,x,y);
139 GetPadIxy(x,y,jx,jy);
140 if ((ix != jx) && (jx!=-1)) {
141 printf("\n %d %f %d %f", ix,x,iy,y);
142 printf("\n %d %f %d %f", jx,x,jy,y);
143 printf("\n \n **********");
149 Int_t AliMUONsegmentationV01::Sector(Int_t ix, Int_t iy)
151 Int_t absix=TMath::Abs(ix);
152 Int_t absiy=TMath::Abs(iy);
154 for (Int_t i=0; i<fNsec; i++) {
155 if (absix<=fNpx[i][absiy]){
164 Float_t AliMUONsegmentationV01::GetAnod(Float_t xhit)
167 // Finds anod-wire position closest to xhit
168 Float_t wire= (xhit<0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
169 // printf("getanod: %f %f %f ",xhit, wire, fWireD*wire);
173 void AliMUONsegmentationV01::
174 GetPadIxy(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
176 // returns pad coordinates (ix,iy) for given real coordinates (x,y)
178 iy = (y>0)? Int_t(y/fDpy)+1 : Int_t(y/fDpy)-1;
179 if (iy > fNpy) iy= fNpy;
180 if (iy < -fNpy) iy=-fNpy;
184 Float_t absx=TMath::Abs(x);
185 Int_t absiy=TMath::Abs(iy);
186 for (Int_t i=0; isec < fNsec; i++) {
187 if (absx <= fCx[i][absiy]) {
193 ix= Int_t((absx-fCx[isec-1][absiy])/fDpxD[isec])
194 +fNpx[isec-1][absiy]+1;
195 } else if (isec == 0) {
196 ix= Int_t(absx/fDpxD[isec])+1;
198 ix=fNpx[fNsec-1][absiy]+1;
200 // printf("\n %d %d",isec,absiy);
205 void AliMUONsegmentationV01::
206 GetPadCxy(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
208 // returns real coordinates (x,y) for given pad coordinates (ix,iy)
210 y = (iy>0) ? Float_t(iy*fDpy)-fDpy/2. : Float_t(iy*fDpy)+fDpy/2.;
213 Int_t isec=Sector(ix,iy);
215 Int_t absix=TMath::Abs(ix);
216 Int_t absiy=TMath::Abs(iy);
218 x=fCx[isec-1][absiy]+(absix-fNpx[isec-1][absiy])*fDpxD[isec];
219 x=(ix>0) ? x-fDpxD[isec]/2 : -x+fDpxD[isec]/2;
226 void AliMUONsegmentationV01::
227 GetSuperPadIxy(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
229 ix = (x>0)? Int_t(x/fDpx)+1 : Int_t(x/fDpx)-1;
230 iy = (y>0)? Int_t(y/fDpy)+1 : Int_t(y/fDpy)-1;
233 void AliMUONsegmentationV01::
234 GetSuperPadCxy(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
236 x = (ix>0) ? Float_t(ix*fDpx)-fDpx/2. : Float_t(ix*fDpx)+fDpx/2.;
237 y = (iy>0) ? Float_t(iy*fDpy)-fDpy/2. : Float_t(iy*fDpy)+fDpy/2.;
240 void AliMUONsegmentationV01::SetPADSIZ(Float_t p1, Float_t p2)
246 void AliMUONsegmentationV01::
247 FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
250 // Find the wire position (center of charge distribution)
251 Float_t x0a=GetAnod(xhit);
253 // and take fNsigma*sigma around this center
254 Float_t x01=x0a - dx;
255 Float_t x02=x0a + dx;
256 Float_t y01=yhit - dy;
257 Float_t y02=yhit + dy;
259 // find the pads over which the charge distributes
260 GetPadIxy(x01,y01,fixmin,fiymin);
261 GetPadIxy(x02,y02,fixmax,fiymax);
265 // upper and lower limits should be checked
267 printf("\n FirstPad called");
268 printf("\n Hit Position %f %f",xhit,yhit);
269 printf("\n Closest wire %f", x0a);
270 printf("\n Integration limits: %i %i %i %i",fixmin,fixmax,fiymin,fiymax);
271 printf("\n Integration limits: %f %f %f %f \n",x01,x02,y01,y02);
274 // Set current pad to lower left corner
275 if (fixmax < fixmin) fixmax=fixmin;
276 if (fiymax < fiymin) fiymax=fiymin;
279 GetPadCxy(fix,fiy,fx,fy);
283 void AliMUONsegmentationV01::NextPad()
286 // Step to next pad in integration region
290 // step from left to right
291 if (fx < fxmax && fx != 0) {
294 } else if (fiy != fiymax) {
296 // get y-position of next row (yc), xc not used here
297 GetPadCxy(fix,fiy,xc,yc);
298 // get x-pad coordiante for 1 pad in row (fix)
299 GetPadIxy(fxmin,yc,fix,iyc);
301 printf("\n Error: Stepping outside integration region\n ");
303 GetPadCxy(fix,fiy,fx,fy);
304 fSector=Sector(fix,fiy);
305 // printf("\n this pad %f %f %d %d",fx,fy,fix,fiy);
309 Int_t AliMUONsegmentationV01::MorePads()
311 // Are there more pads in the integration region
313 if ((fx >= fxmax && fiy >= fiymax) || fy==0) {
320 void AliMUONsegmentationV01::SigGenInit(Float_t x,Float_t y,Float_t)
323 // Initialises pad and wire position during stepping
326 GetPadIxy(x,y,fixt,fiyt);
327 fiwt= (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
330 Int_t AliMUONsegmentationV01::SigGenCond(Float_t x,Float_t y,Float_t)
333 // Signal will be generated if particle crosses pad boundary or
334 // boundary between two wires.
336 GetPadIxy(x,y,ixt,iyt);
338 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
340 if ((ixt != fixt) || (iyt !=fiyt) || (iwt != fiwt)) {
347 void AliMUONsegmentationV01::
348 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
350 x1=fxt-fx-fDpxD[fSector]/2.;
351 x2=x1+fDpxD[fSector];
356 void AliMUONsegmentationV01::
357 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
359 const Float_t epsilon=fDpy/1000;
362 Int_t ixx, iyy, isec1;
364 Int_t isec0=Sector(iX,iY);
376 GetPadCxy(iX,iY,x,y);
377 GetPadIxy(x+epsilon,y+fDpy,ixx,iyy);
380 isec1=Sector(ixx,iyy);
383 // no sector boundary crossing
389 } else if (isec1 < isec0) {
390 // finer segmentation
400 // coarser segmenation
401 if (TMath::Odd(iX-fNpx[isec1-1][iY+1])) {
411 GetPadCxy(iX,iY,x,y);
412 GetPadIxy(x+epsilon,y-fDpy,ixx,iyy);
415 isec1=Sector(ixx,iyy);
418 // no sector boundary crossing
424 } else if (isec1 < isec0) {
425 // finer segmentation
435 // coarser segmenation
436 if (TMath::Odd(iX-fNpx[isec1-1][iY-1])) {
447 //___________________________________________
448 void AliMUONsegmentationV01::
449 FitXY(AliMUONRecCluster* Cluster,TClonesArray* MUONdigits)
450 // Default : Centre of gravity method
458 if (gAlice->TreeD()->GetReadEvent() != Cluster->GetCathod()+1)
459 // next line warns if in the future cathod 1 is not event 2 !
460 printf("ClusterFillXY : not reading the right cathod !\n");
461 for(Int_t clusDigit=Cluster->FirstDigitIndex();
462 clusDigit!=Cluster->InvalidDigitIndex();
463 clusDigit=Cluster->NextDigitIndex()) {
464 AliMUONdigit* pDigit=(AliMUONdigit*)MUONdigits->UncheckedAt(clusDigit);
465 GetPadCxy(pDigit->fPadX,pDigit->fPadY,xToAdd,yToAdd);
466 x+= xToAdd*pDigit->fSignal;
467 y+= yToAdd*pDigit->fSignal;
468 q+= (Float_t) pDigit->fSignal;