]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONSegmentationTriggerX.cxx
Sign error for bz corrected.
[u/mrichter/AliRoot.git] / MUON / AliMUONSegmentationTriggerX.cxx
CommitLineData
a9e2aefa 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
88cb7938 16/* $Id$ */
a9e2aefa 17
5fd73042 18#include <TMath.h>
19#include <TBRIK.h>
20#include <TNode.h>
21#include <TGeometry.h>
22
23#include "AliMUON.h"
a9e2aefa 24#include "AliMUONSegmentationTriggerX.h"
3f2cdba8 25#include "AliMUONTriggerConstants.h"
a9e2aefa 26#include "AliMUONChamber.h"
5fd73042 27#include "AliRun.h" // gAlice
30178c30 28
a9e2aefa 29ClassImp(AliMUONSegmentationTriggerX)
3f2cdba8 30
31//------------------------------------------------------------------
d81db581 32void AliMUONSegmentationTriggerX::Init(Int_t chamber)
a9e2aefa 33{
3f2cdba8 34// intialize X segmentation
9e1a0ddb 35 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
ef077202 36 if(pMUON->GetDebug()>1) printf("%s: Initialize Trigger Chamber Geometry X\n",ClassName());
d81db581 37 AliMUONSegmentationTrigger::Init(chamber);
a9e2aefa 38
39// calculate x & y position of X strips
3f2cdba8 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;
a9e2aefa 47
3f2cdba8 48 fYofxsmin[imodule][istrip] = (fYcmin[imodule]+width*(istrip))*fZscale;
49 fYofxsmax[imodule][istrip] = (fYcmin[imodule]+width*(istrip+1))*fZscale;
a9e2aefa 50 }
51 }
52}
53
54//------------------------------------------------------------------
c3eff6ad 55void AliMUONSegmentationTriggerX::GetPadI(Float_t x,Float_t y,Int_t &ix,Int_t &iy)
56{
a9e2aefa 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;
3f2cdba8 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 }
a9e2aefa 70 }
a9e2aefa 71 }
72}
73
74//------------------------------------------------------------------
c3eff6ad 75void AliMUONSegmentationTriggerX::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
76{
a9e2aefa 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.;
3f2cdba8 81 Int_t nModule=AliMUONTriggerConstants::Nmodule();
82
83 for (Int_t imodule=0; imodule<nModule; imodule++) {
84 if (AliMUONTriggerConstants::ModuleId(imodule)==ix){
a9e2aefa 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//------------------------------------------------------------------
92void AliMUONSegmentationTriggerX::SetPadSize(Float_t p1, Float_t p2)
93{
94// Sets the padsize
95//
96 fDpx=p1;
97 fDpy=p2;
98}
99
100//------------------------------------------------------------------
101void AliMUONSegmentationTriggerX::
03f221a7 102Neighbours(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 }
a9e2aefa 139 }
03f221a7 140
141 } // iY < nStrip
a9e2aefa 142}
143
144//------------------------------------------------------------------
145void AliMUONSegmentationTriggerX::SetPad(Int_t ix, Int_t iy)
146{
147 // Sets virtual pad coordinates, needed for evaluating pad response
148 // outside the tracking program
ecfa008b 149 GetPadC(ix,iy,fX,fY);
150 GetPadI(fX,fY,fIx,fIy);
a9e2aefa 151 fSector=Sector(ix,iy);
152}
153
154//------------------------------------------------------------------
c3eff6ad 155Int_t AliMUONSegmentationTriggerX::ISector()
a9e2aefa 156{ return fSector;}
157
158//------------------------------------------------------------------
159Int_t AliMUONSegmentationTriggerX::Ix()
ecfa008b 160{ return fIx;}
a9e2aefa 161
162//------------------------------------------------------------------
c3eff6ad 163
a9e2aefa 164Int_t AliMUONSegmentationTriggerX::Iy()
ecfa008b 165{ return fIy;}
a9e2aefa 166
167//------------------------------------------------------------------
c3eff6ad 168Float_t AliMUONSegmentationTriggerX::Dpx(Int_t isec) const
3f2cdba8 169{
170// returns x size of x strips for sector isec
a9e2aefa 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//------------------------------------------------------------------
c3eff6ad 190Float_t AliMUONSegmentationTriggerX::Dpy(Int_t isec) const
3f2cdba8 191{
192// returns y size of x strips for sector isec
a9e2aefa 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
e889a146 211//------------------------------------------------------------------
212void 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
a9e2aefa 217//------------------------------------------------------------------
218void AliMUONSegmentationTriggerX::SetHit(Float_t xhit, Float_t yhit)
3f2cdba8 219{
220// set hit during disIntegration
221AliMUONSegmentationTrigger::SetHit(xhit,yhit);
222}
e889a146 223//------------------------------------------------------------------
224void AliMUONSegmentationTriggerX::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
225{
226 SetHit(xhit, yhit);
227}
a9e2aefa 228
229//------------------------------------------------------------------
e889a146 230Int_t AliMUONSegmentationTriggerX::Sector(Int_t ix, Int_t /*iy*/)
a9e2aefa 231{
232// Returns sector number for given module
233//
3f2cdba8 234
a9e2aefa 235 Int_t absix=TMath::Abs(ix);
236 Int_t iwidth=Int_t(StripSizeX(absix));
3f2cdba8 237
a9e2aefa 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//------------------------------------------------------------------
256void AliMUONSegmentationTriggerX::
03f221a7 257IntegrationLimits(Float_t& x1, Float_t& x2, Float_t& x3, Float_t& x4)
3f2cdba8 258{
259// returns quantities needed to evaluate neighbour strip response
260
a9e2aefa 261 Int_t ix,iy;
262 Float_t xstrip,ystrip;
ecfa008b 263 GetPadI(fXhit,fYhit,ix,iy);
a30a000f 264 GetPadC(ix,iy,xstrip,ystrip);
ecfa008b 265 x1=fYhit; // hit y position
a9e2aefa 266 x2=ystrip; // y coordinate of the main strip
ecfa008b 267 x3=fY; // current strip real y coordinate
03f221a7 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
a9e2aefa 278}
279
5fd73042 280//------------------------------------------------------------------
281void AliMUONSegmentationTriggerX::Draw(const char* opt) const
282{
de05461e 283// Draw method for event display
5fd73042 284 if (!strcmp(opt,"eventdisplay")) {
285 TNode *node, *nodeS;
5eb14807 286 char nameChamber[10], nameNode[11];
5fd73042 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}
a9e2aefa 346
347
de05461e 348
349