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