]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTriggerCircuit.cxx
Updated list of MUON libraries
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerCircuit.cxx
CommitLineData
8ff54bb6 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/// \class AliMUONTriggerCircuit
19/// Contains as data members the Y positions of the X declusturized strips and
20/// the X positions of the (doubled or not) Y strips.
21/// This is used to associate the global positions to the fired strips of the
22/// local trigger output (see AliMUONTrackReconstructor::MakeTriggerTrack)
78649106 23///
24/// \author Philippe Crochet (LPCCFd)
8ff54bb6 25
26#include "AliMUONTriggerCircuit.h"
8ff54bb6 27#include "AliMUONLocalTriggerBoard.h"
28#include "AliMUONTriggerCrateStore.h"
29#include "AliMUONTriggerCrate.h"
30#include "AliMUONGeometryTransformer.h"
31
32#include "AliMpTriggerSegmentation.h"
33#include "AliMpTrigger.h"
34#include "AliMpSlat.h"
35#include "AliMpPCB.h"
36#include "AliMpSegmentation.h"
37#include "AliMpVSegmentation.h"
866c3232 38#include "AliMpCathodType.h"
8ff54bb6 39
40#include "AliRun.h"
41#include "AliLog.h"
42
43#include <TMath.h>
9de45220 44#include <Riostream.h>
8ff54bb6 45
46/// \cond CLASSIMP
47ClassImp(AliMUONTriggerCircuit)
48/// \endcond
49
50//----------------------------------------------------------------------
51AliMUONTriggerCircuit::AliMUONTriggerCircuit()
52: TObject(),
53 fILocalBoard(0),
54 fTransformer(0x0)
55{
56/// Constructor
57
58 Int_t i;
59 for (i=0; i<16; i++) { fXpos11[i]=0.; }
60 for (i=0; i<31; i++) { fYpos11[i]=0.; }
61 for (i=0; i<63; i++) { fYpos21[i]=0.; }
62}
63
64//----------------------------------------------------------------------
65AliMUONTriggerCircuit::~AliMUONTriggerCircuit()
66{
67/// Destructor
68}
69
70//----------------------------------------------------------------------
71AliMUONTriggerCircuit::AliMUONTriggerCircuit(const AliMUONTriggerCircuit& circuit)
72 : TObject(circuit),
1cb43687 73 fILocalBoard(circuit.fILocalBoard),
74 fTransformer(0x0)
8ff54bb6 75{
76/// Copy constructor
77
78 for (Int_t i = 0; i < 16; ++i)
79 fXpos11[i] = circuit.fXpos11[i];
80
81 for (Int_t i = 0; i < 31; ++i)
82 fYpos11[i] = circuit.fYpos11[i];
83
84 for (Int_t i = 0; i < 63; ++i)
85 fYpos21[i] = circuit.fYpos21[i];
86
87}
88//----------------------------------------------------------------------
89AliMUONTriggerCircuit& AliMUONTriggerCircuit::operator=(const AliMUONTriggerCircuit& circuit)
90{
91/// Assignment operator
92
93 if (this == &circuit) return *this;
94
95 fILocalBoard = circuit.fILocalBoard;
96
97 for (Int_t i = 0; i < 16; ++i)
98 fXpos11[i] = circuit.fXpos11[i];
99
100 for (Int_t i = 0; i < 31; ++i)
101 fYpos11[i] = circuit.fYpos11[i];
102
103 for (Int_t i = 0; i < 63; ++i)
104 fYpos21[i] = circuit.fYpos21[i];
105
106 return *this;
107
108}
109//----------------------------------------------------------------------
110void AliMUONTriggerCircuit::Init(Int_t iCircuit, const AliMUONTriggerCrateStore& crates)
111{
112/// initialize circuit characteristics
113 fILocalBoard=iCircuit+1;//AliMUONTriggerConstants::CircuitId(iCircuit);
114
115 LoadXPos(crates);
116 LoadYPos(crates);
117
118}
119
120//---------------------------------------------------------------------
121void AliMUONTriggerCircuit::LoadYPos(const AliMUONTriggerCrateStore& crates)
122{
123/// fill fYpos11 and fYpos21 -> y position of X declusterized strips
124
125 const AliMUONLocalTriggerBoard* localBoard = crates.LocalBoard(fILocalBoard);
126
127 if (!localBoard)
128 {
129 AliError(Form("Did not get localboard %d",fILocalBoard));
130 return;
131 }
132 StdoutToAliDebug(1,localBoard->Print("CONF"););
133
134 Int_t ichamber = 0;
135 Int_t icathode = 0;
136
137 const AliMpVSegmentation* seg;
138
139 Int_t zeroDown = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroDown);
140 Int_t zeroUp = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroUp);
141
142 //--- first plane
143 ichamber = 10;
144
145 char side;
146 Int_t iline, icol;
147 DecodeBoardName(localBoard->GetName(),side,iline,icol);
148
149 Int_t detElemId = DetElemId(ichamber,side,iline);
866c3232 150 seg = AliMpSegmentation::Instance()
151 ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));
8ff54bb6 152
153 Int_t iFirstStrip = FirstStrip(localBoard->GetName());
154 Int_t iLastStrip = iFirstStrip + 16;
155 Int_t iStripCircuit = 0;
156 FillXstrips(seg,detElemId,icol,
157 iFirstStrip,iLastStrip,iStripCircuit,fYpos11);
158
159 //--- second plane
160 ichamber = 12;
161
162 detElemId = DetElemId(ichamber,side,iline);
866c3232 163 seg = AliMpSegmentation::Instance()
164 ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));
8ff54bb6 165
166 // second plane middle part
167 Int_t iFirstStripMiddle = FirstStrip(localBoard->GetName());
168 Int_t iLastStripMiddle = iFirstStrip + 16;
169 iStripCircuit=8;
170 FillXstrips(seg,detElemId,icol,
171 iFirstStripMiddle,iLastStripMiddle,iStripCircuit,fYpos21);
172
173 // second plane upper part
174 if (zeroUp == 0) { // something up
175 Int_t iFirstStripUp;
176 Int_t iLastStripUp;
177 Int_t icolUp=icol;
178 // check if we need to move to another detElemId
179 AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,iLastStripMiddle+1),kFALSE);
180 if (pad.IsValid()) { // upper strips within same detElemId
181 iFirstStripUp = iLastStripMiddle;
182 iLastStripUp = iFirstStripUp + 8;
183 // icolUp = icol;
184 } else { // upper strips in another detElemId
185 detElemId = DetElemId(ichamber,side,iline+1); // get detElemId
866c3232 186 seg = AliMpSegmentation::Instance()
187 ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));
8ff54bb6 188
189 iFirstStripUp = 0;
190 iLastStripUp = iFirstStripUp + 8;
191 if (iline == 4) icolUp = icol - 1; // special case
192 if (iline == 5) icolUp = icol + 1; // special case
193 }
194
195 iStripCircuit=24;
196 FillXstrips(seg,detElemId,icolUp,
197 iFirstStripUp,iLastStripUp,iStripCircuit,fYpos21);
198
199 // fill strip between middle and upper part
200 fYpos21[47]=(fYpos21[46]+fYpos21[48])/2.;
201 } // end of something up
202
203 // restore current detElemId & segmentation
204 detElemId = DetElemId(ichamber,side,iline);
866c3232 205 seg = AliMpSegmentation::Instance()
206 ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));
8ff54bb6 207
208 // second plane lower part
209 if (zeroDown == 0) { // something down
210 Int_t iFirstStripDo;
211 Int_t iLastStripDo;
212 Int_t icolDo=icol;
213
214 // check if we need to move to another detElemId
215 AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,iFirstStripMiddle-1),kFALSE);
216 if (pad.IsValid()) { // lower strips within same detElemId
217 iFirstStripDo = iFirstStripMiddle - 8;
218 iLastStripDo = iFirstStripDo + 8;
219 // icolDo = icol;
220 } else { // lower strips in another detElemId
221 detElemId = DetElemId(ichamber,side,iline-1); // get detElemId
866c3232 222 seg = AliMpSegmentation::Instance()
223 ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));
8ff54bb6 224
225 // get iFirstStrip in this module
226 const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(seg);
227 const AliMpTrigger* t = trig->Slat();
228 const AliMpSlat* slat = t->GetLayer(0);
229 if (iline == 5) icolDo = icol + 1; // special case
230 if (iline == 6) icolDo = icol - 1; // special case
231 const AliMpPCB* pcb = slat->GetPCB(icolDo-1);
232 iFirstStripDo = (pcb->Iymax() + 1) - 8;
233 iLastStripDo = iFirstStripDo + 8;
234 }
235
236 iStripCircuit=0;
237 FillXstrips(seg,detElemId,icolDo,
238 iFirstStripDo,iLastStripDo,iStripCircuit,fYpos21);
239
240 // fill strip between middle and upper part
241 fYpos21[15]=(fYpos21[14]+fYpos21[16])/2.;
242 } // end of something down
243
244}
245
246//----------------------------------------------------------------------
247void AliMUONTriggerCircuit::LoadXPos(const AliMUONTriggerCrateStore& crates)
248{
249/// fill fXpos11 -> x position of Y strips for the first plane only
250/// fXpos11 contains the x position of Y strip for the current circuit
251/// taking into account whether or nor not part(s) of the circuit
252/// (middle, up or down) has(have) 16 strips (handdled by means of switchs)
253
254 const AliMUONLocalTriggerBoard* localBoard = crates.LocalBoard(fILocalBoard);
255
256 if (!localBoard)
257 {
258 AliError(Form("Did not get localboard %d",fILocalBoard));
259 return;
260 }
261 StdoutToAliDebug(1,localBoard->Print("CONF"););
262
263 Int_t ichamber = 10;
264 Int_t icathode = 1;
265
266 Int_t x2u = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2u);
267 Int_t x2m = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2m);
268 Int_t x2d = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2d);
269 Int_t zeroAllYLSB = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroAllYLSB);
270 Int_t iStripCircuit = 0;
271 Int_t iFirstStrip = 0;
272 Int_t iLastStrip = 0;
273 Bool_t doubling = kFALSE;
274
275 const AliMpVSegmentation* seg;
276
277 char side;
278 Int_t iline, icol;
279
280 DecodeBoardName(localBoard->GetName(),side,iline,icol);
281
282 Int_t detElemId=DetElemId(ichamber,side,iline); // get detElemId
866c3232 283 seg = AliMpSegmentation::Instance()
284 ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));
8ff54bb6 285
286 // check if one needs a strip doubling or not
287 if ( (x2u == 1 || x2m == 1 || x2d == 1) && x2m == 1) doubling = kTRUE;
288
289 // check if one starts at strip = 0 or 8 (boards 26-29 and 143-146)
290 if (zeroAllYLSB == 1) iStripCircuit = 8;
291
292 // get iFirstStrip in this module
293 const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(seg);
294 const AliMpTrigger* t = trig->Slat();
295 const AliMpSlat* slat = t->GetLayer(0);
296
297 const AliMpPCB* pcb = slat->GetPCB(icol-1);
298 iFirstStrip = pcb->Ixmin();
299
300 if (doubling) iLastStrip = iFirstStrip + 8;
301 else iLastStrip = iFirstStrip + 16;
302
303 FillYstrips(seg,detElemId,
304 iFirstStrip,iLastStrip,iStripCircuit,doubling);
305}
306
307//----------------------------------------------------------------------
308void AliMUONTriggerCircuit::FillYstrips(
309 const AliMpVSegmentation* seg,
310 const Int_t detElemId,
311 const Int_t iFirstStrip, const Int_t iLastStrip, Int_t liStripCircuit,
312 const Bool_t doubling)
313{
314/// fill
315 Double_t xyGlobal[4]={0.,0.,0.,0.};
316 for (Int_t istrip=iFirstStrip; istrip<iLastStrip; istrip++) {
317 AliMpPad pad = seg->PadByIndices(AliMpIntPair(istrip,0),kTRUE);
318 if ( !pad.IsValid() )
319 {
320 StdoutToAliError(cout << "Pad not found in seg " << endl;
321 seg->Print();
322 cout << " ix,iy=" << istrip << "," << 0 << endl;
323 );
324 }
325 XYGlobal(detElemId,pad,xyGlobal);
326
327 if (!doubling) {
328 fXpos11[liStripCircuit]=xyGlobal[0];
329 } else if (doubling) {
330 fXpos11[2*liStripCircuit]=TMath::Sign(1.,xyGlobal[0]) *
331 (TMath::Abs(xyGlobal[0]) - xyGlobal[2]/2.);
332 fXpos11[2*liStripCircuit+1]=TMath::Sign(1.,xyGlobal[0]) *
333 (TMath::Abs(fXpos11[2*liStripCircuit]) + xyGlobal[2]);
334 }
335 liStripCircuit++;
336 }
337}
338
339//----------------------------------------------------------------------
340void AliMUONTriggerCircuit::FillXstrips(
341 const AliMpVSegmentation* seg,
342 const Int_t detElemId, const Int_t icol,
343 const Int_t iFirstStrip, const Int_t iLastStrip,
344 Int_t liStripCircuit, Float_t *tab)
345{
346/// fill
347 Double_t xyGlobal[4]={0.,0.,0.,0.};
348 for (Int_t istrip=iFirstStrip; istrip<iLastStrip; istrip++) {
349 AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,istrip),kTRUE);
350 if ( !pad.IsValid() )
351 {
352 StdoutToAliError(cout << "Pad not found in seg " << endl;
353 seg->Print();
354 cout << " ix,iy=" << icol-1 << "," << istrip << endl;
355 );
356 }
357
358 XYGlobal(detElemId,pad,xyGlobal);
359
360 tab[2*liStripCircuit]=xyGlobal[1];
361 if (istrip!=(iLastStrip-1)) tab[2*liStripCircuit+1]=xyGlobal[1]+xyGlobal[3];
362 liStripCircuit++;
363 }
364}
365
366//----------------------------------------------------------------------
367//--- methods which return member data related info
368//----------------------------------------------------------------------
369Float_t AliMUONTriggerCircuit::GetY11Pos(Int_t istrip) const {
370/// returns Y position of X strip istrip in MC11
371 return fYpos11[istrip];
372}
373//----------------------------------------------------------------------
374Float_t AliMUONTriggerCircuit::GetY21Pos(Int_t istrip) const {
375/// returns Y position of X strip istrip in MC21
376 return fYpos21[istrip];
377}
378//----------------------------------------------------------------------
379Float_t AliMUONTriggerCircuit::GetX11Pos(Int_t istrip) const {
380/// returns X position of Y strip istrip in MC11
381 return fXpos11[istrip];
382}
383//----------------------------------------------------------------------
384//--- end of methods which return member data related info
385//----------------------------------------------------------------------
386/* removed tmp
387void AliMUONTriggerCircuit::dump(const char* what, const Float_t* array, Int_t size)
388{
389 cout << what << " " << endl;
390 for ( Int_t i = 0; i < size; ++i )
391 {
392 cout << array[i] << " , ";
393 }
394 cout << endl;
395}
396
397void AliMUONTriggerCircuit::dump(const char* what, const Int_t* array, Int_t size)
398{
399 cout << what << " " << endl;
400 for ( Int_t i = 0; i < size; ++i )
401 {
402 cout << array[i] << " , ";
403 }
404 cout << endl;
405}
406
407//_____________________________________________________________________________
408void AliMUONTriggerCircuit::Print(Option_t* ) const
409{
410 cout << "IdCircuit " << fILocalBoard << " X2m,X2ud=" << fX2m << ","
411 << fX2ud;
412 for ( Int_t i = 0; i < 2; ++i )
413 {
414 cout << " OrMud[" << i << "]=" << fOrMud[i];
415 }
416 cout << endl;
417 dump("Xpos11",fXpos11,16);
418 dump("Ypos11",fYpos11,31);
419 dump("Ypos21",fYpos21,63);
420 for ( Int_t i = 0; i < 4; ++i )
421 {
422 char s[80];
423 sprintf(s,"Xcode[%d]",i);
424 dump(s,fXcode[i],32);
425 sprintf(s,"Ycode[%d]",i);
426 dump(s,fYcode[i],32);
427 }
428 // Int_t fILocalBoard; // circuit Id number
429 // Int_t fX2m; // internal info needed by TriggerDecision
430 // Int_t fX2ud; // internal info needed by TriggerDecision
431 // Int_t fOrMud[2]; // internal info needed by TriggerDecision
432 // Int_t fXcode[4][32]; // code of X strips
433 // Int_t fYcode[4][32]; // code of Y strips
434 // Float_t fXpos11[16]; // X position of Y strips in MC11
435 // Float_t fYpos11[31]; // Y position of X strips in MC11
436 // Float_t fYpos21[63]; // Y position of X strips in MC21
437
438}
439removed tmp*/
440
441//----------------------------------------------------------------------
442Int_t AliMUONTriggerCircuit::DetElemId(Int_t ichamber, char side, Int_t iline)
443{
444/// returns detection element Id for chamber iChamber, side side and line iline
445 Int_t itmp=0;
446 if ( side == 'R' ) { // right side
447 switch (iline) // (from 1 to 9, from bottom to top)
448 {
449 case 1:
450 itmp = 14;
451 break;
452 case 2:
453 itmp = 15;
454 break;
455 case 3:
456 itmp = 16;
457 break;
458 case 4:
459 itmp = 17;
460 break;
461 case 5:
462 itmp = 0;
463 break;
464 case 6:
465 itmp = 1;
466 break;
467 case 7:
468 itmp = 2;
469 break;
470 case 8:
471 itmp = 3;
472 break;
473 case 9:
474 itmp = 4;
475 break;
476 }
477 } else if ( side == 'L' ) { // left side
478 switch (iline) // (from 1 to 9, from bottom to top)
479 {
480 case 1:
481 itmp = 13;
482 break;
483 case 2:
484 itmp = 12;
485 break;
486 case 3:
487 itmp = 11;
488 break;
489 case 4:
490 itmp = 10;
491 break;
492 case 5:
493 itmp = 9;
494 break;
495 case 6:
496 itmp = 8;
497 break;
498 case 7:
499 itmp = 7;
500 break;
501 case 8:
502 itmp = 6;
503 break;
504 case 9:
505 itmp = 5;
506 break;
507 }
508 }
509 return ((ichamber+1)*100)+itmp;
510}
511
512//----------------------------------------------------------------------
513Int_t
514AliMUONTriggerCircuit::DetElemId(Int_t iChamber, const char* boardName)
515{
516/// returns detection element Id for chamber iChamber and board boardName
517 char side;
518 Int_t iline;
519 Int_t icol;
520
521 DecodeBoardName(boardName, side, iline, icol);
522
523 return DetElemId(iChamber,side,iline);
524}
525
526//----------------------------------------------------------------------
527void
528AliMUONTriggerCircuit::DecodeBoardName(const char* boardName,
529 char& side,
530 Int_t& iLine,
531 Int_t& iCol)
532{
533/// get side, line and col from board boardName
534/// note: icol = icol -1 for iline = 5 w.r.t other ilines
535 side = boardName[0];
536 iLine = boardName[4] - '0';
537 iCol = boardName[2] - '0';
538 if ( iLine == 5 ) --iCol;
539}
540
541//----------------------------------------------------------------------
542Int_t
543AliMUONTriggerCircuit::FirstStrip(const char* boardName)
544{
545/// returns the first strip from mapping for board boardName
546/// take care of special case for boards RC1L6B12 & LC1L6B12
547 Int_t iFirstStrip = -1;
548 Int_t boardNumber = atoi(boardName+6);
549 char side;
550 Int_t iline, icol;
551 DecodeBoardName(boardName,side,iline,icol);
552 switch (boardNumber)
553 {
554 case 12:
555 iFirstStrip = 0;
556 break;
557 case 34:
558 iFirstStrip = 16;
559 break;
560 case 56:
561 iFirstStrip = 32;
562 break;
563 case 78:
564 iFirstStrip = 48;
565 break;
566 }
567 if (icol == 1 && iline == 6) iFirstStrip = iFirstStrip + 16; // special case
568 return iFirstStrip;
569}
570
571//----------------------------------------------------------------------
572void AliMUONTriggerCircuit::XYGlobal(
573 Int_t detElemId, const AliMpPad& pad,
574 Double_t xyGlobal[4])
575{
576/// returns pad x & y positions and x & y pad dimensions in global coordinates
577/// note: no need for transformation for pad dimensions
578
579 // get the pad position and dimensions
580 Double_t xl1 = pad.Position().X();
581 Double_t yl1 = pad.Position().Y();
582 xyGlobal[2] = pad.Dimensions().X(); // half size!
583 xyGlobal[3] = pad.Dimensions().Y(); // half size!
584 Double_t zg1=0;
585
586 // positions from local to global
587 fTransformer->Local2Global(detElemId, xl1, yl1, 0,
588 xyGlobal[0], xyGlobal[1], zg1);
589}