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