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) {
70 for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) { // board begins at 1
72 AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(i);
76 AliError(Form("Did not get localboard %d",i));
87 //----------------------------------------------------------------------
88 AliMUONTriggerCircuit::~AliMUONTriggerCircuit()
91 for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
99 //----------------------------------------------------------------------
100 AliMUONTriggerCircuit::AliMUONTriggerCircuit(const AliMUONTriggerCircuit& circuit)
102 fkTransformer(circuit.fkTransformer), // do not copy, just pointed to
103 fkCurrentSeg(circuit.fkCurrentSeg),
104 fCurrentDetElem(circuit.fCurrentDetElem),
105 fCurrentLocalBoard(circuit.fCurrentLocalBoard)
109 for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
110 fXpos11[i] = circuit.fXpos11[i];
111 fYpos11[i] = circuit.fYpos11[i];
112 fYpos21[i] = circuit.fYpos21[i];
116 //----------------------------------------------------------------------
117 AliMUONTriggerCircuit& AliMUONTriggerCircuit::operator=(const AliMUONTriggerCircuit& circuit)
119 /// Assignment operator
121 if (this == &circuit) return *this;
123 fkTransformer = circuit.fkTransformer;
124 fkCurrentSeg = circuit.fkCurrentSeg;
125 fCurrentDetElem = circuit.fCurrentDetElem;
126 fCurrentLocalBoard = circuit.fCurrentLocalBoard;
128 for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
129 fXpos11[i] = circuit.fXpos11[i];
130 fYpos11[i] = circuit.fYpos11[i];
131 fYpos21[i] = circuit.fYpos21[i];
138 //---------------------------------------------------------------------
139 void AliMUONTriggerCircuit::LoadYPos(AliMpLocalBoard* const localBoard)
141 /// fill fYpos11 and fYpos21 -> y position of X declusterized strips
143 fCurrentLocalBoard = localBoard->GetId();
147 Int_t zeroDown = localBoard->GetSwitch(AliMpLocalBoard::kZeroDown);
148 Int_t zeroUp = localBoard->GetSwitch(AliMpLocalBoard::kZeroUp);
150 Int_t iline = AliMp::PairFirst(localBoard->GetPosition());
151 Int_t icol = AliMp::PairSecond(localBoard->GetPosition());
152 if ( iline == 5 ) --icol;
156 fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
158 fkCurrentSeg = AliMpSegmentation::Instance()
159 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
161 Int_t iFirstStrip = FirstStrip(localBoard);
162 Int_t iLastStrip = iFirstStrip + 16;
163 Int_t iStripCircuit = 0;
165 FillXstrips(icol, iFirstStrip, iLastStrip,
166 iStripCircuit, fYpos11[fCurrentLocalBoard]);
170 fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
172 fkCurrentSeg = AliMpSegmentation::Instance()
173 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
175 // second plane middle part
176 Int_t iFirstStripMiddle = FirstStrip(localBoard);
177 Int_t iLastStripMiddle = iFirstStrip + 16;
180 FillXstrips(icol, iFirstStripMiddle, iLastStripMiddle,
181 iStripCircuit, fYpos21[fCurrentLocalBoard]);
183 // second plane upper part
184 if (zeroUp == 0) { // something up
189 // check if we need to move to another detElemId
190 AliMpPad pad = fkCurrentSeg->PadByIndices(icol-1,iLastStripMiddle+1,kFALSE);
192 if (pad.IsValid()) { // upper strips within same detElemId
193 iFirstStripUp = iLastStripMiddle;
194 iLastStripUp = iFirstStripUp + 8;
196 } else { // upper strips in another detElemId
197 fCurrentDetElem = AliMpDDLStore::Instance()->
198 GetNextDEfromLocalBoard(fCurrentLocalBoard, ichamber);
200 fkCurrentSeg = AliMpSegmentation::Instance()
201 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
204 iLastStripUp = iFirstStripUp + 8;
205 if (iline == 4) icolUp = icol - 1; // special case
206 if (iline == 5) icolUp = icol + 1; // special case
210 FillXstrips(icolUp, iFirstStripUp, iLastStripUp,
211 iStripCircuit, fYpos21[fCurrentLocalBoard]);
213 // fill strip between middle and upper part
214 fYpos21[fCurrentLocalBoard][47] = (fYpos21[fCurrentLocalBoard][46] +
215 fYpos21[fCurrentLocalBoard][48])/2.;
216 } // end of something up
218 // restore current detElemId & segmentation
219 fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
220 fkCurrentSeg = AliMpSegmentation::Instance()
221 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
223 // second plane lower part
224 if (zeroDown == 0) { // something down
229 // check if we need to move to another detElemId
230 AliMpPad pad = fkCurrentSeg->PadByIndices(icol-1,iFirstStripMiddle-1,kFALSE);
231 if (pad.IsValid()) { // lower strips within same detElemId
232 iFirstStripDo = iFirstStripMiddle - 8;
233 iLastStripDo = iFirstStripDo + 8;
235 } else { // lower strips in another detElemId
236 fCurrentDetElem = AliMpDDLStore::Instance()
237 ->GetPreviousDEfromLocalBoard(fCurrentLocalBoard, ichamber);
239 fkCurrentSeg = AliMpSegmentation::Instance()
240 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
242 // get iFirstStrip in this module
243 const AliMpTrigger* t = AliMpSegmentation::Instance()->GetTrigger(fkCurrentSeg);
244 const AliMpSlat* slat = t->GetLayer(0);
246 if (iline == 5) icolDo = icol + 1; // special case
247 if (iline == 6) icolDo = icol - 1; // special case
249 const AliMpPCB* pcb = slat->GetPCB(icolDo-1);
250 iFirstStripDo = (pcb->Iymax() + 1) - 8;
251 iLastStripDo = iFirstStripDo + 8;
255 FillXstrips(icolDo, iFirstStripDo, iLastStripDo,
256 iStripCircuit, fYpos21[fCurrentLocalBoard]);
258 // fill strip between middle and upper part
259 fYpos21[fCurrentLocalBoard][15] = (fYpos21[fCurrentLocalBoard][14] +
260 fYpos21[fCurrentLocalBoard][16])/2.;
261 } // end of something down
265 //----------------------------------------------------------------------
266 void AliMUONTriggerCircuit::FillXstrips(const Int_t icol,
267 const Int_t iFirstStrip, const Int_t iLastStrip,
268 Int_t liStripCircuit, TArrayF& ypos)
271 Double_t xyGlobal[2] = {0.};
272 for (Int_t istrip = iFirstStrip; istrip < iLastStrip; ++istrip) {
274 AliMpPad pad = fkCurrentSeg->PadByIndices(icol-1,istrip,kTRUE);
275 if ( !pad.IsValid() ) {
276 StdoutToAliError(cout << "Pad not found in seg " << endl;
277 fkCurrentSeg->Print();
278 cout << " ix,iy=" << icol-1 << "," << istrip << endl;
281 Float_t yDim = pad.GetDimensionY(); // half size!
283 XYGlobal(pad,xyGlobal);
285 ypos[2*liStripCircuit] = xyGlobal[1];
286 if (istrip != (iLastStrip - 1)) ypos[2*liStripCircuit+1] = xyGlobal[1] + yDim;
292 //----------------------------------------------------------------------
293 void AliMUONTriggerCircuit::LoadXPos(AliMpLocalBoard* const localBoard)
295 /// fill fXpos11 -> x position of Y strips for the first plane only
296 /// fXpos11 contains the x position of Y strip for the current circuit
297 /// taking into account whether or nor not part(s) of the circuit
298 /// (middle, up or down) has(have) 16 strips (handdled by means of switchs)
300 fCurrentLocalBoard = localBoard->GetId();
305 Int_t x2u = localBoard->GetSwitch(AliMpLocalBoard::kX2u);
306 Int_t x2m = localBoard->GetSwitch(AliMpLocalBoard::kX2m);
307 Int_t x2d = localBoard->GetSwitch(AliMpLocalBoard::kX2d);
308 Int_t zeroAllYLSB = localBoard->GetSwitch(AliMpLocalBoard::kZeroAllYLSB);
310 Int_t iStripCircuit = 0;
311 Int_t iFirstStrip = 0;
312 Int_t iLastStrip = 0;
313 Bool_t doubling = kFALSE;
315 Int_t iline = AliMp::PairFirst(localBoard->GetPosition());
316 Int_t icol = AliMp::PairSecond(localBoard->GetPosition());
317 if ( iline == 5 ) --icol;
319 fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
321 fkCurrentSeg = AliMpSegmentation::Instance()
322 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
324 // check if one needs a strip doubling or not
325 if ( (x2u || x2m || x2d ) && x2m ) doubling = kTRUE;
328 // check if one starts at strip = 0 or 8 (boards 26-29 and 143-146)
329 if (zeroAllYLSB) iStripCircuit = 8;
331 // get iFirstStrip in this module
332 const AliMpTrigger* t = AliMpSegmentation::Instance()->GetTrigger(fkCurrentSeg);
333 const AliMpSlat* slat = t->GetLayer(0);
335 const AliMpPCB* pcb = slat->GetPCB(icol-1);
336 iFirstStrip = pcb->Ixmin();
339 if (doubling || zeroAllYLSB == 1) iLastStrip = iFirstStrip + 8;
340 else iLastStrip = iFirstStrip + 16;
342 FillYstrips(iFirstStrip, iLastStrip, iStripCircuit, doubling);
345 //----------------------------------------------------------------------
346 void AliMUONTriggerCircuit::FillYstrips(const Int_t iFirstStrip, const Int_t iLastStrip,
347 Int_t liStripCircuit,
348 const Bool_t doubling)
351 Double_t xyGlobal[2] = {0.};
353 for (Int_t istrip = iFirstStrip; istrip < iLastStrip; ++istrip) {
355 AliMpPad pad = fkCurrentSeg->PadByIndices(istrip,0,kTRUE);
357 if ( !pad.IsValid() )
359 StdoutToAliError(cout << "Pad not found in seg " << endl;
360 fkCurrentSeg->Print();
361 cout << " ix,iy=" << istrip << "," << 0 << endl;
364 Float_t xDim = pad.GetDimensionX(); // half size!
366 XYGlobal(pad,xyGlobal);
369 fXpos11[fCurrentLocalBoard].AddAt(xyGlobal[0], liStripCircuit);
370 } else if (doubling) {
372 fXpos11[fCurrentLocalBoard].AddAt(TMath::Sign(1.,xyGlobal[0]) *
373 (TMath::Abs(xyGlobal[0]) - xDim/2.), 2*liStripCircuit);
375 fXpos11[fCurrentLocalBoard].AddAt(TMath::Sign(1.,xyGlobal[0]) *
376 (TMath::Abs(fXpos11[fCurrentLocalBoard][2*liStripCircuit]) + xDim),
377 2*liStripCircuit + 1);
384 //----------------------------------------------------------------------
385 void AliMUONTriggerCircuit::XYGlobal(const AliMpPad& pad,
388 /// returns pad x & y positions and x & y pad dimensions in global coordinates
389 /// note: no need for transformation for pad dimensions
391 // get the pad position and dimensions
392 Double_t xl1 = pad.GetPositionX();
393 Double_t yl1 = pad.GetPositionY();
396 // positions from local to global
397 fkTransformer->Local2Global(fCurrentDetElem, xl1, yl1, 0,
398 xyGlobal[0], xyGlobal[1], zg1);
402 //----------------------------------------------------------------------
403 //--- methods which return member data related info
404 //----------------------------------------------------------------------
405 Float_t AliMUONTriggerCircuit::GetY11Pos(Int_t localBoardId, Int_t istrip) const
407 /// returns Y position of X strip istrip in MC11
408 return fYpos11[localBoardId][istrip];
410 //----------------------------------------------------------------------
411 Float_t AliMUONTriggerCircuit::GetY21Pos(Int_t localBoardId, Int_t istrip) const
413 /// returns Y position of X strip istrip in MC21
414 return fYpos21[localBoardId][istrip];
416 //----------------------------------------------------------------------
417 Float_t AliMUONTriggerCircuit::GetX11Pos(Int_t localBoardId, Int_t istrip) const
419 /// returns X position of Y strip istrip in MC11
420 return fXpos11[localBoardId][istrip];
423 //----------------------------------------------------------------------
424 Int_t AliMUONTriggerCircuit::FirstStrip(AliMpLocalBoard* localBoard)
426 /// returns the first strip from mapping for board boardName
427 /// take care of special case for boards RC1L6B12 & LC1L6B12
428 Int_t iFirstStrip = -1;
429 Int_t boardNumber = atoi(localBoard->GetName()+6);
431 Int_t iline = AliMp::PairFirst(localBoard->GetPosition());
432 Int_t icol = AliMp::PairSecond(localBoard->GetPosition());
433 if ( iline == 5 ) --icol;
450 if (icol == 1 && iline == 6) iFirstStrip += 16; // special case
454 //----------------------------------------------------------------------
455 Float_t AliMUONTriggerCircuit::PtCal(Int_t localBoardId, Int_t istripX, Int_t idev, Int_t istripY) const{
456 /// returns calculated pt for circuit/istripX/idev/istripY according
457 /// to the formula of the TRD. Note : idev (input) is in [0+30]
459 // Int_t jdev = idev - 15; // jdev in [-15+15]
460 Int_t istripX2=istripX+idev+1; // find istripX2 using istripX and idev
462 Float_t yPosX1=fYpos11[localBoardId][istripX];
463 Float_t yPosX2=fYpos21[localBoardId][istripX2];
464 Float_t xPosY1=fXpos11[localBoardId][istripY];
466 // Z distance between IP and center of dipole
467 Float_t zf= TMath::Abs(0.5 *(AliMUONConstants::CoilZ() + AliMUONConstants::YokeZ()));
468 Float_t z1=AliMUONConstants::DefaultChamberZ(10);
469 Float_t z2=AliMUONConstants::DefaultChamberZ(12);
470 Float_t thetaDev=(1./zf)*(yPosX1*z2-yPosX2*z1)/(z2-z1);
471 Float_t xf=xPosY1*zf/z1;
472 Float_t yf=yPosX2-((yPosX2-yPosX1)*(z2-zf))/(z2-z1);
473 return (3.*0.3/TMath::Abs(thetaDev)) * TMath::Sqrt(xf*xf+yf*yf)/zf;