]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONChamber.cxx
Removing old segmentation classes
[u/mrichter/AliRoot.git] / MUON / AliMUONChamber.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 /* $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
31 ClassImp(AliMUONChamber)        
32
33 AliMUONChamber::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 //_______________________________________________________
52 AliMUONChamber::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 //_______________________________________________________
85 AliMUONChamber::AliMUONChamber(const AliMUONChamber& rChamber)
86   : TObject(rChamber)
87 {
88   // Protected copy constructor
89
90   AliFatal("Not implemented.");
91   // Dummy copy constructor
92 }
93
94 //_______________________________________________________
95 AliMUONChamber::~AliMUONChamber() 
96 {
97   // Destructor
98
99   if (fSegmentation2) {
100     fSegmentation2->Delete();
101     delete fSegmentation2;
102   }
103   
104   delete fGeometry;
105 }
106
107 //_______________________________________________________
108 AliMUONChamber & 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 //_______________________________________________________
120 Bool_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 //_____________________________________________________
130 void 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 //_______________________________________________________
142 void 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 //_______________________________________________________
153 void 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 //_________________________________________________________________
172 Int_t   AliMUONChamber::SigGenCond(AliMUONHit *hit)
173 {
174   // Ask segmentation if signal should be generated 
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     return  ((AliMUONGeometrySegmentation*)fSegmentation2->At(0))->SigGenCond(id, x, y, z);
183   } else {
184     return (((AliMUONGeometrySegmentation*) fSegmentation2->At(0))
185             ->SigGenCond(id, x, y, z)) ||
186       (((AliMUONGeometrySegmentation*) fSegmentation2->At(1))
187        ->SigGenCond(id, x, y, z)) ;
188   }
189 }
190
191 //_________________________________________________________________
192 void    AliMUONChamber::SigGenInit(AliMUONHit *hit)
193 {
194   //
195   // Initialisation of segmentation for hit
196   //  
197   Float_t x = hit->X();
198   Float_t y = hit->Y();
199   Float_t z = hit->Z();
200   Int_t  id = hit->DetElemId();
201
202   if (fnsec==1) {
203     ((AliMUONGeometrySegmentation*) fSegmentation2->At(0))->SigGenInit(id, x, y, z) ;
204   } else {
205     ((AliMUONGeometrySegmentation*) fSegmentation2->At(0))->SigGenInit(id, x, y, z) ;
206     ((AliMUONGeometrySegmentation*) fSegmentation2->At(1))->SigGenInit(id, x, y, z) ;
207   }
208 }
209
210 //_______________________________________________________
211 void AliMUONChamber::DisIntegration(AliMUONHit *hit, 
212                                     Int_t& nnew,Float_t newclust[6][500]) 
213 {
214   //    
215   //  Generates pad hits (simulated cluster) 
216   //  using the segmentation and the response model 
217   Float_t dx, dy;
218
219   Float_t  xhit = hit->X();
220   Float_t  yhit = hit->Y();
221   Float_t  zhit = hit->Z();
222   Int_t      id = hit->DetElemId();
223   Float_t eloss = hit->Eloss();
224
225   //
226   // Width of the integration area
227   //
228   dx=fResponse->SigmaIntegration()*fResponse->ChargeSpreadX();
229   dy=fResponse->SigmaIntegration()*fResponse->ChargeSpreadY();
230   //
231   // Get pulse height from energy loss
232   Float_t qtot = fResponse->IntPH(eloss);
233   //
234   // Loop Over Pads
235     
236   Float_t qp; 
237   nnew=0;
238     
239   // Cathode plane loop
240   for (Int_t i=1; i<=fnsec; i++) {
241     Float_t qcath = qtot * (i==1? fCurrentCorrel : 1/fCurrentCorrel);
242
243     AliMUONGeometrySegmentation* segmentation=
244       (AliMUONGeometrySegmentation*) fSegmentation2->At(i-1);
245
246     for (segmentation->FirstPad(id, xhit, yhit, zhit, dx, dy); 
247          segmentation->MorePads(id); 
248          segmentation->NextPad(id)) 
249       {
250         qp=fResponse->IntXY(id, segmentation);
251         qp=TMath::Abs(qp);
252         //
253         //
254         if (qp > 1.e-4) 
255           {
256             if (nnew >= 500) // Perform a bounds check on nnew since it is assumed
257               // newclust only contains 500 elements.
258               {
259                 AliError("Limit of 500 pad responses reached.");
260                 return;
261               };
262             //
263             // --- store signal information
264             newclust[0][nnew]=qcath;                     // total charge
265             newclust[1][nnew]=segmentation->Ix();       // ix-position of pad
266             newclust[2][nnew]=segmentation->Iy();       // iy-position of pad
267             newclust[3][nnew]=qp * qcath;                // charge on pad
268             newclust[4][nnew]=segmentation->ISector();  // sector id
269             newclust[5][nnew]=(Float_t) i;              // counter
270             nnew++;
271                 
272           }
273       } // Pad loop
274   } // Cathode plane loop
275 }