]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONSegmentationTriggerX.cxx
Dummy return values added
[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 /*
17 $Log$
18 Revision 1.10  2000/12/21 22:12:41  morsch
19 Clean-up of coding rule violations,
20
21 Revision 1.9  2000/11/20 21:44:17  pcrochet
22 some modifications to account for the new class AliMUONResponseTriggerV1
23
24 Revision 1.8  2000/11/12 17:17:03  pcrochet
25 BuildGeometry of AliMUON for trigger chambers delegated to AliMUONSegmentationTriggerX (same strategy as for tracking chambers)
26
27 Revision 1.7  2000/10/03 21:48:07  morsch
28 Adopt to const declaration of some of the methods in AliSegmentation.
29
30 Revision 1.6  2000/10/02 16:58:29  egangler
31 Cleaning of the code :
32 -> coding conventions
33 -> void Streamers
34 -> some useless includes removed or replaced by "class" statement
35
36 Revision 1.5  2000/07/03 11:54:57  morsch
37 AliMUONSegmentation and AliMUONHitMap have been replaced by AliSegmentation and AliHitMap in STEER
38 The methods GetPadIxy and GetPadXxy of AliMUONSegmentation have changed name to GetPadI and GetPadC.
39
40 Revision 1.4  2000/06/29 12:34:09  morsch
41 AliMUONSegmentation class has been made independent of AliMUONChamber. This makes
42 it usable with any other geometry class. The link to the object to which it belongs is
43 established via an index. This assumes that there exists a global geometry manager
44 from which the pointer to the parent object can be obtained (in our case gAlice).
45
46 Revision 1.3  2000/06/26 10:01:26  pcrochet
47 global variables removed
48
49 Revision 1.2  2000/06/15 07:58:48  morsch
50 Code from MUON-dev joined
51
52 Revision 1.1.2.1  2000/06/09 21:51:03  morsch
53 Code from AliMUONSegResTrigger.cxx
54
55 */
56
57
58
59 /*
60 Old Log:
61 Revision 1.1.2.4  2000/04/26 12:33:25  morsch
62 Minor changes in some methods (CP)
63
64 Revision 1.1.2.3  2000/03/20 18:14:16  morsch
65 Missing sector added.
66
67 Revision 1.1.2.2  2000/02/20 07:50:49  morsch
68 Bugs in Dpx, Dpy and ISector methods corrected (P.C.)
69
70 Revision 1.1.2.1  2000/02/17 14:33:49  morsch
71 Draft version from P. Crochet
72
73 */
74
75 #include <TMath.h>
76 #include <TBRIK.h>
77 #include <TNode.h>
78 #include <TGeometry.h>
79
80 #include "AliMUON.h"
81 #include "AliMUONSegmentationTriggerX.h"
82 #include "AliMUONTriggerConstants.h"
83 #include "TMath.h"
84 #include "TRandom.h"
85 #include "TArc.h"
86 #include "AliMUONChamber.h"
87 #include "AliRun.h"  // gAlice
88 #include <iostream.h> 
89 ClassImp(AliMUONSegmentationTriggerX)
90
91 //------------------------------------------------------------------
92 void AliMUONSegmentationTriggerX::Init(Int_t chamber)
93 {
94 // intialize X segmentation 
95   AliMUON *pMUON  = (AliMUON *) gAlice->GetModule("MUON");
96   if(pMUON->GetDebug()) cout << ClassName() << ": Initialize Trigger Chamber Geometry X " << "\n";    
97   AliMUONSegmentationTrigger::Init(chamber);
98
99 // calculate x & y position of X strips
100   Int_t nModule=AliMUONTriggerConstants::Nmodule();
101   for (Int_t imodule=0; imodule<nModule; imodule++) {
102     Float_t width=StripSizeX(AliMUONTriggerConstants::ModuleId(imodule));     
103     Int_t nStrip=AliMUONTriggerConstants::NstripX(imodule);
104     for (Int_t istrip=0; istrip<nStrip; istrip++){    
105       fXofxsmin[imodule][istrip] = AliMUONTriggerConstants::XcMin(imodule)*fZscale;
106       fXofxsmax[imodule][istrip] = AliMUONTriggerConstants::XcMax(imodule)*fZscale;
107       
108       fYofxsmin[imodule][istrip] = (fYcmin[imodule]+width*(istrip))*fZscale;
109       fYofxsmax[imodule][istrip] = (fYcmin[imodule]+width*(istrip+1))*fZscale;
110     }
111   }
112 }
113
114 //------------------------------------------------------------------
115 void AliMUONSegmentationTriggerX::GetPadI(Float_t x,Float_t y,Int_t &ix,Int_t &iy) 
116 {
117 //  Returns pad coordinates (ix,iy) for given real coordinates (x,y)
118 //  x,y = real coordinates; ix = module number , iy = strip number
119   ix = 0;    
120   iy = 0;
121   Int_t nModule=AliMUONTriggerConstants::Nmodule();
122   for (Int_t imodule=0; imodule<nModule; imodule++) {
123       Int_t nStrip=AliMUONTriggerConstants::NstripX(imodule);
124       for (Int_t istrip=0; istrip<nStrip; istrip++){
125           if (x>fXofxsmin[imodule][istrip]&&x<fXofxsmax[imodule][istrip]&&
126               y>fYofxsmin[imodule][istrip]&&y<fYofxsmax[imodule][istrip]){
127               ix = AliMUONTriggerConstants::ModuleId(imodule);
128               iy = istrip;
129           }
130       }
131   }
132 }
133
134 //------------------------------------------------------------------
135 void AliMUONSegmentationTriggerX::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y) 
136 {
137 //  Returns real coordinates (x,y) for given pad coordinates (ix,iy)
138 //  ix = module number , iy = strip number;  x,y = center of strip
139   x = 0.;    
140   y = 0.; 
141   Int_t nModule=AliMUONTriggerConstants::Nmodule();
142
143   for (Int_t imodule=0; imodule<nModule; imodule++) {
144     if (AliMUONTriggerConstants::ModuleId(imodule)==ix){
145       x=fXofxsmin[imodule][iy]+(fXofxsmax[imodule][iy]-fXofxsmin[imodule][iy])/2.;
146       y=fYofxsmin[imodule][iy]+(fYofxsmax[imodule][iy]-fYofxsmin[imodule][iy])/2.;
147     }
148   }
149 }
150
151 //------------------------------------------------------------------
152 void AliMUONSegmentationTriggerX::SetPadSize(Float_t p1, Float_t p2)
153 {
154 //  Sets the padsize 
155 //  
156   fDpx=p1;
157   fDpy=p2;
158 }
159
160 //------------------------------------------------------------------
161 void AliMUONSegmentationTriggerX::
162 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10]){
163 // Returns list of 10 next neighbours for given X strip (ix, iy)  
164 // neighbour number 4 in the list -                     
165 // neighbour number 3 in the list  |                    
166 // neighbour number 2 in the list  |_ Upper part             
167 // neighbour number 1 in the list  |            
168 // neighbour number 0 in the list -           
169 //      X strip (ix, iy) 
170 // neighbour number 5 in the list -       
171 // neighbour number 6 in the list  | _ Lower part
172 // neighbour number 7 in the list  |
173 // neighbour number 8 in the list  | 
174 // neighbour number 9 in the list -
175   
176   Int_t absiX = TMath::Abs(iX); 
177   Int_t numModule = ModuleNumber(absiX);   // module number Id.
178   Int_t nStrip = AliMUONTriggerConstants::NstripX(numModule); //numb of strips
179   Int_t iCandidateUp, iCandidateDo;
180   Int_t j;
181
182   *Nlist = 10;
183   for (Int_t i=0; i<10; i++) Xlist[i]=Ylist[i]=0;
184
185   if (iY < nStrip) {
186
187     for (Int_t i=0; i<5; i++) {
188       j = i + 5;
189       iCandidateUp = iY + (i + 1);
190       iCandidateDo = iY - (i + 1);
191       if (iCandidateUp < nStrip) { 
192         Xlist[i] = iX;
193         Ylist[i] = iCandidateUp;  
194       }
195       if (iCandidateDo >= 0) { 
196         Xlist[j] = iX;
197         Ylist[j] = iCandidateDo;  
198       }
199     }
200     
201   } // iY < nStrip
202 }
203
204 //------------------------------------------------------------------   
205 void AliMUONSegmentationTriggerX::SetPad(Int_t ix, Int_t iy)
206 {
207   // Sets virtual pad coordinates, needed for evaluating pad response 
208   // outside the tracking program
209   GetPadC(ix,iy,fX,fY);
210   GetPadI(fX,fY,fIx,fIy);
211   fSector=Sector(ix,iy);
212 }
213
214 //------------------------------------------------------------------   
215 Int_t AliMUONSegmentationTriggerX::ISector() 
216 { return fSector;}
217
218 //------------------------------------------------------------------   
219 Int_t AliMUONSegmentationTriggerX::Ix()
220 { return fIx;}
221
222 //------------------------------------------------------------------   
223
224 Int_t AliMUONSegmentationTriggerX::Iy()
225 { return fIy;}
226
227 //------------------------------------------------------------------
228 Float_t AliMUONSegmentationTriggerX::Dpx(Int_t isec) const
229
230 // returns x size of x strips for sector isec
231     
232   if (isec==1) {
233     return 17.0*fZscale;
234   } else if (isec==2) {
235     return 34.0*fZscale;
236   } else if (isec==3) {
237     return 34.0*fZscale;
238   } else if (isec==4) {
239     return 34.0*fZscale;
240   } else if (isec==5) {
241     return 34.0*fZscale;
242   } else if (isec==6) {
243     return 68.0*fZscale;
244   } else {
245     return 0.;
246   }
247 }
248
249 //------------------------------------------------------------------
250 Float_t AliMUONSegmentationTriggerX::Dpy(Int_t isec) const
251
252 // returns y size of x strips for sector isec
253
254   if (isec==1) {
255     return 1.0625*fZscale;
256   } else if (isec==2) {
257     return 1.0625*fZscale;
258   } else if (isec==3) {
259     return 1.0625*fZscale;
260   } else if (isec==4) {
261     return 2.125*fZscale;
262   } else if (isec==5) {
263     return 4.25*fZscale;
264   } else if (isec==6) {
265     return 4.25*fZscale;
266   } else {
267     return 0.;  
268   }   
269 }
270
271 //------------------------------------------------------------------   
272 void AliMUONSegmentationTriggerX::SetHit(Float_t xhit, Float_t yhit)
273
274 // set hit during disIntegration
275 AliMUONSegmentationTrigger::SetHit(xhit,yhit);
276 }
277
278 //------------------------------------------------------------------   
279 Int_t AliMUONSegmentationTriggerX::Sector(Int_t ix, Int_t iy) 
280 {
281 // Returns sector number for given module
282 // 
283     
284   Int_t absix=TMath::Abs(ix);
285   Int_t iwidth=Int_t(StripSizeX(absix));
286
287   if (absix==52) {
288     return 1;
289   } else if (absix==41||absix==61) {
290     return 2;
291   } else if (iwidth==1) {
292     return 3;
293   } else if (iwidth==2) {
294     return 4;
295   } else if ((absix>=11&&absix<17)||(absix>=91&&absix<97)) {
296     return 5;
297   } else if (iwidth==4) {
298     return 6;
299   } else {
300     return 0;
301   }
302 }
303
304 //------------------------------------------------------------------   
305 void AliMUONSegmentationTriggerX::
306 IntegrationLimits(Float_t& x1, Float_t& x2, Float_t& x3, Float_t& x4) 
307
308 // returns quantities needed to evaluate neighbour strip response
309
310   Int_t ix,iy;
311   Float_t xstrip,ystrip;
312   GetPadI(fXhit,fYhit,ix,iy);  
313   GetPadC(ix,iy,xstrip,ystrip);  
314   x1=fYhit;        // hit y position
315   x2=ystrip;       // y coordinate of the main strip
316   x3=fY;           // current strip real y coordinate  
317   //  width=StripSizeX(ix);   // width of the main strip 
318
319   // find the position of the 2 borders of the current strip
320   Float_t ymin = fYofxsmin[ModuleNumber(fIx)][fIy];
321   Float_t ymax = fYofxsmax[ModuleNumber(fIx)][fIy];
322   
323   // dist. between the hit and the closest border of the current strip
324   x4 = (TMath::Abs(ymax-x1) > TMath::Abs(ymin-x1)) ? 
325     TMath::Abs(ymin-x1):TMath::Abs(ymax-x1);    
326
327 }
328
329 //------------------------------------------------------------------   
330 void AliMUONSegmentationTriggerX::Draw(const char* opt) const
331 {
332 // Draw method for event display  
333   if (!strcmp(opt,"eventdisplay")) { 
334     TNode *node, *nodeS;
335     char nameChamber[10], nameNode[10];
336     char nameSense1[10], nameSense2[10], nameSense3[10], nameSense4[10];
337     
338     TNode* top=gAlice->GetGeometry()->GetNode("alice"); 
339     sprintf(nameChamber,"C_MUON%d",fId+1);
340     new TBRIK(nameChamber,"Mother","void",340.,340.,0.25);
341     top->cd();
342     sprintf(nameNode,"MUON%d",100+fId+1);
343     node = new TNode(nameNode,"Chambernode",nameChamber,0,0,fChamber->Z(),"");
344     node->SetLineColor(kBlack);    
345     AliMUON *pMUON  = (AliMUON *) gAlice->GetModule("MUON");
346     (pMUON->Nodes())->Add(node);
347     
348     sprintf(nameSense1,"S1_MUON%d",fId+1);
349     sprintf(nameSense2,"S2_MUON%d",fId+1);
350     sprintf(nameSense3,"S3_MUON%d",fId+1);
351     sprintf(nameSense4,"S4_MUON%d",fId+1);
352     
353     for (Int_t imodule=0; imodule<AliMUONTriggerConstants::Nmodule(); imodule++) {    
354       Int_t idModule=AliMUONTriggerConstants::ModuleId(imodule);
355       
356       if (TMath::Abs(idModule)!=51) {    
357         
358         Int_t nStripX=AliMUONTriggerConstants::NstripX(imodule);
359         Float_t xmin=fXofxsmin[imodule][0];
360         Float_t xmax=fXofxsmax[imodule][nStripX-1];
361         Float_t ymin=fYofxsmin[imodule][0];
362         Float_t ymax=fYofxsmax[imodule][nStripX-1];
363         Float_t xpos=xmin+(xmax-xmin)/2.;
364         Float_t ypos=ymin+(ymax-ymin)/2.;
365         Float_t halfx=(xmax-xmin)/2.;
366         Float_t halfy=(ymax-ymin)/2.;
367         
368         if (idModule==11) 
369           new TBRIK(nameSense1,"Module","void",halfx,halfy,0.25);   
370         if (idModule==17) 
371           new TBRIK(nameSense2,"Module","void",halfx,halfy,0.25);   
372         if (idModule==41) 
373           new TBRIK(nameSense3,"Module","void",halfx,halfy,0.25);   
374         if (idModule==52) 
375           new TBRIK(nameSense4,"Module","void",halfx,halfy,0.25); 
376         node->cd();
377         sprintf(nameNode,"S_MUON%d",1000*fId+1+imodule);
378         
379         if (TMath::Abs(idModule)==41||TMath::Abs(idModule)==61) {
380           nodeS = new TNode(nameNode,"Module",nameSense3,xpos,ypos,0,"");
381         } else if (TMath::Abs(idModule)==52) {
382           nodeS = new TNode(nameNode,"Module",nameSense4,xpos,ypos,0,"");
383         } else if (TMath::Abs((idModule-Int_t(idModule/10)*10.))!=7) {
384           nodeS = new TNode(nameNode,"Module",nameSense1,xpos,ypos,0,"");
385         } else {
386           //    } else if (TMath::Abs((idModule-Int_t(idModule/10)*10.))==7) {
387           nodeS = new TNode(nameNode,"Module",nameSense2,xpos,ypos,0,"");
388         }
389         nodeS->SetLineColor(kBlue);
390         node->cd();
391       }
392     }
393   }
394 }
395
396
397
398