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