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