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