]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHChamber.cxx
Updated SDigitizer; Added AliTOFanalyzeSDigits.C macro
[u/mrichter/AliRoot.git] / RICH / AliRICHChamber.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 /*
17   $Log$
18   Revision 1.13  2001/11/06 18:29:36  dibari
19   minor correcttion of Taligent rules
20
21   Revision 1.12  2001/09/07 08:38:10  hristov
22   Pointers initialised to 0 in the default constructors
23
24   Revision 1.11  2001/05/10 12:35:39  jbarbosa
25   Update.
26
27   Revision 1.10  2001/02/23 17:21:17  jbarbosa
28   Re-definition of IntPH() to accomodate for wire sag effect.
29
30   Revision 1.9  2001/02/13 20:15:34  jbarbosa
31   Removed fNsec (number of cathodes - obsolete) related loops and calls.
32
33   Revision 1.8  2000/12/18 17:45:43  jbarbosa
34   Cleaned up PadHits object.
35
36   Revision 1.7  2000/10/03 21:44:09  morsch
37   Use AliSegmentation and AliHit abstract base classes.
38
39   Revision 1.6  2000/10/02 15:44:37  jbarbosa
40   Fixed forward declarations.
41
42   Revision 1.5  2000/07/13 16:19:45  fca
43   Mainly coding conventions + some small bug fixes
44
45   Revision 1.4  2000/06/30 16:48:58  dibari
46   New function GenerateTresholds() for pedestal simulation.
47
48   Revision 1.3  2000/06/12 15:17:58  jbarbosa
49   Cleaned up version.
50
51   Revision 1.2  2000/05/18 13:45:57  jbarbosa
52   Fixed feedback photon origin coordinates
53
54   Revision 1.1  2000/04/19 12:57:20  morsch
55   Newly structured and updated version (JB, AM)
56
57 */
58
59
60 #include "AliRICHChamber.h"
61
62 #include <TLorentzVector.h>
63 #include <TParticle.h>
64 #include <TRandom.h>
65 #include <TObjArray.h>
66 #include <TRotMatrix.h>
67 #include <AliRICHTresholdMap.h>
68 #include <AliSegmentation.h>
69 #include <AliRICHSegmentationV0.h>
70 #include <AliRICHGeometry.h>
71 #include <AliRICHResponse.h>
72
73 ClassImp(AliRICHChamber)        
74     
75 AliRICHChamber::AliRICHChamber() 
76 {
77 // default ctor
78
79     fpRotMatrix = 0;
80     fSegmentation = 0;
81     fResponse = 0;
82     fGeometry = 0;
83     fReconstruction = 0;
84     fTresh = 0;
85     frMin = 0.1;
86     frMax = 140;
87     for(Int_t i=0; i<50; ++i) fIndexMap[i] = 0;
88 }
89
90 void AliRICHChamber::LocaltoGlobal(Float_t pos[3],Float_t Globalpos[3])
91 {
92 // Local coordinates to global coordinates transformation
93
94     Double_t *pMatrix;
95     pMatrix =  fpRotMatrix->GetMatrix();
96     Globalpos[0]=pos[0]*pMatrix[0]+pos[1]*pMatrix[3]+pos[2]*pMatrix[6];
97     Globalpos[1]=pos[0]*pMatrix[1]+pos[1]*pMatrix[4]+pos[2]*pMatrix[7];
98     Globalpos[2]=pos[0]*pMatrix[2]+pos[1]*pMatrix[5]+pos[2]*pMatrix[8];
99     Globalpos[0]+=fX;
100     Globalpos[1]+=fY;
101     Globalpos[2]+=fZ;
102 }
103
104 void AliRICHChamber::GlobaltoLocal(Float_t pos[3],Float_t Localpos[3])
105 {
106 //
107 // Global coordinates to local coordinates transformation
108 //
109     TMatrix matrixCopy(3,3);
110     Double_t *pMatrixOrig = fpRotMatrix->GetMatrix();
111     for(Int_t i=0;i<3;i++)
112       {
113         for(Int_t j=0;j<3;j++)
114           matrixCopy(j,i)=pMatrixOrig[j+3*i];
115       }
116     matrixCopy.Invert();
117     Localpos[0] = pos[0] - fX;
118     Localpos[1] = pos[1] - fY;
119     Localpos[2] = pos[2] - fZ;
120     Localpos[0]=Localpos[0]*matrixCopy(0,0)+Localpos[1]*matrixCopy(0,1)+Localpos[2]*matrixCopy(0,2);
121     Localpos[1]=Localpos[0]*matrixCopy(1,0)+Localpos[1]*matrixCopy(1,1)+Localpos[2]*matrixCopy(1,2);
122     Localpos[2]=Localpos[0]*matrixCopy(2,0)+Localpos[1]*matrixCopy(2,1)+Localpos[2]*matrixCopy(2,2);
123
124
125 void AliRICHChamber::DisIntegration(Float_t eloss, Float_t xhit, Float_t yhit,
126                                     Int_t& nnew,Float_t newclust[5][500],ResponseType res) 
127 {
128 //    
129 //  Generates pad hits (simulated cluster) 
130 //  using the segmentation and the response model
131     
132     Float_t dx, dy;
133     Float_t local[3];
134     //Float_t source[3];
135     Float_t global[3];
136     //
137     // Width of the integration area
138     //
139     dx=(fResponse->SigmaIntegration())*(fResponse->ChargeSpreadX());
140     dy=(fResponse->SigmaIntegration())*(fResponse->ChargeSpreadY());
141     //
142     // Get pulse height from energy loss and generate feedback photons
143     Float_t qtot=0;
144
145     local[0]=xhit;
146     // z-position of the wires relative to the RICH mother volume 
147     // (2 mmm before CsI) old value: 6.076
148     local[1]=1.276 + fGeometry->GetGapThickness()/2  - .2;
149     //printf("AliRICHChamber feedback origin:%f",local[1]);
150     local[2]=yhit;
151
152     LocaltoGlobal(local,global);
153
154     Int_t nFp=0;
155     
156
157     // To calculate wire sag, the origin of y-position must be the middle of the photcathode
158     AliRICHSegmentationV0* segmentation = (AliRICHSegmentationV0*) GetSegmentationModel();
159     Float_t newy;
160     if (yhit>0)
161       newy = yhit - segmentation->GetPadPlaneLength()/2;
162     else
163       newy = yhit + segmentation->GetPadPlaneLength()/2;
164     
165     if (res==kMip) {
166         qtot = fResponse->IntPH(eloss, newy);
167         nFp  = fResponse->FeedBackPhotons(global,qtot);
168         //printf("feedbacks:%d\n",nFp);
169     } else if (res==kCerenkov) {
170         qtot = fResponse->IntPH(newy);
171         nFp  = fResponse->FeedBackPhotons(global,qtot);
172         //printf("feedbacks:%d\n",nFp);
173     }
174
175     //printf("Feedbacks:%d\n",nFp);
176     
177     //
178     // Loop Over Pads
179     
180     Float_t qcheck=0, qp=0;
181     
182     nnew=0;
183     for (fSegmentation->FirstPad(xhit, yhit, 0, dx, dy); 
184          fSegmentation->MorePads(); 
185          fSegmentation->NextPad()) 
186       {
187         qp= fResponse->IntXY(fSegmentation);
188         qp= TMath::Abs(qp);
189         
190         //printf("Qp:%f Qtot %f\n",qp,qtot);
191         
192         if (qp > 1.e-4) {
193           qcheck+=qp;
194           //
195           // --- store signal information
196           newclust[0][nnew]=qp*qtot;
197           newclust[1][nnew]=fSegmentation->Ix();
198           newclust[2][nnew]=fSegmentation->Iy();
199           newclust[3][nnew]=fSegmentation->ISector();
200           nnew++;       
201           //printf("Newcluster:%d\n",i);
202         }
203       } // Pad loop
204     //if (fSegmentation->ISector()==2)
205       //printf("Nnew:%d\n\n\n\n",nnew);
206 }
207
208
209
210
211 void AliRICHChamber::GenerateTresholds()
212 {
213
214 // Generates random treshold charges for all pads 
215
216   //printf("Pads : %dx%d\n",fSegmentation->Npx(),fSegmentation->Npy());
217
218   Int_t nx = fSegmentation->Npx();
219   Int_t ny = fSegmentation->Npy();
220
221   //Int_t size=nx*ny;
222
223   //printf("Size:%d\n",size);
224
225   fTresh = new AliRICHTresholdMap(fSegmentation);
226
227   //printf("Generating tresholds...\n");
228
229   for(Int_t i=-nx/2;i<nx/2;i++)
230     {
231       for(Int_t j=-ny/2;j<ny/2;j++)
232         {
233           Int_t pedestal = (Int_t)(gRandom->Gaus(50, 10));
234           //Int_t pedestal =0;
235           fTresh->SetHit(i,j,pedestal);
236           //printf("Pad %d %d has pedestal %d.\n",i,j,pedestal);
237         }
238     }
239       
240 }