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 /// \author Philippe Crochet (LPCCFd)
26 #include "AliMUONTriggerCircuit.h"
28 #include "AliMUONConstants.h"
29 #include "AliMUONLocalTriggerBoard.h"
30 #include "AliMUONTriggerCrateStore.h"
31 #include "AliMUONTriggerCrate.h"
32 #include "AliMUONGeometryTransformer.h"
34 #include "AliMpTriggerSegmentation.h"
35 #include "AliMpTrigger.h"
36 #include "AliMpSlat.h"
38 #include "AliMpSegmentation.h"
39 #include "AliMpVSegmentation.h"
40 #include "AliMpCathodType.h"
48 ClassImp(AliMUONTriggerCircuit)
51 //----------------------------------------------------------------------
52 AliMUONTriggerCircuit::AliMUONTriggerCircuit()
60 for (i=0; i<16; i++) { fXpos11[i]=0.; }
61 for (i=0; i<31; i++) { fYpos11[i]=0.; }
62 for (i=0; i<63; i++) { fYpos21[i]=0.; }
65 //----------------------------------------------------------------------
66 AliMUONTriggerCircuit::~AliMUONTriggerCircuit()
71 //----------------------------------------------------------------------
72 AliMUONTriggerCircuit::AliMUONTriggerCircuit(const AliMUONTriggerCircuit& circuit)
74 fILocalBoard(circuit.fILocalBoard),
79 for (Int_t i = 0; i < 16; ++i)
80 fXpos11[i] = circuit.fXpos11[i];
82 for (Int_t i = 0; i < 31; ++i)
83 fYpos11[i] = circuit.fYpos11[i];
85 for (Int_t i = 0; i < 63; ++i)
86 fYpos21[i] = circuit.fYpos21[i];
89 //----------------------------------------------------------------------
90 AliMUONTriggerCircuit& AliMUONTriggerCircuit::operator=(const AliMUONTriggerCircuit& circuit)
92 /// Assignment operator
94 if (this == &circuit) return *this;
96 fILocalBoard = circuit.fILocalBoard;
98 for (Int_t i = 0; i < 16; ++i)
99 fXpos11[i] = circuit.fXpos11[i];
101 for (Int_t i = 0; i < 31; ++i)
102 fYpos11[i] = circuit.fYpos11[i];
104 for (Int_t i = 0; i < 63; ++i)
105 fYpos21[i] = circuit.fYpos21[i];
110 //----------------------------------------------------------------------
111 void AliMUONTriggerCircuit::Init(Int_t iCircuit, const AliMUONTriggerCrateStore& crates)
113 /// initialize circuit characteristics
114 fILocalBoard=iCircuit+1;//AliMUONTriggerConstants::CircuitId(iCircuit);
121 //---------------------------------------------------------------------
122 void AliMUONTriggerCircuit::LoadYPos(const AliMUONTriggerCrateStore& crates)
124 /// fill fYpos11 and fYpos21 -> y position of X declusterized strips
126 const AliMUONLocalTriggerBoard* localBoard = crates.LocalBoard(fILocalBoard);
130 AliError(Form("Did not get localboard %d",fILocalBoard));
133 StdoutToAliDebug(1,localBoard->Print("CONF"););
138 const AliMpVSegmentation* seg;
140 Int_t zeroDown = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroDown);
141 Int_t zeroUp = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroUp);
148 DecodeBoardName(localBoard->GetName(),side,iline,icol);
150 Int_t detElemId = DetElemId(ichamber,side,iline);
151 seg = AliMpSegmentation::Instance()
152 ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));
154 Int_t iFirstStrip = FirstStrip(localBoard->GetName());
155 Int_t iLastStrip = iFirstStrip + 16;
156 Int_t iStripCircuit = 0;
157 FillXstrips(seg,detElemId,icol,
158 iFirstStrip,iLastStrip,iStripCircuit,fYpos11);
163 detElemId = DetElemId(ichamber,side,iline);
164 seg = AliMpSegmentation::Instance()
165 ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));
167 // second plane middle part
168 Int_t iFirstStripMiddle = FirstStrip(localBoard->GetName());
169 Int_t iLastStripMiddle = iFirstStrip + 16;
171 FillXstrips(seg,detElemId,icol,
172 iFirstStripMiddle,iLastStripMiddle,iStripCircuit,fYpos21);
174 // second plane upper part
175 if (zeroUp == 0) { // something up
179 // check if we need to move to another detElemId
180 AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,iLastStripMiddle+1),kFALSE);
181 if (pad.IsValid()) { // upper strips within same detElemId
182 iFirstStripUp = iLastStripMiddle;
183 iLastStripUp = iFirstStripUp + 8;
185 } else { // upper strips in another detElemId
186 detElemId = DetElemId(ichamber,side,iline+1); // get detElemId
187 seg = AliMpSegmentation::Instance()
188 ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));
191 iLastStripUp = iFirstStripUp + 8;
192 if (iline == 4) icolUp = icol - 1; // special case
193 if (iline == 5) icolUp = icol + 1; // special case
197 FillXstrips(seg,detElemId,icolUp,
198 iFirstStripUp,iLastStripUp,iStripCircuit,fYpos21);
200 // fill strip between middle and upper part
201 fYpos21[47]=(fYpos21[46]+fYpos21[48])/2.;
202 } // end of something up
204 // restore current detElemId & segmentation
205 detElemId = DetElemId(ichamber,side,iline);
206 seg = AliMpSegmentation::Instance()
207 ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));
209 // second plane lower part
210 if (zeroDown == 0) { // something down
215 // check if we need to move to another detElemId
216 AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,iFirstStripMiddle-1),kFALSE);
217 if (pad.IsValid()) { // lower strips within same detElemId
218 iFirstStripDo = iFirstStripMiddle - 8;
219 iLastStripDo = iFirstStripDo + 8;
221 } else { // lower strips in another detElemId
222 detElemId = DetElemId(ichamber,side,iline-1); // get detElemId
223 seg = AliMpSegmentation::Instance()
224 ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));
226 // get iFirstStrip in this module
227 const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(seg);
228 const AliMpTrigger* t = trig->Slat();
229 const AliMpSlat* slat = t->GetLayer(0);
230 if (iline == 5) icolDo = icol + 1; // special case
231 if (iline == 6) icolDo = icol - 1; // special case
232 const AliMpPCB* pcb = slat->GetPCB(icolDo-1);
233 iFirstStripDo = (pcb->Iymax() + 1) - 8;
234 iLastStripDo = iFirstStripDo + 8;
238 FillXstrips(seg,detElemId,icolDo,
239 iFirstStripDo,iLastStripDo,iStripCircuit,fYpos21);
241 // fill strip between middle and upper part
242 fYpos21[15]=(fYpos21[14]+fYpos21[16])/2.;
243 } // end of something down
247 //----------------------------------------------------------------------
248 void AliMUONTriggerCircuit::LoadXPos(const AliMUONTriggerCrateStore& crates)
250 /// fill fXpos11 -> x position of Y strips for the first plane only
251 /// fXpos11 contains the x position of Y strip for the current circuit
252 /// taking into account whether or nor not part(s) of the circuit
253 /// (middle, up or down) has(have) 16 strips (handdled by means of switchs)
255 const AliMUONLocalTriggerBoard* localBoard = crates.LocalBoard(fILocalBoard);
259 AliError(Form("Did not get localboard %d",fILocalBoard));
262 StdoutToAliDebug(1,localBoard->Print("CONF"););
267 Int_t x2u = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2u);
268 Int_t x2m = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2m);
269 Int_t x2d = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2d);
270 Int_t zeroAllYLSB = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroAllYLSB);
271 Int_t iStripCircuit = 0;
272 Int_t iFirstStrip = 0;
273 Int_t iLastStrip = 0;
274 Bool_t doubling = kFALSE;
276 const AliMpVSegmentation* seg;
281 DecodeBoardName(localBoard->GetName(),side,iline,icol);
283 Int_t detElemId=DetElemId(ichamber,side,iline); // get detElemId
284 seg = AliMpSegmentation::Instance()
285 ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));
287 // check if one needs a strip doubling or not
288 if ( (x2u == 1 || x2m == 1 || x2d == 1) && x2m == 1) doubling = kTRUE;
290 // check if one starts at strip = 0 or 8 (boards 26-29 and 143-146)
291 if (zeroAllYLSB == 1) iStripCircuit = 8;
293 // get iFirstStrip in this module
294 const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(seg);
295 const AliMpTrigger* t = trig->Slat();
296 const AliMpSlat* slat = t->GetLayer(0);
298 const AliMpPCB* pcb = slat->GetPCB(icol-1);
299 iFirstStrip = pcb->Ixmin();
301 if (doubling) iLastStrip = iFirstStrip + 8;
302 else iLastStrip = iFirstStrip + 16;
304 FillYstrips(seg,detElemId,
305 iFirstStrip,iLastStrip,iStripCircuit,doubling);
308 //----------------------------------------------------------------------
309 void AliMUONTriggerCircuit::FillYstrips(
310 const AliMpVSegmentation* seg,
311 const Int_t detElemId,
312 const Int_t iFirstStrip, const Int_t iLastStrip, Int_t liStripCircuit,
313 const Bool_t doubling)
316 Double_t xyGlobal[4]={0.,0.,0.,0.};
317 for (Int_t istrip=iFirstStrip; istrip<iLastStrip; istrip++) {
318 AliMpPad pad = seg->PadByIndices(AliMpIntPair(istrip,0),kTRUE);
319 if ( !pad.IsValid() )
321 StdoutToAliError(cout << "Pad not found in seg " << endl;
323 cout << " ix,iy=" << istrip << "," << 0 << endl;
326 XYGlobal(detElemId,pad,xyGlobal);
329 fXpos11[liStripCircuit]=xyGlobal[0];
330 } else if (doubling) {
331 fXpos11[2*liStripCircuit]=TMath::Sign(1.,xyGlobal[0]) *
332 (TMath::Abs(xyGlobal[0]) - xyGlobal[2]/2.);
333 fXpos11[2*liStripCircuit+1]=TMath::Sign(1.,xyGlobal[0]) *
334 (TMath::Abs(fXpos11[2*liStripCircuit]) + xyGlobal[2]);
340 //----------------------------------------------------------------------
341 void AliMUONTriggerCircuit::FillXstrips(
342 const AliMpVSegmentation* seg,
343 const Int_t detElemId, const Int_t icol,
344 const Int_t iFirstStrip, const Int_t iLastStrip,
345 Int_t liStripCircuit, Float_t *tab)
348 Double_t xyGlobal[4]={0.,0.,0.,0.};
349 for (Int_t istrip=iFirstStrip; istrip<iLastStrip; istrip++) {
350 AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,istrip),kTRUE);
351 if ( !pad.IsValid() )
353 StdoutToAliError(cout << "Pad not found in seg " << endl;
355 cout << " ix,iy=" << icol-1 << "," << istrip << endl;
359 XYGlobal(detElemId,pad,xyGlobal);
361 tab[2*liStripCircuit]=xyGlobal[1];
362 if (istrip!=(iLastStrip-1)) tab[2*liStripCircuit+1]=xyGlobal[1]+xyGlobal[3];
367 //----------------------------------------------------------------------
368 //--- methods which return member data related info
369 //----------------------------------------------------------------------
370 Float_t AliMUONTriggerCircuit::GetY11Pos(Int_t istrip) const {
371 /// returns Y position of X strip istrip in MC11
372 return fYpos11[istrip];
374 //----------------------------------------------------------------------
375 Float_t AliMUONTriggerCircuit::GetY21Pos(Int_t istrip) const {
376 /// returns Y position of X strip istrip in MC21
377 return fYpos21[istrip];
379 //----------------------------------------------------------------------
380 Float_t AliMUONTriggerCircuit::GetX11Pos(Int_t istrip) const {
381 /// returns X position of Y strip istrip in MC11
382 return fXpos11[istrip];
384 //----------------------------------------------------------------------
385 //--- end of methods which return member data related info
386 //----------------------------------------------------------------------
388 void AliMUONTriggerCircuit::dump(const char* what, const Float_t* array, Int_t size)
390 cout << what << " " << endl;
391 for ( Int_t i = 0; i < size; ++i )
393 cout << array[i] << " , ";
398 void AliMUONTriggerCircuit::dump(const char* what, const Int_t* array, Int_t size)
400 cout << what << " " << endl;
401 for ( Int_t i = 0; i < size; ++i )
403 cout << array[i] << " , ";
408 //_____________________________________________________________________________
409 void AliMUONTriggerCircuit::Print(Option_t* ) const
411 cout << "IdCircuit " << fILocalBoard << " X2m,X2ud=" << fX2m << ","
413 for ( Int_t i = 0; i < 2; ++i )
415 cout << " OrMud[" << i << "]=" << fOrMud[i];
418 dump("Xpos11",fXpos11,16);
419 dump("Ypos11",fYpos11,31);
420 dump("Ypos21",fYpos21,63);
421 for ( Int_t i = 0; i < 4; ++i )
424 sprintf(s,"Xcode[%d]",i);
425 dump(s,fXcode[i],32);
426 sprintf(s,"Ycode[%d]",i);
427 dump(s,fYcode[i],32);
429 // Int_t fILocalBoard; // circuit Id number
430 // Int_t fX2m; // internal info needed by TriggerDecision
431 // Int_t fX2ud; // internal info needed by TriggerDecision
432 // Int_t fOrMud[2]; // internal info needed by TriggerDecision
433 // Int_t fXcode[4][32]; // code of X strips
434 // Int_t fYcode[4][32]; // code of Y strips
435 // Float_t fXpos11[16]; // X position of Y strips in MC11
436 // Float_t fYpos11[31]; // Y position of X strips in MC11
437 // Float_t fYpos21[63]; // Y position of X strips in MC21
442 //----------------------------------------------------------------------
443 Int_t AliMUONTriggerCircuit::DetElemId(Int_t ichamber, char side, Int_t iline)
445 /// returns detection element Id for chamber iChamber, side side and line iline
447 if ( side == 'R' ) { // right side
448 switch (iline) // (from 1 to 9, from bottom to top)
478 } else if ( side == 'L' ) { // left side
479 switch (iline) // (from 1 to 9, from bottom to top)
510 return ((ichamber+1)*100)+itmp;
513 //----------------------------------------------------------------------
515 AliMUONTriggerCircuit::DetElemId(Int_t iChamber, const char* boardName)
517 /// returns detection element Id for chamber iChamber and board boardName
522 DecodeBoardName(boardName, side, iline, icol);
524 return DetElemId(iChamber,side,iline);
527 //----------------------------------------------------------------------
529 AliMUONTriggerCircuit::DecodeBoardName(const char* boardName,
534 /// get side, line and col from board boardName
535 /// note: icol = icol -1 for iline = 5 w.r.t other ilines
537 iLine = boardName[4] - '0';
538 iCol = boardName[2] - '0';
539 if ( iLine == 5 ) --iCol;
542 //----------------------------------------------------------------------
544 AliMUONTriggerCircuit::FirstStrip(const char* boardName)
546 /// returns the first strip from mapping for board boardName
547 /// take care of special case for boards RC1L6B12 & LC1L6B12
548 Int_t iFirstStrip = -1;
549 Int_t boardNumber = atoi(boardName+6);
552 DecodeBoardName(boardName,side,iline,icol);
568 if (icol == 1 && iline == 6) iFirstStrip = iFirstStrip + 16; // special case
572 //----------------------------------------------------------------------
573 void AliMUONTriggerCircuit::XYGlobal(
574 Int_t detElemId, const AliMpPad& pad,
575 Double_t xyGlobal[4])
577 /// returns pad x & y positions and x & y pad dimensions in global coordinates
578 /// note: no need for transformation for pad dimensions
580 // get the pad position and dimensions
581 Double_t xl1 = pad.Position().X();
582 Double_t yl1 = pad.Position().Y();
583 xyGlobal[2] = pad.Dimensions().X(); // half size!
584 xyGlobal[3] = pad.Dimensions().Y(); // half size!
587 // positions from local to global
588 fTransformer->Local2Global(detElemId, xl1, yl1, 0,
589 xyGlobal[0], xyGlobal[1], zg1);