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