]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTriggerCircuit.cxx
Updated to use new AliMUONDataInterface and AliMUONVTrackStore
[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"
8ff54bb6 29
30#include "AliMpTriggerSegmentation.h"
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
7103ac2d 240 const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(fCurrentSeg);
8ff54bb6 241 const AliMpTrigger* t = trig->Slat();
242 const AliMpSlat* slat = t->GetLayer(0);
7103ac2d 243
8ff54bb6 244 if (iline == 5) icolDo = icol + 1; // special case
7103ac2d 245 if (iline == 6) icolDo = icol - 1; // special case
246
8ff54bb6 247 const AliMpPCB* pcb = slat->GetPCB(icolDo-1);
248 iFirstStripDo = (pcb->Iymax() + 1) - 8;
249 iLastStripDo = iFirstStripDo + 8;
250 }
251
7103ac2d 252 iStripCircuit = 0;
253 FillXstrips(icolDo, iFirstStripDo, iLastStripDo,
254 iStripCircuit, fYpos21[fCurrentLocalBoard]);
8ff54bb6 255
256 // fill strip between middle and upper part
7103ac2d 257 fYpos21[fCurrentLocalBoard][15] = (fYpos21[fCurrentLocalBoard][14] +
258 fYpos21[fCurrentLocalBoard][16])/2.;
8ff54bb6 259 } // end of something down
260
261}
262
263//----------------------------------------------------------------------
7103ac2d 264void AliMUONTriggerCircuit::FillXstrips(const Int_t icol,
265 const Int_t iFirstStrip, const Int_t iLastStrip,
266 Int_t liStripCircuit, TArrayF& ypos)
267{
268/// fill
269 Double_t xyGlobal[2] = {0.};
270 for (Int_t istrip = iFirstStrip; istrip < iLastStrip; ++istrip) {
271
272 AliMpPad pad = fCurrentSeg->PadByIndices(AliMpIntPair(icol-1,istrip),kTRUE);
273 if ( !pad.IsValid() ) {
274 StdoutToAliError(cout << "Pad not found in seg " << endl;
275 fCurrentSeg->Print();
276 cout << " ix,iy=" << icol-1 << "," << istrip << endl;
277 );
278 }
279 Float_t yDim = pad.Dimensions().Y(); // half size!
280
281 XYGlobal(pad,xyGlobal);
282
283 ypos[2*liStripCircuit] = xyGlobal[1];
284 if (istrip != (iLastStrip - 1)) ypos[2*liStripCircuit+1] = xyGlobal[1] + yDim;
285 liStripCircuit++;
286 }
287}
288
289
290//----------------------------------------------------------------------
291void AliMUONTriggerCircuit::LoadXPos(AliMpLocalBoard* localBoard)
8ff54bb6 292{
293/// fill fXpos11 -> x position of Y strips for the first plane only
294/// fXpos11 contains the x position of Y strip for the current circuit
295/// taking into account whether or nor not part(s) of the circuit
296/// (middle, up or down) has(have) 16 strips (handdled by means of switchs)
7103ac2d 297
298 fCurrentLocalBoard = localBoard->GetId();
299
8ff54bb6 300 Int_t ichamber = 10;
301 Int_t icathode = 1;
302
7103ac2d 303 Int_t x2u = localBoard->GetSwitch(AliMpLocalBoard::kX2u);
304 Int_t x2m = localBoard->GetSwitch(AliMpLocalBoard::kX2m);
305 Int_t x2d = localBoard->GetSwitch(AliMpLocalBoard::kX2d);
306 Int_t zeroAllYLSB = localBoard->GetSwitch(AliMpLocalBoard::kZeroAllYLSB);
307
308 Int_t iStripCircuit = 0;
309 Int_t iFirstStrip = 0;
310 Int_t iLastStrip = 0;
311 Bool_t doubling = kFALSE;
8ff54bb6 312
7103ac2d 313 Int_t iline = localBoard->GetPosition().GetFirst();
314 Int_t icol = localBoard->GetPosition().GetSecond();
315 if ( iline == 5 ) --icol;
8ff54bb6 316
7103ac2d 317 fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
318
319 fCurrentSeg = AliMpSegmentation::Instance()
320 ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));
8ff54bb6 321
322 // check if one needs a strip doubling or not
7103ac2d 323 if ( (x2u || x2m || x2d ) && x2m ) doubling = kTRUE;
324
0d528e1f 325
8ff54bb6 326 // check if one starts at strip = 0 or 8 (boards 26-29 and 143-146)
7103ac2d 327 if (zeroAllYLSB) iStripCircuit = 8;
8ff54bb6 328
329 // get iFirstStrip in this module
7103ac2d 330 const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(fCurrentSeg);
8ff54bb6 331 const AliMpTrigger* t = trig->Slat();
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
7103ac2d 354 AliMpPad pad = fCurrentSeg->PadByIndices(AliMpIntPair(istrip,0),kTRUE);
0d528e1f 355
8ff54bb6 356 if ( !pad.IsValid() )
357 {
358 StdoutToAliError(cout << "Pad not found in seg " << endl;
7103ac2d 359 fCurrentSeg->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
396 fTransformer->Local2Global(fCurrentDetElem, xl1, yl1, 0,
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