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