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"
38 #include "AliMpCathodType.h"
46 ClassImp(AliMUONTriggerCircuit)
49 //----------------------------------------------------------------------
50 AliMUONTriggerCircuit::AliMUONTriggerCircuit()
58 for (i=0; i<16; i++) { fXpos11[i]=0.; }
59 for (i=0; i<31; i++) { fYpos11[i]=0.; }
60 for (i=0; i<63; i++) { fYpos21[i]=0.; }
63 //----------------------------------------------------------------------
64 AliMUONTriggerCircuit::~AliMUONTriggerCircuit()
69 //----------------------------------------------------------------------
70 AliMUONTriggerCircuit::AliMUONTriggerCircuit(const AliMUONTriggerCircuit& circuit)
72 fILocalBoard(circuit.fILocalBoard),
77 for (Int_t i = 0; i < 16; ++i)
78 fXpos11[i] = circuit.fXpos11[i];
80 for (Int_t i = 0; i < 31; ++i)
81 fYpos11[i] = circuit.fYpos11[i];
83 for (Int_t i = 0; i < 63; ++i)
84 fYpos21[i] = circuit.fYpos21[i];
87 //----------------------------------------------------------------------
88 AliMUONTriggerCircuit& AliMUONTriggerCircuit::operator=(const AliMUONTriggerCircuit& circuit)
90 /// Assignment operator
92 if (this == &circuit) return *this;
94 fILocalBoard = circuit.fILocalBoard;
96 for (Int_t i = 0; i < 16; ++i)
97 fXpos11[i] = circuit.fXpos11[i];
99 for (Int_t i = 0; i < 31; ++i)
100 fYpos11[i] = circuit.fYpos11[i];
102 for (Int_t i = 0; i < 63; ++i)
103 fYpos21[i] = circuit.fYpos21[i];
108 //----------------------------------------------------------------------
109 void AliMUONTriggerCircuit::Init(Int_t iCircuit, const AliMUONTriggerCrateStore& crates)
111 /// initialize circuit characteristics
112 fILocalBoard=iCircuit+1;//AliMUONTriggerConstants::CircuitId(iCircuit);
119 //---------------------------------------------------------------------
120 void AliMUONTriggerCircuit::LoadYPos(const AliMUONTriggerCrateStore& crates)
122 /// fill fYpos11 and fYpos21 -> y position of X declusterized strips
124 const AliMUONLocalTriggerBoard* localBoard = crates.LocalBoard(fILocalBoard);
128 AliError(Form("Did not get localboard %d",fILocalBoard));
131 StdoutToAliDebug(1,localBoard->Print("CONF"););
136 const AliMpVSegmentation* seg;
138 Int_t zeroDown = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroDown);
139 Int_t zeroUp = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroUp);
146 DecodeBoardName(localBoard->GetName(),side,iline,icol);
148 Int_t detElemId = DetElemId(ichamber,side,iline);
149 seg = AliMpSegmentation::Instance()
150 ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));
152 Int_t iFirstStrip = FirstStrip(localBoard->GetName());
153 Int_t iLastStrip = iFirstStrip + 16;
154 Int_t iStripCircuit = 0;
155 FillXstrips(seg,detElemId,icol,
156 iFirstStrip,iLastStrip,iStripCircuit,fYpos11);
161 detElemId = DetElemId(ichamber,side,iline);
162 seg = AliMpSegmentation::Instance()
163 ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));
165 // second plane middle part
166 Int_t iFirstStripMiddle = FirstStrip(localBoard->GetName());
167 Int_t iLastStripMiddle = iFirstStrip + 16;
169 FillXstrips(seg,detElemId,icol,
170 iFirstStripMiddle,iLastStripMiddle,iStripCircuit,fYpos21);
172 // second plane upper part
173 if (zeroUp == 0) { // something up
177 // check if we need to move to another detElemId
178 AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,iLastStripMiddle+1),kFALSE);
179 if (pad.IsValid()) { // upper strips within same detElemId
180 iFirstStripUp = iLastStripMiddle;
181 iLastStripUp = iFirstStripUp + 8;
183 } else { // upper strips in another detElemId
184 detElemId = DetElemId(ichamber,side,iline+1); // get detElemId
185 seg = AliMpSegmentation::Instance()
186 ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));
189 iLastStripUp = iFirstStripUp + 8;
190 if (iline == 4) icolUp = icol - 1; // special case
191 if (iline == 5) icolUp = icol + 1; // special case
195 FillXstrips(seg,detElemId,icolUp,
196 iFirstStripUp,iLastStripUp,iStripCircuit,fYpos21);
198 // fill strip between middle and upper part
199 fYpos21[47]=(fYpos21[46]+fYpos21[48])/2.;
200 } // end of something up
202 // restore current detElemId & segmentation
203 detElemId = DetElemId(ichamber,side,iline);
204 seg = AliMpSegmentation::Instance()
205 ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));
207 // second plane lower part
208 if (zeroDown == 0) { // something down
213 // check if we need to move to another detElemId
214 AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,iFirstStripMiddle-1),kFALSE);
215 if (pad.IsValid()) { // lower strips within same detElemId
216 iFirstStripDo = iFirstStripMiddle - 8;
217 iLastStripDo = iFirstStripDo + 8;
219 } else { // lower strips in another detElemId
220 detElemId = DetElemId(ichamber,side,iline-1); // get detElemId
221 seg = AliMpSegmentation::Instance()
222 ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));
224 // get iFirstStrip in this module
225 const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(seg);
226 const AliMpTrigger* t = trig->Slat();
227 const AliMpSlat* slat = t->GetLayer(0);
228 if (iline == 5) icolDo = icol + 1; // special case
229 if (iline == 6) icolDo = icol - 1; // special case
230 const AliMpPCB* pcb = slat->GetPCB(icolDo-1);
231 iFirstStripDo = (pcb->Iymax() + 1) - 8;
232 iLastStripDo = iFirstStripDo + 8;
236 FillXstrips(seg,detElemId,icolDo,
237 iFirstStripDo,iLastStripDo,iStripCircuit,fYpos21);
239 // fill strip between middle and upper part
240 fYpos21[15]=(fYpos21[14]+fYpos21[16])/2.;
241 } // end of something down
245 //----------------------------------------------------------------------
246 void AliMUONTriggerCircuit::LoadXPos(const AliMUONTriggerCrateStore& crates)
248 /// fill fXpos11 -> x position of Y strips for the first plane only
249 /// fXpos11 contains the x position of Y strip for the current circuit
250 /// taking into account whether or nor not part(s) of the circuit
251 /// (middle, up or down) has(have) 16 strips (handdled by means of switchs)
253 const AliMUONLocalTriggerBoard* localBoard = crates.LocalBoard(fILocalBoard);
257 AliError(Form("Did not get localboard %d",fILocalBoard));
260 StdoutToAliDebug(1,localBoard->Print("CONF"););
265 Int_t x2u = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2u);
266 Int_t x2m = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2m);
267 Int_t x2d = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2d);
268 Int_t zeroAllYLSB = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroAllYLSB);
269 Int_t iStripCircuit = 0;
270 Int_t iFirstStrip = 0;
271 Int_t iLastStrip = 0;
272 Bool_t doubling = kFALSE;
274 const AliMpVSegmentation* seg;
279 DecodeBoardName(localBoard->GetName(),side,iline,icol);
281 Int_t detElemId=DetElemId(ichamber,side,iline); // get detElemId
282 seg = AliMpSegmentation::Instance()
283 ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));
285 // check if one needs a strip doubling or not
286 if ( (x2u == 1 || x2m == 1 || x2d == 1) && x2m == 1) doubling = kTRUE;
288 // check if one starts at strip = 0 or 8 (boards 26-29 and 143-146)
289 if (zeroAllYLSB == 1) iStripCircuit = 8;
291 // get iFirstStrip in this module
292 const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(seg);
293 const AliMpTrigger* t = trig->Slat();
294 const AliMpSlat* slat = t->GetLayer(0);
296 const AliMpPCB* pcb = slat->GetPCB(icol-1);
297 iFirstStrip = pcb->Ixmin();
299 if (doubling) iLastStrip = iFirstStrip + 8;
300 else iLastStrip = iFirstStrip + 16;
302 FillYstrips(seg,detElemId,
303 iFirstStrip,iLastStrip,iStripCircuit,doubling);
306 //----------------------------------------------------------------------
307 void AliMUONTriggerCircuit::FillYstrips(
308 const AliMpVSegmentation* seg,
309 const Int_t detElemId,
310 const Int_t iFirstStrip, const Int_t iLastStrip, Int_t liStripCircuit,
311 const Bool_t doubling)
314 Double_t xyGlobal[4]={0.,0.,0.,0.};
315 for (Int_t istrip=iFirstStrip; istrip<iLastStrip; istrip++) {
316 AliMpPad pad = seg->PadByIndices(AliMpIntPair(istrip,0),kTRUE);
317 if ( !pad.IsValid() )
319 StdoutToAliError(cout << "Pad not found in seg " << endl;
321 cout << " ix,iy=" << istrip << "," << 0 << endl;
324 XYGlobal(detElemId,pad,xyGlobal);
327 fXpos11[liStripCircuit]=xyGlobal[0];
328 } else if (doubling) {
329 fXpos11[2*liStripCircuit]=TMath::Sign(1.,xyGlobal[0]) *
330 (TMath::Abs(xyGlobal[0]) - xyGlobal[2]/2.);
331 fXpos11[2*liStripCircuit+1]=TMath::Sign(1.,xyGlobal[0]) *
332 (TMath::Abs(fXpos11[2*liStripCircuit]) + xyGlobal[2]);
338 //----------------------------------------------------------------------
339 void AliMUONTriggerCircuit::FillXstrips(
340 const AliMpVSegmentation* seg,
341 const Int_t detElemId, const Int_t icol,
342 const Int_t iFirstStrip, const Int_t iLastStrip,
343 Int_t liStripCircuit, Float_t *tab)
346 Double_t xyGlobal[4]={0.,0.,0.,0.};
347 for (Int_t istrip=iFirstStrip; istrip<iLastStrip; istrip++) {
348 AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,istrip),kTRUE);
349 if ( !pad.IsValid() )
351 StdoutToAliError(cout << "Pad not found in seg " << endl;
353 cout << " ix,iy=" << icol-1 << "," << istrip << endl;
357 XYGlobal(detElemId,pad,xyGlobal);
359 tab[2*liStripCircuit]=xyGlobal[1];
360 if (istrip!=(iLastStrip-1)) tab[2*liStripCircuit+1]=xyGlobal[1]+xyGlobal[3];
365 //----------------------------------------------------------------------
366 //--- methods which return member data related info
367 //----------------------------------------------------------------------
368 Float_t AliMUONTriggerCircuit::GetY11Pos(Int_t istrip) const {
369 /// returns Y position of X strip istrip in MC11
370 return fYpos11[istrip];
372 //----------------------------------------------------------------------
373 Float_t AliMUONTriggerCircuit::GetY21Pos(Int_t istrip) const {
374 /// returns Y position of X strip istrip in MC21
375 return fYpos21[istrip];
377 //----------------------------------------------------------------------
378 Float_t AliMUONTriggerCircuit::GetX11Pos(Int_t istrip) const {
379 /// returns X position of Y strip istrip in MC11
380 return fXpos11[istrip];
382 //----------------------------------------------------------------------
383 //--- end of methods which return member data related info
384 //----------------------------------------------------------------------
386 void AliMUONTriggerCircuit::dump(const char* what, const Float_t* array, Int_t size)
388 cout << what << " " << endl;
389 for ( Int_t i = 0; i < size; ++i )
391 cout << array[i] << " , ";
396 void AliMUONTriggerCircuit::dump(const char* what, const Int_t* array, Int_t size)
398 cout << what << " " << endl;
399 for ( Int_t i = 0; i < size; ++i )
401 cout << array[i] << " , ";
406 //_____________________________________________________________________________
407 void AliMUONTriggerCircuit::Print(Option_t* ) const
409 cout << "IdCircuit " << fILocalBoard << " X2m,X2ud=" << fX2m << ","
411 for ( Int_t i = 0; i < 2; ++i )
413 cout << " OrMud[" << i << "]=" << fOrMud[i];
416 dump("Xpos11",fXpos11,16);
417 dump("Ypos11",fYpos11,31);
418 dump("Ypos21",fYpos21,63);
419 for ( Int_t i = 0; i < 4; ++i )
422 sprintf(s,"Xcode[%d]",i);
423 dump(s,fXcode[i],32);
424 sprintf(s,"Ycode[%d]",i);
425 dump(s,fYcode[i],32);
427 // Int_t fILocalBoard; // circuit Id number
428 // Int_t fX2m; // internal info needed by TriggerDecision
429 // Int_t fX2ud; // internal info needed by TriggerDecision
430 // Int_t fOrMud[2]; // internal info needed by TriggerDecision
431 // Int_t fXcode[4][32]; // code of X strips
432 // Int_t fYcode[4][32]; // code of Y strips
433 // Float_t fXpos11[16]; // X position of Y strips in MC11
434 // Float_t fYpos11[31]; // Y position of X strips in MC11
435 // Float_t fYpos21[63]; // Y position of X strips in MC21
440 //----------------------------------------------------------------------
441 Int_t AliMUONTriggerCircuit::DetElemId(Int_t ichamber, char side, Int_t iline)
443 /// returns detection element Id for chamber iChamber, side side and line iline
445 if ( side == 'R' ) { // right side
446 switch (iline) // (from 1 to 9, from bottom to top)
476 } else if ( side == 'L' ) { // left side
477 switch (iline) // (from 1 to 9, from bottom to top)
508 return ((ichamber+1)*100)+itmp;
511 //----------------------------------------------------------------------
513 AliMUONTriggerCircuit::DetElemId(Int_t iChamber, const char* boardName)
515 /// returns detection element Id for chamber iChamber and board boardName
520 DecodeBoardName(boardName, side, iline, icol);
522 return DetElemId(iChamber,side,iline);
525 //----------------------------------------------------------------------
527 AliMUONTriggerCircuit::DecodeBoardName(const char* boardName,
532 /// get side, line and col from board boardName
533 /// note: icol = icol -1 for iline = 5 w.r.t other ilines
535 iLine = boardName[4] - '0';
536 iCol = boardName[2] - '0';
537 if ( iLine == 5 ) --iCol;
540 //----------------------------------------------------------------------
542 AliMUONTriggerCircuit::FirstStrip(const char* boardName)
544 /// returns the first strip from mapping for board boardName
545 /// take care of special case for boards RC1L6B12 & LC1L6B12
546 Int_t iFirstStrip = -1;
547 Int_t boardNumber = atoi(boardName+6);
550 DecodeBoardName(boardName,side,iline,icol);
566 if (icol == 1 && iline == 6) iFirstStrip = iFirstStrip + 16; // special case
570 //----------------------------------------------------------------------
571 void AliMUONTriggerCircuit::XYGlobal(
572 Int_t detElemId, const AliMpPad& pad,
573 Double_t xyGlobal[4])
575 /// returns pad x & y positions and x & y pad dimensions in global coordinates
576 /// note: no need for transformation for pad dimensions
578 // get the pad position and dimensions
579 Double_t xl1 = pad.Position().X();
580 Double_t yl1 = pad.Position().Y();
581 xyGlobal[2] = pad.Dimensions().X(); // half size!
582 xyGlobal[3] = pad.Dimensions().Y(); // half size!
585 // positions from local to global
586 fTransformer->Local2Global(detElemId, xl1, yl1, 0,
587 xyGlobal[0], xyGlobal[1], zg1);