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