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