]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONTriggerCircuit.cxx
correction of trivial typo preventing compilation
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerCircuit.cxx
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 AliMUONTriggerCircuit
20 /// Contains as data members the Y positions of the X declusturized strips and 
21 /// the X positions of the (doubled or not) Y strips.
22 /// This is used to associate the global positions to the fired strips of the 
23 /// local trigger output (see AliMUONTrackReconstructor::MakeTriggerTrack)
24 ///
25 /// \author Philippe Crochet (LPCCFd)
26 //-----------------------------------------------------------------------------
27
28 #include "AliMUONTriggerCircuit.h"
29 #include "AliMUONConstants.h"
30
31 #include "AliMpTriggerSegmentation.h"
32 #include "AliMpTrigger.h"
33 #include "AliMpSlat.h"
34 #include "AliMpPCB.h"
35 #include "AliMpSegmentation.h"
36 #include "AliMpVSegmentation.h"
37 #include "AliMpCathodType.h"
38 #include "AliMpDDLStore.h"
39 #include "AliMpLocalBoard.h"
40 #include "AliMpConstants.h"
41
42 #include "AliRun.h"
43 #include "AliLog.h"
44
45 #include <TMath.h>
46 #include <Riostream.h>
47
48 /// \cond CLASSIMP
49 ClassImp(AliMUONTriggerCircuit)
50 /// \endcond
51
52 //----------------------------------------------------------------------
53 AliMUONTriggerCircuit::AliMUONTriggerCircuit(const AliMUONGeometryTransformer* transformer)
54     : TObject(),
55       fTransformer(transformer),
56       fCurrentSeg(0x0),
57       fCurrentDetElem(0x0),
58       fCurrentLocalBoard(0x0)
59 {
60 /// Constructor
61   
62     for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
63       fXpos11[i].Set(16); 
64       fYpos11[i].Set(31);
65       fYpos21[i].Set(63);
66     }
67
68     for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) { // board begins at 1
69   
70     AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(i);
71
72     if (!localBoard)
73     {
74       AliError(Form("Did not get localboard %d",i));
75       continue;
76     }
77
78     LoadXPos(localBoard);
79     LoadYPos(localBoard);
80
81   }
82
83 }
84
85 //----------------------------------------------------------------------
86 AliMUONTriggerCircuit::~AliMUONTriggerCircuit()
87 {
88 /// Destructor
89    for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
90      fXpos11[i].Reset();
91      fYpos11[i].Reset();
92      fYpos21[i].Reset();
93     }
94
95
96
97 //----------------------------------------------------------------------
98 AliMUONTriggerCircuit::AliMUONTriggerCircuit(const AliMUONTriggerCircuit& circuit)
99     :  TObject(circuit),
100        fTransformer(circuit.fTransformer), // do not copy, just pointed to
101        fCurrentSeg(circuit.fCurrentSeg),
102        fCurrentDetElem(circuit.fCurrentDetElem),
103        fCurrentLocalBoard(circuit.fCurrentLocalBoard)
104 {
105 /// Copy constructor
106
107     for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
108       fXpos11[i] = circuit.fXpos11[i];
109       fYpos11[i] = circuit.fYpos11[i];
110       fYpos21[i] = circuit.fYpos21[i];
111     }
112
113 }
114 //----------------------------------------------------------------------
115 AliMUONTriggerCircuit& AliMUONTriggerCircuit::operator=(const AliMUONTriggerCircuit& circuit) 
116 {
117 /// Assignment operator
118
119   if (this == &circuit) return *this;
120
121   fTransformer       = circuit.fTransformer;
122   fCurrentSeg        = circuit.fCurrentSeg;
123   fCurrentDetElem    = circuit.fCurrentDetElem;
124   fCurrentLocalBoard = circuit.fCurrentLocalBoard;
125
126   for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
127     fXpos11[i] = circuit.fXpos11[i];
128     fYpos11[i] = circuit.fYpos11[i];
129     fYpos21[i] = circuit.fYpos21[i];
130   }
131
132   return *this;
133
134 }
135
136 //---------------------------------------------------------------------
137 void AliMUONTriggerCircuit::LoadYPos(AliMpLocalBoard* localBoard)
138 {
139 /// fill fYpos11 and fYpos21 -> y position of X declusterized strips
140   
141   fCurrentLocalBoard = localBoard->GetId();
142   Int_t ichamber = 0;
143   Int_t icathode = 0;    
144     
145   Int_t zeroDown = localBoard->GetSwitch(AliMpLocalBoard::kZeroDown);
146   Int_t zeroUp   = localBoard->GetSwitch(AliMpLocalBoard::kZeroUp);
147  
148   Int_t iline = localBoard->GetPosition().GetFirst();
149   Int_t icol  = localBoard->GetPosition().GetSecond();
150   if ( iline == 5 ) --icol;
151
152   //--- first plane 
153   ichamber = 10;
154   fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
155
156   fCurrentSeg = AliMpSegmentation::Instance()
157         ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));  
158
159   Int_t iFirstStrip = FirstStrip(localBoard);
160   Int_t iLastStrip  = iFirstStrip + 16;    
161   Int_t iStripCircuit = 0;
162
163   FillXstrips(icol, iFirstStrip, iLastStrip, 
164               iStripCircuit, fYpos11[fCurrentLocalBoard]);
165   
166   //--- second plane 
167   ichamber = 12;
168   fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
169
170   fCurrentSeg = AliMpSegmentation::Instance()
171         ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));  
172
173   // second plane middle part
174   Int_t iFirstStripMiddle = FirstStrip(localBoard);
175   Int_t iLastStripMiddle  = iFirstStrip + 16;
176   iStripCircuit = 8;
177
178   FillXstrips(icol, iFirstStripMiddle, iLastStripMiddle,
179               iStripCircuit, fYpos21[fCurrentLocalBoard]);
180   
181   // second plane upper part
182   if (zeroUp == 0) { // something up
183     Int_t iFirstStripUp;
184     Int_t iLastStripUp;
185     Int_t icolUp = icol;
186
187     // check if we need to move to another detElemId
188     AliMpPad pad = fCurrentSeg->PadByIndices(AliMpIntPair(icol-1,iLastStripMiddle+1),kFALSE);
189
190     if (pad.IsValid()) { // upper strips within same detElemId
191       iFirstStripUp = iLastStripMiddle;
192       iLastStripUp  = iFirstStripUp + 8;
193
194     } else {             // upper strips in another detElemId
195       fCurrentDetElem = AliMpDDLStore::Instance()->
196                    GetNextDEfromLocalBoard(fCurrentLocalBoard, ichamber);
197
198       fCurrentSeg = AliMpSegmentation::Instance()
199             ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));  
200
201       iFirstStripUp = 0;
202       iLastStripUp  = iFirstStripUp + 8;
203       if (iline == 4) icolUp = icol - 1; // special case
204       if (iline == 5) icolUp = icol + 1; // special case
205     }
206     
207     iStripCircuit = 24;
208     FillXstrips(icolUp, iFirstStripUp, iLastStripUp,
209                 iStripCircuit, fYpos21[fCurrentLocalBoard]);
210     
211     // fill strip between middle and upper part
212     fYpos21[fCurrentLocalBoard][47] = (fYpos21[fCurrentLocalBoard][46] + 
213                                        fYpos21[fCurrentLocalBoard][48])/2.;
214   } // end of something up
215   
216   // restore current detElemId & segmentation
217   fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
218   fCurrentSeg = AliMpSegmentation::Instance()
219       ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));  
220
221   // second plane lower part
222   if (zeroDown == 0) { // something down
223     Int_t iFirstStripDo;
224     Int_t iLastStripDo;
225     Int_t icolDo = icol;
226     
227     // check if we need to move to another detElemId      
228     AliMpPad pad = fCurrentSeg->PadByIndices(AliMpIntPair(icol-1,iFirstStripMiddle-1),kFALSE);
229     if (pad.IsValid()) { // lower strips within same detElemId
230       iFirstStripDo = iFirstStripMiddle - 8;
231       iLastStripDo  = iFirstStripDo + 8;              
232
233     } else {             // lower strips in another detElemId 
234       fCurrentDetElem = AliMpDDLStore::Instance()
235           ->GetPreviousDEfromLocalBoard(fCurrentLocalBoard, ichamber);
236
237       fCurrentSeg = AliMpSegmentation::Instance()
238           ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));  
239
240       // get iFirstStrip in this module 
241       const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(fCurrentSeg);
242       const AliMpTrigger* t = trig->Slat();
243       const AliMpSlat* slat = t->GetLayer(0);
244
245       if (iline == 5) icolDo = icol + 1; // special case
246       if (iline == 6) icolDo = icol - 1; // special case
247             
248       const AliMpPCB* pcb = slat->GetPCB(icolDo-1);
249       iFirstStripDo = (pcb->Iymax() + 1) - 8;
250       iLastStripDo =  iFirstStripDo + 8;
251     }  
252     
253     iStripCircuit = 0;
254     FillXstrips(icolDo, iFirstStripDo, iLastStripDo,
255                 iStripCircuit, fYpos21[fCurrentLocalBoard]);
256     
257     // fill strip between middle and upper part
258     fYpos21[fCurrentLocalBoard][15] = (fYpos21[fCurrentLocalBoard][14] + 
259                                        fYpos21[fCurrentLocalBoard][16])/2.;
260   } // end of something down
261   
262 }
263
264 //----------------------------------------------------------------------
265 void AliMUONTriggerCircuit::FillXstrips(const Int_t icol, 
266                                         const Int_t iFirstStrip, const Int_t iLastStrip, 
267                                         Int_t liStripCircuit, TArrayF& ypos)
268 {    
269 /// fill 
270   Double_t xyGlobal[2] = {0.};
271   for (Int_t istrip = iFirstStrip; istrip < iLastStrip; ++istrip) {
272
273     AliMpPad pad = fCurrentSeg->PadByIndices(AliMpIntPair(icol-1,istrip),kTRUE);
274     if ( !pad.IsValid() ) {
275       StdoutToAliError(cout << "Pad not found in seg " << endl;
276                        fCurrentSeg->Print();
277                        cout << " ix,iy=" << icol-1 << "," << istrip << endl;
278                        );
279     }
280     Float_t yDim = pad.Dimensions().Y(); // half size! 
281
282     XYGlobal(pad,xyGlobal);
283     
284     ypos[2*liStripCircuit] = xyGlobal[1];
285     if (istrip != (iLastStrip - 1)) ypos[2*liStripCircuit+1] = xyGlobal[1] + yDim;
286     liStripCircuit++;
287   }    
288 }
289
290
291 //----------------------------------------------------------------------
292 void AliMUONTriggerCircuit::LoadXPos(AliMpLocalBoard* localBoard)
293 {
294 /// fill fXpos11 -> x position of Y strips for the first plane only
295 /// fXpos11 contains the x position of Y strip for the current circuit
296 /// taking into account whether or nor not part(s) of the circuit
297 /// (middle, up or down) has(have) 16 strips (handdled by means of switchs)
298
299   fCurrentLocalBoard = localBoard->GetId();
300
301   Int_t ichamber = 10;
302   Int_t icathode = 1;
303   
304   Int_t x2u = localBoard->GetSwitch(AliMpLocalBoard::kX2u);
305   Int_t x2m = localBoard->GetSwitch(AliMpLocalBoard::kX2m);
306   Int_t x2d = localBoard->GetSwitch(AliMpLocalBoard::kX2d);
307   Int_t zeroAllYLSB = localBoard->GetSwitch(AliMpLocalBoard::kZeroAllYLSB);
308
309   Int_t  iStripCircuit = 0;
310   Int_t  iFirstStrip   = 0;
311   Int_t  iLastStrip    = 0;
312   Bool_t doubling      = kFALSE;
313   
314   Int_t iline  = localBoard->GetPosition().GetFirst();
315   Int_t icol   = localBoard->GetPosition().GetSecond();
316   if ( iline == 5 ) --icol;
317
318   fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
319
320   fCurrentSeg = AliMpSegmentation::Instance()
321         ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));  
322
323   // check if one needs a strip doubling or not
324   if ( (x2u || x2m || x2d ) && x2m ) doubling = kTRUE;
325   
326
327   // check if one starts at strip = 0 or 8 (boards 26-29 and 143-146)
328   if (zeroAllYLSB) iStripCircuit = 8;
329   
330   // get iFirstStrip in this module 
331   const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(fCurrentSeg);
332   const AliMpTrigger* t = trig->Slat();
333   const AliMpSlat* slat = t->GetLayer(0);
334   
335   const AliMpPCB* pcb = slat->GetPCB(icol-1);
336   iFirstStrip = pcb->Ixmin();
337   
338
339   if (doubling || zeroAllYLSB == 1) iLastStrip = iFirstStrip + 8;
340   else iLastStrip = iFirstStrip + 16;
341   
342   FillYstrips(iFirstStrip, iLastStrip, iStripCircuit, doubling);  
343 }
344
345 //----------------------------------------------------------------------
346 void AliMUONTriggerCircuit::FillYstrips(const Int_t iFirstStrip, const Int_t iLastStrip, 
347                                         Int_t liStripCircuit,
348                                         const Bool_t doubling)
349 {    
350 /// fill
351   Double_t xyGlobal[2] = {0.};
352
353   for (Int_t istrip = iFirstStrip; istrip < iLastStrip; ++istrip) {
354
355     AliMpPad pad = fCurrentSeg->PadByIndices(AliMpIntPair(istrip,0),kTRUE);
356
357     if ( !pad.IsValid() )
358     {
359         StdoutToAliError(cout << "Pad not found in seg " << endl;
360                          fCurrentSeg->Print();
361                          cout << " ix,iy=" << istrip << "," << 0 << endl;
362                          );
363     }
364     Float_t xDim = pad.Dimensions().X(); // half size!
365
366     XYGlobal(pad,xyGlobal);
367     
368     if (!doubling) {    
369       fXpos11[fCurrentLocalBoard].AddAt(xyGlobal[0], liStripCircuit);
370     } else if (doubling) {
371
372       fXpos11[fCurrentLocalBoard].AddAt(TMath::Sign(1.,xyGlobal[0]) * 
373                                   (TMath::Abs(xyGlobal[0]) - xDim/2.), 2*liStripCircuit);
374
375       fXpos11[fCurrentLocalBoard].AddAt(TMath::Sign(1.,xyGlobal[0]) *
376                                   (TMath::Abs(fXpos11[fCurrentLocalBoard][2*liStripCircuit]) + xDim),
377                                         2*liStripCircuit + 1); 
378     }
379
380     liStripCircuit++;
381   }    
382 }
383
384 //----------------------------------------------------------------------
385 void AliMUONTriggerCircuit::XYGlobal(const AliMpPad& pad,
386                                      Double_t* xyGlobal)
387 {
388 /// returns pad x & y positions and x & y pad dimensions in global coordinates
389 /// note: no need for transformation for pad dimensions
390   
391   // get the pad position and dimensions
392   Double_t xl1 = pad.Position().X();
393   Double_t yl1 = pad.Position().Y();
394   Double_t zg1 = 0;
395   
396   // positions from local to global 
397   fTransformer->Local2Global(fCurrentDetElem, xl1, yl1, 0, 
398                                  xyGlobal[0], xyGlobal[1], zg1);
399 }
400
401
402 //----------------------------------------------------------------------
403 //--- methods which return member data related info
404 //----------------------------------------------------------------------
405 Float_t AliMUONTriggerCircuit::GetY11Pos(Int_t localBoardId, Int_t istrip) const 
406 {
407 /// returns Y position of X strip istrip in MC11
408   return fYpos11[localBoardId][istrip];
409 }
410 //----------------------------------------------------------------------
411 Float_t AliMUONTriggerCircuit::GetY21Pos(Int_t localBoardId, Int_t istrip) const 
412 {
413 /// returns Y position of X strip istrip in MC21
414   return fYpos21[localBoardId][istrip];
415 }
416 //----------------------------------------------------------------------
417 Float_t AliMUONTriggerCircuit::GetX11Pos(Int_t localBoardId, Int_t istrip) const 
418 {
419 /// returns X position of Y strip istrip in MC11
420   return fXpos11[localBoardId][istrip];
421 }
422
423 //----------------------------------------------------------------------
424 Int_t AliMUONTriggerCircuit::FirstStrip(AliMpLocalBoard* localBoard)
425 {
426 /// returns the first strip from mapping for board boardName
427 /// take care of special case for boards RC1L6B12 & LC1L6B12
428   Int_t iFirstStrip = -1;
429   Int_t boardNumber = atoi(localBoard->GetName()+6);
430
431   Int_t iline = localBoard->GetPosition().GetFirst();
432   Int_t icol  = localBoard->GetPosition().GetSecond();
433   if ( iline == 5 ) --icol;
434
435   switch (boardNumber)
436   {
437     case 12:
438       iFirstStrip = 0;
439       break;            
440     case 34:
441       iFirstStrip = 16;
442       break;            
443     case 56:
444       iFirstStrip = 32;
445       break;            
446     case 78:
447       iFirstStrip = 48;
448       break;            
449   }
450   if (icol == 1 && iline == 6) iFirstStrip += 16; // special case
451   return iFirstStrip;
452 }
453
454 //----------------------------------------------------------------------
455 Float_t AliMUONTriggerCircuit::PtCal(Int_t localBoardId, Int_t istripX, Int_t idev, Int_t istripY) const{
456 /// returns calculated pt for circuit/istripX/idev/istripY according 
457 /// to the formula of the TRD. Note : idev (input) is in [0+30]
458
459   //  Int_t jdev = idev - 15;        // jdev in [-15+15]
460   Int_t istripX2=istripX+idev+1; // find istripX2 using istripX and idev
461
462   Float_t yPosX1=fYpos11[localBoardId][istripX];
463   Float_t yPosX2=fYpos21[localBoardId][istripX2];
464   Float_t xPosY1=fXpos11[localBoardId][istripY];
465
466 // Z distance between IP and center of dipole
467   Float_t zf= TMath::Abs(0.5 *(AliMUONConstants::CoilZ() + AliMUONConstants::YokeZ()));
468   Float_t z1=AliMUONConstants::DefaultChamberZ(10);
469   Float_t z2=AliMUONConstants::DefaultChamberZ(12);
470   Float_t thetaDev=(1./zf)*(yPosX1*z2-yPosX2*z1)/(z2-z1);
471   Float_t xf=xPosY1*zf/z1; 
472   Float_t yf=yPosX2-((yPosX2-yPosX1)*(z2-zf))/(z2-z1);
473   return (3.*0.3/TMath::Abs(thetaDev)) * TMath::Sqrt(xf*xf+yf*yf)/zf;
474 }