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 /// \class AliMUONTriggerCircuit
19 /// Contains as data members the Y positions of the X declusturized strips and
20 /// the X positions of the (doubled or not) Y strips.
21 /// This is used to associate the global positions to the fired strips of the
22 /// local trigger output (see AliMUONTrackReconstructor::MakeTriggerTrack)
24 #include "AliMUONTriggerCircuit.h"
26 #include "AliMUONConstants.h"
27 #include "AliMUONLocalTriggerBoard.h"
28 #include "AliMUONTriggerCrateStore.h"
29 #include "AliMUONTriggerCrate.h"
30 #include "AliMUONGeometryTransformer.h"
32 #include "AliMpTriggerSegmentation.h"
33 #include "AliMpTrigger.h"
34 #include "AliMpSlat.h"
36 #include "AliMpSegmentation.h"
37 #include "AliMpVSegmentation.h"
45 ClassImp(AliMUONTriggerCircuit)
48 //----------------------------------------------------------------------
49 AliMUONTriggerCircuit::AliMUONTriggerCircuit()
57 for (i=0; i<16; i++) { fXpos11[i]=0.; }
58 for (i=0; i<31; i++) { fYpos11[i]=0.; }
59 for (i=0; i<63; i++) { fYpos21[i]=0.; }
62 //----------------------------------------------------------------------
63 AliMUONTriggerCircuit::~AliMUONTriggerCircuit()
68 //----------------------------------------------------------------------
69 AliMUONTriggerCircuit::AliMUONTriggerCircuit(const AliMUONTriggerCircuit& circuit)
71 fILocalBoard(circuit.fILocalBoard),
76 for (Int_t i = 0; i < 16; ++i)
77 fXpos11[i] = circuit.fXpos11[i];
79 for (Int_t i = 0; i < 31; ++i)
80 fYpos11[i] = circuit.fYpos11[i];
82 for (Int_t i = 0; i < 63; ++i)
83 fYpos21[i] = circuit.fYpos21[i];
86 //----------------------------------------------------------------------
87 AliMUONTriggerCircuit& AliMUONTriggerCircuit::operator=(const AliMUONTriggerCircuit& circuit)
89 /// Assignment operator
91 if (this == &circuit) return *this;
93 fILocalBoard = circuit.fILocalBoard;
95 for (Int_t i = 0; i < 16; ++i)
96 fXpos11[i] = circuit.fXpos11[i];
98 for (Int_t i = 0; i < 31; ++i)
99 fYpos11[i] = circuit.fYpos11[i];
101 for (Int_t i = 0; i < 63; ++i)
102 fYpos21[i] = circuit.fYpos21[i];
107 //----------------------------------------------------------------------
108 void AliMUONTriggerCircuit::Init(Int_t iCircuit, const AliMUONTriggerCrateStore& crates)
110 /// initialize circuit characteristics
111 fILocalBoard=iCircuit+1;//AliMUONTriggerConstants::CircuitId(iCircuit);
118 //---------------------------------------------------------------------
119 void AliMUONTriggerCircuit::LoadYPos(const AliMUONTriggerCrateStore& crates)
121 /// fill fYpos11 and fYpos21 -> y position of X declusterized strips
123 const AliMUONLocalTriggerBoard* localBoard = crates.LocalBoard(fILocalBoard);
127 AliError(Form("Did not get localboard %d",fILocalBoard));
130 StdoutToAliDebug(1,localBoard->Print("CONF"););
135 const AliMpVSegmentation* seg;
137 Int_t zeroDown = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroDown);
138 Int_t zeroUp = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroUp);
145 DecodeBoardName(localBoard->GetName(),side,iline,icol);
147 Int_t detElemId = DetElemId(ichamber,side,iline);
148 seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, icathode);
150 Int_t iFirstStrip = FirstStrip(localBoard->GetName());
151 Int_t iLastStrip = iFirstStrip + 16;
152 Int_t iStripCircuit = 0;
153 FillXstrips(seg,detElemId,icol,
154 iFirstStrip,iLastStrip,iStripCircuit,fYpos11);
159 detElemId = DetElemId(ichamber,side,iline);
160 seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, icathode);
162 // second plane middle part
163 Int_t iFirstStripMiddle = FirstStrip(localBoard->GetName());
164 Int_t iLastStripMiddle = iFirstStrip + 16;
166 FillXstrips(seg,detElemId,icol,
167 iFirstStripMiddle,iLastStripMiddle,iStripCircuit,fYpos21);
169 // second plane upper part
170 if (zeroUp == 0) { // something up
174 // check if we need to move to another detElemId
175 AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,iLastStripMiddle+1),kFALSE);
176 if (pad.IsValid()) { // upper strips within same detElemId
177 iFirstStripUp = iLastStripMiddle;
178 iLastStripUp = iFirstStripUp + 8;
180 } else { // upper strips in another detElemId
181 detElemId = DetElemId(ichamber,side,iline+1); // get detElemId
182 seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, icathode);
185 iLastStripUp = iFirstStripUp + 8;
186 if (iline == 4) icolUp = icol - 1; // special case
187 if (iline == 5) icolUp = icol + 1; // special case
191 FillXstrips(seg,detElemId,icolUp,
192 iFirstStripUp,iLastStripUp,iStripCircuit,fYpos21);
194 // fill strip between middle and upper part
195 fYpos21[47]=(fYpos21[46]+fYpos21[48])/2.;
196 } // end of something up
198 // restore current detElemId & segmentation
199 detElemId = DetElemId(ichamber,side,iline);
200 seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, icathode);
202 // second plane lower part
203 if (zeroDown == 0) { // something down
208 // check if we need to move to another detElemId
209 AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,iFirstStripMiddle-1),kFALSE);
210 if (pad.IsValid()) { // lower strips within same detElemId
211 iFirstStripDo = iFirstStripMiddle - 8;
212 iLastStripDo = iFirstStripDo + 8;
214 } else { // lower strips in another detElemId
215 detElemId = DetElemId(ichamber,side,iline-1); // get detElemId
216 seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, icathode);
218 // get iFirstStrip in this module
219 const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(seg);
220 const AliMpTrigger* t = trig->Slat();
221 const AliMpSlat* slat = t->GetLayer(0);
222 if (iline == 5) icolDo = icol + 1; // special case
223 if (iline == 6) icolDo = icol - 1; // special case
224 const AliMpPCB* pcb = slat->GetPCB(icolDo-1);
225 iFirstStripDo = (pcb->Iymax() + 1) - 8;
226 iLastStripDo = iFirstStripDo + 8;
230 FillXstrips(seg,detElemId,icolDo,
231 iFirstStripDo,iLastStripDo,iStripCircuit,fYpos21);
233 // fill strip between middle and upper part
234 fYpos21[15]=(fYpos21[14]+fYpos21[16])/2.;
235 } // end of something down
239 //----------------------------------------------------------------------
240 void AliMUONTriggerCircuit::LoadXPos(const AliMUONTriggerCrateStore& crates)
242 /// fill fXpos11 -> x position of Y strips for the first plane only
243 /// fXpos11 contains the x position of Y strip for the current circuit
244 /// taking into account whether or nor not part(s) of the circuit
245 /// (middle, up or down) has(have) 16 strips (handdled by means of switchs)
247 const AliMUONLocalTriggerBoard* localBoard = crates.LocalBoard(fILocalBoard);
251 AliError(Form("Did not get localboard %d",fILocalBoard));
254 StdoutToAliDebug(1,localBoard->Print("CONF"););
259 Int_t x2u = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2u);
260 Int_t x2m = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2m);
261 Int_t x2d = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2d);
262 Int_t zeroAllYLSB = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroAllYLSB);
263 Int_t iStripCircuit = 0;
264 Int_t iFirstStrip = 0;
265 Int_t iLastStrip = 0;
266 Bool_t doubling = kFALSE;
268 const AliMpVSegmentation* seg;
273 DecodeBoardName(localBoard->GetName(),side,iline,icol);
275 Int_t detElemId=DetElemId(ichamber,side,iline); // get detElemId
276 seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, icathode);
278 // check if one needs a strip doubling or not
279 if ( (x2u == 1 || x2m == 1 || x2d == 1) && x2m == 1) doubling = kTRUE;
281 // check if one starts at strip = 0 or 8 (boards 26-29 and 143-146)
282 if (zeroAllYLSB == 1) iStripCircuit = 8;
284 // get iFirstStrip in this module
285 const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(seg);
286 const AliMpTrigger* t = trig->Slat();
287 const AliMpSlat* slat = t->GetLayer(0);
289 const AliMpPCB* pcb = slat->GetPCB(icol-1);
290 iFirstStrip = pcb->Ixmin();
292 if (doubling) iLastStrip = iFirstStrip + 8;
293 else iLastStrip = iFirstStrip + 16;
295 FillYstrips(seg,detElemId,
296 iFirstStrip,iLastStrip,iStripCircuit,doubling);
299 //----------------------------------------------------------------------
300 void AliMUONTriggerCircuit::FillYstrips(
301 const AliMpVSegmentation* seg,
302 const Int_t detElemId,
303 const Int_t iFirstStrip, const Int_t iLastStrip, Int_t liStripCircuit,
304 const Bool_t doubling)
307 Double_t xyGlobal[4]={0.,0.,0.,0.};
308 for (Int_t istrip=iFirstStrip; istrip<iLastStrip; istrip++) {
309 AliMpPad pad = seg->PadByIndices(AliMpIntPair(istrip,0),kTRUE);
310 if ( !pad.IsValid() )
312 StdoutToAliError(cout << "Pad not found in seg " << endl;
314 cout << " ix,iy=" << istrip << "," << 0 << endl;
317 XYGlobal(detElemId,pad,xyGlobal);
320 fXpos11[liStripCircuit]=xyGlobal[0];
321 } else if (doubling) {
322 fXpos11[2*liStripCircuit]=TMath::Sign(1.,xyGlobal[0]) *
323 (TMath::Abs(xyGlobal[0]) - xyGlobal[2]/2.);
324 fXpos11[2*liStripCircuit+1]=TMath::Sign(1.,xyGlobal[0]) *
325 (TMath::Abs(fXpos11[2*liStripCircuit]) + xyGlobal[2]);
331 //----------------------------------------------------------------------
332 void AliMUONTriggerCircuit::FillXstrips(
333 const AliMpVSegmentation* seg,
334 const Int_t detElemId, const Int_t icol,
335 const Int_t iFirstStrip, const Int_t iLastStrip,
336 Int_t liStripCircuit, Float_t *tab)
339 Double_t xyGlobal[4]={0.,0.,0.,0.};
340 for (Int_t istrip=iFirstStrip; istrip<iLastStrip; istrip++) {
341 AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,istrip),kTRUE);
342 if ( !pad.IsValid() )
344 StdoutToAliError(cout << "Pad not found in seg " << endl;
346 cout << " ix,iy=" << icol-1 << "," << istrip << endl;
350 XYGlobal(detElemId,pad,xyGlobal);
352 tab[2*liStripCircuit]=xyGlobal[1];
353 if (istrip!=(iLastStrip-1)) tab[2*liStripCircuit+1]=xyGlobal[1]+xyGlobal[3];
358 //----------------------------------------------------------------------
359 //--- methods which return member data related info
360 //----------------------------------------------------------------------
361 Float_t AliMUONTriggerCircuit::GetY11Pos(Int_t istrip) const {
362 /// returns Y position of X strip istrip in MC11
363 return fYpos11[istrip];
365 //----------------------------------------------------------------------
366 Float_t AliMUONTriggerCircuit::GetY21Pos(Int_t istrip) const {
367 /// returns Y position of X strip istrip in MC21
368 return fYpos21[istrip];
370 //----------------------------------------------------------------------
371 Float_t AliMUONTriggerCircuit::GetX11Pos(Int_t istrip) const {
372 /// returns X position of Y strip istrip in MC11
373 return fXpos11[istrip];
375 //----------------------------------------------------------------------
376 //--- end of methods which return member data related info
377 //----------------------------------------------------------------------
379 void AliMUONTriggerCircuit::dump(const char* what, const Float_t* array, Int_t size)
381 cout << what << " " << endl;
382 for ( Int_t i = 0; i < size; ++i )
384 cout << array[i] << " , ";
389 void AliMUONTriggerCircuit::dump(const char* what, const Int_t* array, Int_t size)
391 cout << what << " " << endl;
392 for ( Int_t i = 0; i < size; ++i )
394 cout << array[i] << " , ";
399 //_____________________________________________________________________________
400 void AliMUONTriggerCircuit::Print(Option_t* ) const
402 cout << "IdCircuit " << fILocalBoard << " X2m,X2ud=" << fX2m << ","
404 for ( Int_t i = 0; i < 2; ++i )
406 cout << " OrMud[" << i << "]=" << fOrMud[i];
409 dump("Xpos11",fXpos11,16);
410 dump("Ypos11",fYpos11,31);
411 dump("Ypos21",fYpos21,63);
412 for ( Int_t i = 0; i < 4; ++i )
415 sprintf(s,"Xcode[%d]",i);
416 dump(s,fXcode[i],32);
417 sprintf(s,"Ycode[%d]",i);
418 dump(s,fYcode[i],32);
420 // Int_t fILocalBoard; // circuit Id number
421 // Int_t fX2m; // internal info needed by TriggerDecision
422 // Int_t fX2ud; // internal info needed by TriggerDecision
423 // Int_t fOrMud[2]; // internal info needed by TriggerDecision
424 // Int_t fXcode[4][32]; // code of X strips
425 // Int_t fYcode[4][32]; // code of Y strips
426 // Float_t fXpos11[16]; // X position of Y strips in MC11
427 // Float_t fYpos11[31]; // Y position of X strips in MC11
428 // Float_t fYpos21[63]; // Y position of X strips in MC21
433 //----------------------------------------------------------------------
434 Int_t AliMUONTriggerCircuit::DetElemId(Int_t ichamber, char side, Int_t iline)
436 /// returns detection element Id for chamber iChamber, side side and line iline
438 if ( side == 'R' ) { // right side
439 switch (iline) // (from 1 to 9, from bottom to top)
469 } else if ( side == 'L' ) { // left side
470 switch (iline) // (from 1 to 9, from bottom to top)
501 return ((ichamber+1)*100)+itmp;
504 //----------------------------------------------------------------------
506 AliMUONTriggerCircuit::DetElemId(Int_t iChamber, const char* boardName)
508 /// returns detection element Id for chamber iChamber and board boardName
513 DecodeBoardName(boardName, side, iline, icol);
515 return DetElemId(iChamber,side,iline);
518 //----------------------------------------------------------------------
520 AliMUONTriggerCircuit::DecodeBoardName(const char* boardName,
525 /// get side, line and col from board boardName
526 /// note: icol = icol -1 for iline = 5 w.r.t other ilines
528 iLine = boardName[4] - '0';
529 iCol = boardName[2] - '0';
530 if ( iLine == 5 ) --iCol;
533 //----------------------------------------------------------------------
535 AliMUONTriggerCircuit::FirstStrip(const char* boardName)
537 /// returns the first strip from mapping for board boardName
538 /// take care of special case for boards RC1L6B12 & LC1L6B12
539 Int_t iFirstStrip = -1;
540 Int_t boardNumber = atoi(boardName+6);
543 DecodeBoardName(boardName,side,iline,icol);
559 if (icol == 1 && iline == 6) iFirstStrip = iFirstStrip + 16; // special case
563 //----------------------------------------------------------------------
564 void AliMUONTriggerCircuit::XYGlobal(
565 Int_t detElemId, const AliMpPad& pad,
566 Double_t xyGlobal[4])
568 /// returns pad x & y positions and x & y pad dimensions in global coordinates
569 /// note: no need for transformation for pad dimensions
571 // get the pad position and dimensions
572 Double_t xl1 = pad.Position().X();
573 Double_t yl1 = pad.Position().Y();
574 xyGlobal[2] = pad.Dimensions().X(); // half size!
575 xyGlobal[3] = pad.Dimensions().Y(); // half size!
578 // positions from local to global
579 fTransformer->Local2Global(detElemId, xl1, yl1, 0,
580 xyGlobal[0], xyGlobal[1], zg1);