TPC fast simulation added.
[u/mrichter/AliRoot.git] / MUON / AliMUONChamber.cxx
CommitLineData
a9e2aefa 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 **************************************************************************/
2682e810 15
88cb7938 16/* $Id$ */
a9e2aefa 17
30178c30 18// --- ROOT includes ---
19#include <TRandom.h>
20#include <TMath.h>
a713db22 21#include "AliRun.h"
22
30178c30 23
681d067b 24// --- MUON includes ---
a713db22 25#include "AliMUON.h"
a9e2aefa 26#include "AliMUONChamber.h"
e118b27e 27#include "AliMUONGeometryModule.h"
a713db22 28#include "AliMUONHit.h"
8c343c7c 29#include "AliLog.h"
a9e2aefa 30
a9e2aefa 31ClassImp(AliMUONChamber)
32
30178c30 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
a713db22 43 fSegmentation2(0),
30178c30 44 fResponse(0),
a713db22 45 fGeometry(0),
46 fMUON(0)
d81db581 47{
48// Default constructor
d81db581 49}
50
a713db22 51//_______________________________________________________
30178c30 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
a713db22 62 fSegmentation2(0),
30178c30 63 fResponse(0),
a713db22 64 fGeometry(0),
65 fMUON(0)
a9e2aefa 66{
a713db22 67
68 // muon
69 fMUON = (AliMUON*)gAlice->GetModule("MUON");
70 if (!fMUON) {
71 AliFatal("MUON detector not defined.");
72 return;
73 }
002920d1 74
a713db22 75 // new segmentation
76 fSegmentation2 = new TObjArray(2);
77 fSegmentation2->AddAt(0,0);
78 fSegmentation2->AddAt(0,1);
79
e118b27e 80 fGeometry = new AliMUONGeometryModule(fId);
a713db22 81
30178c30 82}
83
a713db22 84//_______________________________________________________
30178c30 85AliMUONChamber::AliMUONChamber(const AliMUONChamber& rChamber)
86 : TObject(rChamber)
87{
a713db22 88 // Protected copy constructor
30178c30 89
8c343c7c 90 AliFatal("Not implemented.");
a713db22 91 // Dummy copy constructor
a9e2aefa 92}
93
a713db22 94//_______________________________________________________
a9e2aefa 95AliMUONChamber::~AliMUONChamber()
96{
a713db22 97 // Destructor
002920d1 98
99 if (fSegmentation2) {
100 fSegmentation2->Delete();
101 delete fSegmentation2;
c2c0190f 102 }
002920d1 103
c6df4ef2 104 delete fGeometry;
a9e2aefa 105}
106
a713db22 107//_______________________________________________________
30178c30 108AliMUONChamber & AliMUONChamber::operator =(const AliMUONChamber& rhs)
390151b8 109{
a713db22 110 // Protected assignement operator
a9e2aefa 111
30178c30 112 if (this == &rhs) return *this;
113
8c343c7c 114 AliFatal("Not implemented.");
30178c30 115
116 return *this;
117}
a9e2aefa 118
a713db22 119//_______________________________________________________
d1cd2474 120Bool_t AliMUONChamber::IsSensId(Int_t volId) const
121{
a713db22 122 // Returns true if the volume specified by volId is in the list
123 // of sesitive volumes for this chamber
d1cd2474 124
125 return fGeometry->IsSensitiveVolume(volId);
126}
127
a9e2aefa 128
a713db22 129//_____________________________________________________
681d067b 130void AliMUONChamber::ChargeCorrelationInit() {
a713db22 131 // Initialisation of charge correlation for current hit
132 // the value is stored, and then used by Disintegration
133 if (fnsec==1)
681d067b 134 fCurrentCorrel =1;
a713db22 135 else
681d067b 136 // exponential is here to avoid eventual problems in 0
16d57990 137 // factor 2 because chargecorrel is q1/q2 and not q1/qtrue
138 fCurrentCorrel = TMath::Exp(gRandom->Gaus(0,fResponse->ChargeCorrel()/2));
681d067b 139}
140
a713db22 141//_______________________________________________________
a713db22 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
a9e2aefa 158
a713db22 159 if (!flag) AliFatal("wrong segmentation type.");
a9e2aefa 160
a713db22 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}
190f97ea 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// }
a9e2aefa 188
a713db22 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();
a9e2aefa 203
a713db22 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}