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