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