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