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));
92 //----------------------------------------------------------------------
93 AliMUONTriggerCircuit::~AliMUONTriggerCircuit()
96 for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
102 fXwidth11[i].Reset();
103 fYwidth11[i].Reset();
104 fYwidth21[i].Reset();
109 //----------------------------------------------------------------------
110 AliMUONTriggerCircuit::AliMUONTriggerCircuit(const AliMUONTriggerCircuit& circuit)
112 fkTransformer(circuit.fkTransformer), // do not copy, just pointed to
113 fkCurrentSeg(circuit.fkCurrentSeg),
114 fCurrentDetElem(circuit.fCurrentDetElem),
115 fCurrentLocalBoard(circuit.fCurrentLocalBoard)
119 for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
120 fXpos11[i] = circuit.fXpos11[i];
121 fYpos11[i] = circuit.fYpos11[i];
122 fYpos21[i] = circuit.fYpos21[i];
123 fZpos11[i] = circuit.fZpos11[i];
124 fZpos21[i] = circuit.fZpos21[i];
125 fXwidth11[i] = circuit.fXwidth11[i];
126 fYwidth11[i] = circuit.fYwidth11[i];
127 fYwidth21[i] = circuit.fYwidth21[i];
131 //----------------------------------------------------------------------
132 AliMUONTriggerCircuit& AliMUONTriggerCircuit::operator=(const AliMUONTriggerCircuit& circuit)
134 /// Assignment operator
136 if (this == &circuit) return *this;
138 fkTransformer = circuit.fkTransformer;
139 fkCurrentSeg = circuit.fkCurrentSeg;
140 fCurrentDetElem = circuit.fCurrentDetElem;
141 fCurrentLocalBoard = circuit.fCurrentLocalBoard;
143 for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
144 fXpos11[i] = circuit.fXpos11[i];
145 fYpos11[i] = circuit.fYpos11[i];
146 fYpos21[i] = circuit.fYpos21[i];
147 fZpos11[i] = circuit.fZpos11[i];
148 fZpos21[i] = circuit.fZpos21[i];
149 fXwidth11[i] = circuit.fXwidth11[i];
150 fYwidth11[i] = circuit.fYwidth11[i];
151 fYwidth21[i] = circuit.fYwidth21[i];
158 //---------------------------------------------------------------------
159 void AliMUONTriggerCircuit::LoadYPos(AliMpLocalBoard* const localBoard)
161 /// fill fYpos11 and fYpos21 -> y position of X declusterized strips
163 fCurrentLocalBoard = localBoard->GetId();
167 Int_t zeroDown = localBoard->GetSwitch(AliMpLocalBoard::kZeroDown);
168 Int_t zeroUp = localBoard->GetSwitch(AliMpLocalBoard::kZeroUp);
170 Int_t iline = AliMp::PairFirst(localBoard->GetPosition());
171 Int_t icol = AliMp::PairSecond(localBoard->GetPosition());
172 if ( iline == 5 ) --icol;
176 fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
178 fkCurrentSeg = AliMpSegmentation::Instance()
179 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
181 Int_t iFirstStrip = FirstStrip(localBoard);
182 Int_t iLastStrip = iFirstStrip + 16;
183 Int_t iStripCircuit = 0;
185 FillXstrips(icol, iFirstStrip, iLastStrip,
186 iStripCircuit, kTRUE);
190 fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
192 fkCurrentSeg = AliMpSegmentation::Instance()
193 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
195 // second plane middle part
196 Int_t iFirstStripMiddle = FirstStrip(localBoard);
197 Int_t iLastStripMiddle = iFirstStrip + 16;
200 FillXstrips(icol, iFirstStripMiddle, iLastStripMiddle,
201 iStripCircuit, kFALSE);
203 // second plane upper part
204 if (zeroUp == 0) { // something up
209 // check if we need to move to another detElemId
210 AliMpPad pad = fkCurrentSeg->PadByIndices(icol-1,iLastStripMiddle+1,kFALSE);
212 if (pad.IsValid()) { // upper strips within same detElemId
213 iFirstStripUp = iLastStripMiddle;
214 iLastStripUp = iFirstStripUp + 8;
216 } else { // upper strips in another detElemId
217 fCurrentDetElem = AliMpDDLStore::Instance()->
218 GetNextDEfromLocalBoard(fCurrentLocalBoard, ichamber);
220 fkCurrentSeg = AliMpSegmentation::Instance()
221 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
224 iLastStripUp = iFirstStripUp + 8;
225 if (iline == 4) icolUp = icol - 1; // special case
226 if (iline == 5) icolUp = icol + 1; // special case
230 FillXstrips(icolUp, iFirstStripUp, iLastStripUp,
231 iStripCircuit, kFALSE);
233 // fill strip between middle and upper part
234 fYpos21[fCurrentLocalBoard][47] = (fYpos21[fCurrentLocalBoard][46] +
235 fYpos21[fCurrentLocalBoard][48])/2.;
236 fZpos21[fCurrentLocalBoard][47] = (fZpos21[fCurrentLocalBoard][46] +
237 fZpos21[fCurrentLocalBoard][48])/2.;
238 fYwidth21[fCurrentLocalBoard][47] = (fYwidth21[fCurrentLocalBoard][46] +
239 fYwidth21[fCurrentLocalBoard][48])/2.;
240 } // end of something up
242 // restore current detElemId & segmentation
243 fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
244 fkCurrentSeg = AliMpSegmentation::Instance()
245 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
247 // second plane lower part
248 if (zeroDown == 0) { // something down
253 // check if we need to move to another detElemId
254 AliMpPad pad = fkCurrentSeg->PadByIndices(icol-1,iFirstStripMiddle-1,kFALSE);
255 if (pad.IsValid()) { // lower strips within same detElemId
256 iFirstStripDo = iFirstStripMiddle - 8;
257 iLastStripDo = iFirstStripDo + 8;
259 } else { // lower strips in another detElemId
260 fCurrentDetElem = AliMpDDLStore::Instance()
261 ->GetPreviousDEfromLocalBoard(fCurrentLocalBoard, ichamber);
263 fkCurrentSeg = AliMpSegmentation::Instance()
264 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
266 // get iFirstStrip in this module
267 const AliMpTrigger* t = AliMpSegmentation::Instance()->GetTrigger(fkCurrentSeg);
268 const AliMpSlat* slat = t->GetLayer(0);
270 if (iline == 5) icolDo = icol + 1; // special case
271 if (iline == 6) icolDo = icol - 1; // special case
273 const AliMpPCB* pcb = slat->GetPCB(icolDo-1);
274 iFirstStripDo = (pcb->Iymax() + 1) - 8;
275 iLastStripDo = iFirstStripDo + 8;
279 FillXstrips(icolDo, iFirstStripDo, iLastStripDo,
280 iStripCircuit, kFALSE);
282 // fill strip between middle and upper part
283 fYpos21[fCurrentLocalBoard][15] = (fYpos21[fCurrentLocalBoard][14] +
284 fYpos21[fCurrentLocalBoard][16])/2.;
285 fZpos21[fCurrentLocalBoard][15] = (fZpos21[fCurrentLocalBoard][14] +
286 fZpos21[fCurrentLocalBoard][16])/2.;
287 fYwidth21[fCurrentLocalBoard][15] = (fYwidth21[fCurrentLocalBoard][14] +
288 fYwidth21[fCurrentLocalBoard][16])/2.;
289 } // end of something down
293 //----------------------------------------------------------------------
294 void AliMUONTriggerCircuit::FillXstrips(const Int_t icol,
295 const Int_t iFirstStrip, const Int_t iLastStrip,
296 Int_t liStripCircuit, const Bool_t is11)
299 TArrayF& ypos = (is11) ? fYpos11[fCurrentLocalBoard] : fYpos21[fCurrentLocalBoard];
300 TArrayF& zpos = (is11) ? fZpos11[fCurrentLocalBoard] : fZpos21[fCurrentLocalBoard];
301 TArrayF& ywidth = (is11) ? fYwidth11[fCurrentLocalBoard] : fYwidth21[fCurrentLocalBoard];
303 Double_t xyGlobal[3] = {0.};
304 for (Int_t istrip = iFirstStrip; istrip < iLastStrip; ++istrip) {
306 AliMpPad pad = fkCurrentSeg->PadByIndices(icol-1,istrip,kTRUE);
307 if ( !pad.IsValid() ) {
308 StdoutToAliError(cout << "Pad not found in seg " << endl;
309 fkCurrentSeg->Print();
310 cout << " ix,iy=" << icol-1 << "," << istrip << endl;
313 Float_t yDim = pad.GetDimensionY(); // half size!
315 XYGlobal(pad,xyGlobal);
317 ypos[2*liStripCircuit] = xyGlobal[1];
318 zpos[2*liStripCircuit] = xyGlobal[2];
319 ywidth[2*liStripCircuit] = 2. * yDim;
320 if (istrip != (iLastStrip - 1)) {
321 ypos[2*liStripCircuit+1] = xyGlobal[1] + yDim;
322 zpos[2*liStripCircuit+1] = xyGlobal[2];
323 ywidth[2*liStripCircuit+1] = 2. * yDim;
330 //----------------------------------------------------------------------
331 void AliMUONTriggerCircuit::LoadXPos(AliMpLocalBoard* const localBoard)
333 /// fill fXpos11 -> x position of Y strips for the first plane only
334 /// fXpos11 contains the x position of Y strip for the current circuit
335 /// taking into account whether or nor not part(s) of the circuit
336 /// (middle, up or down) has(have) 16 strips (handdled by means of switchs)
338 fCurrentLocalBoard = localBoard->GetId();
343 Int_t x2u = localBoard->GetSwitch(AliMpLocalBoard::kX2u);
344 Int_t x2m = localBoard->GetSwitch(AliMpLocalBoard::kX2m);
345 Int_t x2d = localBoard->GetSwitch(AliMpLocalBoard::kX2d);
346 Int_t zeroAllYLSB = localBoard->GetSwitch(AliMpLocalBoard::kZeroAllYLSB);
348 Int_t iStripCircuit = 0;
349 Int_t iFirstStrip = 0;
350 Int_t iLastStrip = 0;
351 Bool_t doubling = kFALSE;
353 Int_t iline = AliMp::PairFirst(localBoard->GetPosition());
354 Int_t icol = AliMp::PairSecond(localBoard->GetPosition());
355 if ( iline == 5 ) --icol;
357 fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
359 fkCurrentSeg = AliMpSegmentation::Instance()
360 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
362 // check if one needs a strip doubling or not
363 if ( (x2u || x2m || x2d ) && x2m ) doubling = kTRUE;
366 // check if one starts at strip = 0 or 8 (boards 26-29 and 143-146)
367 if (zeroAllYLSB) iStripCircuit = 8;
369 // get iFirstStrip in this module
370 const AliMpTrigger* t = AliMpSegmentation::Instance()->GetTrigger(fkCurrentSeg);
371 const AliMpSlat* slat = t->GetLayer(0);
373 const AliMpPCB* pcb = slat->GetPCB(icol-1);
374 iFirstStrip = pcb->Ixmin();
377 if (doubling || zeroAllYLSB == 1) iLastStrip = iFirstStrip + 8;
378 else iLastStrip = iFirstStrip + 16;
380 FillYstrips(iFirstStrip, iLastStrip, iStripCircuit, doubling);
383 //----------------------------------------------------------------------
384 void AliMUONTriggerCircuit::FillYstrips(const Int_t iFirstStrip, const Int_t iLastStrip,
385 Int_t liStripCircuit,
386 const Bool_t doubling)
389 Double_t xyGlobal[3] = {0.};
391 for (Int_t istrip = iFirstStrip; istrip < iLastStrip; ++istrip) {
393 AliMpPad pad = fkCurrentSeg->PadByIndices(istrip,0,kTRUE);
395 if ( !pad.IsValid() )
397 StdoutToAliError(cout << "Pad not found in seg " << endl;
398 fkCurrentSeg->Print();
399 cout << " ix,iy=" << istrip << "," << 0 << endl;
402 Float_t xDim = pad.GetDimensionX(); // half size!
404 XYGlobal(pad,xyGlobal);
407 fXpos11[fCurrentLocalBoard].AddAt(xyGlobal[0], liStripCircuit);
408 fXwidth11[fCurrentLocalBoard].AddAt(2. * xDim, liStripCircuit);
409 } else if (doubling) {
411 fXpos11[fCurrentLocalBoard].AddAt(TMath::Sign(1.,xyGlobal[0]) *
412 (TMath::Abs(xyGlobal[0]) - xDim/2.), 2*liStripCircuit);
413 fXwidth11[fCurrentLocalBoard].AddAt(2. * xDim, 2*liStripCircuit);
415 fXpos11[fCurrentLocalBoard].AddAt(TMath::Sign(1.,xyGlobal[0]) *
416 (TMath::Abs(fXpos11[fCurrentLocalBoard][2*liStripCircuit]) + xDim),
417 2*liStripCircuit + 1);
418 fXwidth11[fCurrentLocalBoard].AddAt(2. * xDim, 2*liStripCircuit + 1);
425 //----------------------------------------------------------------------
426 void AliMUONTriggerCircuit::XYGlobal(const AliMpPad& pad,
429 /// returns pad x & y positions and x & y pad dimensions in global coordinates
430 /// note: no need for transformation for pad dimensions
432 // get the pad position and dimensions
433 Double_t xl1 = pad.GetPositionX();
434 Double_t yl1 = pad.GetPositionY();
436 // positions from local to global
437 fkTransformer->Local2Global(fCurrentDetElem, xl1, yl1, 0,
438 xyGlobal[0], xyGlobal[1], xyGlobal[2]);
442 //----------------------------------------------------------------------
443 //--- methods which return member data related info
444 //----------------------------------------------------------------------
445 //----------------------------------------------------------------------
446 Float_t AliMUONTriggerCircuit::GetX11Pos(Int_t localBoardId, Int_t istrip) const
448 /// returns X position of Y strip istrip in MC11
449 return fXpos11[localBoardId][istrip];
451 Float_t AliMUONTriggerCircuit::GetY11Pos(Int_t localBoardId, Int_t istrip) const
453 /// returns Y position of X strip istrip in MC11
454 return fYpos11[localBoardId][istrip];
456 //----------------------------------------------------------------------
457 Float_t AliMUONTriggerCircuit::GetY21Pos(Int_t localBoardId, Int_t istrip) const
459 /// returns Y position of X strip istrip in MC21
460 return fYpos21[localBoardId][istrip];
462 //----------------------------------------------------------------------
463 Float_t AliMUONTriggerCircuit::GetZ11Pos(Int_t localBoardId, Int_t istrip) const
465 /// returns Z position of X strip istrip in MC11
466 return fZpos11[localBoardId][istrip];
468 //----------------------------------------------------------------------
469 Float_t AliMUONTriggerCircuit::GetZ21Pos(Int_t localBoardId, Int_t istrip) const
471 /// returns Z position of X strip istrip in MC21
472 return fZpos21[localBoardId][istrip];
474 Float_t AliMUONTriggerCircuit::GetX11Width(Int_t localBoardId, Int_t istrip) const
476 /// returns width of Y strip istrip in MC11
477 return fXwidth11[localBoardId][istrip];
479 Float_t AliMUONTriggerCircuit::GetY11Width(Int_t localBoardId, Int_t istrip) const
481 /// returns width of X strip istrip in MC11
482 return fYwidth11[localBoardId][istrip];
484 //----------------------------------------------------------------------
485 Float_t AliMUONTriggerCircuit::GetY21Width(Int_t localBoardId, Int_t istrip) const
487 /// returns width of X strip istrip in MC21
488 return fYwidth21[localBoardId][istrip];
491 //----------------------------------------------------------------------
492 Int_t AliMUONTriggerCircuit::FirstStrip(AliMpLocalBoard* localBoard)
494 /// returns the first strip from mapping for board boardName
495 /// take care of special case for boards RC1L6B12 & LC1L6B12
496 Int_t iFirstStrip = -1;
497 Int_t boardNumber = atoi(localBoard->GetName()+6);
499 Int_t iline = AliMp::PairFirst(localBoard->GetPosition());
500 Int_t icol = AliMp::PairSecond(localBoard->GetPosition());
501 if ( iline == 5 ) --icol;
518 if (icol == 1 && iline == 6) iFirstStrip += 16; // special case
522 //----------------------------------------------------------------------
523 Float_t AliMUONTriggerCircuit::PtCal(Int_t localBoardId, Int_t istripX, Int_t idev, Int_t istripY) const{
524 /// returns calculated pt for circuit/istripX/idev/istripY according
525 /// to the formula of the TRD. Note : idev (input) is in [0+30]
527 // Int_t jdev = idev - 15; // jdev in [-15+15]
528 Int_t istripX2=istripX+idev+1; // find istripX2 using istripX and idev
530 Float_t yPosX1=fYpos11[localBoardId][istripX];
531 Float_t yPosX2=fYpos21[localBoardId][istripX2];
532 Float_t xPosY1=fXpos11[localBoardId][istripY];
534 // Z distance between IP and center of dipole
535 Float_t zf= TMath::Abs(0.5 *(AliMUONConstants::CoilZ() + AliMUONConstants::YokeZ()));
536 Float_t z1=AliMUONConstants::DefaultChamberZ(10);
537 Float_t z2=AliMUONConstants::DefaultChamberZ(12);
538 Float_t thetaDev=(1./zf)*(yPosX1*z2-yPosX2*z1)/(z2-z1);
539 Float_t xf=xPosY1*zf/z1;
540 Float_t yf=yPosX2-((yPosX2-yPosX1)*(z2-zf))/(z2-z1);
541 return (3.*0.3/TMath::Abs(thetaDev)) * TMath::Sqrt(xf*xf+yf*yf)/zf;