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