1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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)
24 /// \author Philippe Crochet (LPCCFd)
26 #include "AliMUONTriggerCircuit.h"
27 #include "AliMUONLocalTriggerBoard.h"
28 #include "AliMUONTriggerCrateStore.h"
29 #include "AliMUONTriggerCrate.h"
30 #include "AliMUONGeometryTransformer.h"
32 #include "AliMpTriggerSegmentation.h"
33 #include "AliMpTrigger.h"
34 #include "AliMpSlat.h"
36 #include "AliMpSegmentation.h"
37 #include "AliMpVSegmentation.h"
38 #include "AliMpCathodType.h"
44 #include <Riostream.h>
47 ClassImp(AliMUONTriggerCircuit)
50 //----------------------------------------------------------------------
51 AliMUONTriggerCircuit::AliMUONTriggerCircuit()
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.; }
64 //----------------------------------------------------------------------
65 AliMUONTriggerCircuit::~AliMUONTriggerCircuit()
70 //----------------------------------------------------------------------
71 AliMUONTriggerCircuit::AliMUONTriggerCircuit(const AliMUONTriggerCircuit& circuit)
73 fILocalBoard(circuit.fILocalBoard),
78 for (Int_t i = 0; i < 16; ++i)
79 fXpos11[i] = circuit.fXpos11[i];
81 for (Int_t i = 0; i < 31; ++i)
82 fYpos11[i] = circuit.fYpos11[i];
84 for (Int_t i = 0; i < 63; ++i)
85 fYpos21[i] = circuit.fYpos21[i];
88 //----------------------------------------------------------------------
89 AliMUONTriggerCircuit& AliMUONTriggerCircuit::operator=(const AliMUONTriggerCircuit& circuit)
91 /// Assignment operator
93 if (this == &circuit) return *this;
95 fILocalBoard = circuit.fILocalBoard;
97 for (Int_t i = 0; i < 16; ++i)
98 fXpos11[i] = circuit.fXpos11[i];
100 for (Int_t i = 0; i < 31; ++i)
101 fYpos11[i] = circuit.fYpos11[i];
103 for (Int_t i = 0; i < 63; ++i)
104 fYpos21[i] = circuit.fYpos21[i];
109 //----------------------------------------------------------------------
110 void AliMUONTriggerCircuit::Init(Int_t iCircuit, const AliMUONTriggerCrateStore& crates)
112 /// initialize circuit characteristics
113 fILocalBoard=iCircuit+1;//AliMUONTriggerConstants::CircuitId(iCircuit);
120 //---------------------------------------------------------------------
121 void AliMUONTriggerCircuit::LoadYPos(const AliMUONTriggerCrateStore& crates)
123 /// fill fYpos11 and fYpos21 -> y position of X declusterized strips
125 const AliMUONLocalTriggerBoard* localBoard = crates.LocalBoard(fILocalBoard);
129 AliError(Form("Did not get localboard %d",fILocalBoard));
132 StdoutToAliDebug(1,localBoard->Print("CONF"););
137 const AliMpVSegmentation* seg;
139 Int_t zeroDown = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroDown);
140 Int_t zeroUp = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroUp);
147 DecodeBoardName(localBoard->GetName(),side,iline,icol);
149 Int_t detElemId = DetElemId(ichamber,side,iline);
150 seg = AliMpSegmentation::Instance()
151 ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));
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);
162 detElemId = DetElemId(ichamber,side,iline);
163 seg = AliMpSegmentation::Instance()
164 ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));
166 // second plane middle part
167 Int_t iFirstStripMiddle = FirstStrip(localBoard->GetName());
168 Int_t iLastStripMiddle = iFirstStrip + 16;
170 FillXstrips(seg,detElemId,icol,
171 iFirstStripMiddle,iLastStripMiddle,iStripCircuit,fYpos21);
173 // second plane upper part
174 if (zeroUp == 0) { // something up
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;
184 } else { // upper strips in another detElemId
185 detElemId = DetElemId(ichamber,side,iline+1); // get detElemId
186 seg = AliMpSegmentation::Instance()
187 ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));
190 iLastStripUp = iFirstStripUp + 8;
191 if (iline == 4) icolUp = icol - 1; // special case
192 if (iline == 5) icolUp = icol + 1; // special case
196 FillXstrips(seg,detElemId,icolUp,
197 iFirstStripUp,iLastStripUp,iStripCircuit,fYpos21);
199 // fill strip between middle and upper part
200 fYpos21[47]=(fYpos21[46]+fYpos21[48])/2.;
201 } // end of something up
203 // restore current detElemId & segmentation
204 detElemId = DetElemId(ichamber,side,iline);
205 seg = AliMpSegmentation::Instance()
206 ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));
208 // second plane lower part
209 if (zeroDown == 0) { // something down
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;
220 } else { // lower strips in another detElemId
221 detElemId = DetElemId(ichamber,side,iline-1); // get detElemId
222 seg = AliMpSegmentation::Instance()
223 ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));
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;
237 FillXstrips(seg,detElemId,icolDo,
238 iFirstStripDo,iLastStripDo,iStripCircuit,fYpos21);
240 // fill strip between middle and upper part
241 fYpos21[15]=(fYpos21[14]+fYpos21[16])/2.;
242 } // end of something down
246 //----------------------------------------------------------------------
247 void AliMUONTriggerCircuit::LoadXPos(const AliMUONTriggerCrateStore& crates)
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)
254 const AliMUONLocalTriggerBoard* localBoard = crates.LocalBoard(fILocalBoard);
258 AliError(Form("Did not get localboard %d",fILocalBoard));
261 StdoutToAliDebug(1,localBoard->Print("CONF"););
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;
275 const AliMpVSegmentation* seg;
280 DecodeBoardName(localBoard->GetName(),side,iline,icol);
282 Int_t detElemId=DetElemId(ichamber,side,iline); // get detElemId
283 seg = AliMpSegmentation::Instance()
284 ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));
286 // check if one needs a strip doubling or not
287 if ( (x2u == 1 || x2m == 1 || x2d == 1) && x2m == 1) doubling = kTRUE;
289 // check if one starts at strip = 0 or 8 (boards 26-29 and 143-146)
290 if (zeroAllYLSB == 1) iStripCircuit = 8;
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);
297 const AliMpPCB* pcb = slat->GetPCB(icol-1);
298 iFirstStrip = pcb->Ixmin();
300 if (doubling || zeroAllYLSB == 1) iLastStrip = iFirstStrip + 8;
301 else iLastStrip = iFirstStrip + 16;
303 FillYstrips(seg,detElemId,
304 iFirstStrip,iLastStrip,iStripCircuit,doubling);
307 //----------------------------------------------------------------------
308 void 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)
315 Double_t xyGlobal[4]={0.,0.,0.,0.};
317 for (Int_t istrip=iFirstStrip; istrip<iLastStrip; istrip++) {
319 AliMpPad pad = seg->PadByIndices(AliMpIntPair(istrip,0),kTRUE);
320 if ( !pad.IsValid() )
322 StdoutToAliError(cout << "Pad not found in seg " << endl;
324 cout << " ix,iy=" << istrip << "," << 0 << endl;
327 XYGlobal(detElemId,pad,xyGlobal);
330 fXpos11[liStripCircuit]=xyGlobal[0];
331 } else if (doubling) {
332 fXpos11[2*liStripCircuit]=TMath::Sign(1.,xyGlobal[0]) *
333 (TMath::Abs(xyGlobal[0]) - xyGlobal[2]/2.);
334 fXpos11[2*liStripCircuit+1]=TMath::Sign(1.,xyGlobal[0]) *
335 (TMath::Abs(fXpos11[2*liStripCircuit]) + xyGlobal[2]);
341 //----------------------------------------------------------------------
342 void AliMUONTriggerCircuit::FillXstrips(
343 const AliMpVSegmentation* seg,
344 const Int_t detElemId, const Int_t icol,
345 const Int_t iFirstStrip, const Int_t iLastStrip,
346 Int_t liStripCircuit, Float_t *tab)
349 Double_t xyGlobal[4]={0.,0.,0.,0.};
350 for (Int_t istrip=iFirstStrip; istrip<iLastStrip; istrip++) {
351 AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,istrip),kTRUE);
352 if ( !pad.IsValid() )
354 StdoutToAliError(cout << "Pad not found in seg " << endl;
356 cout << " ix,iy=" << icol-1 << "," << istrip << endl;
360 XYGlobal(detElemId,pad,xyGlobal);
362 tab[2*liStripCircuit]=xyGlobal[1];
363 if (istrip!=(iLastStrip-1)) tab[2*liStripCircuit+1]=xyGlobal[1]+xyGlobal[3];
368 //----------------------------------------------------------------------
369 //--- methods which return member data related info
370 //----------------------------------------------------------------------
371 Float_t AliMUONTriggerCircuit::GetY11Pos(Int_t istrip) const {
372 /// returns Y position of X strip istrip in MC11
373 return fYpos11[istrip];
375 //----------------------------------------------------------------------
376 Float_t AliMUONTriggerCircuit::GetY21Pos(Int_t istrip) const {
377 /// returns Y position of X strip istrip in MC21
378 return fYpos21[istrip];
380 //----------------------------------------------------------------------
381 Float_t AliMUONTriggerCircuit::GetX11Pos(Int_t istrip) const {
382 /// returns X position of Y strip istrip in MC11
383 return fXpos11[istrip];
385 //----------------------------------------------------------------------
386 //--- end of methods which return member data related info
387 //----------------------------------------------------------------------
389 void AliMUONTriggerCircuit::dump(const char* what, const Float_t* array, Int_t size)
391 cout << what << " " << endl;
392 for ( Int_t i = 0; i < size; ++i )
394 cout << array[i] << " , ";
399 void AliMUONTriggerCircuit::dump(const char* what, const Int_t* array, Int_t size)
401 cout << what << " " << endl;
402 for ( Int_t i = 0; i < size; ++i )
404 cout << array[i] << " , ";
409 //_____________________________________________________________________________
410 void AliMUONTriggerCircuit::Print(Option_t* ) const
412 cout << "IdCircuit " << fILocalBoard << " X2m,X2ud=" << fX2m << ","
414 for ( Int_t i = 0; i < 2; ++i )
416 cout << " OrMud[" << i << "]=" << fOrMud[i];
419 dump("Xpos11",fXpos11,16);
420 dump("Ypos11",fYpos11,31);
421 dump("Ypos21",fYpos21,63);
422 for ( Int_t i = 0; i < 4; ++i )
425 sprintf(s,"Xcode[%d]",i);
426 dump(s,fXcode[i],32);
427 sprintf(s,"Ycode[%d]",i);
428 dump(s,fYcode[i],32);
430 // Int_t fILocalBoard; // circuit Id number
431 // Int_t fX2m; // internal info needed by TriggerDecision
432 // Int_t fX2ud; // internal info needed by TriggerDecision
433 // Int_t fOrMud[2]; // internal info needed by TriggerDecision
434 // Int_t fXcode[4][32]; // code of X strips
435 // Int_t fYcode[4][32]; // code of Y strips
436 // Float_t fXpos11[16]; // X position of Y strips in MC11
437 // Float_t fYpos11[31]; // Y position of X strips in MC11
438 // Float_t fYpos21[63]; // Y position of X strips in MC21
443 //----------------------------------------------------------------------
444 Int_t AliMUONTriggerCircuit::DetElemId(Int_t ichamber, char side, Int_t iline)
446 /// returns detection element Id for chamber iChamber, side side and line iline
448 if ( side == 'R' ) { // right side
449 switch (iline) // (from 1 to 9, from bottom to top)
479 } else if ( side == 'L' ) { // left side
480 switch (iline) // (from 1 to 9, from bottom to top)
511 return ((ichamber+1)*100)+itmp;
514 //----------------------------------------------------------------------
516 AliMUONTriggerCircuit::DetElemId(Int_t iChamber, const char* boardName)
518 /// returns detection element Id for chamber iChamber and board boardName
523 DecodeBoardName(boardName, side, iline, icol);
525 return DetElemId(iChamber,side,iline);
528 //----------------------------------------------------------------------
530 AliMUONTriggerCircuit::DecodeBoardName(const char* boardName,
535 /// get side, line and col from board boardName
536 /// note: icol = icol -1 for iline = 5 w.r.t other ilines
538 iLine = boardName[4] - '0';
539 iCol = boardName[2] - '0';
540 if ( iLine == 5 ) --iCol;
543 //----------------------------------------------------------------------
545 AliMUONTriggerCircuit::FirstStrip(const char* boardName)
547 /// returns the first strip from mapping for board boardName
548 /// take care of special case for boards RC1L6B12 & LC1L6B12
549 Int_t iFirstStrip = -1;
550 Int_t boardNumber = atoi(boardName+6);
553 DecodeBoardName(boardName,side,iline,icol);
569 if (icol == 1 && iline == 6) iFirstStrip = iFirstStrip + 16; // special case
573 //----------------------------------------------------------------------
574 void AliMUONTriggerCircuit::XYGlobal(
575 Int_t detElemId, const AliMpPad& pad,
576 Double_t xyGlobal[4])
578 /// returns pad x & y positions and x & y pad dimensions in global coordinates
579 /// note: no need for transformation for pad dimensions
581 // get the pad position and dimensions
582 Double_t xl1 = pad.Position().X();
583 Double_t yl1 = pad.Position().Y();
584 xyGlobal[2] = pad.Dimensions().X(); // half size!
585 xyGlobal[3] = pad.Dimensions().Y(); // half size!
588 // positions from local to global
589 fTransformer->Local2Global(detElemId, xl1, yl1, 0,
590 xyGlobal[0], xyGlobal[1], zg1);