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>
53 ClassImp(AliMUONTriggerCircuit)
56 //----------------------------------------------------------------------
57 AliMUONTriggerCircuit::AliMUONTriggerCircuit(const AliMUONGeometryTransformer* transformer)
59 fkTransformer(transformer),
62 fCurrentLocalBoard(0x0)
66 for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
77 for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) { // board begins at 1
79 AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(i);
83 AliError(Form("Did not get localboard %d",i));
90 printf("LocalBoard %03d \n",i);
92 for (Int_t i1 = 0; i1 < 16; i1++)
93 printf("%02d %7.2f \n",i1,fXpos11[i][i1]);
95 for (Int_t i2 = 0; i2 < 32; i2++)
96 printf("%02d %7.2f \n",i2,fYpos11[i][i2]);
98 for (Int_t i3 = 0; i3 < 64; i3++)
99 printf("%02d %7.2f \n",i3,fYpos21[i][i3]);
100 printf("fZpos11 \n");
101 for (Int_t i4 = 0; i4 < 32; i4++)
102 printf("%02d %8.2f \n",i4,fZpos11[i][i4]);
103 printf("fZpos21 \n");
104 for (Int_t i5 = 0; i5 < 64; i5++)
105 printf("%02d %8.2f \n",i5,fZpos21[i][i5]);
111 //----------------------------------------------------------------------
112 AliMUONTriggerCircuit::~AliMUONTriggerCircuit()
115 for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
121 fXwidth11[i].Reset();
122 fYwidth11[i].Reset();
123 fYwidth21[i].Reset();
128 //----------------------------------------------------------------------
129 AliMUONTriggerCircuit::AliMUONTriggerCircuit(const AliMUONTriggerCircuit& circuit)
131 fkTransformer(circuit.fkTransformer), // do not copy, just pointed to
132 fkCurrentSeg(circuit.fkCurrentSeg),
133 fCurrentDetElem(circuit.fCurrentDetElem),
134 fCurrentLocalBoard(circuit.fCurrentLocalBoard)
138 for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
139 fXpos11[i] = circuit.fXpos11[i];
140 fYpos11[i] = circuit.fYpos11[i];
141 fYpos21[i] = circuit.fYpos21[i];
142 fZpos11[i] = circuit.fZpos11[i];
143 fZpos21[i] = circuit.fZpos21[i];
144 fXwidth11[i] = circuit.fXwidth11[i];
145 fYwidth11[i] = circuit.fYwidth11[i];
146 fYwidth21[i] = circuit.fYwidth21[i];
150 //----------------------------------------------------------------------
151 AliMUONTriggerCircuit& AliMUONTriggerCircuit::operator=(const AliMUONTriggerCircuit& circuit)
153 /// Assignment operator
155 if (this == &circuit) return *this;
157 fkTransformer = circuit.fkTransformer;
158 fkCurrentSeg = circuit.fkCurrentSeg;
159 fCurrentDetElem = circuit.fCurrentDetElem;
160 fCurrentLocalBoard = circuit.fCurrentLocalBoard;
162 for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
163 fXpos11[i] = circuit.fXpos11[i];
164 fYpos11[i] = circuit.fYpos11[i];
165 fYpos21[i] = circuit.fYpos21[i];
166 fZpos11[i] = circuit.fZpos11[i];
167 fZpos21[i] = circuit.fZpos21[i];
168 fXwidth11[i] = circuit.fXwidth11[i];
169 fYwidth11[i] = circuit.fYwidth11[i];
170 fYwidth21[i] = circuit.fYwidth21[i];
177 //---------------------------------------------------------------------
178 void AliMUONTriggerCircuit::LoadYPos(AliMpLocalBoard* const localBoard)
180 /// fill fYpos11 and fYpos21 -> y position of X declusterized strips
182 fCurrentLocalBoard = localBoard->GetId();
186 Int_t zeroDown = localBoard->GetSwitch(AliMpLocalBoard::kZeroDown);
187 Int_t zeroUp = localBoard->GetSwitch(AliMpLocalBoard::kZeroUp);
189 Int_t iline = AliMp::PairFirst(localBoard->GetPosition());
190 Int_t icol = AliMp::PairSecond(localBoard->GetPosition());
191 if ( iline == 5 ) --icol;
195 fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
197 fkCurrentSeg = AliMpSegmentation::Instance()
198 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
200 Int_t iFirstStrip = FirstStrip(localBoard);
201 Int_t iLastStrip = iFirstStrip + 16;
202 Int_t iStripCircuit = 0;
204 FillXstrips(icol, iFirstStrip, iLastStrip,
205 iStripCircuit, kTRUE);
209 fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
211 fkCurrentSeg = AliMpSegmentation::Instance()
212 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
214 // second plane middle part
215 Int_t iFirstStripMiddle = FirstStrip(localBoard);
216 Int_t iLastStripMiddle = iFirstStrip + 16;
219 FillXstrips(icol, iFirstStripMiddle, iLastStripMiddle,
220 iStripCircuit, kFALSE);
222 // second plane upper part
223 if (zeroUp == 0) { // something up
228 // check if we need to move to another detElemId
229 AliMpPad pad = fkCurrentSeg->PadByIndices(icol-1,iLastStripMiddle+1,kFALSE);
231 if (pad.IsValid()) { // upper strips within same detElemId
232 iFirstStripUp = iLastStripMiddle;
233 iLastStripUp = iFirstStripUp + 8;
235 } else { // upper strips in another detElemId
236 fCurrentDetElem = AliMpDDLStore::Instance()->
237 GetNextDEfromLocalBoard(fCurrentLocalBoard, ichamber);
239 fkCurrentSeg = AliMpSegmentation::Instance()
240 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
243 iLastStripUp = iFirstStripUp + 8;
244 if (iline == 4) icolUp = icol - 1; // special case
245 if (iline == 5) icolUp = icol + 1; // special case
249 FillXstrips(icolUp, iFirstStripUp, iLastStripUp,
250 iStripCircuit, kFALSE);
252 // fill strip between middle and upper part
253 fYpos21[fCurrentLocalBoard][47] = (fYpos21[fCurrentLocalBoard][46] +
254 fYpos21[fCurrentLocalBoard][48])/2.;
255 fZpos21[fCurrentLocalBoard][47] = (fZpos21[fCurrentLocalBoard][46] +
256 fZpos21[fCurrentLocalBoard][48])/2.;
257 fYwidth21[fCurrentLocalBoard][47] = (fYwidth21[fCurrentLocalBoard][46] +
258 fYwidth21[fCurrentLocalBoard][48])/2.;
259 } // end of something up
261 // restore current detElemId & segmentation
262 fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
263 fkCurrentSeg = AliMpSegmentation::Instance()
264 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
266 // second plane lower part
267 if (zeroDown == 0) { // something down
272 // check if we need to move to another detElemId
273 AliMpPad pad = fkCurrentSeg->PadByIndices(icol-1,iFirstStripMiddle-1,kFALSE);
274 if (pad.IsValid()) { // lower strips within same detElemId
275 iFirstStripDo = iFirstStripMiddle - 8;
276 iLastStripDo = iFirstStripDo + 8;
278 } else { // lower strips in another detElemId
279 fCurrentDetElem = AliMpDDLStore::Instance()
280 ->GetPreviousDEfromLocalBoard(fCurrentLocalBoard, ichamber);
282 fkCurrentSeg = AliMpSegmentation::Instance()
283 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
285 // get iFirstStrip in this module
286 const AliMpTrigger* t = AliMpSegmentation::Instance()->GetTrigger(fkCurrentSeg);
287 const AliMpSlat* slat = t->GetLayer(0);
289 if (iline == 5) icolDo = icol + 1; // special case
290 if (iline == 6) icolDo = icol - 1; // special case
292 const AliMpPCB* pcb = slat->GetPCB(icolDo-1);
293 iFirstStripDo = (pcb->Iymax() + 1) - 8;
294 iLastStripDo = iFirstStripDo + 8;
298 FillXstrips(icolDo, iFirstStripDo, iLastStripDo,
299 iStripCircuit, kFALSE);
301 // fill strip between middle and upper part
302 fYpos21[fCurrentLocalBoard][15] = (fYpos21[fCurrentLocalBoard][14] +
303 fYpos21[fCurrentLocalBoard][16])/2.;
304 fZpos21[fCurrentLocalBoard][15] = (fZpos21[fCurrentLocalBoard][14] +
305 fZpos21[fCurrentLocalBoard][16])/2.;
306 fYwidth21[fCurrentLocalBoard][15] = (fYwidth21[fCurrentLocalBoard][14] +
307 fYwidth21[fCurrentLocalBoard][16])/2.;
308 } // end of something down
312 //----------------------------------------------------------------------
313 void AliMUONTriggerCircuit::FillXstrips(const Int_t icol,
314 const Int_t iFirstStrip, const Int_t iLastStrip,
315 Int_t liStripCircuit, const Bool_t is11)
318 TArrayF& ypos = (is11) ? fYpos11[fCurrentLocalBoard] : fYpos21[fCurrentLocalBoard];
319 TArrayF& zpos = (is11) ? fZpos11[fCurrentLocalBoard] : fZpos21[fCurrentLocalBoard];
320 TArrayF& ywidth = (is11) ? fYwidth11[fCurrentLocalBoard] : fYwidth21[fCurrentLocalBoard];
322 Double_t xyGlobal[3] = {0.};
323 for (Int_t istrip = iFirstStrip; istrip < iLastStrip; ++istrip) {
325 AliMpPad pad = fkCurrentSeg->PadByIndices(icol-1,istrip,kTRUE);
326 if ( !pad.IsValid() ) {
327 StdoutToAliError(cout << "Pad not found in seg " << endl;
328 fkCurrentSeg->Print();
329 cout << " ix,iy=" << icol-1 << "," << istrip << endl;
332 Float_t yDim = pad.GetDimensionY(); // half size!
334 XYGlobal(pad,xyGlobal);
336 ypos[2*liStripCircuit] = xyGlobal[1];
337 zpos[2*liStripCircuit] = xyGlobal[2];
338 ywidth[2*liStripCircuit] = 2. * yDim;
339 if (istrip != (iLastStrip - 1)) {
340 ypos[2*liStripCircuit+1] = xyGlobal[1] + yDim;
341 zpos[2*liStripCircuit+1] = xyGlobal[2];
342 ywidth[2*liStripCircuit+1] = 2. * yDim;
349 //----------------------------------------------------------------------
350 void AliMUONTriggerCircuit::LoadXPos(AliMpLocalBoard* const localBoard)
352 /// fill fXpos11 -> x position of Y strips for the first plane only
353 /// fXpos11 contains the x position of Y strip for the current circuit
354 /// taking into account whether or nor not part(s) of the circuit
355 /// (middle, up or down) has(have) 16 strips (handdled by means of switchs)
357 fCurrentLocalBoard = localBoard->GetId();
362 Int_t x2u = localBoard->GetSwitch(AliMpLocalBoard::kX2u);
363 Int_t x2m = localBoard->GetSwitch(AliMpLocalBoard::kX2m);
364 Int_t x2d = localBoard->GetSwitch(AliMpLocalBoard::kX2d);
365 Int_t zeroAllYLSB = localBoard->GetSwitch(AliMpLocalBoard::kZeroAllYLSB);
367 Int_t iStripCircuit = 0;
368 Int_t iFirstStrip = 0;
369 Int_t iLastStrip = 0;
370 Bool_t doubling = kFALSE;
372 Int_t iline = AliMp::PairFirst(localBoard->GetPosition());
373 Int_t icol = AliMp::PairSecond(localBoard->GetPosition());
374 if ( iline == 5 ) --icol;
376 fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
378 fkCurrentSeg = AliMpSegmentation::Instance()
379 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
381 // check if one needs a strip doubling or not
382 if ( (x2u || x2m || x2d ) && x2m ) doubling = kTRUE;
385 // check if one starts at strip = 0 or 8 (boards 26-29 and 143-146)
386 if (zeroAllYLSB) iStripCircuit = 8;
388 // get iFirstStrip in this module
389 const AliMpTrigger* t = AliMpSegmentation::Instance()->GetTrigger(fkCurrentSeg);
390 const AliMpSlat* slat = t->GetLayer(0);
392 const AliMpPCB* pcb = slat->GetPCB(icol-1);
393 iFirstStrip = pcb->Ixmin();
396 if (doubling || zeroAllYLSB == 1) iLastStrip = iFirstStrip + 8;
397 else iLastStrip = iFirstStrip + 16;
399 FillYstrips(iFirstStrip, iLastStrip, iStripCircuit, doubling);
402 //----------------------------------------------------------------------
403 void AliMUONTriggerCircuit::FillYstrips(const Int_t iFirstStrip, const Int_t iLastStrip,
404 Int_t liStripCircuit,
405 const Bool_t doubling)
408 Double_t xyGlobal[3] = {0.};
410 for (Int_t istrip = iFirstStrip; istrip < iLastStrip; ++istrip) {
412 AliMpPad pad = fkCurrentSeg->PadByIndices(istrip,0,kTRUE);
414 if ( !pad.IsValid() )
416 StdoutToAliError(cout << "Pad not found in seg " << endl;
417 fkCurrentSeg->Print();
418 cout << " ix,iy=" << istrip << "," << 0 << endl;
421 Float_t xDim = pad.GetDimensionX(); // half size!
423 XYGlobal(pad,xyGlobal);
426 fXpos11[fCurrentLocalBoard].AddAt(xyGlobal[0], liStripCircuit);
427 fXwidth11[fCurrentLocalBoard].AddAt(2. * xDim, liStripCircuit);
428 } else if (doubling) {
430 fXpos11[fCurrentLocalBoard].AddAt(TMath::Sign(1.,xyGlobal[0]) *
431 (TMath::Abs(xyGlobal[0]) - xDim/2.), 2*liStripCircuit);
432 fXwidth11[fCurrentLocalBoard].AddAt(2. * xDim, 2*liStripCircuit);
434 fXpos11[fCurrentLocalBoard].AddAt(TMath::Sign(1.,xyGlobal[0]) *
435 (TMath::Abs(fXpos11[fCurrentLocalBoard][2*liStripCircuit]) + xDim),
436 2*liStripCircuit + 1);
437 fXwidth11[fCurrentLocalBoard].AddAt(2. * xDim, 2*liStripCircuit + 1);
444 //----------------------------------------------------------------------
445 void AliMUONTriggerCircuit::XYGlobal(const AliMpPad& pad,
448 /// returns pad x & y positions and x & y pad dimensions in global coordinates
449 /// note: no need for transformation for pad dimensions
451 // get the pad position and dimensions
452 Double_t xl1 = pad.GetPositionX();
453 Double_t yl1 = pad.GetPositionY();
455 // positions from local to global
456 fkTransformer->Local2Global(fCurrentDetElem, xl1, yl1, 0,
457 xyGlobal[0], xyGlobal[1], xyGlobal[2]);
461 //----------------------------------------------------------------------
462 //--- methods which return member data related info
463 //----------------------------------------------------------------------
464 //----------------------------------------------------------------------
465 Float_t AliMUONTriggerCircuit::GetX11Pos(Int_t localBoardId, Int_t istrip) const
467 /// returns X position of Y strip istrip in MC11
468 return fXpos11[localBoardId][istrip];
470 Float_t AliMUONTriggerCircuit::GetY11Pos(Int_t localBoardId, Int_t istrip) const
472 /// returns Y position of X strip istrip in MC11
473 return fYpos11[localBoardId][istrip];
475 //----------------------------------------------------------------------
476 Float_t AliMUONTriggerCircuit::GetY21Pos(Int_t localBoardId, Int_t istrip) const
478 /// returns Y position of X strip istrip in MC21
479 return fYpos21[localBoardId][istrip];
481 //----------------------------------------------------------------------
482 Float_t AliMUONTriggerCircuit::GetZ11Pos(Int_t localBoardId, Int_t istrip) const
484 /// returns Z position of X strip istrip in MC11
485 return fZpos11[localBoardId][istrip];
487 //----------------------------------------------------------------------
488 Float_t AliMUONTriggerCircuit::GetZ21Pos(Int_t localBoardId, Int_t istrip) const
490 /// returns Z position of X strip istrip in MC21
491 return fZpos21[localBoardId][istrip];
493 Float_t AliMUONTriggerCircuit::GetX11Width(Int_t localBoardId, Int_t istrip) const
495 /// returns width of Y strip istrip in MC11
496 return fXwidth11[localBoardId][istrip];
498 Float_t AliMUONTriggerCircuit::GetY11Width(Int_t localBoardId, Int_t istrip) const
500 /// returns width of X strip istrip in MC11
501 return fYwidth11[localBoardId][istrip];
503 //----------------------------------------------------------------------
504 Float_t AliMUONTriggerCircuit::GetY21Width(Int_t localBoardId, Int_t istrip) const
506 /// returns width of X strip istrip in MC21
507 return fYwidth21[localBoardId][istrip];
510 //----------------------------------------------------------------------
511 Int_t AliMUONTriggerCircuit::FirstStrip(AliMpLocalBoard* localBoard)
513 /// returns the first strip from mapping for board boardName
514 /// take care of special case for boards RC1L6B12 & LC1L6B12
515 Int_t iFirstStrip = -1;
516 Int_t boardNumber = atoi(localBoard->GetName()+6);
518 Int_t iline = AliMp::PairFirst(localBoard->GetPosition());
519 Int_t icol = AliMp::PairSecond(localBoard->GetPosition());
520 if ( iline == 5 ) --icol;
537 if (icol == 1 && iline == 6) iFirstStrip += 16; // special case
541 //----------------------------------------------------------------------
542 Float_t AliMUONTriggerCircuit::PtCal(Int_t localBoardId, Int_t istripX, Int_t idev, Int_t istripY) const{
543 /// returns calculated pt for circuit/istripX/idev/istripY according
544 /// to the formula of the TRD. Note : idev (input) is in [0+30]
546 Int_t istripX2=istripX+idev+1; // find istripX2 using istripX and idev
548 Float_t yPosX1=fYpos11[localBoardId][istripX];
549 Float_t yPosX2=fYpos21[localBoardId][istripX2];
550 Float_t xPosY1=fXpos11[localBoardId][istripY];
552 // Z distance between IP and center of dipole
553 Float_t zf= 0.5 *(AliMUONConstants::CoilZ() + AliMUONConstants::YokeZ());
554 Float_t z1=fZpos11[localBoardId][istripX];
555 Float_t z2=fZpos21[localBoardId][istripX2];
556 Float_t thetaDev=(1./TMath::Abs(zf))*(yPosX1*z2-yPosX2*z1)/(z2-z1);
557 Float_t xf=xPosY1*zf/z1;
558 Float_t yf=yPosX2-((yPosX2-yPosX1)*(z2-zf))/(z2-z1);
559 return (3.*0.3/TMath::Abs(thetaDev)) * TMath::Sqrt(xf*xf+yf*yf)/TMath::Abs(zf);