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