]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONResponseV0.cxx
IntPH(..): Protec Log against random numbers equal to 0.
[u/mrichter/AliRoot.git] / MUON / AliMUONResponseV0.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 /*
17 $Log$
18 Revision 1.3  2000/07/03 11:54:57  morsch
19 AliMUONSegmentation and AliMUONHitMap have been replaced by AliSegmentation and AliHitMap in STEER
20 The methods GetPadIxy and GetPadXxy of AliMUONSegmentation have changed name to GetPadI and GetPadC.
21
22 Revision 1.2  2000/06/15 07:58:48  morsch
23 Code from MUON-dev joined
24
25 Revision 1.1.2.1  2000/06/09 21:33:35  morsch
26 AliMUONResponse code  from  AliMUONSegResV0.cxx
27
28 */
29
30 #include "AliMUONResponseV0.h"
31 #include "AliSegmentation.h"
32 #include <TMath.h>
33 #include <TRandom.h>
34
35
36 ClassImp(AliMUONResponseV0)     
37 Float_t AliMUONResponseV0::IntPH(Float_t eloss)
38 {
39   // Calculate charge from given ionization energy loss
40   Int_t nel;
41   nel= Int_t(eloss*1.e9/32.);
42   Float_t charge=0;
43   if (nel == 0) nel=1;
44   for (Int_t i=1;i<=nel;i++) {
45       Float_t arg=0.;
46       while(!arg) arg = gRandom->Rndm();
47       charge -= fChargeSlope*TMath::Log(arg);    
48   }
49   return charge;
50 }
51 // -------------------------------------------
52
53 Float_t AliMUONResponseV0::IntXY(AliSegmentation * segmentation)
54 {
55 // Calculate charge on current pad according to Mathieson distribution
56 // 
57     const Float_t kInversePitch = 1/fPitch;
58 //
59 //  Integration limits defined by segmentation model
60 //  
61     Float_t xi1, xi2, yi1, yi2;
62     segmentation->IntegrationLimits(xi1,xi2,yi1,yi2);
63     xi1=xi1*kInversePitch;
64     xi2=xi2*kInversePitch;
65     yi1=yi1*kInversePitch;
66     yi2=yi2*kInversePitch;
67 //
68 // The Mathieson function 
69     Double_t ux1=fSqrtKx3*TMath::TanH(fKx2*xi1);
70     Double_t ux2=fSqrtKx3*TMath::TanH(fKx2*xi2);
71
72     Double_t uy1=fSqrtKy3*TMath::TanH(fKy2*yi1);
73     Double_t uy2=fSqrtKy3*TMath::TanH(fKy2*yi2);
74
75     
76     return Float_t(4.*fKx4*(TMath::ATan(ux2)-TMath::ATan(ux1))*
77                       fKy4*(TMath::ATan(uy2)-TMath::ATan(uy1)));
78 }
79
80 Int_t  AliMUONResponseV0::DigitResponse(Int_t digit)
81 {
82     // add white noise and do zero-suppression and signal truncation
83     Float_t meanNoise = gRandom->Gaus(1, 0.2);
84     Float_t noise     = gRandom->Gaus(0, meanNoise);
85     digit+=(Int_t)noise; 
86     if ( digit <= ZeroSuppression()) digit = 0;
87     if ( digit >  MaxAdc())          digit=MaxAdc();
88     return digit;
89 }
90
91
92
93
94
95
96
97
98