]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONTriggerCircuit.cxx
Message commented out
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerCircuit.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
20 #include "AliMUONTriggerCircuit.h"
21 #include "AliRun.h"
22 #include "AliMUON.h"
23 #include "AliMUONTriggerConstants.h"
24 #include "AliSegmentation.h"
25 #include "AliMUONChamber.h"
26 #include "AliMUONConstants.h"
27 #include "AliLog.h"
28
29 ClassImp(AliMUONTriggerCircuit)
30
31 //----------------------------------------------------------------------
32 AliMUONTriggerCircuit::AliMUONTriggerCircuit()
33   : TObject() 
34 {
35 // Constructor
36   fSegmentation=0;
37   fIdCircuit=0;
38   fX2m=0;
39   fX2ud=0;
40   fOrMud[0]=fOrMud[1]=0;
41   Int_t i;  
42   for (i=0; i<4; i++) {
43     for (Int_t j=0; j<32; j++) {      
44       fXcode[i][j]=0;
45       fYcode[i][j]=0;
46     }
47   }
48   for (i=0; i<16; i++) { fXpos11[i]=0.; }
49   for (i=0; i<31; i++) { fYpos11[i]=0.; }
50   for (i=0; i<63; i++) { fYpos21[i]=0.; }
51 }
52
53 //----------------------------------------------------------------------
54 AliMUONTriggerCircuit::AliMUONTriggerCircuit(const AliMUONTriggerCircuit& theMUONTriggerCircuit)
55   : TObject(theMUONTriggerCircuit)
56 {
57 // Protected copy constructor
58
59   AliFatal("Not implemented.");
60 }
61
62 //----------------------------------------------------------------------
63 AliMUONTriggerCircuit & 
64 AliMUONTriggerCircuit::operator=(const AliMUONTriggerCircuit& rhs)
65 {
66 // Protected assignement operator
67
68   if (this == &rhs) return *this;
69
70   AliFatal("Not implemented.");
71     
72   return *this;  
73 }
74
75 //----------------------------------------------------------------------
76 void AliMUONTriggerCircuit::Init(Int_t iCircuit) {
77 // initialize circuit characteristics
78   fIdCircuit=AliMUONTriggerConstants::CircuitId(iCircuit);
79   LoadX2();
80   LoadXCode();
81   LoadYCode();
82   LoadXPos();
83   LoadYPos();
84 }
85
86 //----------------------------------------------------------------------
87 Int_t AliMUONTriggerCircuit::CircuitNumber(Int_t idCircuit) const {
88 // returns circuit number iCircuit (0-234) corresponding to circuit idCircuit
89   Int_t iCircuit=0;
90   for (Int_t i=0; i<234; i++) {
91     if (AliMUONTriggerConstants::CircuitId(i)==idCircuit) {
92       iCircuit=i;
93       break;
94     }
95   }
96   return iCircuit;
97 }
98 //----------------------------------------------------------------------
99 Int_t AliMUONTriggerCircuit::ModuleNumber(Int_t idModule) const {
100 // returns module number imod (from 0 to 63) corresponding to module idmodule
101   Int_t absidModule=TMath::Abs(idModule);
102   Int_t iModule=0;
103   for (Int_t i=0; i<63; i++) {
104     if (AliMUONTriggerConstants::ModuleId(i)==absidModule) { 
105       iModule=i;
106       break;
107     }
108   }
109   return iModule;
110 }
111
112 //----------------------------------------------------------------------
113 Int_t AliMUONTriggerCircuit::Module(Int_t idCircuit) const {
114 // returns ModuleId where Circuit idCircuit is sitting
115   return Int_t(idCircuit/10);
116 }
117 //----------------------------------------------------------------------
118 Int_t AliMUONTriggerCircuit::Position(Int_t idCircuit) const {
119 // returns position of idCircuit in correcponding Module
120   return TMath::Abs(idCircuit)-TMath::Abs(Module(idCircuit))*10;
121 }
122
123 //----------------------------------------------------------------------
124 void AliMUONTriggerCircuit::LoadX2() {
125 // initialize fX2m, fX2ud and fOrMud
126   
127   Int_t idModule=Module(fIdCircuit);        // corresponding module Id.
128 // and its number of X strips
129   Int_t nStrX=AliMUONTriggerConstants::NstripX(ModuleNumber(idModule)); 
130 // and its number of Y strips
131   Int_t nStrY=AliMUONTriggerConstants::NstripY(ModuleNumber(idModule)); 
132   Int_t iPosCircuit=Position(fIdCircuit); // position of circuit in module
133   
134 // first step : look at lower part 
135   if (iPosCircuit==1) {               // need to scan lower module       
136     if(idModule<91&&TMath::Abs(idModule)!=41&&idModule>-91) { 
137       fOrMud[0]=1;
138       Int_t idModuleD=(TMath::Abs(idModule)+10)*(TMath::Abs(idModule)/idModule); 
139       Int_t nStrD=AliMUONTriggerConstants::NstripY(ModuleNumber(idModuleD));
140       
141       if (nStrY!=nStrD    
142           &&TMath::Abs(idModule)!=42&&TMath::Abs(idModule)!=52) {   
143         if (nStrY==8) fX2m=1; 
144         if (nStrD==8) fX2ud=1; 
145       }      
146     }      
147
148   } else {                         // lower strips within same module       
149     fOrMud[0]=0;
150   }    
151   
152 // second step : look at upper part
153   if ((iPosCircuit==1&&nStrX==16)||(iPosCircuit==2&&nStrX==32)|| 
154       (iPosCircuit==3&&nStrX==48)||(iPosCircuit==4&&nStrX==64)) {   
155     if ((idModule>17||idModule<-17)&&TMath::Abs(idModule)!=61) {  
156       fOrMud[1]=1;
157       Int_t idModuleU=(TMath::Abs(idModule)-10)*(TMath::Abs(idModule)/idModule); 
158       Int_t nStrU=AliMUONTriggerConstants::NstripY(ModuleNumber(idModuleU)); 
159
160       if (nStrY!=nStrU    
161           &&TMath::Abs(idModule)!=62&&TMath::Abs(idModule)!=52) {   
162         if (nStrY==8) fX2m=1; 
163         if (nStrU==8) fX2ud=1;
164       }      
165     }     
166     
167   } else {                       // upper strips within same module       
168     fOrMud[1]=0;
169   }
170 }  
171
172 //----------------------------------------------------------------------
173 void AliMUONTriggerCircuit::LoadXCode(){
174 // assign a Id. number to each X strip of current circuit 
175 // Id.=(corresponding module Id.)*100+(Id. strip of module)
176
177 // first part : fill XMC11 XMC12 and strips 8 to 24 (middle) XMC21 XMC22
178   Int_t iStripCircMT1=0, iStripCircMT2=8;
179   Int_t idModule=Module(fIdCircuit);        // corresponding module Id.
180 // and its number of strips
181   Int_t nStrX=AliMUONTriggerConstants::NstripX(ModuleNumber(idModule)); 
182   Int_t iPosCircuit=Position(fIdCircuit);   // position of circuit in module  
183   Int_t sign=TMath::Abs(idModule)/idModule; // left or right 
184   Int_t istrip;
185
186   for (istrip=(iPosCircuit-1)*16; 
187        istrip<(iPosCircuit-1)*16+16; istrip++) {
188         
189     fXcode[0][iStripCircMT1]=sign*(TMath::Abs(idModule)*100+istrip); 
190     fXcode[1][iStripCircMT1]=sign*(TMath::Abs(idModule)*100+istrip); 
191     fXcode[2][iStripCircMT2]=sign*(TMath::Abs(idModule)*100+istrip); 
192     fXcode[3][iStripCircMT2]=sign*(TMath::Abs(idModule)*100+istrip);     
193     iStripCircMT1++;
194     iStripCircMT2++;
195   }
196
197 // second part 
198 // XMC21 XMC22 strips 0 to 7 and 24 to 31 
199   Int_t idModuleD, idModuleU;
200   Int_t nStrD, nStrU;
201
202   idModule=Module(fIdCircuit); // corresponding module Id.
203 // number of X strips
204   nStrX=AliMUONTriggerConstants::NstripX(ModuleNumber(idModule));  
205   sign=TMath::Abs(idModule)/idModule;
206
207 // fill lower part (0 to 7)
208   if (iPosCircuit==1) {                 // need to scan lower module 
209     if(idModule<91&&TMath::Abs(idModule)!=41&&idModule>-91) { // non-existing
210       idModuleD=sign*(TMath::Abs(idModule)+10);  // lower module Id
211 // and its number of strips
212       nStrD=AliMUONTriggerConstants::NstripX(ModuleNumber(idModuleD)); 
213       
214       iStripCircMT2=0;
215       for (istrip=nStrD-8; istrip<nStrD; istrip++) {  
216         fXcode[2][iStripCircMT2]=sign*(TMath::Abs(idModuleD)*100+istrip); 
217         fXcode[3][iStripCircMT2]=sign*(TMath::Abs(idModuleD)*100+istrip); 
218         iStripCircMT2++;
219       }
220     }
221      
222   } else {                       // lower strips within same module 
223     
224     iStripCircMT2=0;
225     for (istrip=(iPosCircuit-1)*16-8; 
226          istrip<(iPosCircuit-1)*16; istrip++) {  
227       fXcode[2][iStripCircMT2]=sign*(TMath::Abs(idModule)*100+istrip); 
228       fXcode[3][iStripCircMT2]=sign*(TMath::Abs(idModule)*100+istrip); 
229       iStripCircMT2++;
230     }
231   }
232   
233 // fill upper part (24 to 31)
234   if ((iPosCircuit==1&&nStrX==16)||(iPosCircuit==2&&nStrX==32)|| 
235       (iPosCircuit==3&&nStrX==48)||(iPosCircuit==4&&nStrX==64)) {   
236     if ((idModule>17||idModule<-17)&&TMath::Abs(idModule)!=61) {  
237       idModuleU=sign*(TMath::Abs(idModule)-10);  // upper module Id
238 // and its number of strips
239       nStrU=AliMUONTriggerConstants::NstripX(ModuleNumber(idModuleU)); 
240       
241       iStripCircMT2=24;
242       for (istrip=0; istrip<8; istrip++) {        
243         fXcode[2][iStripCircMT2]=sign*(TMath::Abs(idModuleU)*100+istrip); 
244         fXcode[3][iStripCircMT2]=sign*(TMath::Abs(idModuleU)*100+istrip); 
245         iStripCircMT2++;
246       }
247     }
248     
249   } else if ((iPosCircuit==1&&nStrX>16)||(iPosCircuit==2&&nStrX>32)|| 
250              (iPosCircuit==3&&nStrX>48)) { // upper strips within same mod. 
251     
252     iStripCircMT2=24;
253     for (istrip=(iPosCircuit-1)*16+16; 
254          istrip<(iPosCircuit-1)*16+24; istrip++) {  
255       fXcode[2][iStripCircMT2]=sign*(TMath::Abs(idModule)*100+istrip); 
256       fXcode[3][iStripCircMT2]=sign*(TMath::Abs(idModule)*100+istrip); 
257       iStripCircMT2++;
258     }   
259   }
260 }
261
262 //----------------------------------------------------------------------
263 void AliMUONTriggerCircuit::LoadYCode(){
264 // assign a Id. number to each Y strip of current circuit 
265 // Id.=(corresponding module Id.)*100+(Id. strip of module)
266 // note : for Y plane fill only "central part" of circuit
267 // (upper and lower parts are filled in PreHandlingY of AliMUONTriggerDecision)
268     
269   Int_t idModule=Module(fIdCircuit);        // corresponding module Id.
270 // and its number of Y strips
271   Int_t nStrY=AliMUONTriggerConstants::NstripY(ModuleNumber(idModule)); 
272   Int_t sign=TMath::Abs(idModule)/idModule; // left or right 
273
274   for (Int_t istrip=0; istrip<nStrY; istrip++) {
275     fYcode[0][istrip]=sign*(TMath::Abs(idModule)*100+istrip); 
276     fYcode[1][istrip]=sign*(TMath::Abs(idModule)*100+istrip); 
277     fYcode[2][istrip]=sign*(TMath::Abs(idModule)*100+istrip); 
278     fYcode[3][istrip]=sign*(TMath::Abs(idModule)*100+istrip); 
279   }
280 }
281
282 //----------------------------------------------------------------------
283 void AliMUONTriggerCircuit::LoadYPos(){
284 // fill fYpos11 and fYpos21 -> y position of X declusterized strips
285
286   Int_t chamber, cathode;
287   Int_t code, idModule, idStrip, idSector;
288   Float_t x, y, z, width;
289   Int_t istrip;
290
291   AliMUON *pMUON  = (AliMUON*)gAlice->GetModule("MUON");  
292   AliMUONChamber*  iChamber;
293   AliSegmentation*  segmentation;    
294
295 // first plane (11)
296   chamber=11;
297   cathode=1;
298   iChamber = &(pMUON->Chamber(chamber-1));
299   segmentation=iChamber->SegmentationModel(cathode);
300   
301   for (istrip=0; istrip<16; istrip++) {
302     code=fXcode[0][istrip];           // decode current strip
303     idModule=Int_t(code/100);           // corresponding module Id.
304     idStrip=TMath::Abs(code-idModule*100); // corresp. strip number in module
305     idSector=segmentation->Sector(idModule,idStrip); // corresponding sector
306     width=segmentation->Dpy(idSector);      // corresponding strip width
307     segmentation->GetPadC(idModule,idStrip,x,y,z); // get strip real position
308     
309     fYpos11[2*istrip]=y;
310     if (istrip!=15) fYpos11[2*istrip+1]=y+width/2.;
311   }   
312    
313 // second plane (21)
314   chamber=13;
315   cathode=1;
316   iChamber = &(pMUON->Chamber(chamber-1));
317   segmentation=iChamber->SegmentationModel(cathode);
318   
319   for (istrip=0; istrip<32; istrip++) {
320     code=fXcode[2][istrip];    // decode current strip
321     idModule=Int_t(code/100);           // corresponding module Id.
322     idStrip=TMath::Abs(code-idModule*100); // corresp. strip number in module
323     idSector=segmentation->Sector(idModule,idStrip); // corresponding sector
324     width=segmentation->Dpy(idSector);      // corresponding strip width
325     segmentation->GetPadC(idModule,idStrip,x,y,z); // get strip real position
326     
327 // using idModule!=0 prevents to fill garbage in case of circuits 
328 // in the first and last rows 
329     if (idModule!=0) { 
330       fYpos21[2*istrip]=y;
331       if (istrip!=31) fYpos21[2*istrip+1]=y+width/2.;
332     }
333   }   
334 }
335
336 //----------------------------------------------------------------------
337 void AliMUONTriggerCircuit::LoadXPos(){
338 // fill fXpos11 -> x position of Y strips for the first plane only
339 // fXpos11 contains the x position of Y strip for the current circuit
340 // taking into account whether or nor not part(s) of the circuit
341 // (middle, up or down) has(have) 16 strips
342   
343   Float_t x, y, z;
344   Int_t istrip;  
345
346   Int_t chamber=11;
347   Int_t cathode=2;
348   AliMUON *pMUON  = (AliMUON*)gAlice->GetModule("MUON");  
349   AliMUONChamber*  iChamber;
350   AliSegmentation*  segmentation; 
351   iChamber = &(pMUON->Chamber(chamber-1));
352   segmentation=iChamber->SegmentationModel(cathode);
353   
354   Int_t idModule=Module(fIdCircuit);        // corresponding module Id.  
355 // number of Y strips
356   Int_t nStrY=AliMUONTriggerConstants::NstripY(ModuleNumber(idModule)); 
357   Int_t idSector=segmentation->Sector(idModule,0); // corresp. sector
358   Float_t width=segmentation->Dpx(idSector);      // corresponding strip width
359   
360 // first case : up middle and down parts have all 8 or 16 strip 
361   if ((nStrY==16)||(nStrY==8&&fX2m==0&&fX2ud==0)) { 
362     for (istrip=0; istrip<nStrY; istrip++) {
363       segmentation->GetPadC(idModule,istrip,x,y,z); 
364       fXpos11[istrip]=x;
365     }
366 // second case : mixing 8 and 16 strips within same circuit      
367   } else {
368     for (istrip=0; istrip<nStrY; istrip++) {
369       if (nStrY!=8) { printf(" bug in LoadXpos \n");}
370       segmentation->GetPadC(idModule,istrip,x,y,z); 
371       fXpos11[2*istrip]=x-width/4.;
372       fXpos11[2*istrip+1]=fXpos11[2*istrip]+width/2.;
373     }
374   }   
375 }
376
377 //----------------------------------------------------------------------
378 Float_t AliMUONTriggerCircuit::PtCal(Int_t istripX, Int_t idev, Int_t istripY){
379 // returns calculated pt for circuit/istripX/idev/istripY according 
380 // to the formula of the TRD. Note : idev (input) is in [0+30]
381
382   //  Int_t jdev = idev - 15;        // jdev in [-15+15]
383   Int_t istripX2=istripX+idev+1; // find istripX2 using istripX and idev
384
385   Float_t yPosX1=fYpos11[istripX];
386   Float_t yPosX2=fYpos21[istripX2];
387   Float_t xPosY1=fXpos11[istripY];
388   
389   Float_t zf=975.;
390   Float_t z1=AliMUONConstants::DefaultChamberZ(10);
391   Float_t z2=AliMUONConstants::DefaultChamberZ(12);
392   Float_t thetaDev=(1./zf)*(yPosX1*z2-yPosX2*z1)/(z2-z1);
393   Float_t xf=xPosY1*zf/z1; 
394   Float_t yf=yPosX2-((yPosX2-yPosX1)*(z2-zf))/(z2-z1);
395   return (3.*0.3/TMath::Abs(thetaDev)) * TMath::Sqrt(xf*xf+yf*yf)/zf;
396 }
397
398 //----------------------------------------------------------------------
399 //--- methods which return member data related info
400 //----------------------------------------------------------------------
401 Int_t AliMUONTriggerCircuit::GetIdCircuit() const { 
402 // returns circuit Id
403   return fIdCircuit;
404 }
405 //----------------------------------------------------------------------
406 Int_t AliMUONTriggerCircuit::GetIdModule() const { 
407 // returns module Id
408   return Module(fIdCircuit);
409 }
410 //----------------------------------------------------------------------
411 Int_t AliMUONTriggerCircuit::GetNstripX() const { 
412 // returns the number of X strips in the module where the circuit is sitting
413   return AliMUONTriggerConstants::NstripX(ModuleNumber(Module(fIdCircuit)));
414 }
415 //----------------------------------------------------------------------
416 Int_t AliMUONTriggerCircuit::GetNstripY() const { 
417 // returns the number of Y strips in the module where the circuit is sitting
418   return AliMUONTriggerConstants::NstripY(ModuleNumber(Module(fIdCircuit)));
419 }
420 //----------------------------------------------------------------------
421 Int_t AliMUONTriggerCircuit::GetPosCircuit() const { 
422 // returns the position of the circuit in its module
423   return Position(fIdCircuit);
424 }
425 //----------------------------------------------------------------------
426 Int_t AliMUONTriggerCircuit::GetIdCircuitD() const {
427 // returns the Id of the circuit down 
428   Int_t idModule=Module(fIdCircuit);
429   Int_t idModuleD=(TMath::Abs(idModule)+10)*(TMath::Abs(idModule)/idModule); 
430   return (TMath::Abs(idModuleD)*10+1)*(TMath::Abs(idModule)/idModule);
431 }
432 //----------------------------------------------------------------------
433 Int_t AliMUONTriggerCircuit::GetICircuitD() const {
434 // returns the number of the circuit down 
435   Int_t idModule=Module(fIdCircuit);
436   Int_t idModuleD=(TMath::Abs(idModule)+10)*(TMath::Abs(idModule)/idModule); 
437   Int_t idCircuitD=
438     (TMath::Abs(idModuleD)*10+1)*(TMath::Abs(idModule)/idModule);
439   return CircuitNumber(idCircuitD);
440 }
441 //----------------------------------------------------------------------
442 Int_t AliMUONTriggerCircuit::GetIdCircuitU() const {
443 // returns the Id of the circuit up 
444   Int_t idModule=Module(fIdCircuit);
445   Int_t idModuleU=(TMath::Abs(idModule)-10)*(TMath::Abs(idModule)/idModule); 
446   return (TMath::Abs(idModuleU)*10+1)*(TMath::Abs(idModule)/idModule);
447 }
448 //----------------------------------------------------------------------
449 Int_t AliMUONTriggerCircuit::GetICircuitU() const {
450 // returns the number of the circuit up 
451   Int_t idModule=Module(fIdCircuit);
452   Int_t idModuleU=(TMath::Abs(idModule)-10)*(TMath::Abs(idModule)/idModule); 
453   Int_t idCircuitU=
454     (TMath::Abs(idModuleU)*10+1)*(TMath::Abs(idModule)/idModule);
455   return CircuitNumber(idCircuitU);
456 }
457 //----------------------------------------------------------------------
458 Int_t AliMUONTriggerCircuit::GetX2m() const { 
459 // returns fX2m
460   return fX2m;
461 }
462 //----------------------------------------------------------------------
463 Int_t AliMUONTriggerCircuit::GetX2ud() const { 
464 // returns fX2ud
465   return fX2ud;
466 }
467 //----------------------------------------------------------------------
468 void AliMUONTriggerCircuit::GetOrMud(Int_t orMud[2]) const {
469 // returns fOrMud 
470   orMud[0]=fOrMud[0];
471   orMud[1]=fOrMud[1];
472 }
473 //----------------------------------------------------------------------
474 Int_t AliMUONTriggerCircuit::GetXcode(Int_t chamber, Int_t istrip) const {
475 // returns X code of circuit/chamber/istrip (warning : chamber in [0,3])
476   return fXcode[chamber][istrip];
477 }
478 //----------------------------------------------------------------------
479 Int_t AliMUONTriggerCircuit::GetYcode(Int_t chamber, Int_t istrip) const {
480 // returns Y code of circuit/chamber/istrip (warning : chamber in [0,3])
481   return fYcode[chamber][istrip];
482 }
483 //----------------------------------------------------------------------
484 Float_t AliMUONTriggerCircuit::GetY11Pos(Int_t istrip) const {
485 // returns Y position of X strip istrip in MC11
486   return fYpos11[istrip];
487 }
488 //----------------------------------------------------------------------
489 Float_t AliMUONTriggerCircuit::GetY21Pos(Int_t istrip) const {
490 // returns Y position of X strip istrip in MC21
491   return fYpos21[istrip];
492 }
493 //----------------------------------------------------------------------
494 Float_t AliMUONTriggerCircuit::GetX11Pos(Int_t istrip) const {
495 // returns X position of Y strip istrip in MC11
496   return fXpos11[istrip];
497 }
498 //----------------------------------------------------------------------
499 //--- end of methods which return member data related info
500 //----------------------------------------------------------------------
501
502
503
504
505
506
507