]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTriggerCircuitNew.cxx
ReadRaw(): TGraphs are created once per event (B.Polichtchouk)
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerCircuitNew.cxx
CommitLineData
66d6c51b 1/**************************************************************************
2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
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**************************************************************************/
15
16/* $Id$ */
17
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)
25
26#include <TMath.h>
27#include "AliMUONTriggerCircuitNew.h"
28#include "AliRun.h"
29#include "AliMUON.h"
30#include "AliMUONTriggerConstants.h"
31#include "AliMUONGeometrySegmentation.h"
32#include "AliMUONSegmentation.h"
33#include "AliMUONConstants.h"
34#include "AliLog.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"
41#include "AliMpPCB.h"
42#include "AliMpVSegmentation.h"
43#include "AliMUONGeometryTransformer.h"
44
5398f946 45/// \cond CLASSIMP
66d6c51b 46ClassImp(AliMUONTriggerCircuitNew)
5398f946 47/// \endcond
66d6c51b 48
49//----------------------------------------------------------------------
50AliMUONTriggerCircuitNew::AliMUONTriggerCircuitNew()
51: TObject(),
52fILocalBoard(0)
53{
5398f946 54/// Constructor
66d6c51b 55
56 Int_t i;
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.; }
60}
61
62//----------------------------------------------------------------------
5398f946 63AliMUONTriggerCircuitNew::~AliMUONTriggerCircuitNew()
66d6c51b 64{
5398f946 65/// Destructor
66}
66d6c51b 67
68//----------------------------------------------------------------------
69void AliMUONTriggerCircuitNew::Init(Int_t iCircuit, const AliMUONTriggerCrateStore& crates)
70{
5398f946 71/// initialize circuit characteristics
66d6c51b 72 fILocalBoard=iCircuit+1;//AliMUONTriggerConstants::CircuitId(iCircuit);
73
74 LoadXPos(crates);
75 LoadYPos(crates);
76
77}
78
79//---------------------------------------------------------------------
80void AliMUONTriggerCircuitNew::LoadYPos(const AliMUONTriggerCrateStore& crates)
81{
5398f946 82/// fill fYpos11 and fYpos21 -> y position of X declusterized strips
66d6c51b 83
84 const AliMUONLocalTriggerBoard* localBoard = crates.LocalBoard(fILocalBoard);
85
86 if (!localBoard)
87 {
88 AliError(Form("Did not get localboard %d",fILocalBoard));
89 return;
90 }
91 StdoutToAliDebug(1,localBoard->Print("CONF"););
92
93 Int_t ichamber = 0;
94 Int_t icathode = 0;
95
96 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
97 const AliMpVSegmentation* seg;
98 const AliMUONGeometryTransformer* kGeomTransformer
99 = pMUON->GetGeometryTransformer();
100
101 Int_t zeroDown = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroDown);
102 Int_t zeroUp = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroUp);
103
104 //--- first plane
105 ichamber = 11;
106
107 char side;
108 Int_t iline, icol;
109 DecodeBoardName(localBoard->GetName(),side,iline,icol);
110
111 Int_t detElemId = DetElemId(ichamber,side,iline);
112 seg = pMUON->GetSegmentation()->GetMpSegmentation(detElemId,icathode);
113
114 Int_t iFirstStrip = FirstStrip(localBoard->GetName());
115 Int_t iLastStrip = iFirstStrip + 16;
116 Int_t iStripCircuit = 0;
117 FillXstrips(kGeomTransformer,seg,detElemId,icol,
118 iFirstStrip,iLastStrip,iStripCircuit,fYpos11);
119
120 //--- second plane
121 ichamber = 13;
122
123 detElemId = DetElemId(ichamber,side,iline);
124 seg = pMUON->GetSegmentation()->GetMpSegmentation(detElemId,icathode);
125
126 // second plane middle part
127 Int_t iFirstStripMiddle = FirstStrip(localBoard->GetName());
128 Int_t iLastStripMiddle = iFirstStrip + 16;
129 iStripCircuit=8;
130 FillXstrips(kGeomTransformer,seg,detElemId,icol,
131 iFirstStripMiddle,iLastStripMiddle,iStripCircuit,fYpos21);
132
133 // second plane upper part
134 if (zeroUp == 0) { // something up
135 Int_t iFirstStripUp;
136 Int_t iLastStripUp;
137 Int_t icolUp=icol;
138 // check if we need to move to another detElemId
139 AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,iLastStripMiddle+1),kFALSE);
140 if (pad.IsValid()) { // upper strips within same detElemId
141 iFirstStripUp = iLastStripMiddle;
142 iLastStripUp = iFirstStripUp + 8;
143 // icolUp = icol;
144 } else { // upper strips in another detElemId
145 detElemId = DetElemId(ichamber,side,iline+1); // get detElemId
146 seg = pMUON->GetSegmentation()->GetMpSegmentation(detElemId,icathode);
147 iFirstStripUp = 0;
148 iLastStripUp = iFirstStripUp + 8;
149 if (iline == 4) icolUp = icol - 1; // special case
150 if (iline == 5) icolUp = icol + 1; // special case
151 }
152
153 iStripCircuit=24;
154 FillXstrips(kGeomTransformer,seg,detElemId,icolUp,
155 iFirstStripUp,iLastStripUp,iStripCircuit,fYpos21);
156
157 // fill strip between middle and upper part
158 fYpos21[47]=(fYpos21[46]+fYpos21[48])/2.;
159 } // end of something up
160
161 // restore current detElemId & segmentation
162 detElemId = DetElemId(ichamber,side,iline);
163 seg = pMUON->GetSegmentation()->GetMpSegmentation(detElemId,icathode);
164
165 // second plane lower part
166 if (zeroDown == 0) { // something down
167 Int_t iFirstStripDo;
168 Int_t iLastStripDo;
169 Int_t icolDo=icol;
170
171 // check if we need to move to another detElemId
172 AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,iFirstStripMiddle-1),kFALSE);
173 if (pad.IsValid()) { // lower strips within same detElemId
174 iFirstStripDo = iFirstStripMiddle - 8;
175 iLastStripDo = iFirstStripDo + 8;
176 // icolDo = icol;
177 } else { // lower strips in another detElemId
178 detElemId = DetElemId(ichamber,side,iline-1); // get detElemId
179 seg = pMUON->GetSegmentation()->GetMpSegmentation(detElemId,icathode);
180
181 // get iFirstStrip in this module
182 const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(seg);
183 const AliMpTrigger* t = trig->Slat();
184 const AliMpSlat* slat = t->GetLayer(0);
185 if (iline == 5) icolDo = icol + 1; // special case
186 if (iline == 6) icolDo = icol - 1; // special case
187 const AliMpPCB* pcb = slat->GetPCB(icolDo-1);
188 iFirstStripDo = (pcb->Iymax() + 1) - 8;
189 iLastStripDo = iFirstStripDo + 8;
190 }
191
192 iStripCircuit=0;
193 FillXstrips(kGeomTransformer,seg,detElemId,icolDo,
194 iFirstStripDo,iLastStripDo,iStripCircuit,fYpos21);
195
196 // fill strip between middle and upper part
197 fYpos21[15]=(fYpos21[14]+fYpos21[16])/2.;
198 } // end of something down
199
200}
201
202//----------------------------------------------------------------------
203void AliMUONTriggerCircuitNew::LoadXPos(const AliMUONTriggerCrateStore& crates)
204{
5398f946 205/// fill fXpos11 -> x position of Y strips for the first plane only
206/// fXpos11 contains the x position of Y strip for the current circuit
207/// taking into account whether or nor not part(s) of the circuit
208/// (middle, up or down) has(have) 16 strips (handdled by means of switchs)
66d6c51b 209
210 const AliMUONLocalTriggerBoard* localBoard = crates.LocalBoard(fILocalBoard);
211
212 if (!localBoard)
213 {
214 AliError(Form("Did not get localboard %d",fILocalBoard));
215 return;
216 }
217 StdoutToAliDebug(1,localBoard->Print("CONF"););
218
219 Int_t ichamber = 11;
220 Int_t icathode = 1;
221
222 Int_t x2u = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2u);
223 Int_t x2m = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2m);
224 Int_t x2d = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2d);
225 Int_t zeroAllYLSB = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroAllYLSB);
226 Int_t iStripCircuit = 0;
227 Int_t iFirstStrip = 0;
228 Int_t iLastStrip = 0;
229 Bool_t doubling = kFALSE;
230
231 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
232 const AliMpVSegmentation* seg;
233 const AliMUONGeometryTransformer* kGeomTransformer
234 = pMUON->GetGeometryTransformer();
235
236 char side;
237 Int_t iline, icol;
238
239 DecodeBoardName(localBoard->GetName(),side,iline,icol);
240
241 Int_t detElemId=DetElemId(ichamber,side,iline); // get detElemId
242 seg = pMUON->GetSegmentation()->GetMpSegmentation(detElemId,icathode);
243
244 // check if one needs a strip doubling or not
245 if ( (x2u == 1 || x2m == 1 || x2d == 1) && x2m == 1) doubling = kTRUE;
246
247 // check if one starts at strip = 0 or 8 (boards 26-29 and 143-146)
248 if (zeroAllYLSB == 1) iStripCircuit = 8;
249
250 // get iFirstStrip in this module
251 const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(seg);
252 const AliMpTrigger* t = trig->Slat();
253 const AliMpSlat* slat = t->GetLayer(0);
254
255 const AliMpPCB* pcb = slat->GetPCB(icol-1);
256 iFirstStrip = pcb->Ixmin();
257
258 if (doubling) iLastStrip = iFirstStrip + 8;
259 else iLastStrip = iFirstStrip + 16;
260
261 FillYstrips(kGeomTransformer,seg,detElemId,
262 iFirstStrip,iLastStrip,iStripCircuit,doubling);
263}
264
265//----------------------------------------------------------------------
266void AliMUONTriggerCircuitNew::FillYstrips(
267 const AliMUONGeometryTransformer* kGeomTransformer,
268 const AliMpVSegmentation* seg,
269 const Int_t detElemId,
270 const Int_t iFirstStrip, const Int_t iLastStrip, Int_t liStripCircuit,
271 const Bool_t doubling)
272{
5398f946 273/// fill
66d6c51b 274 Double_t xyGlobal[4]={0.,0.,0.,0.};
275 for (Int_t istrip=iFirstStrip; istrip<iLastStrip; istrip++) {
276 AliMpPad pad = seg->PadByIndices(AliMpIntPair(istrip,0),kTRUE);
277 if ( !pad.IsValid() )
278 {
279 StdoutToAliError(cout << "Pad not found in seg " << endl;
280 seg->Print();
281 cout << " ix,iy=" << istrip << "," << 0 << endl;
282 );
283 }
284 XYGlobal(kGeomTransformer,detElemId,pad,xyGlobal);
285
286 if (!doubling) {
287 fXpos11[liStripCircuit]=xyGlobal[0];
288 } else if (doubling) {
289 fXpos11[2*liStripCircuit]=TMath::Sign(1.,xyGlobal[0]) *
290 (TMath::Abs(xyGlobal[0]) - xyGlobal[2]/2.);
291 fXpos11[2*liStripCircuit+1]=TMath::Sign(1.,xyGlobal[0]) *
292 (TMath::Abs(fXpos11[2*liStripCircuit]) + xyGlobal[2]);
293 }
294 liStripCircuit++;
295 }
296}
297
298//----------------------------------------------------------------------
299void AliMUONTriggerCircuitNew::FillXstrips(
300 const AliMUONGeometryTransformer* kGeomTransformer,
301 const AliMpVSegmentation* seg,
302 const Int_t detElemId, const Int_t icol,
303 const Int_t iFirstStrip, const Int_t iLastStrip,
304 Int_t liStripCircuit, Float_t *tab)
305{
5398f946 306/// fill
66d6c51b 307 Double_t xyGlobal[4]={0.,0.,0.,0.};
308 for (Int_t istrip=iFirstStrip; istrip<iLastStrip; istrip++) {
309 AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,istrip),kTRUE);
310 if ( !pad.IsValid() )
311 {
312 StdoutToAliError(cout << "Pad not found in seg " << endl;
313 seg->Print();
314 cout << " ix,iy=" << icol-1 << "," << istrip << endl;
315 );
316 }
317
318 XYGlobal(kGeomTransformer,detElemId,pad,xyGlobal);
319
320 tab[2*liStripCircuit]=xyGlobal[1];
321 if (istrip!=(iLastStrip-1)) tab[2*liStripCircuit+1]=xyGlobal[1]+xyGlobal[3];
322 liStripCircuit++;
323 }
324}
325
326//----------------------------------------------------------------------
327//--- methods which return member data related info
328//----------------------------------------------------------------------
329Float_t AliMUONTriggerCircuitNew::GetY11Pos(Int_t istrip) const {
5398f946 330/// returns Y position of X strip istrip in MC11
66d6c51b 331 return fYpos11[istrip];
332}
333//----------------------------------------------------------------------
334Float_t AliMUONTriggerCircuitNew::GetY21Pos(Int_t istrip) const {
5398f946 335/// returns Y position of X strip istrip in MC21
66d6c51b 336 return fYpos21[istrip];
337}
338//----------------------------------------------------------------------
339Float_t AliMUONTriggerCircuitNew::GetX11Pos(Int_t istrip) const {
5398f946 340/// returns X position of Y strip istrip in MC11
66d6c51b 341 return fXpos11[istrip];
342}
343//----------------------------------------------------------------------
344//--- end of methods which return member data related info
345//----------------------------------------------------------------------
346/* removed tmp
347void AliMUONTriggerCircuitNew::dump(const char* what, const Float_t* array, Int_t size)
348{
349 cout << what << " " << endl;
350 for ( Int_t i = 0; i < size; ++i )
351 {
352 cout << array[i] << " , ";
353 }
354 cout << endl;
355}
356
357void AliMUONTriggerCircuitNew::dump(const char* what, const Int_t* array, Int_t size)
358{
359 cout << what << " " << endl;
360 for ( Int_t i = 0; i < size; ++i )
361 {
362 cout << array[i] << " , ";
363 }
364 cout << endl;
365}
366
367//_____________________________________________________________________________
368void AliMUONTriggerCircuitNew::Print(Option_t* ) const
369{
370 cout << "IdCircuit " << fILocalBoard << " X2m,X2ud=" << fX2m << ","
371 << fX2ud;
372 for ( Int_t i = 0; i < 2; ++i )
373 {
374 cout << " OrMud[" << i << "]=" << fOrMud[i];
375 }
376 cout << endl;
377 dump("Xpos11",fXpos11,16);
378 dump("Ypos11",fYpos11,31);
379 dump("Ypos21",fYpos21,63);
380 for ( Int_t i = 0; i < 4; ++i )
381 {
382 char s[80];
383 sprintf(s,"Xcode[%d]",i);
384 dump(s,fXcode[i],32);
385 sprintf(s,"Ycode[%d]",i);
386 dump(s,fYcode[i],32);
387 }
388 // Int_t fILocalBoard; // circuit Id number
389 // Int_t fX2m; // internal info needed by TriggerDecision
390 // Int_t fX2ud; // internal info needed by TriggerDecision
391 // Int_t fOrMud[2]; // internal info needed by TriggerDecision
392 // Int_t fXcode[4][32]; // code of X strips
393 // Int_t fYcode[4][32]; // code of Y strips
394 // Float_t fXpos11[16]; // X position of Y strips in MC11
395 // Float_t fYpos11[31]; // Y position of X strips in MC11
396 // Float_t fYpos21[63]; // Y position of X strips in MC21
397
398}
399removed tmp*/
400
401//----------------------------------------------------------------------
402Int_t AliMUONTriggerCircuitNew::DetElemId(Int_t ichamber, char side, Int_t iline)
403{
5398f946 404/// returns detection element Id for chamber iChamber, side side and line iline
66d6c51b 405 Int_t itmp=0;
406 if ( side == 'R' ) { // right side
407 switch (iline) // (from 1 to 9, from bottom to top)
408 {
409 case 1:
410 itmp = 14;
411 break;
412 case 2:
413 itmp = 15;
414 break;
415 case 3:
416 itmp = 16;
417 break;
418 case 4:
419 itmp = 17;
420 break;
421 case 5:
422 itmp = 0;
423 break;
424 case 6:
425 itmp = 1;
426 break;
427 case 7:
428 itmp = 2;
429 break;
430 case 8:
431 itmp = 3;
432 break;
433 case 9:
434 itmp = 4;
435 break;
436 }
437 } else if ( side == 'L' ) { // left side
438 switch (iline) // (from 1 to 9, from bottom to top)
439 {
440 case 1:
441 itmp = 13;
442 break;
443 case 2:
444 itmp = 12;
445 break;
446 case 3:
447 itmp = 11;
448 break;
449 case 4:
450 itmp = 10;
451 break;
452 case 5:
453 itmp = 9;
454 break;
455 case 6:
456 itmp = 8;
457 break;
458 case 7:
459 itmp = 7;
460 break;
461 case 8:
462 itmp = 6;
463 break;
464 case 9:
465 itmp = 5;
466 break;
467 }
468 }
469 return (ichamber*100)+itmp;
470}
471
472//----------------------------------------------------------------------
473Int_t
474AliMUONTriggerCircuitNew::DetElemId(Int_t iChamber, const char* boardName)
475{
5398f946 476/// returns detection element Id for chamber iChamber and board boardName
66d6c51b 477 char side = boardName[5];
478 Int_t iline = boardName[4] - '0';
479 return DetElemId(iChamber,side,iline);
480}
481
482//----------------------------------------------------------------------
483void
484AliMUONTriggerCircuitNew::DecodeBoardName(const char* boardName,
485 char& side,
486 Int_t& iLine,
487 Int_t& iCol)
488{
5398f946 489/// get side, line and col from board boardName
490/// note: icol = icol -1 for iline = 5 w.r.t other ilines
66d6c51b 491 side = boardName[0];
492 iLine = boardName[4] - '0';
493 iCol = boardName[2] - '0';
494 if ( iLine == 5 ) --iCol;
495}
496
497//----------------------------------------------------------------------
498Int_t
499AliMUONTriggerCircuitNew::FirstStrip(const char* boardName)
500{
5398f946 501/// returns the first strip from mapping for board boardName
502/// take care of special case for boards RC1L6B12 & LC1L6B12
66d6c51b 503 Int_t iFirstStrip = -1;
504 Int_t boardNumber = atoi(boardName+6);
505 char side;
506 Int_t iline, icol;
507 DecodeBoardName(boardName,side,iline,icol);
508 switch (boardNumber)
509 {
510 case 12:
511 iFirstStrip = 0;
512 break;
513 case 34:
514 iFirstStrip = 16;
515 break;
516 case 56:
517 iFirstStrip = 32;
518 break;
519 case 78:
520 iFirstStrip = 48;
521 break;
522 }
523 if (icol == 1 && iline == 6) iFirstStrip = iFirstStrip + 16; // special case
524 return iFirstStrip;
525}
526
527//----------------------------------------------------------------------
528void AliMUONTriggerCircuitNew::XYGlobal(
529 const AliMUONGeometryTransformer* kGeomTransformer,
530 Int_t detElemId, const AliMpPad& pad,
531 Double_t xyGlobal[4])
532{
5398f946 533/// returns pad x & y positions and x & y pad dimensions in global coordinates
534/// note: no need for transformation for pad dimensions
66d6c51b 535
536 // get the pad position and dimensions
537 Double_t xl1 = pad.Position().X();
538 Double_t yl1 = pad.Position().Y();
539 xyGlobal[2] = pad.Dimensions().X(); // half size!
540 xyGlobal[3] = pad.Dimensions().Y(); // half size!
541 Double_t zg1=0;
542
543 // positions from local to global
544 kGeomTransformer->Local2Global(detElemId, xl1, yl1, 0,
545 xyGlobal[0], xyGlobal[1], zg1);
546}