]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHChamber.cxx
AliCRTModule added
[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 "AliRICHParam.h"
18 #include "AliSegmentation.h"
19 #include "AliRICHSegmentationV0.h"
20 #include "AliRICHGeometry.h"
21 #include "AliRICHResponse.h"
22 #include <TRotMatrix.h>
23
24 ClassImp(AliRICHChamber)        
25 //______________________________________________________________________________    
26 AliRICHChamber::AliRICHChamber() 
27 {
28 //default ctor
29   fpParam=0;    
30   fpRotMatrix=0;
31   
32     fSegmentation = 0;
33     fResponse = 0;
34     fGeometry = 0;
35 }
36 //______________________________________________________________________________
37 AliRICHChamber::AliRICHChamber(Int_t iModuleN,AliRICHParam *pParam)
38 {
39 //main ctor. Defines all geometry parameters for the given module.
40   SetToZenith();//put to up position   
41   switch(iModuleN){
42     case 1:
43       RotateX(-pParam->AngleYZ());   
44       RotateZ(-pParam->AngleXY());      
45       fName="RICHc1";fTitle="RICH chamber 1";
46       break;      
47     case 2:
48       RotateZ(-pParam->AngleXY());      
49       fName="RICHc2";fTitle="RICH chamber 2";
50       break;      
51     case 3:
52       RotateX(-pParam->AngleYZ());
53       fName="RICHc3";fTitle="RICH chamber 3";
54       break;      
55     case 4:          
56       fName="RICHc4";fTitle="RICH chamber 4";  //no turns
57       break;      
58     case 5:
59       RotateX(pParam->AngleYZ());
60       fName="RICHc5";fTitle="RICH chamber 5";
61       break;      
62     case 6:
63       RotateZ(pParam->AngleXY());      
64       fName="RICHc6";fTitle="RICH chamber 6";
65       break;      
66     case 7:
67       RotateX(pParam->AngleYZ());            
68       RotateZ(pParam->AngleXY());      
69       fName="RICHc7";fTitle="RICH chamber 7";
70       break;      
71     default:
72       Fatal("named ctor","Wrong chamber number %i, check CreateChamber ctor",iModuleN);
73   }//switch(iModuleN)
74   RotateZ(pParam->AngleRot());//apply common rotation  
75   fpRotMatrix=new TRotMatrix("rot"+fName,"rot"+fName, Rot().ThetaX()*TMath::RadToDeg(), Rot().PhiX()*TMath::RadToDeg(),
76                                                       Rot().ThetaY()*TMath::RadToDeg(), Rot().PhiY()*TMath::RadToDeg(),
77                                                       Rot().ThetaZ()*TMath::RadToDeg(), Rot().PhiZ()*TMath::RadToDeg());
78   fpParam=pParam;
79   fX=fCenterV3.X();fY=fCenterV3.Y();fZ=fCenterV3.Z();
80   
81   fSegmentation = 0;  fResponse = 0;    fGeometry = 0;
82 }
83 //______________________________________________________________________________
84
85 void AliRICHChamber::LocaltoGlobal(Float_t local[3],Float_t global[3])
86 {
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 {
101 // Global coordinates to local coordinates transformation
102     TMatrix matrixCopy(3,3);
103     Double_t *pMatrixOrig = fpRotMatrix->GetMatrix();
104     for(Int_t i=0;i<3;i++)
105       {
106         for(Int_t j=0;j<3;j++)
107           matrixCopy(j,i)=pMatrixOrig[j+3*i];
108       }
109     matrixCopy.Invert();
110     local[0] = global[0] - fX;
111     local[1] = global[1] - fY;
112     local[2] = global[2] - fZ;
113     local[0]=local[0]*matrixCopy(0,0)+local[1]*matrixCopy(0,1)+local[2]*matrixCopy(0,2);
114     local[1]=local[0]*matrixCopy(1,0)+local[1]*matrixCopy(1,1)+local[2]*matrixCopy(1,2);
115     local[2]=local[0]*matrixCopy(2,0)+local[1]*matrixCopy(2,1)+local[2]*matrixCopy(2,2);
116
117
118 void AliRICHChamber::DisIntegration(Float_t eloss, Float_t xhit, Float_t yhit,
119                                     Int_t& iNpads,Float_t cluster[5][500],ResponseType res) 
120 {
121 //Generates pad hits (simulated cluster) using the segmentation and the response model
122
123   Float_t local[3],global[3];
124 // Width of the integration area
125   Float_t dx=(fResponse->SigmaIntegration())*(fResponse->ChargeSpreadX());
126   Float_t dy=(fResponse->SigmaIntegration())*(fResponse->ChargeSpreadY());
127 // Get pulse height from energy loss and generate feedback photons
128   Float_t qtot=0;
129   local[0]=xhit;
130 //z-position of the wires relative to the RICH mother volume (2 mm before CsI) old value: 6.076 ???????
131   local[1]=1.276 + fGeometry->GetGapThickness()/2  - .2;
132   local[2]=yhit;
133
134   LocaltoGlobal(local,global);
135
136
137
138 //To calculate wire sag, the origin of y-position must be the middle of the photcathode
139   AliRICHSegmentationV0* segmentation = (AliRICHSegmentationV0*) GetSegmentationModel();
140   Float_t newy;
141   if (yhit>0)
142     newy = yhit - segmentation->GetPadPlaneLength()/2;
143   else
144     newy = yhit + segmentation->GetPadPlaneLength()/2;
145
146   if(res==kMip){
147     qtot = fResponse->IntPH(eloss, newy);
148     fResponse->FeedBackPhotons(global,qtot);
149   }else if(res==kPhoton){
150     qtot = fResponse->IntPH(newy);
151     fResponse->FeedBackPhotons(global,qtot);
152   }
153
154     // Loop Over Pads
155
156   Float_t qcheck=0, qp=0;
157
158   iNpads=0;
159   for(fSegmentation->FirstPad(xhit, yhit, 0, dx, dy); fSegmentation->MorePads(); 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 }//DisIntegration(...
172 //__________________________________________________________________________________________________
173 void AliRICHChamber::Print(Option_t *) const
174 {
175 //debug printout method 
176   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(),
177                      Rho(), ThetaD(),PhiD(),   X(),    Y(),    Z(),
178                      ThetaXd(),PhiXd(),ThetaYd(),PhiYd(),ThetaZd(),PhiZd());
179 }//Print()
180 //__________________________________________________________________________________________________