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