new Hits2SDigits.
[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
803d1ab0 16/* $Id$ */
2e5f0f7b 17
18#include "AliRICHChamber.h"
853634d3 19#include "AliRICHConst.h" //for r2d
20#include "AliRICHParam.h"
2e5f0f7b 21#include <TRandom.h>
488e98ba 22#include <TRotMatrix.h>
853634d3 23#include "AliRICHTresholdMap.h"
24#include "AliSegmentation.h"
25#include "AliRICHSegmentationV0.h"
26#include "AliRICHGeometry.h"
27#include "AliRICHResponse.h"
2e5f0f7b 28
29ClassImp(AliRICHChamber)
853634d3 30//______________________________________________________________________________
2e5f0f7b 31AliRICHChamber::AliRICHChamber()
853634d3 32{//default ctor
33 fpParam=0;
34 fpRotMatrix=0;
35
2e5f0f7b 36 fSegmentation = 0;
4faf338d 37 fResponse = 0;
38 fGeometry = 0;
edf34242 39 fReconstruction = 0;
4faf338d 40 fTresh = 0;
41 frMin = 0.1;
42 frMax = 140;
ef42d733 43 for(Int_t i=0; i<50; ++i) fIndexMap[i] = 0;
2e5f0f7b 44}
853634d3 45//______________________________________________________________________________
46AliRICHChamber::AliRICHChamber(Int_t iModuleN,AliRICHParam *pParam)
47{//named ctor. Defines all geometry parameters for the given module.
48 // 4 5 6 |----> X
49 // 1 2 3 |
50 // 0 V Z
51 SetCenter(0,pParam->Offset(),0);//put to 2 position
52 switch(iModuleN){
53 case 0:
54 RotateX(pParam->AngleYZ());
55 fName="RICHc0";fTitle="RICH chamber 0";
56 break;
57 case 1:
58 RotateZ(pParam->AngleXY());
59 fName="RICHc1";fTitle="RICH chamber 1";
60 break;
61 case 2:
62 fName="RICHc2";fTitle="RICH chamber 2";
63 break;
64 case 3:
65 RotateZ(-pParam->AngleXY());
66 fName="RICHc3";fTitle="RICH chamber 3";
67 break;
68 case 4:
69 RotateX(-pParam->AngleYZ()); //ÐÏÒÑÄÏË ×ÁÖÅÎ, ÐÏ×ÏÒÏÔ ÎÅ ËÏÍÕÔÁÔÉ×ÅÎ
70 RotateZ( pParam->AngleXY());
71 fName="RICHc4";fTitle="RICH chamber 4";
72 break;
73 case 5:
74 RotateX(-pParam->AngleYZ());
75 fName="RICHc5";fTitle="RICH chamber 5";
76 break;
77 case 6:
78 RotateX(-pParam->AngleYZ());
79 RotateZ(-pParam->AngleXY());
80 fName="RICHc6";fTitle="RICH chamber 6";
81 break;
82 default:
83 Fatal("named ctor","Wrong chamber number %i, check muster class ctor",iModuleN);
84 }//switch(iModuleN)
85 RotateZ(pParam->AngleRot());//apply common rotation
86 new TRotMatrix("rot"+fName,"rot"+fName, Rot().ThetaX()*r2d, Rot().PhiX()*r2d,
87 Rot().ThetaY()*r2d, Rot().PhiY()*r2d,
88 Rot().ThetaZ()*r2d, Rot().PhiZ()*r2d);
89 fpParam=pParam;
90}
91//______________________________________________________________________________
2e5f0f7b 92
2e5f0f7b 93void AliRICHChamber::LocaltoGlobal(Float_t pos[3],Float_t Globalpos[3])
853634d3 94{//Local coordinates to global coordinates transformation
237c933d 95
2d857021 96 Double_t *pMatrix;
97 pMatrix = fpRotMatrix->GetMatrix();
98 Globalpos[0]=pos[0]*pMatrix[0]+pos[1]*pMatrix[3]+pos[2]*pMatrix[6];
99 Globalpos[1]=pos[0]*pMatrix[1]+pos[1]*pMatrix[4]+pos[2]*pMatrix[7];
100 Globalpos[2]=pos[0]*pMatrix[2]+pos[1]*pMatrix[5]+pos[2]*pMatrix[8];
101 Globalpos[0]+=fX;
102 Globalpos[1]+=fY;
103 Globalpos[2]+=fZ;
2e5f0f7b 104}
105
106void AliRICHChamber::GlobaltoLocal(Float_t pos[3],Float_t Localpos[3])
853634d3 107{// Global coordinates to local coordinates transformation
2d857021 108 TMatrix matrixCopy(3,3);
109 Double_t *pMatrixOrig = fpRotMatrix->GetMatrix();
2e5f0f7b 110 for(Int_t i=0;i<3;i++)
111 {
112 for(Int_t j=0;j<3;j++)
2d857021 113 matrixCopy(j,i)=pMatrixOrig[j+3*i];
2e5f0f7b 114 }
2d857021 115 matrixCopy.Invert();
116 Localpos[0] = pos[0] - fX;
117 Localpos[1] = pos[1] - fY;
118 Localpos[2] = pos[2] - fZ;
119 Localpos[0]=Localpos[0]*matrixCopy(0,0)+Localpos[1]*matrixCopy(0,1)+Localpos[2]*matrixCopy(0,2);
120 Localpos[1]=Localpos[0]*matrixCopy(1,0)+Localpos[1]*matrixCopy(1,1)+Localpos[2]*matrixCopy(1,2);
121 Localpos[2]=Localpos[0]*matrixCopy(2,0)+Localpos[1]*matrixCopy(2,1)+Localpos[2]*matrixCopy(2,2);
2e5f0f7b 122}
123
2e5f0f7b 124void AliRICHChamber::DisIntegration(Float_t eloss, Float_t xhit, Float_t yhit,
176a9917 125 Int_t& nnew,Float_t newclust[5][500],ResponseType res)
2e5f0f7b 126{
2e5f0f7b 127// Generates pad hits (simulated cluster)
128// using the segmentation and the response model
129
130 Float_t dx, dy;
131 Float_t local[3];
132 //Float_t source[3];
133 Float_t global[3];
134 //
135 // Width of the integration area
136 //
137 dx=(fResponse->SigmaIntegration())*(fResponse->ChargeSpreadX());
138 dy=(fResponse->SigmaIntegration())*(fResponse->ChargeSpreadY());
139 //
140 // Get pulse height from energy loss and generate feedback photons
141 Float_t qtot=0;
142
143 local[0]=xhit;
144 // z-position of the wires relative to the RICH mother volume
145 // (2 mmm before CsI) old value: 6.076
64cdfc12 146 local[1]=1.276 + fGeometry->GetGapThickness()/2 - .2;
2e5f0f7b 147 //printf("AliRICHChamber feedback origin:%f",local[1]);
148 local[2]=yhit;
149
150 LocaltoGlobal(local,global);
151
237c933d 152 Int_t nFp=0;
2e5f0f7b 153
733b4fa4 154
155 // To calculate wire sag, the origin of y-position must be the middle of the photcathode
156 AliRICHSegmentationV0* segmentation = (AliRICHSegmentationV0*) GetSegmentationModel();
157 Float_t newy;
158 if (yhit>0)
159 newy = yhit - segmentation->GetPadPlaneLength()/2;
160 else
161 newy = yhit + segmentation->GetPadPlaneLength()/2;
162
237c933d 163 if (res==kMip) {
733b4fa4 164 qtot = fResponse->IntPH(eloss, newy);
237c933d 165 nFp = fResponse->FeedBackPhotons(global,qtot);
b577b475 166 //printf("feedbacks:%d\n",nFp);
237c933d 167 } else if (res==kCerenkov) {
733b4fa4 168 qtot = fResponse->IntPH(newy);
237c933d 169 nFp = fResponse->FeedBackPhotons(global,qtot);
b577b475 170 //printf("feedbacks:%d\n",nFp);
2e5f0f7b 171 }
172
237c933d 173 //printf("Feedbacks:%d\n",nFp);
2e5f0f7b 174
175 //
176 // Loop Over Pads
177
178 Float_t qcheck=0, qp=0;
179
180 nnew=0;
f73582a8 181 for (fSegmentation->FirstPad(xhit, yhit, 0, dx, dy);
182 fSegmentation->MorePads();
183 fSegmentation->NextPad())
184 {
185 qp= fResponse->IntXY(fSegmentation);
186 qp= TMath::Abs(qp);
187
733b4fa4 188 //printf("Qp:%f Qtot %f\n",qp,qtot);
f73582a8 189
190 if (qp > 1.e-4) {
191 qcheck+=qp;
192 //
193 // --- store signal information
194 newclust[0][nnew]=qp*qtot;
195 newclust[1][nnew]=fSegmentation->Ix();
196 newclust[2][nnew]=fSegmentation->Iy();
197 newclust[3][nnew]=fSegmentation->ISector();
198 nnew++;
199 //printf("Newcluster:%d\n",i);
200 }
201 } // Pad loop
853634d3 202}//void AliRICHChamber::DisIntegration(...
203//______________________________________________________________________________
4faf338d 204void AliRICHChamber::GenerateTresholds()
853634d3 205{//Generates random treshold charges for all pads
4faf338d 206 Int_t nx = fSegmentation->Npx();
207 Int_t ny = fSegmentation->Npy();
208
4faf338d 209 fTresh = new AliRICHTresholdMap(fSegmentation);
853634d3 210 for(Int_t i=-nx/2;i<nx/2;i++){
211 for(Int_t j=-ny/2;j<ny/2;j++){
212 Int_t pedestal = (Int_t)(gRandom->Gaus(50, 10));
213 fTresh->SetHit(i,j,pedestal);
4faf338d 214 }
853634d3 215 }
216}//void AliRICHChamber::GenerateTresholds()
217//______________________________________________________________________________
218void AliRICHChamber::Print(Option_t *option) const
219{
220 Info(fName.Data(),"r=%8.3f theta=%5.1f phi=%5.1f x=%8.3f y=%8.3f z=%8.3f",
221 Rho(), Theta()*r2d,Phi()*r2d , X(), Y(), Z());
222}//void AliRICHChamber::Print(Option_t *option)const