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