]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONResponseTriggerV1.cxx
Fixing RC20 violations
[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
3d1463c8 18//-----------------------------------------------------------------------------
d1525c79 19// Class AliMUONTriggerResponseV1
20// ------------------
21// Trigger chamber response
22// with cluster size activated
3d1463c8 23//-----------------------------------------------------------------------------
d1525c79 24
e087fe7f 25#include "AliMUONResponseTriggerV1.h"
4e702a25 26#include "AliMUON.h"
27#include "AliMUONDigit.h"
28#include "AliMUONGeometryTransformer.h"
d344444e 29#include "AliMUONConstants.h"
e087fe7f 30
9265505b 31#include "AliMpPad.h"
32#include "AliMpSegmentation.h"
33#include "AliMpVSegmentation.h"
866c3232 34#include "AliMpCathodType.h"
9265505b 35
36#include "AliRun.h"
37
38#include <TMath.h>
39#include <TRandom.h>
40
41/// \cond CLASSIMP
e087fe7f 42ClassImp(AliMUONResponseTriggerV1)
9265505b 43/// \endcond
e087fe7f 44
4e702a25 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
4e702a25 65}
66
e087fe7f 67//------------------------------------------------------------------
30178c30 68AliMUONResponseTriggerV1::AliMUONResponseTriggerV1()
1657f946 69 : AliMUONResponseTrigger(),
70 fGenerCluster(0),
71 fA(0),
72 fB(0),
73 fC(0)
30178c30 74{
9265505b 75/// default constructor
e087fe7f 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{
9265505b 88/// Constructor
e087fe7f 89 SetParameters(hv);
90}
91
92//------------------------------------------------------------------
9265505b 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)
87b39c02 103/// this parametrisation is valid only for the "streamer" mode
e087fe7f 104 fA = 6.089 * hv - 52.70;
105 fB = 2.966;
106 fC = 4.3e-4 * hv - 3.5e-3;
107}
108
109//------------------------------------------------------------------
9265505b 110Int_t AliMUONResponseTriggerV1::SetGenerCluster()
111{
112/// Set the GenerCluster parameter and return 1
e087fe7f 113 fGenerCluster = gRandom->Rndm();
114 return 1;
337c9041 115}
e087fe7f 116
117//------------------------------------------------------------------
85fec35d 118Float_t AliMUONResponseTriggerV1::FireStripProb(Float_t x4, Float_t theta)
119const
120{
71a2d3aa 121/// parametrisation of the probability that a strip neighbour of the main
122/// strip is fired (V.Barret B.Espagnon and P.Rosnet INT/DIM/01-04 (2001)
123/// WARNING : need to convert x4 from cm to mm
87b39c02 124/// this parametrisation is valid only for the "streamer" mode
e087fe7f 125
4e702a25 126 return
127 (TMath::Cos(theta)*fA/(fA+TMath::Cos(theta)*TMath::Power(x4*10.,fB))+fC)/
128 (TMath::Cos(theta)+fC);
129}
130
131//------------------------------------------------------------------
a572c9f4 132void AliMUONResponseTriggerV1::DisIntegrate(const AliMUONHit& hit, TList& digits, Float_t /*timeDif*/)
4e702a25 133{
9265505b 134 /// Generate digits (on each cathode) from 1 hit, with cluster-size
135 /// generation.
4e702a25 136
137 digits.Clear();
138
139 Float_t xhit = hit.X();
140 Float_t yhit = hit.Y();
87b39c02 141 Float_t zhit = hit.Z();
4e702a25 142 Int_t detElemId = hit.DetElemId();
143
144 Double_t x,y,z;
145 Global2Local(detElemId,xhit,yhit,zhit,x,y,z);
146
147 Float_t tof = hit.Age();
148 Int_t twentyNano(100);
d344444e 149 if (tof<AliMUONConstants::TriggerTofLimit())
4e702a25 150 {
151 twentyNano=1;
152 }
d5315275 153
7fde4d96 154 Int_t nboard = 0;
7d7d22a6 155
866c3232 156 for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath )
4e702a25 157 {
9265505b 158 const AliMpVSegmentation* seg
866c3232 159 = AliMpSegmentation::Instance()
160 ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cath));
4e702a25 161
6e97fbb8 162 AliMpPad pad = seg->PadByPosition(x,y,kFALSE);
168e9c4d 163 Int_t ix = pad.GetIx();
164 Int_t iy = pad.GetIy();
4e702a25 165
87b39c02 166 AliDebug(1,Form("xhit,yhit=%e,%e lx,ly,lz=%e,%e,%e ix,iy=%d,%d",
167 xhit,yhit,x,y,z,ix,iy));
168
169 if ( !pad.IsValid() )
170 {
171 AliWarning(Form("hit w/o strip %d-%d xhit,yhit=%e,%e local x,y,z "
172 "%e,%e,%e ix,iy=%d,%d",detElemId,
173 cath,
174 xhit,yhit,x,y,z,ix,iy));
175 continue;
176 }
7fde4d96 177
d5315275 178 if ( cath == AliMp::kCath0 ) nboard = pad.GetLocalBoardId(0);
179
180 AliMUONDigit* d = new AliMUONDigit(detElemId,nboard,
168e9c4d 181 pad.GetLocalBoardChannel(0),
2a7d64a9 182 cath);
183 d->SetPadXY(ix,iy);
4e702a25 184
2a7d64a9 185 d->SetCharge(twentyNano);
7d7d22a6 186
7d7d22a6 187
4e702a25 188 digits.Add(d);
189
190 SetGenerCluster(); // 1 randum number per cathode (to be checked)
191
192 Int_t xList[10], yList[10];
193 Neighbours(cath,ix,iy,xList,yList);
194
195// cout << " detElemId cath ix iy = " << detElemId << " " << cath
196// << " " << ix << " " << iy << "\n";
197// for (Int_t i=0; i<10; i++) cout << " " << xList[i] << " " << yList[i];
198// cout << "\n";
199
200 Int_t qp = 0; // fired/no-fired strip = 1/0
201 for (Int_t i=0; i<10; i++) { // loop on neighbors
202 if (i==0||i==5||qp!=0) { // built-up cluster
203
204 // need to iterate in iy/ix for bending/non-bending plane
205 Int_t ixNeigh = ( cath == 0 ) ? ix : xList[i];
206 Int_t iyNeigh = ( cath == 0 ) ? yList[i] : iy;
207
168e9c4d 208 AliMpPad padNeigh = seg->PadByIndices(ixNeigh,iyNeigh,kFALSE);
4e702a25 209 if(padNeigh.IsValid()){ // existing neighbourg
210
211 Int_t dix=-(ixNeigh-ix);
212 Int_t diy=-(iyNeigh-iy);
6e97fbb8 213 Float_t xlocalNeigh = padNeigh.GetPositionX();
214 Float_t ylocalNeigh = padNeigh.GetPositionY();
215 Float_t dpx = padNeigh.GetDimensionX();
216 Float_t dpy = padNeigh.GetDimensionY();
4e702a25 217 Float_t distX = TMath::Abs((Float_t)dix) * ((Float_t)dix * dpx + xlocalNeigh - x);
218 Float_t distY = TMath::Abs((Float_t)diy) * ((Float_t)diy * dpy + ylocalNeigh - y);
219 Float_t dist = TMath::Sqrt(distX*distX+distY*distY);
220
221// cout << " here " << dist << " " << fGenerCluster << " " << FireStripProb(dist,0) << "\n";
222
223 if (fGenerCluster<FireStripProb(dist,0)) qp = 1;
224 else qp = 0;
225
226 if (qp == 1) { // this digit is fired
d5315275 227 Int_t neighBoard = 0;
228 if ( cath == AliMp::kCath0 ) neighBoard = padNeigh.GetLocalBoardId(0);
229 else {
230 const AliMpVSegmentation* seg0
231 = AliMpSegmentation::Instance()
232 ->GetMpSegmentation(detElemId,AliMp::GetCathodType(AliMp::kCath0));
233 AliMpPad padNeigh0 = seg0->PadByPosition(xlocalNeigh, y, kFALSE);
234 if ( ! padNeigh0.IsValid() ) continue; // This can happen only on the cut RPC, at boards 25, 30, 142 and 147
235 neighBoard = padNeigh0.GetLocalBoardId(0);
236 }
237 AliMUONDigit* dNeigh = new AliMUONDigit(detElemId,neighBoard,
168e9c4d 238 padNeigh.GetLocalBoardChannel(0),
2a7d64a9 239 cath);
4e702a25 240
2a7d64a9 241 dNeigh->SetPadXY(ixNeigh,iyNeigh);
242 dNeigh->SetCharge(twentyNano);
4e702a25 243 digits.Add(dNeigh);
244 } // digit fired
245 } // pad is valid
246 } // built-up cluster
247 } // loop on neighbors
248 } // loop on cathode
249}
250
251//------------------------------------------------------------------
252void AliMUONResponseTriggerV1::Neighbours(const Int_t cath,
253 const Int_t ix, const Int_t iy,
9ee1d6ff 254 Int_t Xlist[10], Int_t Ylist[10]) const
4e702a25 255{
9265505b 256 ///-----------------BENDING----------------------------------------- /n
257 /// Returns list of 10 next neighbours for given X strip (ix, iy) /n
258 /// neighbour number 4 in the list - /n
259 /// neighbour number 3 in the list | /n
260 /// neighbour number 2 in the list |_ Upper part /n
261 /// neighbour number 1 in the list | /n
262 /// neighbour number 0 in the list - /n
263 /// X strip (ix, iy) /n
264 /// neighbour number 5 in the list - /n
265 /// neighbour number 6 in the list | _ Lower part /n
266 /// neighbour number 7 in the list | /n
267 /// neighbour number 8 in the list | /n
268 /// neighbour number 9 in the list - /n
269 /// /n
270 ///-----------------NON-BENDING------------------------------------- /n
271 /// Returns list of 10 next neighbours for given Y strip (ix, iy) /n
272 /// neighbour number 9 8 7 6 5 (Y strip (ix, iy)) 0 1 2 3 4 in the list /n
c4ee792d 273 /// |_______| |_______/ /n
274
9265505b 275 /// left right /n
4e702a25 276
277 for (Int_t i=0; i<10; i++) {
278 Xlist[i]=-1;
279 Ylist[i]=-1;
280 }
281
282 Int_t iList[10]={9,8,7,6,5, 0,1,2,3,4};
283
284 // need to iterate in iy/ix for bending/non-bending plane
285 Int_t iNeigh = ( cath == 0 ) ? iy : ix;
286
287 Int_t i=0;
288 for (Int_t j=iNeigh-5; j<=iNeigh+5; j++){
289 if (j == iNeigh) continue;
290 // need to iterate in iy/ix for bending/non-bending plane
291 Int_t ixNeigh = ( cath == 0 ) ? ix : j;
292 Int_t iyNeigh = ( cath == 0 ) ? j : iy;
293
294// cout << " " << cath << " " << ix << " " << iy
295// << " " << ixNeigh << " " << iyNeigh << "\n";
296
297 Xlist[iList[i]]=ixNeigh;
298 Ylist[iList[i]]=iyNeigh;
299 i++;
300 }
e087fe7f 301}
302