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