]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHChamber.cxx
New Local2Global with respect to PC. Old v3 geometry is deleted
[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 #include "AliRICHChamber.h"
17 #include "AliRICHConst.h" //for kR2d
18 #include "AliRICHParam.h"
19 #include <TRandom.h>
20 #include <TRotMatrix.h>
21 #include "AliRICHTresholdMap.h"
22 #include "AliSegmentation.h"
23 #include "AliRICHSegmentationV0.h"
24 #include "AliRICHGeometry.h"
25 #include "AliRICHResponse.h"
26
27 ClassImp(AliRICHChamber)        
28 //______________________________________________________________________________    
29 AliRICHChamber::AliRICHChamber() 
30 {//default ctor
31   fpParam=0;    
32   fpRotMatrix=0;
33   
34     fSegmentation = 0;
35     fResponse = 0;
36     fGeometry = 0;
37     fTresh = 0;
38     for(Int_t i=0; i<50; ++i) fIndexMap[i] = 0;
39 }
40 //______________________________________________________________________________
41 AliRICHChamber::AliRICHChamber(Int_t iModuleN,AliRICHParam *pParam)
42 {//main ctor. Defines all geometry parameters for the given module.
43   SetToZenith();//put to up position   
44   switch(iModuleN){
45     case 1:
46       RotateX(-pParam->AngleYZ());   
47       RotateZ(-pParam->AngleXY());      
48       fName="RICHc1";fTitle="RICH chamber 1";
49       break;      
50     case 2:
51       RotateZ(-pParam->AngleXY());      
52       fName="RICHc2";fTitle="RICH chamber 2";
53       break;      
54     case 3:
55       RotateX(-pParam->AngleYZ());
56       fName="RICHc3";fTitle="RICH chamber 3";
57       break;      
58     case 4:          
59       fName="RICHc4";fTitle="RICH chamber 4";  //no turns
60       break;      
61     case 5:
62       RotateX(pParam->AngleYZ());
63       fName="RICHc5";fTitle="RICH chamber 5";
64       break;      
65     case 6:
66       RotateZ(pParam->AngleXY());      
67       fName="RICHc6";fTitle="RICH chamber 6";
68       break;      
69     case 7:
70       RotateX(pParam->AngleYZ());            
71       RotateZ(pParam->AngleXY());      
72       fName="RICHc7";fTitle="RICH chamber 7";
73       break;      
74     default:
75       Fatal("named ctor","Wrong chamber number %i, check CreateChamber ctor",iModuleN);
76   }//switch(iModuleN)
77   RotateZ(pParam->AngleRot());//apply common rotation  
78   fpRotMatrix=new TRotMatrix("rot"+fName,"rot"+fName, Rot().ThetaX()*kR2d, Rot().PhiX()*kR2d,
79                                                       Rot().ThetaY()*kR2d, Rot().PhiY()*kR2d,
80                                                       Rot().ThetaZ()*kR2d, Rot().PhiZ()*kR2d);
81   fpParam=pParam;
82   fX=fCenterV3.X();fY=fCenterV3.Y();fZ=fCenterV3.Z();
83 }
84 //______________________________________________________________________________
85
86 void AliRICHChamber::LocaltoGlobal(Float_t local[3],Float_t global[3])
87 {//Local coordinates to global coordinates transformation
88
89     Double_t *pMatrix;
90     pMatrix =  fpRotMatrix->GetMatrix();
91     global[0]=local[0]*pMatrix[0]+local[1]*pMatrix[3]+local[2]*pMatrix[6];
92     global[1]=local[0]*pMatrix[1]+local[1]*pMatrix[4]+local[2]*pMatrix[7];
93     global[2]=local[0]*pMatrix[2]+local[1]*pMatrix[5]+local[2]*pMatrix[8];
94     global[0]+=fX;
95     global[1]+=fY;
96     global[2]+=fZ;
97 }
98
99 void AliRICHChamber::GlobaltoLocal(Float_t global[3],Float_t local[3])
100 {// Global coordinates to local coordinates transformation
101     TMatrix matrixCopy(3,3);
102     Double_t *pMatrixOrig = fpRotMatrix->GetMatrix();
103     for(Int_t i=0;i<3;i++)
104       {
105         for(Int_t j=0;j<3;j++)
106           matrixCopy(j,i)=pMatrixOrig[j+3*i];
107       }
108     matrixCopy.Invert();
109     local[0] = global[0] - fX;
110     local[1] = global[1] - fY;
111     local[2] = global[2] - fZ;
112     local[0]=local[0]*matrixCopy(0,0)+local[1]*matrixCopy(0,1)+local[2]*matrixCopy(0,2);
113     local[1]=local[0]*matrixCopy(1,0)+local[1]*matrixCopy(1,1)+local[2]*matrixCopy(1,2);
114     local[2]=local[0]*matrixCopy(2,0)+local[1]*matrixCopy(2,1)+local[2]*matrixCopy(2,2);
115
116
117 void AliRICHChamber::DisIntegration(Float_t eloss, Float_t xhit, Float_t yhit,
118                                     Int_t& iNpads,Float_t cluster[5][500],ResponseType res) 
119 {//Generates pad hits (simulated cluster) using the segmentation and the response model
120
121   Float_t local[3],global[3];
122 // Width of the integration area
123   Float_t dx=(fResponse->SigmaIntegration())*(fResponse->ChargeSpreadX());
124   Float_t dy=(fResponse->SigmaIntegration())*(fResponse->ChargeSpreadY());
125 // Get pulse height from energy loss and generate feedback photons
126   Float_t qtot=0;
127   local[0]=xhit;
128 //z-position of the wires relative to the RICH mother volume (2 mm before CsI) old value: 6.076 ???????
129   local[1]=1.276 + fGeometry->GetGapThickness()/2  - .2;
130   local[2]=yhit;
131
132   LocaltoGlobal(local,global);
133
134
135
136 //To calculate wire sag, the origin of y-position must be the middle of the photcathode
137   AliRICHSegmentationV0* segmentation = (AliRICHSegmentationV0*) GetSegmentationModel();
138   Float_t newy;
139   if (yhit>0)
140     newy = yhit - segmentation->GetPadPlaneLength()/2;
141   else
142     newy = yhit + segmentation->GetPadPlaneLength()/2;
143
144   if(res==kMip){
145     qtot = fResponse->IntPH(eloss, newy);
146     fResponse->FeedBackPhotons(global,qtot);
147   }else if(res==kPhoton){
148     qtot = fResponse->IntPH(newy);
149     fResponse->FeedBackPhotons(global,qtot);
150   }
151
152     // Loop Over Pads
153
154   Float_t qcheck=0, qp=0;
155
156   iNpads=0;
157   for(fSegmentation->FirstPad(xhit, yhit, 0, dx, dy);
158       fSegmentation->MorePads();
159       fSegmentation->NextPad()) {
160     qp= fResponse->IntXY(fSegmentation);
161     qp= TMath::Abs(qp);
162     if(qp >1.e-4){
163       qcheck+=qp;
164       cluster[0][iNpads]=qp*qtot;// --- store signal information
165       cluster[1][iNpads]=fSegmentation->Ix();
166       cluster[2][iNpads]=fSegmentation->Iy();
167       cluster[3][iNpads]=fSegmentation->ISector();
168       iNpads++;
169     }
170   }//pad loop
171 }//void AliRICHChamber::DisIntegration(...
172 //__________________________________________________________________________________________________
173 void AliRICHChamber::GenerateTresholds()
174 {//Generates random treshold charges for all pads
175   Int_t nx = fSegmentation->Npx();
176   Int_t ny = fSegmentation->Npy();
177
178   fTresh = new AliRICHTresholdMap(fSegmentation);
179   for(Int_t i=-nx/2;i<nx/2;i++){
180     for(Int_t j=-ny/2;j<ny/2;j++){
181       Int_t pedestal = (Int_t)(gRandom->Gaus(50, 10));
182       fTresh->SetHit(i,j,pedestal);
183     }
184   }      
185 }//void AliRICHChamber::GenerateTresholds()
186 //__________________________________________________________________________________________________
187 void AliRICHChamber::Print(Option_t *) const
188 {
189   printf("%s r=%8.3f theta=%5.1f phi=%5.1f x=%8.3f y=%8.3f z=%8.3f  %6.2f,%6.2f %6.2f,%6.2f %6.2f,%6.2f\n",fName.Data(),
190                      Rho(), ThetaD(),PhiD(),   X(),    Y(),    Z(),
191                      ThetaXd(),PhiXd(),ThetaYd(),PhiYd(),ThetaZd(),PhiZd());
192 }//void AliRICHChamber::Print(Option_t *option)const
193 //__________________________________________________________________________________________________