]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONSegmentationTriggerX.cxx
-New method to retrive the update Sternheimer parameters for the pemf
[u/mrichter/AliRoot.git] / MUON / AliMUONSegmentationTriggerX.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 /* $Id$ */
17
18 #include <TMath.h>
19 #include <TBRIK.h>
20 #include <TNode.h>
21 #include <TGeometry.h>
22
23 #include "AliMUON.h"
24 #include "AliMUONSegmentationTriggerX.h"
25 #include "AliMUONTriggerConstants.h"
26 #include "AliMUONChamber.h"
27 #include "AliRun.h"  // gAlice
28
29 ClassImp(AliMUONSegmentationTriggerX)
30
31 //------------------------------------------------------------------
32 void AliMUONSegmentationTriggerX::Init(Int_t chamber)
33 {
34 // intialize X segmentation 
35   AliMUON *pMUON  = (AliMUON *) gAlice->GetModule("MUON");
36   if(pMUON->GetDebug()>1) printf("%s: Initialize Trigger Chamber Geometry X\n",ClassName());
37   AliMUONSegmentationTrigger::Init(chamber);
38
39 // calculate x & y position of X strips
40   Int_t nModule=AliMUONTriggerConstants::Nmodule();
41   for (Int_t imodule=0; imodule<nModule; imodule++) {
42     Float_t width=StripSizeX(AliMUONTriggerConstants::ModuleId(imodule));     
43     Int_t nStrip=AliMUONTriggerConstants::NstripX(imodule);
44     for (Int_t istrip=0; istrip<nStrip; istrip++){    
45       fXofxsmin[imodule][istrip] = AliMUONTriggerConstants::XcMin(imodule)*fZscale;
46       fXofxsmax[imodule][istrip] = AliMUONTriggerConstants::XcMax(imodule)*fZscale;
47       
48       fYofxsmin[imodule][istrip] = (fYcmin[imodule]+width*(istrip))*fZscale;
49       fYofxsmax[imodule][istrip] = (fYcmin[imodule]+width*(istrip+1))*fZscale;
50     }
51   }
52 }
53
54 //------------------------------------------------------------------
55 void AliMUONSegmentationTriggerX::GetPadI(Float_t x,Float_t y,Int_t &ix,Int_t &iy) 
56 {
57 //  Returns pad coordinates (ix,iy) for given real coordinates (x,y)
58 //  x,y = real coordinates; ix = module number , iy = strip number
59   ix = 0;    
60   iy = 0;
61   Int_t nModule=AliMUONTriggerConstants::Nmodule();
62   for (Int_t imodule=0; imodule<nModule; imodule++) {
63       Int_t nStrip=AliMUONTriggerConstants::NstripX(imodule);
64       for (Int_t istrip=0; istrip<nStrip; istrip++){
65           if (x>fXofxsmin[imodule][istrip]&&x<fXofxsmax[imodule][istrip]&&
66               y>fYofxsmin[imodule][istrip]&&y<fYofxsmax[imodule][istrip]){
67               ix = AliMUONTriggerConstants::ModuleId(imodule);
68               iy = istrip;
69           }
70       }
71   }
72 }
73
74 //------------------------------------------------------------------
75 void AliMUONSegmentationTriggerX::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y) 
76 {
77 //  Returns real coordinates (x,y) for given pad coordinates (ix,iy)
78 //  ix = module number , iy = strip number;  x,y = center of strip
79   x = 0.;    
80   y = 0.; 
81   Int_t nModule=AliMUONTriggerConstants::Nmodule();
82
83   for (Int_t imodule=0; imodule<nModule; imodule++) {
84     if (AliMUONTriggerConstants::ModuleId(imodule)==ix){
85       x=fXofxsmin[imodule][iy]+(fXofxsmax[imodule][iy]-fXofxsmin[imodule][iy])/2.;
86       y=fYofxsmin[imodule][iy]+(fYofxsmax[imodule][iy]-fYofxsmin[imodule][iy])/2.;
87     }
88   }
89 }
90
91 //------------------------------------------------------------------
92 void AliMUONSegmentationTriggerX::SetPadSize(Float_t p1, Float_t p2)
93 {
94 //  Sets the padsize 
95 //  
96   fDpx=p1;
97   fDpy=p2;
98 }
99
100 //------------------------------------------------------------------
101 void AliMUONSegmentationTriggerX::
102 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10]){
103 // Returns list of 10 next neighbours for given X strip (ix, iy)  
104 // neighbour number 4 in the list -                     
105 // neighbour number 3 in the list  |                    
106 // neighbour number 2 in the list  |_ Upper part             
107 // neighbour number 1 in the list  |            
108 // neighbour number 0 in the list -           
109 //      X strip (ix, iy) 
110 // neighbour number 5 in the list -       
111 // neighbour number 6 in the list  | _ Lower part
112 // neighbour number 7 in the list  |
113 // neighbour number 8 in the list  | 
114 // neighbour number 9 in the list -
115   
116   Int_t absiX = TMath::Abs(iX); 
117   Int_t numModule = ModuleNumber(absiX);   // module number Id.
118   Int_t nStrip = AliMUONTriggerConstants::NstripX(numModule); //numb of strips
119   Int_t iCandidateUp, iCandidateDo;
120   Int_t j;
121
122   *Nlist = 10;
123   for (Int_t i=0; i<10; i++) Xlist[i]=Ylist[i]=0;
124
125   if (iY < nStrip) {
126
127     for (Int_t i=0; i<5; i++) {
128       j = i + 5;
129       iCandidateUp = iY + (i + 1);
130       iCandidateDo = iY - (i + 1);
131       if (iCandidateUp < nStrip) { 
132         Xlist[i] = iX;
133         Ylist[i] = iCandidateUp;  
134       }
135       if (iCandidateDo >= 0) { 
136         Xlist[j] = iX;
137         Ylist[j] = iCandidateDo;  
138       }
139     }
140     
141   } // iY < nStrip
142 }
143
144 //------------------------------------------------------------------   
145 void AliMUONSegmentationTriggerX::SetPad(Int_t ix, Int_t iy)
146 {
147   // Sets virtual pad coordinates, needed for evaluating pad response 
148   // outside the tracking program
149   GetPadC(ix,iy,fX,fY);
150   GetPadI(fX,fY,fIx,fIy);
151   fSector=Sector(ix,iy);
152 }
153
154 //------------------------------------------------------------------   
155 Int_t AliMUONSegmentationTriggerX::ISector() 
156 { return fSector;}
157
158 //------------------------------------------------------------------   
159 Int_t AliMUONSegmentationTriggerX::Ix()
160 { return fIx;}
161
162 //------------------------------------------------------------------   
163
164 Int_t AliMUONSegmentationTriggerX::Iy()
165 { return fIy;}
166
167 //------------------------------------------------------------------
168 Float_t AliMUONSegmentationTriggerX::Dpx(Int_t isec) const
169
170 // returns x size of x strips for sector isec
171     
172   if (isec==1) {
173     return 17.0*fZscale;
174   } else if (isec==2) {
175     return 34.0*fZscale;
176   } else if (isec==3) {
177     return 34.0*fZscale;
178   } else if (isec==4) {
179     return 34.0*fZscale;
180   } else if (isec==5) {
181     return 34.0*fZscale;
182   } else if (isec==6) {
183     return 68.0*fZscale;
184   } else {
185     return 0.;
186   }
187 }
188
189 //------------------------------------------------------------------
190 Float_t AliMUONSegmentationTriggerX::Dpy(Int_t isec) const
191
192 // returns y size of x strips for sector isec
193
194   if (isec==1) {
195     return 1.0625*fZscale;
196   } else if (isec==2) {
197     return 1.0625*fZscale;
198   } else if (isec==3) {
199     return 1.0625*fZscale;
200   } else if (isec==4) {
201     return 2.125*fZscale;
202   } else if (isec==5) {
203     return 4.25*fZscale;
204   } else if (isec==6) {
205     return 4.25*fZscale;
206   } else {
207     return 0.;  
208   }   
209 }
210
211 //------------------------------------------------------------------   
212 void AliMUONSegmentationTriggerX::GetPadI(Float_t x, Float_t y, Float_t /*z*/, Int_t &ix, Int_t &iy) 
213 {
214   GetPadI(x, y, ix, iy);
215 }
216
217 //------------------------------------------------------------------   
218 void AliMUONSegmentationTriggerX::SetHit(Float_t xhit, Float_t yhit)
219
220 // set hit during disIntegration
221 AliMUONSegmentationTrigger::SetHit(xhit,yhit);
222 }
223 //------------------------------------------------------------------   
224 void AliMUONSegmentationTriggerX::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
225 {
226   SetHit(xhit, yhit);
227 }
228
229 //------------------------------------------------------------------   
230 Int_t AliMUONSegmentationTriggerX::Sector(Int_t ix, Int_t /*iy*/) 
231 {
232 // Returns sector number for given module
233 // 
234     
235   Int_t absix=TMath::Abs(ix);
236   Int_t iwidth=Int_t(StripSizeX(absix));
237
238   if (absix==52) {
239     return 1;
240   } else if (absix==41||absix==61) {
241     return 2;
242   } else if (iwidth==1) {
243     return 3;
244   } else if (iwidth==2) {
245     return 4;
246   } else if ((absix>=11&&absix<17)||(absix>=91&&absix<97)) {
247     return 5;
248   } else if (iwidth==4) {
249     return 6;
250   } else {
251     return 0;
252   }
253 }
254
255 //------------------------------------------------------------------   
256 void AliMUONSegmentationTriggerX::
257 IntegrationLimits(Float_t& x1, Float_t& x2, Float_t& x3, Float_t& x4) 
258
259 // returns quantities needed to evaluate neighbour strip response
260
261   Int_t ix,iy;
262   Float_t xstrip,ystrip;
263   GetPadI(fXhit,fYhit,ix,iy);  
264   GetPadC(ix,iy,xstrip,ystrip);  
265   x1=fYhit;        // hit y position
266   x2=ystrip;       // y coordinate of the main strip
267   x3=fY;           // current strip real y coordinate  
268   //  width=StripSizeX(ix);   // width of the main strip 
269
270   // find the position of the 2 borders of the current strip
271   Float_t ymin = fYofxsmin[ModuleNumber(fIx)][fIy];
272   Float_t ymax = fYofxsmax[ModuleNumber(fIx)][fIy];
273   
274   // dist. between the hit and the closest border of the current strip
275   x4 = (TMath::Abs(ymax-x1) > TMath::Abs(ymin-x1)) ? 
276     TMath::Abs(ymin-x1):TMath::Abs(ymax-x1);    
277
278 }
279
280 //------------------------------------------------------------------   
281 void AliMUONSegmentationTriggerX::Draw(const char* opt) const
282 {
283 // Draw method for event display  
284   if (!strcmp(opt,"eventdisplay")) { 
285     TNode *node, *nodeS;
286     char nameChamber[10], nameNode[11];
287     char nameSense1[10], nameSense2[10], nameSense3[10], nameSense4[10];
288     
289     TNode* top=gAlice->GetGeometry()->GetNode("alice"); 
290     sprintf(nameChamber,"C_MUON%d",fId+1);
291     new TBRIK(nameChamber,"Mother","void",340.,340.,0.25);
292     top->cd();
293     sprintf(nameNode,"MUON%d",100+fId+1);
294     node = new TNode(nameNode,"Chambernode",nameChamber,0,0,fChamber->Z(),"");
295     node->SetLineColor(kBlack);    
296     AliMUON *pMUON  = (AliMUON *) gAlice->GetModule("MUON");
297     (pMUON->Nodes())->Add(node);
298     
299     sprintf(nameSense1,"S1_MUON%d",fId+1);
300     sprintf(nameSense2,"S2_MUON%d",fId+1);
301     sprintf(nameSense3,"S3_MUON%d",fId+1);
302     sprintf(nameSense4,"S4_MUON%d",fId+1);
303     
304     for (Int_t imodule=0; imodule<AliMUONTriggerConstants::Nmodule(); imodule++) {    
305       Int_t idModule=AliMUONTriggerConstants::ModuleId(imodule);
306       
307       if (TMath::Abs(idModule)!=51) {    
308         
309         Int_t nStripX=AliMUONTriggerConstants::NstripX(imodule);
310         Float_t xmin=fXofxsmin[imodule][0];
311         Float_t xmax=fXofxsmax[imodule][nStripX-1];
312         Float_t ymin=fYofxsmin[imodule][0];
313         Float_t ymax=fYofxsmax[imodule][nStripX-1];
314         Float_t xpos=xmin+(xmax-xmin)/2.;
315         Float_t ypos=ymin+(ymax-ymin)/2.;
316         Float_t halfx=(xmax-xmin)/2.;
317         Float_t halfy=(ymax-ymin)/2.;
318         
319         if (idModule==11) 
320           new TBRIK(nameSense1,"Module","void",halfx,halfy,0.25);   
321         if (idModule==17) 
322           new TBRIK(nameSense2,"Module","void",halfx,halfy,0.25);   
323         if (idModule==41) 
324           new TBRIK(nameSense3,"Module","void",halfx,halfy,0.25);   
325         if (idModule==52) 
326           new TBRIK(nameSense4,"Module","void",halfx,halfy,0.25); 
327         node->cd();
328         sprintf(nameNode,"S_MUON%d",1000*fId+1+imodule);
329         
330         if (TMath::Abs(idModule)==41||TMath::Abs(idModule)==61) {
331           nodeS = new TNode(nameNode,"Module",nameSense3,xpos,ypos,0,"");
332         } else if (TMath::Abs(idModule)==52) {
333           nodeS = new TNode(nameNode,"Module",nameSense4,xpos,ypos,0,"");
334         } else if (TMath::Abs((idModule-Int_t(idModule/10)*10.))!=7) {
335           nodeS = new TNode(nameNode,"Module",nameSense1,xpos,ypos,0,"");
336         } else {
337           //    } else if (TMath::Abs((idModule-Int_t(idModule/10)*10.))==7) {
338           nodeS = new TNode(nameNode,"Module",nameSense2,xpos,ypos,0,"");
339         }
340         nodeS->SetLineColor(kBlue);
341         node->cd();
342       }
343     }
344   }
345 }
346
347
348
349