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