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