]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONChamber.cxx
Geometry framework classes were made independent from the rest of MUON and linked...
[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     fReconstruction(0),
41     fResponse(0),
42     fGeometry(0)
43 {
44 // Default constructor
45 }
46
47 AliMUONChamber::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)
61 {
62 // Construtor with chamber id 
63     fSegmentation = new TObjArray(2);
64     fSegmentation->AddAt(0,0);
65     fSegmentation->AddAt(0,1);
66
67     fGeometry = new AliMUONGeometryModule(fId);
68 }
69
70 AliMUONChamber::AliMUONChamber(const AliMUONChamber& rChamber)
71   : TObject(rChamber)
72 {
73 // Protected copy constructor
74
75   AliFatal("Not implemented.");
76  // Dummy copy constructor
77 }
78
79 AliMUONChamber::~AliMUONChamber() 
80 {
81 // Destructor
82   if (fSegmentation) {
83     fSegmentation->Delete();
84     delete fSegmentation;
85   }
86   delete fGeometry;
87 }
88
89 AliMUONChamber & AliMUONChamber::operator =(const AliMUONChamber& rhs)
90 {
91 // Protected assignement operator
92
93   if (this == &rhs) return *this;
94
95   AliFatal("Not implemented.");
96     
97   return *this;  
98 }
99
100 Bool_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
108 void AliMUONChamber::Init()
109 {
110 // Initalisation ..
111 //
112 // ... for chamber segmentation
113   //PH    if ((*fSegmentation)[0]) 
114   //PH    ((AliSegmentation *) (*fSegmentation)[0])->Init(fId);
115     if (fSegmentation->At(0)) 
116     ((AliSegmentation *) fSegmentation->At(0))->Init(fId);
117
118     if (fnsec==2) {
119       //PH      if ((*fSegmentation)[1])
120       //PH      ((AliSegmentation *) (*fSegmentation)[1])->Init(fId);
121         if (fSegmentation->At(1))
122         ((AliSegmentation *) fSegmentation->At(1))->Init(fId);
123     }
124 }
125
126 Int_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) {
130       //PH      return ((AliSegmentation*) (*fSegmentation)[0])
131         return ((AliSegmentation*) fSegmentation->At(0))
132             ->SigGenCond(x, y, z) ;
133     } else {
134       //PH      return (((AliSegmentation*) (*fSegmentation)[0])
135         return (((AliSegmentation*) fSegmentation->At(0))
136                 ->SigGenCond(x, y, z)) ||
137       //PH          (((AliSegmentation*) (*fSegmentation)[1])
138             (((AliSegmentation*) fSegmentation->At(1))
139              ->SigGenCond(x, y, z)) ;
140     }
141 }
142
143
144 void    AliMUONChamber::SigGenInit(Float_t x, Float_t y, Float_t z)
145 {
146 //
147 // Initialisation of segmentation for hit
148 //  
149     if (fnsec==1) {
150       //PH      ((AliSegmentation*) (*fSegmentation)[0])->SigGenInit(x, y, z) ;
151         ((AliSegmentation*) fSegmentation->At(0))->SigGenInit(x, y, z) ;
152     } else {
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) ;
157     }
158 }
159
160 void AliMUONChamber::ChargeCorrelationInit() {
161 // Initialisation of charge correlation for current hit
162 // the value is stored, and then used by Disintegration
163 if (fnsec==1) 
164     fCurrentCorrel =1;
165 else 
166     // exponential is here to avoid eventual problems in 0 
167     // factor 2 because chargecorrel is q1/q2 and not q1/qtrue
168     fCurrentCorrel = TMath::Exp(gRandom->Gaus(0,fResponse->ChargeCorrel()/2));
169 }
170
171 void AliMUONChamber::DisIntegration(Float_t eloss, Float_t /*tof*/, 
172                                     Float_t xhit, Float_t yhit, Float_t zhit,
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     
190     Float_t qp; 
191     nnew=0;
192     
193     // Cathode plane loop
194     for (Int_t i=1; i<=fnsec; i++) {
195         Float_t qcath = qtot * (i==1? fCurrentCorrel : 1/fCurrentCorrel);
196         AliSegmentation * segmentation=
197       //PH          (AliSegmentation *) (*fSegmentation)[i-1];
198             (AliSegmentation *) fSegmentation->At(i-1);
199         for (segmentation->FirstPad(xhit, yhit, zhit, dx, dy); 
200              segmentation->MorePads(); 
201              segmentation->NextPad()) 
202         {
203             qp=fResponse->IntXY(segmentation);
204             qp=TMath::Abs(qp);
205 //
206 //
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                 {
212                         AliError("Limit of 500 pad responses reached.");
213                         return;
214                 };
215                 //
216                 // --- store signal information
217                 newclust[0][nnew]=qcath;                     // total charge
218                 newclust[1][nnew]=segmentation->Ix();       // ix-position of pad
219                 newclust[2][nnew]=segmentation->Iy();       // iy-position of pad
220                 newclust[3][nnew]=qp * qcath;                // charge on pad
221                 newclust[4][nnew]=segmentation->ISector();  // sector id
222                 newclust[5][nnew]=(Float_t) i;              // counter
223                 nnew++;
224                 
225             }
226         } // Pad loop
227         
228     } // Cathode plane loop
229 }
230
231
232
233 void AliMUONChamber::InitGeo(Float_t /*zpos*/)
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