]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - MUON/AliMUONChamber.cxx
TPC fast simulation added.
[u/mrichter/AliRoot.git] / MUON / AliMUONChamber.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// --- ROOT includes ---
19#include <TRandom.h>
20#include <TMath.h>
21#include "AliRun.h"
22
23
24// --- MUON includes ---
25#include "AliMUON.h"
26#include "AliMUONChamber.h"
27#include "AliMUONGeometryModule.h"
28#include "AliMUONHit.h"
29#include "AliLog.h"
30
31ClassImp(AliMUONChamber)
32
33AliMUONChamber::AliMUONChamber()
34 : TObject(),
35 fId(0),
36 fdGas(0.),
37 fdAlu(0.),
38 fZ(0.),
39 fnsec(1),
40 frMin(0.),
41 frMax(0.),
42 fCurrentCorrel(1), // to avoid mistakes if ChargeCorrelInit is not called
43 fSegmentation2(0),
44 fResponse(0),
45 fGeometry(0),
46 fMUON(0)
47{
48// Default constructor
49}
50
51//_______________________________________________________
52AliMUONChamber::AliMUONChamber(Int_t id)
53 : TObject(),
54 fId(id),
55 fdGas(0.),
56 fdAlu(0.),
57 fZ(0.),
58 fnsec(1),
59 frMin(0.),
60 frMax(0.),
61 fCurrentCorrel(1), // to avoid mistakes if ChargeCorrelInit is not called
62 fSegmentation2(0),
63 fResponse(0),
64 fGeometry(0),
65 fMUON(0)
66{
67
68 // muon
69 fMUON = (AliMUON*)gAlice->GetModule("MUON");
70 if (!fMUON) {
71 AliFatal("MUON detector not defined.");
72 return;
73 }
74
75 // new segmentation
76 fSegmentation2 = new TObjArray(2);
77 fSegmentation2->AddAt(0,0);
78 fSegmentation2->AddAt(0,1);
79
80 fGeometry = new AliMUONGeometryModule(fId);
81
82}
83
84//_______________________________________________________
85AliMUONChamber::AliMUONChamber(const AliMUONChamber& rChamber)
86 : TObject(rChamber)
87{
88 // Protected copy constructor
89
90 AliFatal("Not implemented.");
91 // Dummy copy constructor
92}
93
94//_______________________________________________________
95AliMUONChamber::~AliMUONChamber()
96{
97 // Destructor
98
99 if (fSegmentation2) {
100 fSegmentation2->Delete();
101 delete fSegmentation2;
102 }
103
104 delete fGeometry;
105}
106
107//_______________________________________________________
108AliMUONChamber & AliMUONChamber::operator =(const AliMUONChamber& rhs)
109{
110 // Protected assignement operator
111
112 if (this == &rhs) return *this;
113
114 AliFatal("Not implemented.");
115
116 return *this;
117}
118
119//_______________________________________________________
120Bool_t AliMUONChamber::IsSensId(Int_t volId) const
121{
122 // Returns true if the volume specified by volId is in the list
123 // of sesitive volumes for this chamber
124
125 return fGeometry->IsSensitiveVolume(volId);
126}
127
128
129//_____________________________________________________
130void AliMUONChamber::ChargeCorrelationInit() {
131 // Initialisation of charge correlation for current hit
132 // the value is stored, and then used by Disintegration
133 if (fnsec==1)
134 fCurrentCorrel =1;
135 else
136 // exponential is here to avoid eventual problems in 0
137 // factor 2 because chargecorrel is q1/q2 and not q1/qtrue
138 fCurrentCorrel = TMath::Exp(gRandom->Gaus(0,fResponse->ChargeCorrel()/2));
139}
140
141//_______________________________________________________
142void AliMUONChamber::InitGeo(Float_t /*zpos*/)
143{
144 // sensitive gas gap
145 fdGas= 0.5;
146 // 3% radiation length of aluminum (X0=8.9 cm)
147 fdAlu= 3.0/100*8.9;
148}
149//_______________________________________________________
150//
151// NEW SEGMENTATION
152//_______________________________________________________
153void AliMUONChamber::Init(Int_t flag)
154{
155 // Initalisation ..
156 //
157 // ... for chamber segmentation
158
159 if (!flag) AliFatal("wrong segmentation type.");
160
161
162 if (fSegmentation2->At(0))
163 ((AliMUONGeometrySegmentation*) fSegmentation2->At(0))->Init(fId);
164
165 if (fnsec==2) {
166 if (fSegmentation2->At(1))
167 ((AliMUONGeometrySegmentation*) fSegmentation2->At(1))->Init(fId);
168 }
169}
170// //_________________________________________________________________
171// void AliMUONChamber::SigGenInit(AliMUONHit *hit)
172// {
173// //
174// // Initialisation of segmentation for hit
175// //
176// Float_t x = hit->X();
177// Float_t y = hit->Y();
178// Float_t z = hit->Z();
179// Int_t id = hit->DetElemId();
180
181// if (fnsec==1) {
182// ((AliMUONGeometrySegmentation*) fSegmentation2->At(0))->SigGenInit(id, x, y, z) ;
183// } else {
184// ((AliMUONGeometrySegmentation*) fSegmentation2->At(0))->SigGenInit(id, x, y, z) ;
185// ((AliMUONGeometrySegmentation*) fSegmentation2->At(1))->SigGenInit(id, x, y, z) ;
186// }
187// }
188
189//_______________________________________________________
190void AliMUONChamber::DisIntegration(AliMUONHit *hit,
191 Int_t& nnew,Float_t newclust[6][500])
192{
193 //
194 // Generates pad hits (simulated cluster)
195 // using the segmentation and the response model
196 Float_t dx, dy;
197
198 Float_t xhit = hit->X();
199 Float_t yhit = hit->Y();
200 Float_t zhit = hit->Z();
201 Int_t id = hit->DetElemId();
202 Float_t eloss = hit->Eloss();
203
204 //
205 // Width of the integration area
206 //
207 dx=fResponse->SigmaIntegration()*fResponse->ChargeSpreadX();
208 dy=fResponse->SigmaIntegration()*fResponse->ChargeSpreadY();
209 //
210 // Get pulse height from energy loss
211 Float_t qtot = fResponse->IntPH(eloss);
212 //
213 // Loop Over Pads
214
215 Float_t qp;
216 nnew=0;
217
218 // Cathode plane loop
219 for (Int_t i=1; i<=fnsec; i++) {
220 Float_t qcath = qtot * (i==1? fCurrentCorrel : 1/fCurrentCorrel);
221
222 AliMUONGeometrySegmentation* segmentation=
223 (AliMUONGeometrySegmentation*) fSegmentation2->At(i-1);
224
225 for (segmentation->FirstPad(id, xhit, yhit, zhit, dx, dy);
226 segmentation->MorePads(id);
227 segmentation->NextPad(id))
228 {
229 qp=fResponse->IntXY(id, segmentation);
230 qp=TMath::Abs(qp);
231 //
232 //
233 if (qp > 1.e-4)
234 {
235 if (nnew >= 500) // Perform a bounds check on nnew since it is assumed
236 // newclust only contains 500 elements.
237 {
238 AliError("Limit of 500 pad responses reached.");
239 return;
240 };
241 //
242 // --- store signal information
243 newclust[0][nnew]=qcath; // total charge
244 newclust[1][nnew]=segmentation->Ix(); // ix-position of pad
245 newclust[2][nnew]=segmentation->Iy(); // iy-position of pad
246 newclust[3][nnew]=qp * qcath; // charge on pad
247 newclust[4][nnew]=segmentation->ISector(); // sector id
248 newclust[5][nnew]=(Float_t) i; // counter
249 nnew++;
250
251 }
252 } // Pad loop
253 } // Cathode plane loop
254}