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