]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONResponseTriggerV1.cxx
Changing ownership logic (Laurent)
[u/mrichter/AliRoot.git] / MUON / AliMUONResponseTriggerV1.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 AliMUONTriggerResponseV1
20 // ------------------
21 // Trigger chamber response 
22 // with cluster size activated
23
24 #include "AliMUONResponseTriggerV1.h"
25 #include "AliMUON.h"
26 #include "AliMUONDigit.h"
27 #include "AliMUONGeometryTransformer.h"
28 #include "AliMUONConstants.h"
29
30 #include "AliMpPad.h"
31 #include "AliMpSegmentation.h"
32 #include "AliMpVSegmentation.h"
33 #include "AliMpCathodType.h"
34
35 #include "AliRun.h"
36
37 #include <TMath.h>
38 #include <TRandom.h>
39
40 /// \cond CLASSIMP
41 ClassImp(AliMUONResponseTriggerV1)
42 /// \endcond
43
44 namespace
45 {
46   AliMUON* muon()
47   {
48     return static_cast<AliMUON*>(gAlice->GetModule("MUON"));
49   }
50
51   void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg,
52                   Double_t& xl, Double_t& yl, Double_t& zl)
53   {  
54   // ideally should be : 
55   // Double_t x,y,z;
56   // AliMUONGeometry::Global2Local(detElemId,xg,yg,zg,x,y,z);
57   // but while waiting for this geometry singleton, let's go through
58   // AliMUON still.
59   
60     const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
61     transformer->Global2Local(detElemId,xg,yg,zg,xl,yl,zl);
62   }
63
64 }
65
66 //------------------------------------------------------------------   
67 AliMUONResponseTriggerV1::AliMUONResponseTriggerV1()
68     : AliMUONResponseTrigger(),
69       fGenerCluster(0),
70       fA(0),
71       fB(0),       
72       fC(0)
73 {
74 /// default constructor 
75   Float_t hv=9.2;
76   SetParameters(hv);
77 }
78
79 //------------------------------------------------------------------   
80 AliMUONResponseTriggerV1::AliMUONResponseTriggerV1(Float_t hv)
81     : AliMUONResponseTrigger(),
82       fGenerCluster(0),
83       fA(0),
84       fB(0),       
85       fC(0)
86 {
87 /// Constructor 
88   SetParameters(hv);
89 }
90
91 //------------------------------------------------------------------   
92 AliMUONResponseTriggerV1::~AliMUONResponseTriggerV1()
93 {
94 /// destructor 
95 }
96
97 //------------------------------------------------------------------   
98 void AliMUONResponseTriggerV1::SetParameters(Float_t hv)
99 {
100 /// initialize parameters accoring to HV
101 /// (see V.Barret B.Espagnon and P.Rosnet Alice/note xxx)
102   fA = 6.089 * hv - 52.70;
103   fB = 2.966;
104   fC = 4.3e-4 * hv - 3.5e-3;
105 }
106
107 //------------------------------------------------------------------   
108 Int_t AliMUONResponseTriggerV1::SetGenerCluster()
109 {
110 /// Set the GenerCluster parameter and return 1
111   fGenerCluster = gRandom->Rndm();
112   return 1;
113 }
114
115 //------------------------------------------------------------------   
116 Float_t AliMUONResponseTriggerV1::FireStripProb(Float_t x4, Float_t theta)
117 const
118 {
119 /// parametrisation of the probability that a strip neighbour of the main 
120 /// strip is fired (V.Barret B.Espagnon and P.Rosnet INT/DIM/01-04 (2001)
121 /// WARNING : need to convert x4 from cm to mm
122
123  return 
124      (TMath::Cos(theta)*fA/(fA+TMath::Cos(theta)*TMath::Power(x4*10.,fB))+fC)/
125      (TMath::Cos(theta)+fC);
126 }
127
128 //------------------------------------------------------------------  
129 void AliMUONResponseTriggerV1::DisIntegrate(const AliMUONHit& hit, TList& digits)
130 {
131   /// Generate digits (on each cathode) from 1 hit, with cluster-size
132   /// generation.
133   
134   digits.Clear();
135   
136   Float_t xhit = hit.X();
137   Float_t yhit = hit.Y();
138   Float_t zhit = 0; // FIXME : should it be hit.Z() ?
139   Int_t detElemId = hit.DetElemId();  
140   
141   Double_t x,y,z;
142   Global2Local(detElemId,xhit,yhit,zhit,x,y,z);
143   
144   Float_t tof = hit.Age();
145   Int_t twentyNano(100);
146   if (tof<AliMUONConstants::TriggerTofLimit())
147   {
148     twentyNano=1;
149   }
150
151   for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath )
152   {
153     const AliMpVSegmentation* seg 
154       = AliMpSegmentation::Instance()
155         ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cath));
156
157     AliMpPad pad = seg->PadByPosition(TVector2(x,y),kFALSE);
158     Int_t ix = pad.GetIndices().GetFirst();
159     Int_t iy = pad.GetIndices().GetSecond();
160     
161     AliMUONDigit* d = new AliMUONDigit(detElemId,pad.GetLocation().GetFirst(),
162                                        pad.GetLocation().GetSecond(),
163                                        cath);
164     d->SetPadXY(ix,iy);
165
166     d->SetCharge(twentyNano);
167     digits.Add(d);
168
169     SetGenerCluster(); // 1 randum number per cathode (to be checked)
170
171     Int_t xList[10], yList[10];
172     Neighbours(cath,ix,iy,xList,yList);
173     
174 //    cout << " detElemId cath ix iy = " << detElemId << " " << cath 
175 //       << " " << ix << " " << iy << "\n";
176 //    for (Int_t i=0; i<10; i++) cout << " " << xList[i] << " " << yList[i];
177 //    cout << "\n";
178
179     Int_t qp = 0; // fired/no-fired strip = 1/0
180     for (Int_t i=0; i<10; i++) { // loop on neighbors
181         if (i==0||i==5||qp!=0) { // built-up cluster
182             
183             // need to iterate in iy/ix for bending/non-bending plane
184             Int_t ixNeigh = ( cath == 0 ) ? ix : xList[i];
185             Int_t iyNeigh = ( cath == 0 ) ? yList[i] : iy;
186             
187             AliMpIntPair pairNeigh = AliMpIntPair(ixNeigh,iyNeigh);
188             AliMpPad padNeigh = seg->PadByIndices(pairNeigh,kFALSE);
189             if(padNeigh.IsValid()){ // existing neighbourg              
190                 
191                 Int_t dix=-(ixNeigh-ix);
192                 Int_t diy=-(iyNeigh-iy);
193                 Float_t xlocalNeigh = padNeigh.Position().X();
194                 Float_t ylocalNeigh = padNeigh.Position().Y();
195                 Float_t dpx = padNeigh.Dimensions().X();
196                 Float_t dpy = padNeigh.Dimensions().Y();
197                 Float_t distX = TMath::Abs((Float_t)dix) * ((Float_t)dix * dpx + xlocalNeigh - x);
198                 Float_t distY = TMath::Abs((Float_t)diy) * ((Float_t)diy * dpy + ylocalNeigh - y);
199                 Float_t dist = TMath::Sqrt(distX*distX+distY*distY);
200                 
201 //              cout << " here " << dist << " " << fGenerCluster << " " << FireStripProb(dist,0) << "\n";
202                 
203                 if (fGenerCluster<FireStripProb(dist,0)) qp = 1;
204                 else qp = 0;
205                 
206                 if (qp == 1) { // this digit is fired    
207                     AliMUONDigit* dNeigh = new AliMUONDigit(detElemId,padNeigh.GetLocation().GetFirst(),
208                                                 padNeigh.GetLocation().GetSecond(),
209                                                 cath);
210                     
211                     dNeigh->SetPadXY(ixNeigh,iyNeigh);      
212                     dNeigh->SetCharge(twentyNano);
213                     digits.Add(dNeigh);
214                 } // digit fired                
215             } // pad is valid
216         } // built-up cluster
217     } // loop on neighbors
218   } // loop on cathode
219 }
220
221 //------------------------------------------------------------------  
222 void AliMUONResponseTriggerV1::Neighbours(const Int_t cath, 
223                                           const Int_t ix, const Int_t iy, 
224                                           Int_t Xlist[10], Int_t Ylist[10]) 
225 {
226     ///-----------------BENDING-----------------------------------------      /n
227     /// Returns list of 10 next neighbours for given X strip (ix, iy)         /n
228     /// neighbour number 4 in the list -                                      /n    
229     /// neighbour number 3 in the list  |                                     /n   
230     /// neighbour number 2 in the list  |_ Upper part                         /n         
231     /// neighbour number 1 in the list  |                                     /n    
232     /// neighbour number 0 in the list -                                      /n   
233     ///      X strip (ix, iy)                                                 /n
234     /// neighbour number 5 in the list -                                      /n
235     /// neighbour number 6 in the list  | _ Lower part                        /n
236     /// neighbour number 7 in the list  |                                     /n
237     /// neighbour number 8 in the list  |                                     /n
238     /// neighbour number 9 in the list -                                      /n
239     ///                                                                       /n
240     ///-----------------NON-BENDING-------------------------------------      /n
241     /// Returns list of 10 next neighbours for given Y strip (ix, iy)         /n 
242     /// neighbour number 9 8 7 6 5 (Y strip (ix, iy)) 0 1 2 3 4 in the list   /n 
243     ///                  |_______|                    |_______/               /n 
244
245     ///                    left                         right                 /n
246     
247     for (Int_t i=0; i<10; i++) {
248         Xlist[i]=-1;
249         Ylist[i]=-1;
250     }
251     
252     Int_t iList[10]={9,8,7,6,5, 0,1,2,3,4};
253
254     // need to iterate in iy/ix for bending/non-bending plane
255     Int_t iNeigh = ( cath == 0 ) ? iy : ix;
256     
257     Int_t i=0;
258     for (Int_t j=iNeigh-5; j<=iNeigh+5; j++){
259         if (j == iNeigh) continue;
260         // need to iterate in iy/ix for bending/non-bending plane
261         Int_t ixNeigh = ( cath == 0 ) ? ix : j;
262         Int_t iyNeigh = ( cath == 0 ) ? j : iy;
263         
264 //      cout << " " << cath << " " << ix << " " << iy 
265 //           << " "  << ixNeigh << " " << iyNeigh << "\n";
266         
267         Xlist[iList[i]]=ixNeigh;        
268         Ylist[iList[i]]=iyNeigh;        
269         i++;
270     } 
271 }
272