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