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