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 "AliMUONGeometrySegmentation.h"
32 #include "AliMUONSegmentation.h"
33 #include "AliMUONConstants.h"
35 #include "AliMUONLocalTriggerBoard.h"
36 #include "AliMUONTriggerCrateStore.h"
37 #include "AliMUONTriggerCrate.h"
38 #include "AliMpTriggerSegmentation.h"
39 #include "AliMpTrigger.h"
40 #include "AliMpSlat.h"
42 #include "AliMpVSegmentation.h"
43 #include "AliMUONGeometryTransformer.h"
45 ClassImp(AliMUONTriggerCircuitNew)
47 //----------------------------------------------------------------------
48 AliMUONTriggerCircuitNew::AliMUONTriggerCircuitNew()
55 for (i=0; i<16; i++) { fXpos11[i]=0.; }
56 for (i=0; i<31; i++) { fYpos11[i]=0.; }
57 for (i=0; i<63; i++) { fYpos21[i]=0.; }
60 //----------------------------------------------------------------------
61 AliMUONTriggerCircuitNew::AliMUONTriggerCircuitNew(const AliMUONTriggerCircuitNew& theMUONTriggerCircuit)
62 : TObject(theMUONTriggerCircuit)
64 // Protected copy constructor
66 AliFatal("Not implemented.");
69 //----------------------------------------------------------------------
70 AliMUONTriggerCircuitNew &
71 AliMUONTriggerCircuitNew::operator=(const AliMUONTriggerCircuitNew& rhs)
73 // Protected assignement operator
75 if (this == &rhs) return *this;
77 AliFatal("Not implemented.");
82 //----------------------------------------------------------------------
83 void AliMUONTriggerCircuitNew::Init(Int_t iCircuit, const AliMUONTriggerCrateStore& crates)
85 // initialize circuit characteristics
86 fILocalBoard=iCircuit+1;//AliMUONTriggerConstants::CircuitId(iCircuit);
93 //---------------------------------------------------------------------
94 void AliMUONTriggerCircuitNew::LoadYPos(const AliMUONTriggerCrateStore& crates)
96 // fill fYpos11 and fYpos21 -> y position of X declusterized strips
98 const AliMUONLocalTriggerBoard* localBoard = crates.LocalBoard(fILocalBoard);
102 AliError(Form("Did not get localboard %d",fILocalBoard));
105 StdoutToAliDebug(1,localBoard->Print("CONF"););
110 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
111 const AliMpVSegmentation* seg;
112 const AliMUONGeometryTransformer* kGeomTransformer
113 = pMUON->GetGeometryTransformer();
115 Int_t zeroDown = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroDown);
116 Int_t zeroUp = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroUp);
123 DecodeBoardName(localBoard->GetName(),side,iline,icol);
125 Int_t detElemId = DetElemId(ichamber,side,iline);
126 seg = pMUON->GetSegmentation()->GetMpSegmentation(detElemId,icathode);
128 Int_t iFirstStrip = FirstStrip(localBoard->GetName());
129 Int_t iLastStrip = iFirstStrip + 16;
130 Int_t iStripCircuit = 0;
131 FillXstrips(kGeomTransformer,seg,detElemId,icol,
132 iFirstStrip,iLastStrip,iStripCircuit,fYpos11);
137 detElemId = DetElemId(ichamber,side,iline);
138 seg = pMUON->GetSegmentation()->GetMpSegmentation(detElemId,icathode);
140 // second plane middle part
141 Int_t iFirstStripMiddle = FirstStrip(localBoard->GetName());
142 Int_t iLastStripMiddle = iFirstStrip + 16;
144 FillXstrips(kGeomTransformer,seg,detElemId,icol,
145 iFirstStripMiddle,iLastStripMiddle,iStripCircuit,fYpos21);
147 // second plane upper part
148 if (zeroUp == 0) { // something up
152 // check if we need to move to another detElemId
153 AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,iLastStripMiddle+1),kFALSE);
154 if (pad.IsValid()) { // upper strips within same detElemId
155 iFirstStripUp = iLastStripMiddle;
156 iLastStripUp = iFirstStripUp + 8;
158 } else { // upper strips in another detElemId
159 detElemId = DetElemId(ichamber,side,iline+1); // get detElemId
160 seg = pMUON->GetSegmentation()->GetMpSegmentation(detElemId,icathode);
162 iLastStripUp = iFirstStripUp + 8;
163 if (iline == 4) icolUp = icol - 1; // special case
164 if (iline == 5) icolUp = icol + 1; // special case
168 FillXstrips(kGeomTransformer,seg,detElemId,icolUp,
169 iFirstStripUp,iLastStripUp,iStripCircuit,fYpos21);
171 // fill strip between middle and upper part
172 fYpos21[47]=(fYpos21[46]+fYpos21[48])/2.;
173 } // end of something up
175 // restore current detElemId & segmentation
176 detElemId = DetElemId(ichamber,side,iline);
177 seg = pMUON->GetSegmentation()->GetMpSegmentation(detElemId,icathode);
179 // second plane lower part
180 if (zeroDown == 0) { // something down
185 // check if we need to move to another detElemId
186 AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,iFirstStripMiddle-1),kFALSE);
187 if (pad.IsValid()) { // lower strips within same detElemId
188 iFirstStripDo = iFirstStripMiddle - 8;
189 iLastStripDo = iFirstStripDo + 8;
191 } else { // lower strips in another detElemId
192 detElemId = DetElemId(ichamber,side,iline-1); // get detElemId
193 seg = pMUON->GetSegmentation()->GetMpSegmentation(detElemId,icathode);
195 // get iFirstStrip in this module
196 const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(seg);
197 const AliMpTrigger* t = trig->Slat();
198 const AliMpSlat* slat = t->GetLayer(0);
199 if (iline == 5) icolDo = icol + 1; // special case
200 if (iline == 6) icolDo = icol - 1; // special case
201 const AliMpPCB* pcb = slat->GetPCB(icolDo-1);
202 iFirstStripDo = (pcb->Iymax() + 1) - 8;
203 iLastStripDo = iFirstStripDo + 8;
207 FillXstrips(kGeomTransformer,seg,detElemId,icolDo,
208 iFirstStripDo,iLastStripDo,iStripCircuit,fYpos21);
210 // fill strip between middle and upper part
211 fYpos21[15]=(fYpos21[14]+fYpos21[16])/2.;
212 } // end of something down
216 //----------------------------------------------------------------------
217 void AliMUONTriggerCircuitNew::LoadXPos(const AliMUONTriggerCrateStore& crates)
219 // fill fXpos11 -> x position of Y strips for the first plane only
220 // fXpos11 contains the x position of Y strip for the current circuit
221 // taking into account whether or nor not part(s) of the circuit
222 // (middle, up or down) has(have) 16 strips (handdled by means of switchs)
224 const AliMUONLocalTriggerBoard* localBoard = crates.LocalBoard(fILocalBoard);
228 AliError(Form("Did not get localboard %d",fILocalBoard));
231 StdoutToAliDebug(1,localBoard->Print("CONF"););
236 Int_t x2u = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2u);
237 Int_t x2m = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2m);
238 Int_t x2d = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2d);
239 Int_t zeroAllYLSB = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroAllYLSB);
240 Int_t iStripCircuit = 0;
241 Int_t iFirstStrip = 0;
242 Int_t iLastStrip = 0;
243 Bool_t doubling = kFALSE;
245 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
246 const AliMpVSegmentation* seg;
247 const AliMUONGeometryTransformer* kGeomTransformer
248 = pMUON->GetGeometryTransformer();
253 DecodeBoardName(localBoard->GetName(),side,iline,icol);
255 Int_t detElemId=DetElemId(ichamber,side,iline); // get detElemId
256 seg = pMUON->GetSegmentation()->GetMpSegmentation(detElemId,icathode);
258 // check if one needs a strip doubling or not
259 if ( (x2u == 1 || x2m == 1 || x2d == 1) && x2m == 1) doubling = kTRUE;
261 // check if one starts at strip = 0 or 8 (boards 26-29 and 143-146)
262 if (zeroAllYLSB == 1) iStripCircuit = 8;
264 // get iFirstStrip in this module
265 const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(seg);
266 const AliMpTrigger* t = trig->Slat();
267 const AliMpSlat* slat = t->GetLayer(0);
269 const AliMpPCB* pcb = slat->GetPCB(icol-1);
270 iFirstStrip = pcb->Ixmin();
272 if (doubling) iLastStrip = iFirstStrip + 8;
273 else iLastStrip = iFirstStrip + 16;
275 FillYstrips(kGeomTransformer,seg,detElemId,
276 iFirstStrip,iLastStrip,iStripCircuit,doubling);
279 //----------------------------------------------------------------------
280 void AliMUONTriggerCircuitNew::FillYstrips(
281 const AliMUONGeometryTransformer* kGeomTransformer,
282 const AliMpVSegmentation* seg,
283 const Int_t detElemId,
284 const Int_t iFirstStrip, const Int_t iLastStrip, Int_t liStripCircuit,
285 const Bool_t doubling)
288 Double_t xyGlobal[4]={0.,0.,0.,0.};
289 for (Int_t istrip=iFirstStrip; istrip<iLastStrip; istrip++) {
290 AliMpPad pad = seg->PadByIndices(AliMpIntPair(istrip,0),kTRUE);
291 if ( !pad.IsValid() )
293 StdoutToAliError(cout << "Pad not found in seg " << endl;
295 cout << " ix,iy=" << istrip << "," << 0 << endl;
298 XYGlobal(kGeomTransformer,detElemId,pad,xyGlobal);
301 fXpos11[liStripCircuit]=xyGlobal[0];
302 } else if (doubling) {
303 fXpos11[2*liStripCircuit]=TMath::Sign(1.,xyGlobal[0]) *
304 (TMath::Abs(xyGlobal[0]) - xyGlobal[2]/2.);
305 fXpos11[2*liStripCircuit+1]=TMath::Sign(1.,xyGlobal[0]) *
306 (TMath::Abs(fXpos11[2*liStripCircuit]) + xyGlobal[2]);
312 //----------------------------------------------------------------------
313 void AliMUONTriggerCircuitNew::FillXstrips(
314 const AliMUONGeometryTransformer* kGeomTransformer,
315 const AliMpVSegmentation* seg,
316 const Int_t detElemId, const Int_t icol,
317 const Int_t iFirstStrip, const Int_t iLastStrip,
318 Int_t liStripCircuit, Float_t *tab)
321 Double_t xyGlobal[4]={0.,0.,0.,0.};
322 for (Int_t istrip=iFirstStrip; istrip<iLastStrip; istrip++) {
323 AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,istrip),kTRUE);
324 if ( !pad.IsValid() )
326 StdoutToAliError(cout << "Pad not found in seg " << endl;
328 cout << " ix,iy=" << icol-1 << "," << istrip << endl;
332 XYGlobal(kGeomTransformer,detElemId,pad,xyGlobal);
334 tab[2*liStripCircuit]=xyGlobal[1];
335 if (istrip!=(iLastStrip-1)) tab[2*liStripCircuit+1]=xyGlobal[1]+xyGlobal[3];
340 //----------------------------------------------------------------------
341 //--- methods which return member data related info
342 //----------------------------------------------------------------------
343 Float_t AliMUONTriggerCircuitNew::GetY11Pos(Int_t istrip) const {
344 // returns Y position of X strip istrip in MC11
345 return fYpos11[istrip];
347 //----------------------------------------------------------------------
348 Float_t AliMUONTriggerCircuitNew::GetY21Pos(Int_t istrip) const {
349 // returns Y position of X strip istrip in MC21
350 return fYpos21[istrip];
352 //----------------------------------------------------------------------
353 Float_t AliMUONTriggerCircuitNew::GetX11Pos(Int_t istrip) const {
354 // returns X position of Y strip istrip in MC11
355 return fXpos11[istrip];
357 //----------------------------------------------------------------------
358 //--- end of methods which return member data related info
359 //----------------------------------------------------------------------
361 void AliMUONTriggerCircuitNew::dump(const char* what, const Float_t* array, Int_t size)
363 cout << what << " " << endl;
364 for ( Int_t i = 0; i < size; ++i )
366 cout << array[i] << " , ";
371 void AliMUONTriggerCircuitNew::dump(const char* what, const Int_t* array, Int_t size)
373 cout << what << " " << endl;
374 for ( Int_t i = 0; i < size; ++i )
376 cout << array[i] << " , ";
381 //_____________________________________________________________________________
382 void AliMUONTriggerCircuitNew::Print(Option_t* ) const
384 cout << "IdCircuit " << fILocalBoard << " X2m,X2ud=" << fX2m << ","
386 for ( Int_t i = 0; i < 2; ++i )
388 cout << " OrMud[" << i << "]=" << fOrMud[i];
391 dump("Xpos11",fXpos11,16);
392 dump("Ypos11",fYpos11,31);
393 dump("Ypos21",fYpos21,63);
394 for ( Int_t i = 0; i < 4; ++i )
397 sprintf(s,"Xcode[%d]",i);
398 dump(s,fXcode[i],32);
399 sprintf(s,"Ycode[%d]",i);
400 dump(s,fYcode[i],32);
402 // Int_t fILocalBoard; // circuit Id number
403 // Int_t fX2m; // internal info needed by TriggerDecision
404 // Int_t fX2ud; // internal info needed by TriggerDecision
405 // Int_t fOrMud[2]; // internal info needed by TriggerDecision
406 // Int_t fXcode[4][32]; // code of X strips
407 // Int_t fYcode[4][32]; // code of Y strips
408 // Float_t fXpos11[16]; // X position of Y strips in MC11
409 // Float_t fYpos11[31]; // Y position of X strips in MC11
410 // Float_t fYpos21[63]; // Y position of X strips in MC21
415 //----------------------------------------------------------------------
416 Int_t AliMUONTriggerCircuitNew::DetElemId(Int_t ichamber, char side, Int_t iline)
418 // returns detection element Id for chamber iChamber, side side and line iline
420 if ( side == 'R' ) { // right side
421 switch (iline) // (from 1 to 9, from bottom to top)
451 } else if ( side == 'L' ) { // left side
452 switch (iline) // (from 1 to 9, from bottom to top)
483 return (ichamber*100)+itmp;
486 //----------------------------------------------------------------------
488 AliMUONTriggerCircuitNew::DetElemId(Int_t iChamber, const char* boardName)
490 // returns detection element Id for chamber iChamber and board boardName
491 char side = boardName[5];
492 Int_t iline = boardName[4] - '0';
493 return DetElemId(iChamber,side,iline);
496 //----------------------------------------------------------------------
498 AliMUONTriggerCircuitNew::DecodeBoardName(const char* boardName,
503 // get side, line and col from board boardName
504 // note: icol = icol -1 for iline = 5 w.r.t other ilines
506 iLine = boardName[4] - '0';
507 iCol = boardName[2] - '0';
508 if ( iLine == 5 ) --iCol;
511 //----------------------------------------------------------------------
513 AliMUONTriggerCircuitNew::FirstStrip(const char* boardName)
515 // returns the first strip from mapping for board boardName
516 // take care of special case for boards RC1L6B12 & LC1L6B12
517 Int_t iFirstStrip = -1;
518 Int_t boardNumber = atoi(boardName+6);
521 DecodeBoardName(boardName,side,iline,icol);
537 if (icol == 1 && iline == 6) iFirstStrip = iFirstStrip + 16; // special case
541 //----------------------------------------------------------------------
542 void AliMUONTriggerCircuitNew::XYGlobal(
543 const AliMUONGeometryTransformer* kGeomTransformer,
544 Int_t detElemId, const AliMpPad& pad,
545 Double_t xyGlobal[4])
547 // returns pad x & y positions and x & y pad dimensions in global coordinates
548 // note: no need for transformation for pad dimensions
550 // get the pad position and dimensions
551 Double_t xl1 = pad.Position().X();
552 Double_t yl1 = pad.Position().Y();
553 xyGlobal[2] = pad.Dimensions().X(); // half size!
554 xyGlobal[3] = pad.Dimensions().Y(); // half size!
557 // positions from local to global
558 kGeomTransformer->Local2Global(detElemId, xl1, yl1, 0,
559 xyGlobal[0], xyGlobal[1], zg1);