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 //-----------------------------------------------------------------------------
19 /// \class AliMUONTriggerCircuit
20 /// Contains as data members the Y positions of the X declusturized strips and
21 /// the X positions of the (doubled or not) Y strips.
22 /// This is used to associate the global positions to the fired strips of the
23 /// local trigger output (see AliMUONTrackReconstructor::MakeTriggerTrack)
25 /// \author Philippe Crochet (LPCCFd)
26 //-----------------------------------------------------------------------------
28 #include "AliMUONTriggerCircuit.h"
29 #include "AliMUONConstants.h"
30 #include "AliMUONGeometryTransformer.h"
32 #include "AliMpTrigger.h"
33 #include "AliMpSlat.h"
35 #include "AliMpSegmentation.h"
36 #include "AliMpVSegmentation.h"
37 #include "AliMpCathodType.h"
38 #include "AliMpDDLStore.h"
39 #include "AliMpLocalBoard.h"
40 #include "AliMpConstants.h"
42 #include "AliMpEncodePair.h"
48 #include <Riostream.h>
51 ClassImp(AliMUONTriggerCircuit)
54 //----------------------------------------------------------------------
55 AliMUONTriggerCircuit::AliMUONTriggerCircuit(const AliMUONGeometryTransformer* transformer)
57 fkTransformer(transformer),
60 fCurrentLocalBoard(0x0)
64 for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
75 for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) { // board begins at 1
77 AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(i);
81 AliError(Form("Did not get localboard %d",i));
88 printf("LocalBoard %03d \n",i);
90 for (Int_t i1 = 0; i1 < 16; i1++)
91 printf("%02d %7.2f \n",i1,fXpos11[i][i1]);
93 for (Int_t i2 = 0; i2 < 32; i2++)
94 printf("%02d %7.2f \n",i2,fYpos11[i][i2]);
96 for (Int_t i3 = 0; i3 < 64; i3++)
97 printf("%02d %7.2f \n",i3,fYpos21[i][i3]);
99 for (Int_t i4 = 0; i4 < 32; i4++)
100 printf("%02d %8.2f \n",i4,fZpos11[i][i4]);
101 printf("fZpos21 \n");
102 for (Int_t i5 = 0; i5 < 64; i5++)
103 printf("%02d %8.2f \n",i5,fZpos21[i][i5]);
109 //----------------------------------------------------------------------
110 AliMUONTriggerCircuit::~AliMUONTriggerCircuit()
113 for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
119 fXwidth11[i].Reset();
120 fYwidth11[i].Reset();
121 fYwidth21[i].Reset();
126 //----------------------------------------------------------------------
127 AliMUONTriggerCircuit::AliMUONTriggerCircuit(const AliMUONTriggerCircuit& circuit)
129 fkTransformer(circuit.fkTransformer), // do not copy, just pointed to
130 fkCurrentSeg(circuit.fkCurrentSeg),
131 fCurrentDetElem(circuit.fCurrentDetElem),
132 fCurrentLocalBoard(circuit.fCurrentLocalBoard)
136 for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
137 fXpos11[i] = circuit.fXpos11[i];
138 fYpos11[i] = circuit.fYpos11[i];
139 fYpos21[i] = circuit.fYpos21[i];
140 fZpos11[i] = circuit.fZpos11[i];
141 fZpos21[i] = circuit.fZpos21[i];
142 fXwidth11[i] = circuit.fXwidth11[i];
143 fYwidth11[i] = circuit.fYwidth11[i];
144 fYwidth21[i] = circuit.fYwidth21[i];
148 //----------------------------------------------------------------------
149 AliMUONTriggerCircuit& AliMUONTriggerCircuit::operator=(const AliMUONTriggerCircuit& circuit)
151 /// Assignment operator
153 if (this == &circuit) return *this;
155 fkTransformer = circuit.fkTransformer;
156 fkCurrentSeg = circuit.fkCurrentSeg;
157 fCurrentDetElem = circuit.fCurrentDetElem;
158 fCurrentLocalBoard = circuit.fCurrentLocalBoard;
160 for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
161 fXpos11[i] = circuit.fXpos11[i];
162 fYpos11[i] = circuit.fYpos11[i];
163 fYpos21[i] = circuit.fYpos21[i];
164 fZpos11[i] = circuit.fZpos11[i];
165 fZpos21[i] = circuit.fZpos21[i];
166 fXwidth11[i] = circuit.fXwidth11[i];
167 fYwidth11[i] = circuit.fYwidth11[i];
168 fYwidth21[i] = circuit.fYwidth21[i];
175 //---------------------------------------------------------------------
176 void AliMUONTriggerCircuit::LoadYPos(AliMpLocalBoard* const localBoard)
178 /// fill fYpos11 and fYpos21 -> y position of X declusterized strips
180 fCurrentLocalBoard = localBoard->GetId();
184 Int_t zeroDown = localBoard->GetSwitch(AliMpLocalBoard::kZeroDown);
185 Int_t zeroUp = localBoard->GetSwitch(AliMpLocalBoard::kZeroUp);
187 Int_t iline = AliMp::PairFirst(localBoard->GetPosition());
188 Int_t icol = AliMp::PairSecond(localBoard->GetPosition());
189 if ( iline == 5 ) --icol;
193 fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
195 fkCurrentSeg = AliMpSegmentation::Instance()
196 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
198 Int_t iFirstStrip = FirstStrip(localBoard);
199 Int_t iLastStrip = iFirstStrip + 16;
200 Int_t iStripCircuit = 0;
202 FillXstrips(icol, iFirstStrip, iLastStrip,
203 iStripCircuit, kTRUE);
207 fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
209 fkCurrentSeg = AliMpSegmentation::Instance()
210 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
212 // second plane middle part
213 Int_t iFirstStripMiddle = FirstStrip(localBoard);
214 Int_t iLastStripMiddle = iFirstStrip + 16;
217 FillXstrips(icol, iFirstStripMiddle, iLastStripMiddle,
218 iStripCircuit, kFALSE);
220 // second plane upper part
221 if (zeroUp == 0) { // something up
226 // check if we need to move to another detElemId
227 AliMpPad pad = fkCurrentSeg->PadByIndices(icol-1,iLastStripMiddle+1,kFALSE);
229 if (pad.IsValid()) { // upper strips within same detElemId
230 iFirstStripUp = iLastStripMiddle;
231 iLastStripUp = iFirstStripUp + 8;
233 } else { // upper strips in another detElemId
234 fCurrentDetElem = AliMpDDLStore::Instance()->
235 GetNextDEfromLocalBoard(fCurrentLocalBoard, ichamber);
237 fkCurrentSeg = AliMpSegmentation::Instance()
238 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
241 iLastStripUp = iFirstStripUp + 8;
242 if (iline == 4) icolUp = icol - 1; // special case
243 if (iline == 5) icolUp = icol + 1; // special case
247 FillXstrips(icolUp, iFirstStripUp, iLastStripUp,
248 iStripCircuit, kFALSE);
250 // fill strip between middle and upper part
251 fYpos21[fCurrentLocalBoard][47] = (fYpos21[fCurrentLocalBoard][46] +
252 fYpos21[fCurrentLocalBoard][48])/2.;
253 fZpos21[fCurrentLocalBoard][47] = (fZpos21[fCurrentLocalBoard][46] +
254 fZpos21[fCurrentLocalBoard][48])/2.;
255 fYwidth21[fCurrentLocalBoard][47] = (fYwidth21[fCurrentLocalBoard][46] +
256 fYwidth21[fCurrentLocalBoard][48])/2.;
257 } // end of something up
259 // restore current detElemId & segmentation
260 fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
261 fkCurrentSeg = AliMpSegmentation::Instance()
262 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
264 // second plane lower part
265 if (zeroDown == 0) { // something down
270 // check if we need to move to another detElemId
271 AliMpPad pad = fkCurrentSeg->PadByIndices(icol-1,iFirstStripMiddle-1,kFALSE);
272 if (pad.IsValid()) { // lower strips within same detElemId
273 iFirstStripDo = iFirstStripMiddle - 8;
274 iLastStripDo = iFirstStripDo + 8;
276 } else { // lower strips in another detElemId
277 fCurrentDetElem = AliMpDDLStore::Instance()
278 ->GetPreviousDEfromLocalBoard(fCurrentLocalBoard, ichamber);
280 fkCurrentSeg = AliMpSegmentation::Instance()
281 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
283 // get iFirstStrip in this module
284 const AliMpTrigger* t = AliMpSegmentation::Instance()->GetTrigger(fkCurrentSeg);
285 const AliMpSlat* slat = t->GetLayer(0);
287 if (iline == 5) icolDo = icol + 1; // special case
288 if (iline == 6) icolDo = icol - 1; // special case
290 const AliMpPCB* pcb = slat->GetPCB(icolDo-1);
291 iFirstStripDo = (pcb->Iymax() + 1) - 8;
292 iLastStripDo = iFirstStripDo + 8;
296 FillXstrips(icolDo, iFirstStripDo, iLastStripDo,
297 iStripCircuit, kFALSE);
299 // fill strip between middle and upper part
300 fYpos21[fCurrentLocalBoard][15] = (fYpos21[fCurrentLocalBoard][14] +
301 fYpos21[fCurrentLocalBoard][16])/2.;
302 fZpos21[fCurrentLocalBoard][15] = (fZpos21[fCurrentLocalBoard][14] +
303 fZpos21[fCurrentLocalBoard][16])/2.;
304 fYwidth21[fCurrentLocalBoard][15] = (fYwidth21[fCurrentLocalBoard][14] +
305 fYwidth21[fCurrentLocalBoard][16])/2.;
306 } // end of something down
310 //----------------------------------------------------------------------
311 void AliMUONTriggerCircuit::FillXstrips(const Int_t icol,
312 const Int_t iFirstStrip, const Int_t iLastStrip,
313 Int_t liStripCircuit, const Bool_t is11)
316 TArrayF& ypos = (is11) ? fYpos11[fCurrentLocalBoard] : fYpos21[fCurrentLocalBoard];
317 TArrayF& zpos = (is11) ? fZpos11[fCurrentLocalBoard] : fZpos21[fCurrentLocalBoard];
318 TArrayF& ywidth = (is11) ? fYwidth11[fCurrentLocalBoard] : fYwidth21[fCurrentLocalBoard];
320 Double_t xyGlobal[3] = {0.};
321 for (Int_t istrip = iFirstStrip; istrip < iLastStrip; ++istrip) {
323 AliMpPad pad = fkCurrentSeg->PadByIndices(icol-1,istrip,kTRUE);
324 if ( !pad.IsValid() ) {
325 StdoutToAliError(cout << "Pad not found in seg " << endl;
326 fkCurrentSeg->Print();
327 cout << " ix,iy=" << icol-1 << "," << istrip << endl;
330 Float_t yDim = pad.GetDimensionY(); // half size!
332 XYGlobal(pad,xyGlobal);
334 ypos[2*liStripCircuit] = xyGlobal[1];
335 zpos[2*liStripCircuit] = xyGlobal[2];
336 ywidth[2*liStripCircuit] = 2. * yDim;
337 if (istrip != (iLastStrip - 1)) {
338 ypos[2*liStripCircuit+1] = xyGlobal[1] + yDim;
339 zpos[2*liStripCircuit+1] = xyGlobal[2];
340 ywidth[2*liStripCircuit+1] = 2. * yDim;
347 //----------------------------------------------------------------------
348 void AliMUONTriggerCircuit::LoadXPos(AliMpLocalBoard* const localBoard)
350 /// fill fXpos11 -> x position of Y strips for the first plane only
351 /// fXpos11 contains the x position of Y strip for the current circuit
352 /// taking into account whether or nor not part(s) of the circuit
353 /// (middle, up or down) has(have) 16 strips (handdled by means of switchs)
355 fCurrentLocalBoard = localBoard->GetId();
360 Int_t x2u = localBoard->GetSwitch(AliMpLocalBoard::kX2u);
361 Int_t x2m = localBoard->GetSwitch(AliMpLocalBoard::kX2m);
362 Int_t x2d = localBoard->GetSwitch(AliMpLocalBoard::kX2d);
363 Int_t zeroAllYLSB = localBoard->GetSwitch(AliMpLocalBoard::kZeroAllYLSB);
365 Int_t iStripCircuit = 0;
366 Int_t iFirstStrip = 0;
367 Int_t iLastStrip = 0;
368 Bool_t doubling = kFALSE;
370 Int_t iline = AliMp::PairFirst(localBoard->GetPosition());
371 Int_t icol = AliMp::PairSecond(localBoard->GetPosition());
372 if ( iline == 5 ) --icol;
374 fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
376 fkCurrentSeg = AliMpSegmentation::Instance()
377 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
379 // check if one needs a strip doubling or not
380 if ( (x2u || x2m || x2d ) && x2m ) doubling = kTRUE;
383 // check if one starts at strip = 0 or 8 (boards 26-29 and 143-146)
384 if (zeroAllYLSB) iStripCircuit = 8;
386 // get iFirstStrip in this module
387 const AliMpTrigger* t = AliMpSegmentation::Instance()->GetTrigger(fkCurrentSeg);
388 const AliMpSlat* slat = t->GetLayer(0);
390 const AliMpPCB* pcb = slat->GetPCB(icol-1);
391 iFirstStrip = pcb->Ixmin();
394 if (doubling || zeroAllYLSB == 1) iLastStrip = iFirstStrip + 8;
395 else iLastStrip = iFirstStrip + 16;
397 FillYstrips(iFirstStrip, iLastStrip, iStripCircuit, doubling);
400 //----------------------------------------------------------------------
401 void AliMUONTriggerCircuit::FillYstrips(const Int_t iFirstStrip, const Int_t iLastStrip,
402 Int_t liStripCircuit,
403 const Bool_t doubling)
406 Double_t xyGlobal[3] = {0.};
408 for (Int_t istrip = iFirstStrip; istrip < iLastStrip; ++istrip) {
410 AliMpPad pad = fkCurrentSeg->PadByIndices(istrip,0,kTRUE);
412 if ( !pad.IsValid() )
414 StdoutToAliError(cout << "Pad not found in seg " << endl;
415 fkCurrentSeg->Print();
416 cout << " ix,iy=" << istrip << "," << 0 << endl;
419 Float_t xDim = pad.GetDimensionX(); // half size!
421 XYGlobal(pad,xyGlobal);
424 fXpos11[fCurrentLocalBoard].AddAt(xyGlobal[0], liStripCircuit);
425 fXwidth11[fCurrentLocalBoard].AddAt(2. * xDim, liStripCircuit);
426 } else if (doubling) {
428 fXpos11[fCurrentLocalBoard].AddAt(TMath::Sign(1.,xyGlobal[0]) *
429 (TMath::Abs(xyGlobal[0]) - xDim/2.), 2*liStripCircuit);
430 fXwidth11[fCurrentLocalBoard].AddAt(2. * xDim, 2*liStripCircuit);
432 fXpos11[fCurrentLocalBoard].AddAt(TMath::Sign(1.,xyGlobal[0]) *
433 (TMath::Abs(fXpos11[fCurrentLocalBoard][2*liStripCircuit]) + xDim),
434 2*liStripCircuit + 1);
435 fXwidth11[fCurrentLocalBoard].AddAt(2. * xDim, 2*liStripCircuit + 1);
442 //----------------------------------------------------------------------
443 void AliMUONTriggerCircuit::XYGlobal(const AliMpPad& pad,
446 /// returns pad x & y positions and x & y pad dimensions in global coordinates
447 /// note: no need for transformation for pad dimensions
449 // get the pad position and dimensions
450 Double_t xl1 = pad.GetPositionX();
451 Double_t yl1 = pad.GetPositionY();
453 // positions from local to global
454 fkTransformer->Local2Global(fCurrentDetElem, xl1, yl1, 0,
455 xyGlobal[0], xyGlobal[1], xyGlobal[2]);
459 //----------------------------------------------------------------------
460 //--- methods which return member data related info
461 //----------------------------------------------------------------------
462 //----------------------------------------------------------------------
463 Float_t AliMUONTriggerCircuit::GetX11Pos(Int_t localBoardId, Int_t istrip) const
465 /// returns X position of Y strip istrip in MC11
466 return fXpos11[localBoardId][istrip];
468 Float_t AliMUONTriggerCircuit::GetY11Pos(Int_t localBoardId, Int_t istrip) const
470 /// returns Y position of X strip istrip in MC11
471 return fYpos11[localBoardId][istrip];
473 //----------------------------------------------------------------------
474 Float_t AliMUONTriggerCircuit::GetY21Pos(Int_t localBoardId, Int_t istrip) const
476 /// returns Y position of X strip istrip in MC21
477 return fYpos21[localBoardId][istrip];
479 //----------------------------------------------------------------------
480 Float_t AliMUONTriggerCircuit::GetZ11Pos(Int_t localBoardId, Int_t istrip) const
482 /// returns Z position of X strip istrip in MC11
483 return fZpos11[localBoardId][istrip];
485 //----------------------------------------------------------------------
486 Float_t AliMUONTriggerCircuit::GetZ21Pos(Int_t localBoardId, Int_t istrip) const
488 /// returns Z position of X strip istrip in MC21
489 return fZpos21[localBoardId][istrip];
491 Float_t AliMUONTriggerCircuit::GetX11Width(Int_t localBoardId, Int_t istrip) const
493 /// returns width of Y strip istrip in MC11
494 return fXwidth11[localBoardId][istrip];
496 Float_t AliMUONTriggerCircuit::GetY11Width(Int_t localBoardId, Int_t istrip) const
498 /// returns width of X strip istrip in MC11
499 return fYwidth11[localBoardId][istrip];
501 //----------------------------------------------------------------------
502 Float_t AliMUONTriggerCircuit::GetY21Width(Int_t localBoardId, Int_t istrip) const
504 /// returns width of X strip istrip in MC21
505 return fYwidth21[localBoardId][istrip];
508 //----------------------------------------------------------------------
509 Int_t AliMUONTriggerCircuit::FirstStrip(AliMpLocalBoard* localBoard)
511 /// returns the first strip from mapping for board boardName
512 /// take care of special case for boards RC1L6B12 & LC1L6B12
513 Int_t iFirstStrip = -1;
514 Int_t boardNumber = atoi(localBoard->GetName()+6);
516 Int_t iline = AliMp::PairFirst(localBoard->GetPosition());
517 Int_t icol = AliMp::PairSecond(localBoard->GetPosition());
518 if ( iline == 5 ) --icol;
535 if (icol == 1 && iline == 6) iFirstStrip += 16; // special case
539 //----------------------------------------------------------------------
540 Float_t AliMUONTriggerCircuit::PtCal(Int_t localBoardId, Int_t istripX, Int_t idev, Int_t istripY) const{
541 /// returns calculated pt for circuit/istripX/idev/istripY according
542 /// to the formula of the TRD. Note : idev (input) is in [0+30]
544 Int_t istripX2=istripX+idev+1; // find istripX2 using istripX and idev
546 Float_t yPosX1=fYpos11[localBoardId][istripX];
547 Float_t yPosX2=fYpos21[localBoardId][istripX2];
548 Float_t xPosY1=fXpos11[localBoardId][istripY];
550 // Z distance between IP and center of dipole
551 Float_t zf= 0.5 *(AliMUONConstants::CoilZ() + AliMUONConstants::YokeZ());
552 Float_t z1=fZpos11[localBoardId][istripX];
553 Float_t z2=fZpos21[localBoardId][istripX2];
554 Float_t thetaDev=(1./TMath::Abs(zf))*(yPosX1*z2-yPosX2*z1)/(z2-z1);
555 Float_t xf=xPosY1*zf/z1;
556 Float_t yf=yPosX2-((yPosX2-yPosX1)*(z2-zf))/(z2-z1);
557 return (3.*0.3/TMath::Abs(thetaDev)) * TMath::Sqrt(xf*xf+yf*yf)/TMath::Abs(zf);