]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONChamber.cxx
f5b79d031dc55415b8ce73d7bc34f3a7b9d324c5
[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 $Log$
17 Revision 1.6  2000/10/09 14:01:12  morsch
18 Double inclusion of AliResponse removed.
19
20 Revision 1.5  2000/07/03 11:54:57  morsch
21 AliMUONSegmentation and AliMUONHitMap have been replaced by AliSegmentation and AliHitMap in STEER
22 The methods GetPadIxy and GetPadXxy of AliMUONSegmentation have changed name to GetPadI and GetPadC.
23
24 Revision 1.4  2000/06/29 12:34:09  morsch
25 AliMUONSegmentation class has been made independent of AliMUONChamber. This makes
26 it usable with any other geometry class. The link to the object to which it belongs is
27 established via an index. This assumes that there exists a global geometry manager
28 from which the pointer to the parent object can be obtained (in our case gAlice).
29
30 Revision 1.3  2000/06/28 15:16:35  morsch
31 (1) Client code adapted to new method signatures in AliMUONSegmentation (see comments there)
32 to allow development of slat-muon chamber simulation and reconstruction code in the MUON
33 framework. The changes should have no side effects (mostly dummy arguments).
34 (2) Hit disintegration uses 3-dim hit coordinates to allow simulation
35 of chambers with overlapping modules (MakePadHits, Disintegration).
36
37 Revision 1.2  2000/06/15 07:58:48  morsch
38 Code from MUON-dev joined
39
40 Revision 1.1.2.5  2000/06/09 21:27:01  morsch
41 Most coding rule violations corrected.
42
43 Revision 1.1.2.4  2000/05/05 11:34:12  morsch
44 Log inside comments.
45
46 Revision 1.1.2.3  2000/05/05 10:09:52  morsch
47 Log messages included
48 */
49
50 // --- MUON includes ---
51 #include "AliMUONChamber.h"
52
53 // --- ROOT includes ---
54
55 #include "TRandom.h"
56 #include "TMath.h"
57
58 ClassImp(AliMUONChamber)        
59
60     AliMUONChamber::AliMUONChamber()
61 {
62 // Default constructor
63     fSegmentation = new TObjArray(2);
64     (*fSegmentation)[0] = 0;
65     (*fSegmentation)[1] = 0;    
66     fResponse=0;
67     fnsec=1;
68     fReconstruction=0;
69     fId=0;
70     // to avoid mistakes if ChargeCorrelInit is not called
71     fChargeCorrel = 0;
72     fCurrentCorrel =1;
73 }
74
75     AliMUONChamber::AliMUONChamber(Int_t id) 
76 {
77 // Construtor with chamber id 
78     fSegmentation = new TObjArray(2);
79     (*fSegmentation)[0] = 0;
80     (*fSegmentation)[1] = 0;    
81     fResponse=0;
82     fnsec=1;
83     fReconstruction=0;
84     fId=id;
85     // to avoid mistakes if ChargeCorrelInit is not called
86     fChargeCorrel = 0;
87     fCurrentCorrel =1;
88 }
89
90 AliMUONChamber::~AliMUONChamber() 
91 {
92 // Destructor
93     if (fSegmentation) delete fSegmentation;
94 }
95
96 AliMUONChamber::AliMUONChamber(const AliMUONChamber& rChamber)
97 {
98 // Dummy copy constructor
99     ;
100 }
101
102
103 void AliMUONChamber::Init()
104 {
105 // Initalisation ..
106 //
107 // ... for chamber segmentation
108     if ((*fSegmentation)[0]) 
109     ((AliSegmentation *) (*fSegmentation)[0])->Init(fId);
110
111     if (fnsec==2) {
112         if ((*fSegmentation)[1])
113         ((AliSegmentation *) (*fSegmentation)[1])->Init(fId);
114     }
115 }
116
117 Int_t   AliMUONChamber::SigGenCond(Float_t x, Float_t y, Float_t z)
118 {
119 // Ask segmentation if signal should be generated 
120     if (fnsec==1) {
121         return ((AliSegmentation*) (*fSegmentation)[0])
122             ->SigGenCond(x, y, z) ;
123     } else {
124         return (((AliSegmentation*) (*fSegmentation)[0])
125                 ->SigGenCond(x, y, z)) ||
126             (((AliSegmentation*) (*fSegmentation)[1])
127              ->SigGenCond(x, y, z)) ;
128     }
129 }
130
131
132 void    AliMUONChamber::SigGenInit(Float_t x, Float_t y, Float_t z)
133 {
134 //
135 // Initialisation of segmentation for hit
136 //  
137     if (fnsec==1) {
138         ((AliSegmentation*) (*fSegmentation)[0])->SigGenInit(x, y, z) ;
139     } else {
140         ((AliSegmentation*) (*fSegmentation)[0])->SigGenInit(x, y, z) ;
141         ((AliSegmentation*) (*fSegmentation)[1])->SigGenInit(x, y, z) ;
142     }
143 }
144
145 void AliMUONChamber::ChargeCorrelationInit() {
146 // Initialisation of charge correlation for current hit
147 // the value is stored, and then used by Disintegration
148 if (fnsec==1) 
149     fCurrentCorrel =1;
150 else 
151     // exponential is here to avoid eventual problems in 0 
152     fCurrentCorrel = TMath::Exp(gRandom->Gaus(0,fChargeCorrel/2));
153 }
154
155 void AliMUONChamber::DisIntegration(Float_t eloss, Float_t tof, 
156                                     Float_t xhit, Float_t yhit, Float_t zhit,
157                                     Int_t& nnew,Float_t newclust[6][500]) 
158 {
159 //    
160 //  Generates pad hits (simulated cluster) 
161 //  using the segmentation and the response model 
162     Float_t dx, dy;
163     //
164     // Width of the integration area
165     //
166     dx=fResponse->SigmaIntegration()*fResponse->ChargeSpreadX();
167     dy=fResponse->SigmaIntegration()*fResponse->ChargeSpreadY();
168     //
169     // Get pulse height from energy loss
170     Float_t qtot = fResponse->IntPH(eloss);
171     //
172     // Loop Over Pads
173     
174     Float_t qcheck=0, qp;
175     nnew=0;
176     
177     // Cathode plane loop
178     for (Int_t i=1; i<=fnsec; i++) {
179         qcheck=0;
180         Float_t qcath = qtot * (i==1? fCurrentCorrel : 1/fCurrentCorrel);
181         AliSegmentation * segmentation=
182             (AliSegmentation *) (*fSegmentation)[i-1];
183         for (segmentation->FirstPad(xhit, yhit, zhit, dx, dy); 
184              segmentation->MorePads(); 
185              segmentation->NextPad()) 
186         {
187             qp=fResponse->IntXY(segmentation);
188             qp=TMath::Abs(qp);
189 //
190 //
191             if (qp > 1.e-4) {
192                 qcheck+=qp*qcath;
193             //
194             // --- store signal information
195                 newclust[0][nnew]=qcath;                     // total charge
196                 newclust[1][nnew]=segmentation->Ix();       // ix-position of pad
197                 newclust[2][nnew]=segmentation->Iy();       // iy-position of pad
198                 newclust[3][nnew]=qp * qcath;                // charge on pad
199                 newclust[4][nnew]=segmentation->ISector();  // sector id
200                 newclust[5][nnew]=(Float_t) i;              // counter
201                 nnew++;
202 //              if (i==2) printf("\n i, nnew, q %d %d %f", i, nnew, qp*qcath);
203                 
204             }
205         } // Pad loop
206         
207     } // Cathode plane loop
208 }
209
210
211
212 void AliMUONChamber::InitGeo(Float_t zpos)
213 {
214 //    sensitive gas gap
215       fdGas= 0.5;
216 //    3% radiation length of aluminum (X0=8.9 cm)      
217       fdAlu= 3.0/100*8.9;
218 }
219
220
221 AliMUONChamber & AliMUONChamber::operator =(const AliMUONChamber& rhs)
222 {
223 // Dummy assignment operator
224     return *this;
225 }