removed rehash
[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 **************************************************************************/
15/*
aac5be80 16$Log$
a30a000f 17Revision 1.4 2000/06/28 15:16:35 morsch
18(1) Client code adapted to new method signatures in AliMUONSegmentation (see comments there)
19to allow development of slat-muon chamber simulation and reconstruction code in the MUON
20framework. The changes should have no side effects (mostly dummy arguments).
21(2) Hit disintegration uses 3-dim hit coordinates to allow simulation
22of chambers with overlapping modules (MakePadHits, Disintegration).
23
802a864d 24Revision 1.3 2000/06/26 10:04:49 pcrochet
25problem with HP compiler solved (PH), static variables removed : now defined in AliMUONTriggerConstants
26
a9e2aefa 27*/
aac5be80 28
a9e2aefa 29#include "AliRun.h"
30#include "AliMUON.h"
31#include "AliMUONPoints.h"
32#include "AliMUONTriggerCircuit.h"
aac5be80 33#include "AliMUONTriggerConstants.h"
a30a000f 34#include "AliSegmentation.h"
a9e2aefa 35#include "AliMUONResponse.h"
36#include "AliMUONChamber.h"
37#include "TMath.h"
38#include "iostream.h"
39
40ClassImp(AliMUONTriggerCircuit)
41
a9e2aefa 42//----------------------------------------------------------------------
43AliMUONTriggerCircuit::AliMUONTriggerCircuit()
44{
45// Constructor
46 fidCircuit=0;
47 fx2m=0;
48 fx2ud=0;
49 fOrMud[0]=fOrMud[1]=0;
aac5be80 50 Int_t i;
51 for (i=0; i<4; i++) {
a9e2aefa 52 for (Int_t j=0; j<32; j++) {
53 fXcode[i][j]=0;
54 fYcode[i][j]=0;
55 }
56 }
aac5be80 57 for (i=0; i<16; i++) { fXpos11[i]=0.; }
58 for (i=0; i<31; i++) { fYpos11[i]=0.; }
59 for (i=0; i<63; i++) { fYpos21[i]=0.; }
a9e2aefa 60}
61
62//----------------------------------------------------------------------
63AliMUONTriggerCircuit::AliMUONTriggerCircuit(const AliMUONTriggerCircuit& MUONTriggerCircuit)
64{
65// Dummy copy constructor
66}
67
68//----------------------------------------------------------------------
69AliMUONTriggerCircuit & AliMUONTriggerCircuit::operator=(const AliMUONTriggerCircuit& MUONTriggerCircuit)
70{
71// Dummy assignment operator
72 return *this;
73}
74
75//----------------------------------------------------------------------
76void AliMUONTriggerCircuit::Init(Int_t iCircuit) {
77// initialize circuit characteristics
aac5be80 78 fidCircuit=AliMUONTriggerConstants::CircuitId(iCircuit);
a9e2aefa 79 LoadX2();
80 LoadXCode();
81 LoadYCode();
82 LoadXPos();
83 LoadYPos();
84}
85
86//----------------------------------------------------------------------
87Int_t AliMUONTriggerCircuit::CircuitNumber(Int_t idCircuit){
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++) {
aac5be80 91 if (AliMUONTriggerConstants::CircuitId(i)==idCircuit) {
a9e2aefa 92 iCircuit=i;
93 break;
94 }
95 }
96 return iCircuit;
97}
98//----------------------------------------------------------------------
99Int_t AliMUONTriggerCircuit::ModuleNumber(Int_t idModule){
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++) {
aac5be80 104 if (AliMUONTriggerConstants::ModuleId(i)==absidModule) {
a9e2aefa 105 iModule=i;
106 break;
107 }
108 }
109 return iModule;
110}
111
112//----------------------------------------------------------------------
113Int_t AliMUONTriggerCircuit::Module(Int_t idCircuit) {
114// returns ModuleId where Circuit idCircuit is sitting
115 return Int_t(idCircuit/10);
116}
117//----------------------------------------------------------------------
118Int_t AliMUONTriggerCircuit::Position(Int_t idCircuit) {
119// returns position of idCircuit in correcponding Module
120 return TMath::Abs(idCircuit)-TMath::Abs(Module(idCircuit))*10;
121}
122
123//----------------------------------------------------------------------
124void AliMUONTriggerCircuit::LoadX2() {
125// initialize fx2m, fx2ud and fOrMud
126
127 Int_t idModule=Module(fidCircuit); // corresponding module Id.
aac5be80 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));
a9e2aefa 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);
aac5be80 139 Int_t nStrD=AliMUONTriggerConstants::NstripY(ModuleNumber(idModuleD));
a9e2aefa 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);
aac5be80 158 Int_t nStrU=AliMUONTriggerConstants::NstripY(ModuleNumber(idModuleU));
a9e2aefa 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//----------------------------------------------------------------------
173void 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.
aac5be80 180// and its number of strips
181 Int_t nStrX=AliMUONTriggerConstants::NstripX(ModuleNumber(idModule));
a9e2aefa 182 Int_t iPosCircuit=Position(fidCircuit); // position of circuit in module
183 Int_t sign=TMath::Abs(idModule)/idModule; // left or right
aac5be80 184 Int_t istrip;
a9e2aefa 185
aac5be80 186 for (istrip=(iPosCircuit-1)*16;
a9e2aefa 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.
aac5be80 203// number of X strips
204 nStrX=AliMUONTriggerConstants::NstripX(ModuleNumber(idModule));
a9e2aefa 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
aac5be80 211// and its number of strips
212 nStrD=AliMUONTriggerConstants::NstripX(ModuleNumber(idModuleD));
a9e2aefa 213
214 iStripCircMT2=0;
aac5be80 215 for (istrip=nStrD-8; istrip<nStrD; istrip++) {
a9e2aefa 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;
aac5be80 225 for (istrip=(iPosCircuit-1)*16-8;
a9e2aefa 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
aac5be80 238// and its number of strips
239 nStrU=AliMUONTriggerConstants::NstripX(ModuleNumber(idModuleU));
a9e2aefa 240
241 iStripCircMT2=24;
aac5be80 242 for (istrip=0; istrip<8; istrip++) {
a9e2aefa 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;
aac5be80 253 for (istrip=(iPosCircuit-1)*16+16;
a9e2aefa 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//----------------------------------------------------------------------
263void 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.
aac5be80 270// and its number of Y strips
271 Int_t nStrY=AliMUONTriggerConstants::NstripY(ModuleNumber(idModule));
a9e2aefa 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//----------------------------------------------------------------------
283void 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;
802a864d 288 Float_t x, y, z, width;
aac5be80 289 Int_t istrip;
a9e2aefa 290
291 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
292 AliMUONChamber* iChamber;
a30a000f 293 AliSegmentation* segmentation;
a9e2aefa 294
295// first plane (11)
296 chamber=11;
297 cathode=1;
298 iChamber = &(pMUON->Chamber(chamber-1));
299 segmentation=iChamber->SegmentationModel(cathode);
300
aac5be80 301 for (istrip=0; istrip<16; istrip++) {
a9e2aefa 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
a30a000f 307 segmentation->GetPadC(idModule,idStrip,x,y,z); // get strip real position
a9e2aefa 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
aac5be80 319 for (istrip=0; istrip<32; istrip++) {
a9e2aefa 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
a30a000f 325 segmentation->GetPadC(idModule,idStrip,x,y,z); // get strip real position
a9e2aefa 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//----------------------------------------------------------------------
337void 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
802a864d 343 Float_t x, y, z;
aac5be80 344 Int_t istrip;
a9e2aefa 345
346 Int_t chamber=11;
347 Int_t cathode=2;
348 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
349 AliMUONChamber* iChamber;
a30a000f 350 AliSegmentation* segmentation;
a9e2aefa 351 iChamber = &(pMUON->Chamber(chamber-1));
352 segmentation=iChamber->SegmentationModel(cathode);
353
354 Int_t idModule=Module(fidCircuit); // corresponding module Id.
aac5be80 355// number of Y strips
356 Int_t nStrY=AliMUONTriggerConstants::NstripY(ModuleNumber(idModule));
a9e2aefa 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)) {
aac5be80 362 for (istrip=0; istrip<nStrY; istrip++) {
a30a000f 363 segmentation->GetPadC(idModule,istrip,x,y,z);
a9e2aefa 364 fXpos11[istrip]=x;
365 }
366// second case : mixing 8 and 16 strips within same circuit
367 } else {
aac5be80 368 for (istrip=0; istrip<nStrY; istrip++) {
a9e2aefa 369 if (nStrY!=8) { cout << " bug in LoadXpos " << "\n";}
a30a000f 370 segmentation->GetPadC(idModule,istrip,x,y,z);
a9e2aefa 371 fXpos11[2*istrip]=x-width/4.;
372 fXpos11[2*istrip+1]=fXpos11[2*istrip]+width/2.;
373 }
374 }
375}
376
377//----------------------------------------------------------------------
378Float_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., z1=1603.5, z2=1703.5;
390 Float_t thetaDev=(1./zf)*(yPosX1*z2-yPosX2*z1)/(z2-z1);
391 Float_t xf=xPosY1*zf/z1;
392 Float_t yf=yPosX2-((yPosX2-yPosX1)*(z2-zf))/(z2-z1);
393 return (3.*0.3/TMath::Abs(thetaDev)) * TMath::Sqrt(xf*xf+yf*yf)/zf;
394}
395
396//----------------------------------------------------------------------
397//--- methods which return member data related info
398//----------------------------------------------------------------------
399Int_t AliMUONTriggerCircuit::GetIdCircuit(){
400// returns circuit Id
401 return fidCircuit;
402}
403//----------------------------------------------------------------------
404Int_t AliMUONTriggerCircuit::GetIdModule(){
405// returns module Id
406 return Module(fidCircuit);
407}
408//----------------------------------------------------------------------
409Int_t AliMUONTriggerCircuit::GetNstripX() {
410// returns the number of X strips in the module where the circuit is sitting
aac5be80 411 return AliMUONTriggerConstants::NstripX(ModuleNumber(Module(fidCircuit)));
a9e2aefa 412}
413//----------------------------------------------------------------------
414Int_t AliMUONTriggerCircuit::GetNstripY() {
415// returns the number of Y strips in the module where the circuit is sitting
aac5be80 416 return AliMUONTriggerConstants::NstripY(ModuleNumber(Module(fidCircuit)));
a9e2aefa 417}
418//----------------------------------------------------------------------
419Int_t AliMUONTriggerCircuit::GetPosCircuit() {
420// returns the position of the circuit in its module
421 return Position(fidCircuit);
422}
423//----------------------------------------------------------------------
424Int_t AliMUONTriggerCircuit::GetIdCircuitD(){
425// returns the Id of the circuit down
426 Int_t idModule=Module(fidCircuit);
427 Int_t idModuleD=(TMath::Abs(idModule)+10)*(TMath::Abs(idModule)/idModule);
428 return (TMath::Abs(idModuleD)*10+1)*(TMath::Abs(idModule)/idModule);
429}
430//----------------------------------------------------------------------
431Int_t AliMUONTriggerCircuit::GetICircuitD(){
432// returns the number of the circuit down
433 Int_t idModule=Module(fidCircuit);
434 Int_t idModuleD=(TMath::Abs(idModule)+10)*(TMath::Abs(idModule)/idModule);
435 Int_t idCircuitD=
436 (TMath::Abs(idModuleD)*10+1)*(TMath::Abs(idModule)/idModule);
437 return CircuitNumber(idCircuitD);
438}
439//----------------------------------------------------------------------
440Int_t AliMUONTriggerCircuit::GetIdCircuitU(){
441// returns the Id of the circuit up
442 Int_t idModule=Module(fidCircuit);
443 Int_t idModuleU=(TMath::Abs(idModule)-10)*(TMath::Abs(idModule)/idModule);
444 return (TMath::Abs(idModuleU)*10+1)*(TMath::Abs(idModule)/idModule);
445}
446//----------------------------------------------------------------------
447Int_t AliMUONTriggerCircuit::GetICircuitU(){
448// returns the number of the circuit up
449 Int_t idModule=Module(fidCircuit);
450 Int_t idModuleU=(TMath::Abs(idModule)-10)*(TMath::Abs(idModule)/idModule);
451 Int_t idCircuitU=
452 (TMath::Abs(idModuleU)*10+1)*(TMath::Abs(idModule)/idModule);
453 return CircuitNumber(idCircuitU);
454}
455//----------------------------------------------------------------------
456Int_t AliMUONTriggerCircuit::GetX2m(){
457// returns fx2m
458 return fx2m;
459}
460//----------------------------------------------------------------------
461Int_t AliMUONTriggerCircuit::GetX2ud(){
462// returns fx2ud
463 return fx2ud;
464}
465//----------------------------------------------------------------------
466void AliMUONTriggerCircuit::GetOrMud(Int_t orMud[2]){
467// returns fOrMud
468 orMud[0]=fOrMud[0];
469 orMud[1]=fOrMud[1];
470}
471//----------------------------------------------------------------------
472Int_t AliMUONTriggerCircuit::GetXcode(Int_t chamber, Int_t istrip){
473// returns X code of circuit/chamber/istrip (warning : chamber in [0,3])
474 return fXcode[chamber][istrip];
475}
476//----------------------------------------------------------------------
477Int_t AliMUONTriggerCircuit::GetYcode(Int_t chamber, Int_t istrip){
478// returns Y code of circuit/chamber/istrip (warning : chamber in [0,3])
479 return fYcode[chamber][istrip];
480}
481//----------------------------------------------------------------------
482Float_t AliMUONTriggerCircuit::GetY11Pos(Int_t istrip){
483// returns Y position of X strip istrip in MC11
484 return fYpos11[istrip];
485}
486//----------------------------------------------------------------------
487Float_t AliMUONTriggerCircuit::GetY21Pos(Int_t istrip){
488// returns Y position of X strip istrip in MC21
489 return fYpos21[istrip];
490}
491//----------------------------------------------------------------------
492Float_t AliMUONTriggerCircuit::GetX11Pos(Int_t istrip){
493// returns X position of Y strip istrip in MC11
494 return fXpos11[istrip];
495}
496//----------------------------------------------------------------------
497//--- end of methods which return member data related info
498//----------------------------------------------------------------------
499
500
501
502
503
504
505