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)
75 for (Int_t i = 0; i < 16; ++i)
76 fXpos11[i] = circuit.fXpos11[i];
78 for (Int_t i = 0; i < 31; ++i)
79 fYpos11[i] = circuit.fYpos11[i];
81 for (Int_t i = 0; i < 63; ++i)
82 fYpos21[i] = circuit.fYpos21[i];
85 //----------------------------------------------------------------------
86 AliMUONTriggerCircuit& AliMUONTriggerCircuit::operator=(const AliMUONTriggerCircuit& circuit)
88 /// Assignment operator
90 if (this == &circuit) return *this;
92 fILocalBoard = circuit.fILocalBoard;
94 for (Int_t i = 0; i < 16; ++i)
95 fXpos11[i] = circuit.fXpos11[i];
97 for (Int_t i = 0; i < 31; ++i)
98 fYpos11[i] = circuit.fYpos11[i];
100 for (Int_t i = 0; i < 63; ++i)
101 fYpos21[i] = circuit.fYpos21[i];
106 //----------------------------------------------------------------------
107 void AliMUONTriggerCircuit::Init(Int_t iCircuit, const AliMUONTriggerCrateStore& crates)
109 /// initialize circuit characteristics
110 fILocalBoard=iCircuit+1;//AliMUONTriggerConstants::CircuitId(iCircuit);
117 //---------------------------------------------------------------------
118 void AliMUONTriggerCircuit::LoadYPos(const AliMUONTriggerCrateStore& crates)
120 /// fill fYpos11 and fYpos21 -> y position of X declusterized strips
122 const AliMUONLocalTriggerBoard* localBoard = crates.LocalBoard(fILocalBoard);
126 AliError(Form("Did not get localboard %d",fILocalBoard));
129 StdoutToAliDebug(1,localBoard->Print("CONF"););
134 const AliMpVSegmentation* seg;
136 Int_t zeroDown = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroDown);
137 Int_t zeroUp = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroUp);
144 DecodeBoardName(localBoard->GetName(),side,iline,icol);
146 Int_t detElemId = DetElemId(ichamber,side,iline);
147 seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, icathode);
149 Int_t iFirstStrip = FirstStrip(localBoard->GetName());
150 Int_t iLastStrip = iFirstStrip + 16;
151 Int_t iStripCircuit = 0;
152 FillXstrips(seg,detElemId,icol,
153 iFirstStrip,iLastStrip,iStripCircuit,fYpos11);
158 detElemId = DetElemId(ichamber,side,iline);
159 seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, icathode);
161 // second plane middle part
162 Int_t iFirstStripMiddle = FirstStrip(localBoard->GetName());
163 Int_t iLastStripMiddle = iFirstStrip + 16;
165 FillXstrips(seg,detElemId,icol,
166 iFirstStripMiddle,iLastStripMiddle,iStripCircuit,fYpos21);
168 // second plane upper part
169 if (zeroUp == 0) { // something up
173 // check if we need to move to another detElemId
174 AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,iLastStripMiddle+1),kFALSE);
175 if (pad.IsValid()) { // upper strips within same detElemId
176 iFirstStripUp = iLastStripMiddle;
177 iLastStripUp = iFirstStripUp + 8;
179 } else { // upper strips in another detElemId
180 detElemId = DetElemId(ichamber,side,iline+1); // get detElemId
181 seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, icathode);
184 iLastStripUp = iFirstStripUp + 8;
185 if (iline == 4) icolUp = icol - 1; // special case
186 if (iline == 5) icolUp = icol + 1; // special case
190 FillXstrips(seg,detElemId,icolUp,
191 iFirstStripUp,iLastStripUp,iStripCircuit,fYpos21);
193 // fill strip between middle and upper part
194 fYpos21[47]=(fYpos21[46]+fYpos21[48])/2.;
195 } // end of something up
197 // restore current detElemId & segmentation
198 detElemId = DetElemId(ichamber,side,iline);
199 seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, icathode);
201 // second plane lower part
202 if (zeroDown == 0) { // something down
207 // check if we need to move to another detElemId
208 AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,iFirstStripMiddle-1),kFALSE);
209 if (pad.IsValid()) { // lower strips within same detElemId
210 iFirstStripDo = iFirstStripMiddle - 8;
211 iLastStripDo = iFirstStripDo + 8;
213 } else { // lower strips in another detElemId
214 detElemId = DetElemId(ichamber,side,iline-1); // get detElemId
215 seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, icathode);
217 // get iFirstStrip in this module
218 const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(seg);
219 const AliMpTrigger* t = trig->Slat();
220 const AliMpSlat* slat = t->GetLayer(0);
221 if (iline == 5) icolDo = icol + 1; // special case
222 if (iline == 6) icolDo = icol - 1; // special case
223 const AliMpPCB* pcb = slat->GetPCB(icolDo-1);
224 iFirstStripDo = (pcb->Iymax() + 1) - 8;
225 iLastStripDo = iFirstStripDo + 8;
229 FillXstrips(seg,detElemId,icolDo,
230 iFirstStripDo,iLastStripDo,iStripCircuit,fYpos21);
232 // fill strip between middle and upper part
233 fYpos21[15]=(fYpos21[14]+fYpos21[16])/2.;
234 } // end of something down
238 //----------------------------------------------------------------------
239 void AliMUONTriggerCircuit::LoadXPos(const AliMUONTriggerCrateStore& crates)
241 /// fill fXpos11 -> x position of Y strips for the first plane only
242 /// fXpos11 contains the x position of Y strip for the current circuit
243 /// taking into account whether or nor not part(s) of the circuit
244 /// (middle, up or down) has(have) 16 strips (handdled by means of switchs)
246 const AliMUONLocalTriggerBoard* localBoard = crates.LocalBoard(fILocalBoard);
250 AliError(Form("Did not get localboard %d",fILocalBoard));
253 StdoutToAliDebug(1,localBoard->Print("CONF"););
258 Int_t x2u = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2u);
259 Int_t x2m = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2m);
260 Int_t x2d = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2d);
261 Int_t zeroAllYLSB = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroAllYLSB);
262 Int_t iStripCircuit = 0;
263 Int_t iFirstStrip = 0;
264 Int_t iLastStrip = 0;
265 Bool_t doubling = kFALSE;
267 const AliMpVSegmentation* seg;
272 DecodeBoardName(localBoard->GetName(),side,iline,icol);
274 Int_t detElemId=DetElemId(ichamber,side,iline); // get detElemId
275 seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, icathode);
277 // check if one needs a strip doubling or not
278 if ( (x2u == 1 || x2m == 1 || x2d == 1) && x2m == 1) doubling = kTRUE;
280 // check if one starts at strip = 0 or 8 (boards 26-29 and 143-146)
281 if (zeroAllYLSB == 1) iStripCircuit = 8;
283 // get iFirstStrip in this module
284 const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(seg);
285 const AliMpTrigger* t = trig->Slat();
286 const AliMpSlat* slat = t->GetLayer(0);
288 const AliMpPCB* pcb = slat->GetPCB(icol-1);
289 iFirstStrip = pcb->Ixmin();
291 if (doubling) iLastStrip = iFirstStrip + 8;
292 else iLastStrip = iFirstStrip + 16;
294 FillYstrips(seg,detElemId,
295 iFirstStrip,iLastStrip,iStripCircuit,doubling);
298 //----------------------------------------------------------------------
299 void AliMUONTriggerCircuit::FillYstrips(
300 const AliMpVSegmentation* seg,
301 const Int_t detElemId,
302 const Int_t iFirstStrip, const Int_t iLastStrip, Int_t liStripCircuit,
303 const Bool_t doubling)
306 Double_t xyGlobal[4]={0.,0.,0.,0.};
307 for (Int_t istrip=iFirstStrip; istrip<iLastStrip; istrip++) {
308 AliMpPad pad = seg->PadByIndices(AliMpIntPair(istrip,0),kTRUE);
309 if ( !pad.IsValid() )
311 StdoutToAliError(cout << "Pad not found in seg " << endl;
313 cout << " ix,iy=" << istrip << "," << 0 << endl;
316 XYGlobal(detElemId,pad,xyGlobal);
319 fXpos11[liStripCircuit]=xyGlobal[0];
320 } else if (doubling) {
321 fXpos11[2*liStripCircuit]=TMath::Sign(1.,xyGlobal[0]) *
322 (TMath::Abs(xyGlobal[0]) - xyGlobal[2]/2.);
323 fXpos11[2*liStripCircuit+1]=TMath::Sign(1.,xyGlobal[0]) *
324 (TMath::Abs(fXpos11[2*liStripCircuit]) + xyGlobal[2]);
330 //----------------------------------------------------------------------
331 void AliMUONTriggerCircuit::FillXstrips(
332 const AliMpVSegmentation* seg,
333 const Int_t detElemId, const Int_t icol,
334 const Int_t iFirstStrip, const Int_t iLastStrip,
335 Int_t liStripCircuit, Float_t *tab)
338 Double_t xyGlobal[4]={0.,0.,0.,0.};
339 for (Int_t istrip=iFirstStrip; istrip<iLastStrip; istrip++) {
340 AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,istrip),kTRUE);
341 if ( !pad.IsValid() )
343 StdoutToAliError(cout << "Pad not found in seg " << endl;
345 cout << " ix,iy=" << icol-1 << "," << istrip << endl;
349 XYGlobal(detElemId,pad,xyGlobal);
351 tab[2*liStripCircuit]=xyGlobal[1];
352 if (istrip!=(iLastStrip-1)) tab[2*liStripCircuit+1]=xyGlobal[1]+xyGlobal[3];
357 //----------------------------------------------------------------------
358 //--- methods which return member data related info
359 //----------------------------------------------------------------------
360 Float_t AliMUONTriggerCircuit::GetY11Pos(Int_t istrip) const {
361 /// returns Y position of X strip istrip in MC11
362 return fYpos11[istrip];
364 //----------------------------------------------------------------------
365 Float_t AliMUONTriggerCircuit::GetY21Pos(Int_t istrip) const {
366 /// returns Y position of X strip istrip in MC21
367 return fYpos21[istrip];
369 //----------------------------------------------------------------------
370 Float_t AliMUONTriggerCircuit::GetX11Pos(Int_t istrip) const {
371 /// returns X position of Y strip istrip in MC11
372 return fXpos11[istrip];
374 //----------------------------------------------------------------------
375 //--- end of methods which return member data related info
376 //----------------------------------------------------------------------
378 void AliMUONTriggerCircuit::dump(const char* what, const Float_t* array, Int_t size)
380 cout << what << " " << endl;
381 for ( Int_t i = 0; i < size; ++i )
383 cout << array[i] << " , ";
388 void AliMUONTriggerCircuit::dump(const char* what, const Int_t* array, Int_t size)
390 cout << what << " " << endl;
391 for ( Int_t i = 0; i < size; ++i )
393 cout << array[i] << " , ";
398 //_____________________________________________________________________________
399 void AliMUONTriggerCircuit::Print(Option_t* ) const
401 cout << "IdCircuit " << fILocalBoard << " X2m,X2ud=" << fX2m << ","
403 for ( Int_t i = 0; i < 2; ++i )
405 cout << " OrMud[" << i << "]=" << fOrMud[i];
408 dump("Xpos11",fXpos11,16);
409 dump("Ypos11",fYpos11,31);
410 dump("Ypos21",fYpos21,63);
411 for ( Int_t i = 0; i < 4; ++i )
414 sprintf(s,"Xcode[%d]",i);
415 dump(s,fXcode[i],32);
416 sprintf(s,"Ycode[%d]",i);
417 dump(s,fYcode[i],32);
419 // Int_t fILocalBoard; // circuit Id number
420 // Int_t fX2m; // internal info needed by TriggerDecision
421 // Int_t fX2ud; // internal info needed by TriggerDecision
422 // Int_t fOrMud[2]; // internal info needed by TriggerDecision
423 // Int_t fXcode[4][32]; // code of X strips
424 // Int_t fYcode[4][32]; // code of Y strips
425 // Float_t fXpos11[16]; // X position of Y strips in MC11
426 // Float_t fYpos11[31]; // Y position of X strips in MC11
427 // Float_t fYpos21[63]; // Y position of X strips in MC21
432 //----------------------------------------------------------------------
433 Int_t AliMUONTriggerCircuit::DetElemId(Int_t ichamber, char side, Int_t iline)
435 /// returns detection element Id for chamber iChamber, side side and line iline
437 if ( side == 'R' ) { // right side
438 switch (iline) // (from 1 to 9, from bottom to top)
468 } else if ( side == 'L' ) { // left side
469 switch (iline) // (from 1 to 9, from bottom to top)
500 return ((ichamber+1)*100)+itmp;
503 //----------------------------------------------------------------------
505 AliMUONTriggerCircuit::DetElemId(Int_t iChamber, const char* boardName)
507 /// returns detection element Id for chamber iChamber and board boardName
512 DecodeBoardName(boardName, side, iline, icol);
514 return DetElemId(iChamber,side,iline);
517 //----------------------------------------------------------------------
519 AliMUONTriggerCircuit::DecodeBoardName(const char* boardName,
524 /// get side, line and col from board boardName
525 /// note: icol = icol -1 for iline = 5 w.r.t other ilines
527 iLine = boardName[4] - '0';
528 iCol = boardName[2] - '0';
529 if ( iLine == 5 ) --iCol;
532 //----------------------------------------------------------------------
534 AliMUONTriggerCircuit::FirstStrip(const char* boardName)
536 /// returns the first strip from mapping for board boardName
537 /// take care of special case for boards RC1L6B12 & LC1L6B12
538 Int_t iFirstStrip = -1;
539 Int_t boardNumber = atoi(boardName+6);
542 DecodeBoardName(boardName,side,iline,icol);
558 if (icol == 1 && iline == 6) iFirstStrip = iFirstStrip + 16; // special case
562 //----------------------------------------------------------------------
563 void AliMUONTriggerCircuit::XYGlobal(
564 Int_t detElemId, const AliMpPad& pad,
565 Double_t xyGlobal[4])
567 /// returns pad x & y positions and x & y pad dimensions in global coordinates
568 /// note: no need for transformation for pad dimensions
570 // get the pad position and dimensions
571 Double_t xl1 = pad.Position().X();
572 Double_t yl1 = pad.Position().Y();
573 xyGlobal[2] = pad.Dimensions().X(); // half size!
574 xyGlobal[3] = pad.Dimensions().Y(); // half size!
577 // positions from local to global
578 fTransformer->Local2Global(detElemId, xl1, yl1, 0,
579 xyGlobal[0], xyGlobal[1], zg1);