]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTriggerCircuit.cxx
In Mapping/macros:
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerCircuit.cxx
CommitLineData
8ff54bb6 1/**************************************************************************
2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
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**************************************************************************/
15
16/* $Id$ */
17
3d1463c8 18//-----------------------------------------------------------------------------
8ff54bb6 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)
78649106 24///
25/// \author Philippe Crochet (LPCCFd)
3d1463c8 26//-----------------------------------------------------------------------------
8ff54bb6 27
28#include "AliMUONTriggerCircuit.h"
afeb2b33 29#include "AliMUONConstants.h"
da142235 30#include "AliMUONGeometryTransformer.h"
8ff54bb6 31
8ff54bb6 32#include "AliMpTrigger.h"
33#include "AliMpSlat.h"
34#include "AliMpPCB.h"
35#include "AliMpSegmentation.h"
36#include "AliMpVSegmentation.h"
866c3232 37#include "AliMpCathodType.h"
7103ac2d 38#include "AliMpDDLStore.h"
39#include "AliMpLocalBoard.h"
40#include "AliMpConstants.h"
da142235 41#include "AliMpPad.h"
8ff54bb6 42
43#include "AliRun.h"
44#include "AliLog.h"
45
46#include <TMath.h>
9de45220 47#include <Riostream.h>
8ff54bb6 48
49/// \cond CLASSIMP
50ClassImp(AliMUONTriggerCircuit)
51/// \endcond
52
53//----------------------------------------------------------------------
7103ac2d 54AliMUONTriggerCircuit::AliMUONTriggerCircuit(const AliMUONGeometryTransformer* transformer)
55 : TObject(),
da142235 56 fkTransformer(transformer),
57 fkCurrentSeg(0x0),
7103ac2d 58 fCurrentDetElem(0x0),
59 fCurrentLocalBoard(0x0)
8ff54bb6 60{
61/// Constructor
62
7103ac2d 63 for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
64 fXpos11[i].Set(16);
65 fYpos11[i].Set(31);
66 fYpos21[i].Set(63);
67 }
68
69 for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) { // board begins at 1
70
71 AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(i);
72
73 if (!localBoard)
74 {
75 AliError(Form("Did not get localboard %d",i));
76 continue;
77 }
78
79 LoadXPos(localBoard);
80 LoadYPos(localBoard);
81
82 }
83
8ff54bb6 84}
85
86//----------------------------------------------------------------------
87AliMUONTriggerCircuit::~AliMUONTriggerCircuit()
88{
89/// Destructor
7103ac2d 90 for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
91 fXpos11[i].Reset();
92 fYpos11[i].Reset();
93 fYpos21[i].Reset();
94 }
95
8ff54bb6 96}
97
98//----------------------------------------------------------------------
99AliMUONTriggerCircuit::AliMUONTriggerCircuit(const AliMUONTriggerCircuit& circuit)
7103ac2d 100 : TObject(circuit),
da142235 101 fkTransformer(circuit.fkTransformer), // do not copy, just pointed to
102 fkCurrentSeg(circuit.fkCurrentSeg),
7103ac2d 103 fCurrentDetElem(circuit.fCurrentDetElem),
104 fCurrentLocalBoard(circuit.fCurrentLocalBoard)
8ff54bb6 105{
106/// Copy constructor
107
7103ac2d 108 for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
109 fXpos11[i] = circuit.fXpos11[i];
110 fYpos11[i] = circuit.fYpos11[i];
111 fYpos21[i] = circuit.fYpos21[i];
112 }
8ff54bb6 113
114}
115//----------------------------------------------------------------------
116AliMUONTriggerCircuit& AliMUONTriggerCircuit::operator=(const AliMUONTriggerCircuit& circuit)
117{
118/// Assignment operator
119
120 if (this == &circuit) return *this;
121
da142235 122 fkTransformer = circuit.fkTransformer;
123 fkCurrentSeg = circuit.fkCurrentSeg;
7103ac2d 124 fCurrentDetElem = circuit.fCurrentDetElem;
125 fCurrentLocalBoard = circuit.fCurrentLocalBoard;
8ff54bb6 126
7103ac2d 127 for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
8ff54bb6 128 fXpos11[i] = circuit.fXpos11[i];
8ff54bb6 129 fYpos11[i] = circuit.fYpos11[i];
8ff54bb6 130 fYpos21[i] = circuit.fYpos21[i];
7103ac2d 131 }
8ff54bb6 132
133 return *this;
134
8ff54bb6 135}
136
137//---------------------------------------------------------------------
da142235 138void AliMUONTriggerCircuit::LoadYPos(AliMpLocalBoard* const localBoard)
8ff54bb6 139{
140/// fill fYpos11 and fYpos21 -> y position of X declusterized strips
141
7103ac2d 142 fCurrentLocalBoard = localBoard->GetId();
8ff54bb6 143 Int_t ichamber = 0;
144 Int_t icathode = 0;
7103ac2d 145
146 Int_t zeroDown = localBoard->GetSwitch(AliMpLocalBoard::kZeroDown);
147 Int_t zeroUp = localBoard->GetSwitch(AliMpLocalBoard::kZeroUp);
148
149 Int_t iline = localBoard->GetPosition().GetFirst();
150 Int_t icol = localBoard->GetPosition().GetSecond();
151 if ( iline == 5 ) --icol;
152
8ff54bb6 153 //--- first plane
154 ichamber = 10;
7103ac2d 155 fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
8ff54bb6 156
da142235 157 fkCurrentSeg = AliMpSegmentation::Instance()
7103ac2d 158 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
159
160 Int_t iFirstStrip = FirstStrip(localBoard);
161 Int_t iLastStrip = iFirstStrip + 16;
8ff54bb6 162 Int_t iStripCircuit = 0;
7103ac2d 163
164 FillXstrips(icol, iFirstStrip, iLastStrip,
165 iStripCircuit, fYpos11[fCurrentLocalBoard]);
8ff54bb6 166
167 //--- second plane
168 ichamber = 12;
7103ac2d 169 fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
170
da142235 171 fkCurrentSeg = AliMpSegmentation::Instance()
7103ac2d 172 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
8ff54bb6 173
174 // second plane middle part
7103ac2d 175 Int_t iFirstStripMiddle = FirstStrip(localBoard);
176 Int_t iLastStripMiddle = iFirstStrip + 16;
177 iStripCircuit = 8;
178
179 FillXstrips(icol, iFirstStripMiddle, iLastStripMiddle,
180 iStripCircuit, fYpos21[fCurrentLocalBoard]);
8ff54bb6 181
182 // second plane upper part
183 if (zeroUp == 0) { // something up
184 Int_t iFirstStripUp;
185 Int_t iLastStripUp;
7103ac2d 186 Int_t icolUp = icol;
187
8ff54bb6 188 // check if we need to move to another detElemId
da142235 189 AliMpPad pad = fkCurrentSeg->PadByIndices(AliMpIntPair(icol-1,iLastStripMiddle+1),kFALSE);
7103ac2d 190
8ff54bb6 191 if (pad.IsValid()) { // upper strips within same detElemId
192 iFirstStripUp = iLastStripMiddle;
7103ac2d 193 iLastStripUp = iFirstStripUp + 8;
194
8ff54bb6 195 } else { // upper strips in another detElemId
7103ac2d 196 fCurrentDetElem = AliMpDDLStore::Instance()->
197 GetNextDEfromLocalBoard(fCurrentLocalBoard, ichamber);
198
da142235 199 fkCurrentSeg = AliMpSegmentation::Instance()
7103ac2d 200 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
8ff54bb6 201
202 iFirstStripUp = 0;
7103ac2d 203 iLastStripUp = iFirstStripUp + 8;
8ff54bb6 204 if (iline == 4) icolUp = icol - 1; // special case
205 if (iline == 5) icolUp = icol + 1; // special case
206 }
207
7103ac2d 208 iStripCircuit = 24;
209 FillXstrips(icolUp, iFirstStripUp, iLastStripUp,
210 iStripCircuit, fYpos21[fCurrentLocalBoard]);
8ff54bb6 211
212 // fill strip between middle and upper part
7103ac2d 213 fYpos21[fCurrentLocalBoard][47] = (fYpos21[fCurrentLocalBoard][46] +
214 fYpos21[fCurrentLocalBoard][48])/2.;
8ff54bb6 215 } // end of something up
216
217 // restore current detElemId & segmentation
7103ac2d 218 fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
da142235 219 fkCurrentSeg = AliMpSegmentation::Instance()
7103ac2d 220 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
8ff54bb6 221
222 // second plane lower part
223 if (zeroDown == 0) { // something down
224 Int_t iFirstStripDo;
225 Int_t iLastStripDo;
7103ac2d 226 Int_t icolDo = icol;
8ff54bb6 227
228 // check if we need to move to another detElemId
da142235 229 AliMpPad pad = fkCurrentSeg->PadByIndices(AliMpIntPair(icol-1,iFirstStripMiddle-1),kFALSE);
8ff54bb6 230 if (pad.IsValid()) { // lower strips within same detElemId
231 iFirstStripDo = iFirstStripMiddle - 8;
7103ac2d 232 iLastStripDo = iFirstStripDo + 8;
233
8ff54bb6 234 } else { // lower strips in another detElemId
7103ac2d 235 fCurrentDetElem = AliMpDDLStore::Instance()
236 ->GetPreviousDEfromLocalBoard(fCurrentLocalBoard, ichamber);
237
da142235 238 fkCurrentSeg = AliMpSegmentation::Instance()
7103ac2d 239 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
8ff54bb6 240
241 // get iFirstStrip in this module
da142235 242 const AliMpTrigger* t = AliMpSegmentation::Instance()->GetTrigger(fkCurrentSeg);
8ff54bb6 243 const AliMpSlat* slat = t->GetLayer(0);
7103ac2d 244
8ff54bb6 245 if (iline == 5) icolDo = icol + 1; // special case
7103ac2d 246 if (iline == 6) icolDo = icol - 1; // special case
247
8ff54bb6 248 const AliMpPCB* pcb = slat->GetPCB(icolDo-1);
249 iFirstStripDo = (pcb->Iymax() + 1) - 8;
250 iLastStripDo = iFirstStripDo + 8;
251 }
252
7103ac2d 253 iStripCircuit = 0;
254 FillXstrips(icolDo, iFirstStripDo, iLastStripDo,
255 iStripCircuit, fYpos21[fCurrentLocalBoard]);
8ff54bb6 256
257 // fill strip between middle and upper part
7103ac2d 258 fYpos21[fCurrentLocalBoard][15] = (fYpos21[fCurrentLocalBoard][14] +
259 fYpos21[fCurrentLocalBoard][16])/2.;
8ff54bb6 260 } // end of something down
261
262}
263
264//----------------------------------------------------------------------
7103ac2d 265void AliMUONTriggerCircuit::FillXstrips(const Int_t icol,
266 const Int_t iFirstStrip, const Int_t iLastStrip,
267 Int_t liStripCircuit, TArrayF& ypos)
268{
269/// fill
270 Double_t xyGlobal[2] = {0.};
271 for (Int_t istrip = iFirstStrip; istrip < iLastStrip; ++istrip) {
272
da142235 273 AliMpPad pad = fkCurrentSeg->PadByIndices(AliMpIntPair(icol-1,istrip),kTRUE);
7103ac2d 274 if ( !pad.IsValid() ) {
275 StdoutToAliError(cout << "Pad not found in seg " << endl;
da142235 276 fkCurrentSeg->Print();
7103ac2d 277 cout << " ix,iy=" << icol-1 << "," << istrip << endl;
278 );
279 }
280 Float_t yDim = pad.Dimensions().Y(); // half size!
281
282 XYGlobal(pad,xyGlobal);
283
284 ypos[2*liStripCircuit] = xyGlobal[1];
285 if (istrip != (iLastStrip - 1)) ypos[2*liStripCircuit+1] = xyGlobal[1] + yDim;
286 liStripCircuit++;
287 }
288}
289
290
291//----------------------------------------------------------------------
da142235 292void AliMUONTriggerCircuit::LoadXPos(AliMpLocalBoard* const localBoard)
8ff54bb6 293{
294/// fill fXpos11 -> x position of Y strips for the first plane only
295/// fXpos11 contains the x position of Y strip for the current circuit
296/// taking into account whether or nor not part(s) of the circuit
297/// (middle, up or down) has(have) 16 strips (handdled by means of switchs)
7103ac2d 298
299 fCurrentLocalBoard = localBoard->GetId();
300
8ff54bb6 301 Int_t ichamber = 10;
302 Int_t icathode = 1;
303
7103ac2d 304 Int_t x2u = localBoard->GetSwitch(AliMpLocalBoard::kX2u);
305 Int_t x2m = localBoard->GetSwitch(AliMpLocalBoard::kX2m);
306 Int_t x2d = localBoard->GetSwitch(AliMpLocalBoard::kX2d);
307 Int_t zeroAllYLSB = localBoard->GetSwitch(AliMpLocalBoard::kZeroAllYLSB);
308
309 Int_t iStripCircuit = 0;
310 Int_t iFirstStrip = 0;
311 Int_t iLastStrip = 0;
312 Bool_t doubling = kFALSE;
8ff54bb6 313
7103ac2d 314 Int_t iline = localBoard->GetPosition().GetFirst();
315 Int_t icol = localBoard->GetPosition().GetSecond();
316 if ( iline == 5 ) --icol;
8ff54bb6 317
7103ac2d 318 fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
319
da142235 320 fkCurrentSeg = AliMpSegmentation::Instance()
7103ac2d 321 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
8ff54bb6 322
323 // check if one needs a strip doubling or not
7103ac2d 324 if ( (x2u || x2m || x2d ) && x2m ) doubling = kTRUE;
325
0d528e1f 326
8ff54bb6 327 // check if one starts at strip = 0 or 8 (boards 26-29 and 143-146)
7103ac2d 328 if (zeroAllYLSB) iStripCircuit = 8;
8ff54bb6 329
330 // get iFirstStrip in this module
da142235 331 const AliMpTrigger* t = AliMpSegmentation::Instance()->GetTrigger(fkCurrentSeg);
8ff54bb6 332 const AliMpSlat* slat = t->GetLayer(0);
333
334 const AliMpPCB* pcb = slat->GetPCB(icol-1);
335 iFirstStrip = pcb->Ixmin();
336
7103ac2d 337
0d528e1f 338 if (doubling || zeroAllYLSB == 1) iLastStrip = iFirstStrip + 8;
8ff54bb6 339 else iLastStrip = iFirstStrip + 16;
340
7103ac2d 341 FillYstrips(iFirstStrip, iLastStrip, iStripCircuit, doubling);
8ff54bb6 342}
343
344//----------------------------------------------------------------------
7103ac2d 345void AliMUONTriggerCircuit::FillYstrips(const Int_t iFirstStrip, const Int_t iLastStrip,
346 Int_t liStripCircuit,
347 const Bool_t doubling)
8ff54bb6 348{
349/// fill
7103ac2d 350 Double_t xyGlobal[2] = {0.};
351
352 for (Int_t istrip = iFirstStrip; istrip < iLastStrip; ++istrip) {
0d528e1f 353
da142235 354 AliMpPad pad = fkCurrentSeg->PadByIndices(AliMpIntPair(istrip,0),kTRUE);
0d528e1f 355
8ff54bb6 356 if ( !pad.IsValid() )
357 {
358 StdoutToAliError(cout << "Pad not found in seg " << endl;
da142235 359 fkCurrentSeg->Print();
8ff54bb6 360 cout << " ix,iy=" << istrip << "," << 0 << endl;
361 );
362 }
7103ac2d 363 Float_t xDim = pad.Dimensions().X(); // half size!
8ff54bb6 364
7103ac2d 365 XYGlobal(pad,xyGlobal);
8ff54bb6 366
7103ac2d 367 if (!doubling) {
368 fXpos11[fCurrentLocalBoard].AddAt(xyGlobal[0], liStripCircuit);
369 } else if (doubling) {
370
371 fXpos11[fCurrentLocalBoard].AddAt(TMath::Sign(1.,xyGlobal[0]) *
372 (TMath::Abs(xyGlobal[0]) - xDim/2.), 2*liStripCircuit);
373
374 fXpos11[fCurrentLocalBoard].AddAt(TMath::Sign(1.,xyGlobal[0]) *
375 (TMath::Abs(fXpos11[fCurrentLocalBoard][2*liStripCircuit]) + xDim),
376 2*liStripCircuit + 1);
377 }
378
8ff54bb6 379 liStripCircuit++;
380 }
381}
382
383//----------------------------------------------------------------------
7103ac2d 384void AliMUONTriggerCircuit::XYGlobal(const AliMpPad& pad,
385 Double_t* xyGlobal)
8ff54bb6 386{
7103ac2d 387/// returns pad x & y positions and x & y pad dimensions in global coordinates
388/// note: no need for transformation for pad dimensions
8ff54bb6 389
7103ac2d 390 // get the pad position and dimensions
391 Double_t xl1 = pad.Position().X();
392 Double_t yl1 = pad.Position().Y();
393 Double_t zg1 = 0;
394
395 // positions from local to global
da142235 396 fkTransformer->Local2Global(fCurrentDetElem, xl1, yl1, 0,
7103ac2d 397 xyGlobal[0], xyGlobal[1], zg1);
8ff54bb6 398}
7103ac2d 399
8ff54bb6 400
401//----------------------------------------------------------------------
7103ac2d 402//--- methods which return member data related info
403//----------------------------------------------------------------------
404Float_t AliMUONTriggerCircuit::GetY11Pos(Int_t localBoardId, Int_t istrip) const
8ff54bb6 405{
7103ac2d 406/// returns Y position of X strip istrip in MC11
407 return fYpos11[localBoardId][istrip];
8ff54bb6 408}
8ff54bb6 409//----------------------------------------------------------------------
7103ac2d 410Float_t AliMUONTriggerCircuit::GetY21Pos(Int_t localBoardId, Int_t istrip) const
8ff54bb6 411{
7103ac2d 412/// returns Y position of X strip istrip in MC21
413 return fYpos21[localBoardId][istrip];
8ff54bb6 414}
8ff54bb6 415//----------------------------------------------------------------------
7103ac2d 416Float_t AliMUONTriggerCircuit::GetX11Pos(Int_t localBoardId, Int_t istrip) const
8ff54bb6 417{
7103ac2d 418/// returns X position of Y strip istrip in MC11
419 return fXpos11[localBoardId][istrip];
8ff54bb6 420}
421
422//----------------------------------------------------------------------
7103ac2d 423Int_t AliMUONTriggerCircuit::FirstStrip(AliMpLocalBoard* localBoard)
8ff54bb6 424{
425/// returns the first strip from mapping for board boardName
426/// take care of special case for boards RC1L6B12 & LC1L6B12
427 Int_t iFirstStrip = -1;
7103ac2d 428 Int_t boardNumber = atoi(localBoard->GetName()+6);
429
430 Int_t iline = localBoard->GetPosition().GetFirst();
431 Int_t icol = localBoard->GetPosition().GetSecond();
432 if ( iline == 5 ) --icol;
433
8ff54bb6 434 switch (boardNumber)
435 {
436 case 12:
437 iFirstStrip = 0;
438 break;
439 case 34:
440 iFirstStrip = 16;
441 break;
442 case 56:
443 iFirstStrip = 32;
444 break;
445 case 78:
446 iFirstStrip = 48;
447 break;
448 }
7103ac2d 449 if (icol == 1 && iline == 6) iFirstStrip += 16; // special case
8ff54bb6 450 return iFirstStrip;
451}
452
afeb2b33 453//----------------------------------------------------------------------
454Float_t AliMUONTriggerCircuit::PtCal(Int_t localBoardId, Int_t istripX, Int_t idev, Int_t istripY) const{
455/// returns calculated pt for circuit/istripX/idev/istripY according
456/// to the formula of the TRD. Note : idev (input) is in [0+30]
457
458 // Int_t jdev = idev - 15; // jdev in [-15+15]
459 Int_t istripX2=istripX+idev+1; // find istripX2 using istripX and idev
460
461 Float_t yPosX1=fYpos11[localBoardId][istripX];
462 Float_t yPosX2=fYpos21[localBoardId][istripX2];
463 Float_t xPosY1=fXpos11[localBoardId][istripY];
464
465// Z distance between IP and center of dipole
466 Float_t zf= TMath::Abs(0.5 *(AliMUONConstants::CoilZ() + AliMUONConstants::YokeZ()));
467 Float_t z1=AliMUONConstants::DefaultChamberZ(10);
468 Float_t z2=AliMUONConstants::DefaultChamberZ(12);
469 Float_t thetaDev=(1./zf)*(yPosX1*z2-yPosX2*z1)/(z2-z1);
470 Float_t xf=xPosY1*zf/z1;
471 Float_t yf=yPosX2-((yPosX2-yPosX1)*(z2-zf))/(z2-z1);
472 return (3.*0.3/TMath::Abs(thetaDev)) * TMath::Sqrt(xf*xf+yf*yf)/zf;
473}