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