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 // --------------------
19 // Class AliMUONTriggerCircuitNew
20 // --------------------
21 // Contains as data members the Y positions of the X declusturized strips and
22 // the X positions of the (doubled or not) Y strips.
23 // This is used to associate the global positions to the fired strips of the
24 // local trigger output (see AliMUONTrackReconstructor::MakeTriggerTrack)
27 #include "AliMUONTriggerCircuitNew.h"
30 #include "AliMUONTriggerConstants.h"
31 #include "AliMUONConstants.h"
33 #include "AliMUONLocalTriggerBoard.h"
34 #include "AliMUONTriggerCrateStore.h"
35 #include "AliMUONTriggerCrate.h"
36 #include "AliMpTriggerSegmentation.h"
37 #include "AliMpTrigger.h"
38 #include "AliMpSlat.h"
40 #include "AliMpVSegmentation.h"
41 #include "AliMUONGeometryTransformer.h"
42 #include "AliMpSegFactory.h"
45 ClassImp(AliMUONTriggerCircuitNew)
48 //----------------------------------------------------------------------
49 AliMUONTriggerCircuitNew::AliMUONTriggerCircuitNew()
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 AliMUONTriggerCircuitNew::~AliMUONTriggerCircuitNew()
69 //----------------------------------------------------------------------
70 AliMUONTriggerCircuitNew::AliMUONTriggerCircuitNew(const AliMUONTriggerCircuitNew& circuit)
72 fILocalBoard(circuit.fILocalBoard)
74 for (Int_t i = 0; i < 16; ++i)
75 fXpos11[i] = circuit.fXpos11[i];
77 for (Int_t i = 0; i < 31; ++i)
78 fYpos11[i] = circuit.fYpos11[i];
80 for (Int_t i = 0; i < 63; ++i)
81 fYpos21[i] = circuit.fYpos21[i];
84 //----------------------------------------------------------------------
85 AliMUONTriggerCircuitNew& AliMUONTriggerCircuitNew::operator=(const AliMUONTriggerCircuitNew& circuit)
87 if (this == &circuit) return *this;
89 fILocalBoard = circuit.fILocalBoard;
91 for (Int_t i = 0; i < 16; ++i)
92 fXpos11[i] = circuit.fXpos11[i];
94 for (Int_t i = 0; i < 31; ++i)
95 fYpos11[i] = circuit.fYpos11[i];
97 for (Int_t i = 0; i < 63; ++i)
98 fYpos21[i] = circuit.fYpos21[i];
103 //----------------------------------------------------------------------
104 void AliMUONTriggerCircuitNew::Init(Int_t iCircuit, const AliMUONTriggerCrateStore& crates)
106 /// initialize circuit characteristics
107 fILocalBoard=iCircuit+1;//AliMUONTriggerConstants::CircuitId(iCircuit);
114 //---------------------------------------------------------------------
115 void AliMUONTriggerCircuitNew::LoadYPos(const AliMUONTriggerCrateStore& crates)
117 /// fill fYpos11 and fYpos21 -> y position of X declusterized strips
119 const AliMUONLocalTriggerBoard* localBoard = crates.LocalBoard(fILocalBoard);
123 AliError(Form("Did not get localboard %d",fILocalBoard));
126 StdoutToAliDebug(1,localBoard->Print("CONF"););
131 const AliMpVSegmentation* seg;
133 Int_t zeroDown = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroDown);
134 Int_t zeroUp = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroUp);
141 DecodeBoardName(localBoard->GetName(),side,iline,icol);
143 Int_t detElemId = DetElemId(ichamber,side,iline);
144 seg = fSegFactory->CreateMpSegmentation(detElemId, icathode);
146 Int_t iFirstStrip = FirstStrip(localBoard->GetName());
147 Int_t iLastStrip = iFirstStrip + 16;
148 Int_t iStripCircuit = 0;
149 FillXstrips(seg,detElemId,icol,
150 iFirstStrip,iLastStrip,iStripCircuit,fYpos11);
155 detElemId = DetElemId(ichamber,side,iline);
156 seg = fSegFactory->CreateMpSegmentation(detElemId, icathode);
158 // second plane middle part
159 Int_t iFirstStripMiddle = FirstStrip(localBoard->GetName());
160 Int_t iLastStripMiddle = iFirstStrip + 16;
162 FillXstrips(seg,detElemId,icol,
163 iFirstStripMiddle,iLastStripMiddle,iStripCircuit,fYpos21);
165 // second plane upper part
166 if (zeroUp == 0) { // something up
170 // check if we need to move to another detElemId
171 AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,iLastStripMiddle+1),kFALSE);
172 if (pad.IsValid()) { // upper strips within same detElemId
173 iFirstStripUp = iLastStripMiddle;
174 iLastStripUp = iFirstStripUp + 8;
176 } else { // upper strips in another detElemId
177 detElemId = DetElemId(ichamber,side,iline+1); // get detElemId
178 seg = fSegFactory->CreateMpSegmentation(detElemId, icathode);
181 iLastStripUp = iFirstStripUp + 8;
182 if (iline == 4) icolUp = icol - 1; // special case
183 if (iline == 5) icolUp = icol + 1; // special case
187 FillXstrips(seg,detElemId,icolUp,
188 iFirstStripUp,iLastStripUp,iStripCircuit,fYpos21);
190 // fill strip between middle and upper part
191 fYpos21[47]=(fYpos21[46]+fYpos21[48])/2.;
192 } // end of something up
194 // restore current detElemId & segmentation
195 detElemId = DetElemId(ichamber,side,iline);
196 seg = fSegFactory->CreateMpSegmentation(detElemId, icathode);
198 // second plane lower part
199 if (zeroDown == 0) { // something down
204 // check if we need to move to another detElemId
205 AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,iFirstStripMiddle-1),kFALSE);
206 if (pad.IsValid()) { // lower strips within same detElemId
207 iFirstStripDo = iFirstStripMiddle - 8;
208 iLastStripDo = iFirstStripDo + 8;
210 } else { // lower strips in another detElemId
211 detElemId = DetElemId(ichamber,side,iline-1); // get detElemId
212 seg = fSegFactory->CreateMpSegmentation(detElemId, icathode);
214 // get iFirstStrip in this module
215 const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(seg);
216 const AliMpTrigger* t = trig->Slat();
217 const AliMpSlat* slat = t->GetLayer(0);
218 if (iline == 5) icolDo = icol + 1; // special case
219 if (iline == 6) icolDo = icol - 1; // special case
220 const AliMpPCB* pcb = slat->GetPCB(icolDo-1);
221 iFirstStripDo = (pcb->Iymax() + 1) - 8;
222 iLastStripDo = iFirstStripDo + 8;
226 FillXstrips(seg,detElemId,icolDo,
227 iFirstStripDo,iLastStripDo,iStripCircuit,fYpos21);
229 // fill strip between middle and upper part
230 fYpos21[15]=(fYpos21[14]+fYpos21[16])/2.;
231 } // end of something down
235 //----------------------------------------------------------------------
236 void AliMUONTriggerCircuitNew::LoadXPos(const AliMUONTriggerCrateStore& crates)
238 /// fill fXpos11 -> x position of Y strips for the first plane only
239 /// fXpos11 contains the x position of Y strip for the current circuit
240 /// taking into account whether or nor not part(s) of the circuit
241 /// (middle, up or down) has(have) 16 strips (handdled by means of switchs)
243 const AliMUONLocalTriggerBoard* localBoard = crates.LocalBoard(fILocalBoard);
247 AliError(Form("Did not get localboard %d",fILocalBoard));
250 StdoutToAliDebug(1,localBoard->Print("CONF"););
255 Int_t x2u = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2u);
256 Int_t x2m = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2m);
257 Int_t x2d = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2d);
258 Int_t zeroAllYLSB = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroAllYLSB);
259 Int_t iStripCircuit = 0;
260 Int_t iFirstStrip = 0;
261 Int_t iLastStrip = 0;
262 Bool_t doubling = kFALSE;
264 const AliMpVSegmentation* seg;
269 DecodeBoardName(localBoard->GetName(),side,iline,icol);
271 Int_t detElemId=DetElemId(ichamber,side,iline); // get detElemId
272 seg = fSegFactory->CreateMpSegmentation(detElemId, icathode);
274 // check if one needs a strip doubling or not
275 if ( (x2u == 1 || x2m == 1 || x2d == 1) && x2m == 1) doubling = kTRUE;
277 // check if one starts at strip = 0 or 8 (boards 26-29 and 143-146)
278 if (zeroAllYLSB == 1) iStripCircuit = 8;
280 // get iFirstStrip in this module
281 const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(seg);
282 const AliMpTrigger* t = trig->Slat();
283 const AliMpSlat* slat = t->GetLayer(0);
285 const AliMpPCB* pcb = slat->GetPCB(icol-1);
286 iFirstStrip = pcb->Ixmin();
288 if (doubling) iLastStrip = iFirstStrip + 8;
289 else iLastStrip = iFirstStrip + 16;
291 FillYstrips(seg,detElemId,
292 iFirstStrip,iLastStrip,iStripCircuit,doubling);
295 //----------------------------------------------------------------------
296 void AliMUONTriggerCircuitNew::FillYstrips(
297 const AliMpVSegmentation* seg,
298 const Int_t detElemId,
299 const Int_t iFirstStrip, const Int_t iLastStrip, Int_t liStripCircuit,
300 const Bool_t doubling)
303 Double_t xyGlobal[4]={0.,0.,0.,0.};
304 for (Int_t istrip=iFirstStrip; istrip<iLastStrip; istrip++) {
305 AliMpPad pad = seg->PadByIndices(AliMpIntPair(istrip,0),kTRUE);
306 if ( !pad.IsValid() )
308 StdoutToAliError(cout << "Pad not found in seg " << endl;
310 cout << " ix,iy=" << istrip << "," << 0 << endl;
313 XYGlobal(detElemId,pad,xyGlobal);
316 fXpos11[liStripCircuit]=xyGlobal[0];
317 } else if (doubling) {
318 fXpos11[2*liStripCircuit]=TMath::Sign(1.,xyGlobal[0]) *
319 (TMath::Abs(xyGlobal[0]) - xyGlobal[2]/2.);
320 fXpos11[2*liStripCircuit+1]=TMath::Sign(1.,xyGlobal[0]) *
321 (TMath::Abs(fXpos11[2*liStripCircuit]) + xyGlobal[2]);
327 //----------------------------------------------------------------------
328 void AliMUONTriggerCircuitNew::FillXstrips(
329 const AliMpVSegmentation* seg,
330 const Int_t detElemId, const Int_t icol,
331 const Int_t iFirstStrip, const Int_t iLastStrip,
332 Int_t liStripCircuit, Float_t *tab)
335 Double_t xyGlobal[4]={0.,0.,0.,0.};
336 for (Int_t istrip=iFirstStrip; istrip<iLastStrip; istrip++) {
337 AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,istrip),kTRUE);
338 if ( !pad.IsValid() )
340 StdoutToAliError(cout << "Pad not found in seg " << endl;
342 cout << " ix,iy=" << icol-1 << "," << istrip << endl;
346 XYGlobal(detElemId,pad,xyGlobal);
348 tab[2*liStripCircuit]=xyGlobal[1];
349 if (istrip!=(iLastStrip-1)) tab[2*liStripCircuit+1]=xyGlobal[1]+xyGlobal[3];
354 //----------------------------------------------------------------------
355 //--- methods which return member data related info
356 //----------------------------------------------------------------------
357 Float_t AliMUONTriggerCircuitNew::GetY11Pos(Int_t istrip) const {
358 /// returns Y position of X strip istrip in MC11
359 return fYpos11[istrip];
361 //----------------------------------------------------------------------
362 Float_t AliMUONTriggerCircuitNew::GetY21Pos(Int_t istrip) const {
363 /// returns Y position of X strip istrip in MC21
364 return fYpos21[istrip];
366 //----------------------------------------------------------------------
367 Float_t AliMUONTriggerCircuitNew::GetX11Pos(Int_t istrip) const {
368 /// returns X position of Y strip istrip in MC11
369 return fXpos11[istrip];
371 //----------------------------------------------------------------------
372 //--- end of methods which return member data related info
373 //----------------------------------------------------------------------
375 void AliMUONTriggerCircuitNew::dump(const char* what, const Float_t* array, Int_t size)
377 cout << what << " " << endl;
378 for ( Int_t i = 0; i < size; ++i )
380 cout << array[i] << " , ";
385 void AliMUONTriggerCircuitNew::dump(const char* what, const Int_t* array, Int_t size)
387 cout << what << " " << endl;
388 for ( Int_t i = 0; i < size; ++i )
390 cout << array[i] << " , ";
395 //_____________________________________________________________________________
396 void AliMUONTriggerCircuitNew::Print(Option_t* ) const
398 cout << "IdCircuit " << fILocalBoard << " X2m,X2ud=" << fX2m << ","
400 for ( Int_t i = 0; i < 2; ++i )
402 cout << " OrMud[" << i << "]=" << fOrMud[i];
405 dump("Xpos11",fXpos11,16);
406 dump("Ypos11",fYpos11,31);
407 dump("Ypos21",fYpos21,63);
408 for ( Int_t i = 0; i < 4; ++i )
411 sprintf(s,"Xcode[%d]",i);
412 dump(s,fXcode[i],32);
413 sprintf(s,"Ycode[%d]",i);
414 dump(s,fYcode[i],32);
416 // Int_t fILocalBoard; // circuit Id number
417 // Int_t fX2m; // internal info needed by TriggerDecision
418 // Int_t fX2ud; // internal info needed by TriggerDecision
419 // Int_t fOrMud[2]; // internal info needed by TriggerDecision
420 // Int_t fXcode[4][32]; // code of X strips
421 // Int_t fYcode[4][32]; // code of Y strips
422 // Float_t fXpos11[16]; // X position of Y strips in MC11
423 // Float_t fYpos11[31]; // Y position of X strips in MC11
424 // Float_t fYpos21[63]; // Y position of X strips in MC21
429 //----------------------------------------------------------------------
430 Int_t AliMUONTriggerCircuitNew::DetElemId(Int_t ichamber, char side, Int_t iline)
432 /// returns detection element Id for chamber iChamber, side side and line iline
434 if ( side == 'R' ) { // right side
435 switch (iline) // (from 1 to 9, from bottom to top)
465 } else if ( side == 'L' ) { // left side
466 switch (iline) // (from 1 to 9, from bottom to top)
497 return ((ichamber+1)*100)+itmp;
500 //----------------------------------------------------------------------
502 AliMUONTriggerCircuitNew::DetElemId(Int_t iChamber, const char* boardName)
504 /// returns detection element Id for chamber iChamber and board boardName
509 DecodeBoardName(boardName, side, iline, icol);
511 return DetElemId(iChamber,side,iline);
514 //----------------------------------------------------------------------
516 AliMUONTriggerCircuitNew::DecodeBoardName(const char* boardName,
521 /// get side, line and col from board boardName
522 /// note: icol = icol -1 for iline = 5 w.r.t other ilines
524 iLine = boardName[4] - '0';
525 iCol = boardName[2] - '0';
526 if ( iLine == 5 ) --iCol;
529 //----------------------------------------------------------------------
531 AliMUONTriggerCircuitNew::FirstStrip(const char* boardName)
533 /// returns the first strip from mapping for board boardName
534 /// take care of special case for boards RC1L6B12 & LC1L6B12
535 Int_t iFirstStrip = -1;
536 Int_t boardNumber = atoi(boardName+6);
539 DecodeBoardName(boardName,side,iline,icol);
555 if (icol == 1 && iline == 6) iFirstStrip = iFirstStrip + 16; // special case
559 //----------------------------------------------------------------------
560 void AliMUONTriggerCircuitNew::XYGlobal(
561 Int_t detElemId, const AliMpPad& pad,
562 Double_t xyGlobal[4])
564 /// returns pad x & y positions and x & y pad dimensions in global coordinates
565 /// note: no need for transformation for pad dimensions
567 // get the pad position and dimensions
568 Double_t xl1 = pad.Position().X();
569 Double_t yl1 = pad.Position().Y();
570 xyGlobal[2] = pad.Dimensions().X(); // half size!
571 xyGlobal[3] = pad.Dimensions().Y(); // half size!
574 // positions from local to global
575 fTransformer->Local2Global(detElemId, xl1, yl1, 0,
576 xyGlobal[0], xyGlobal[1], zg1);