]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHChamber.cxx
some cleaning
[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 /* $Id$ */
17
18 #include "AliRICHChamber.h"
19 #include "AliRICHConst.h" //for r2d
20 #include "AliRICHParam.h"
21 #include <TRandom.h>
22 #include <TRotMatrix.h>
23 #include "AliRICHTresholdMap.h"
24 #include "AliSegmentation.h"
25 #include "AliRICHSegmentationV0.h"
26 #include "AliRICHGeometry.h"
27 #include "AliRICHResponse.h"
28
29 ClassImp(AliRICHChamber)        
30 //______________________________________________________________________________    
31 AliRICHChamber::AliRICHChamber() 
32 {//default ctor
33   fpParam=0;    
34   fpRotMatrix=0;
35   
36     fSegmentation = 0;
37     fResponse = 0;
38     fGeometry = 0;
39     fReconstruction = 0;
40     fTresh = 0;
41     frMin = 0.1;
42     frMax = 140;
43     for(Int_t i=0; i<50; ++i) fIndexMap[i] = 0;
44 }
45 //______________________________________________________________________________
46 AliRICHChamber::AliRICHChamber(Int_t iModuleN,AliRICHParam *pParam)
47 {//named ctor. Defines all geometry parameters for the given module.
48  //   6 7 |----> X
49  // 3 4 5 | 
50  // 1 2   V Z  
51   SetCenter(0,pParam->Offset()-pParam->GapThickness()/2,0);//put to up position   
52   switch(iModuleN){
53     case 1:
54       RotateX(-pParam->AngleYZ());  //ÐÏÒÑÄÏË ×ÁÖÅÎ, ÐÏ×ÏÒÏÔ ÎÅ ËÏÍÕÔÁÔÉ×ÅΠ   
55       RotateZ(-pParam->AngleXY());      
56       fName="RICHc1";fTitle="RICH chamber 1";
57       break;      
58     case 2:
59       RotateZ(-pParam->AngleXY());      
60       fName="RICHc2";fTitle="RICH chamber 2";
61       break;      
62     case 3:
63       RotateX(-pParam->AngleYZ());
64       fName="RICHc3";fTitle="RICH chamber 3";
65       break;      
66     case 4:          
67       fName="RICHc4";fTitle="RICH chamber 4";  //no turns
68       break;      
69     case 5:
70       RotateX(pParam->AngleYZ());
71       fName="RICHc5";fTitle="RICH chamber 5";
72       break;      
73     case 6:
74       RotateZ(pParam->AngleXY());      
75       fName="RICHc6";fTitle="RICH chamber 6";
76       break;      
77     case 7:
78       RotateX(pParam->AngleYZ());            
79       RotateZ(pParam->AngleXY());      
80       fName="RICHc7";fTitle="RICH chamber 7";
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   fpRotMatrix=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 //______________________________________________________________________________
92
93 void AliRICHChamber::LocaltoGlobal(Float_t pos[3],Float_t Globalpos[3])
94 {//Local coordinates to global coordinates transformation
95
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;
104 }
105
106 void AliRICHChamber::GlobaltoLocal(Float_t pos[3],Float_t Localpos[3])
107 {// Global coordinates to local coordinates transformation
108     TMatrix matrixCopy(3,3);
109     Double_t *pMatrixOrig = fpRotMatrix->GetMatrix();
110     for(Int_t i=0;i<3;i++)
111       {
112         for(Int_t j=0;j<3;j++)
113           matrixCopy(j,i)=pMatrixOrig[j+3*i];
114       }
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);
122
123
124 void AliRICHChamber::DisIntegration(Float_t eloss, Float_t xhit, Float_t yhit,
125                                     Int_t& iNpads,Float_t cluster[5][500],ResponseType res) 
126 {//Generates pad hits (simulated cluster) using the segmentation and the response model
127     
128   Float_t local[3];
129   Float_t global[3];
130 // Width of the integration area
131   Float_t dx=(fResponse->SigmaIntegration())*(fResponse->ChargeSpreadX());
132   Float_t dy=(fResponse->SigmaIntegration())*(fResponse->ChargeSpreadY());
133 // Get pulse height from energy loss and generate feedback photons
134   Float_t qtot=0;
135   local[0]=xhit;
136 //z-position of the wires relative to the RICH mother volume (2 mm before CsI) old value: 6.076 ???????
137   local[1]=1.276 + fGeometry->GetGapThickness()/2  - .2;
138   local[2]=yhit;
139
140   LocaltoGlobal(local,global);
141
142   Int_t nFp=0;
143     
144 //To calculate wire sag, the origin of y-position must be the middle of the photcathode
145   AliRICHSegmentationV0* segmentation = (AliRICHSegmentationV0*) GetSegmentationModel();
146   Float_t newy;
147   if (yhit>0)
148     newy = yhit - segmentation->GetPadPlaneLength()/2;
149   else
150     newy = yhit + segmentation->GetPadPlaneLength()/2;
151     
152   if(res==kMip){
153     qtot = fResponse->IntPH(eloss, newy);
154     nFp  = fResponse->FeedBackPhotons(global,qtot);
155   }else if(res==kCerenkov){
156     qtot = fResponse->IntPH(newy);
157     nFp  = fResponse->FeedBackPhotons(global,qtot);
158   }
159
160     // Loop Over Pads
161     
162   Float_t qcheck=0, qp=0;
163     
164   iNpads=0;
165   for(fSegmentation->FirstPad(xhit, yhit, 0, dx, dy); 
166       fSegmentation->MorePads(); 
167       fSegmentation->NextPad()) {
168     qp= fResponse->IntXY(fSegmentation);
169     qp= TMath::Abs(qp);
170     if(qp >1.e-4){
171       qcheck+=qp;
172       cluster[0][iNpads]=qp*qtot;// --- store signal information
173       cluster[1][iNpads]=fSegmentation->Ix();
174       cluster[2][iNpads]=fSegmentation->Iy();
175       cluster[3][iNpads]=fSegmentation->ISector();
176       iNpads++; 
177     }
178   }//pad loop
179 }//void AliRICHChamber::DisIntegration(...
180 //______________________________________________________________________________
181 void AliRICHChamber::GenerateTresholds()
182 {//Generates random treshold charges for all pads 
183   Int_t nx = fSegmentation->Npx();
184   Int_t ny = fSegmentation->Npy();
185
186   fTresh = new AliRICHTresholdMap(fSegmentation);
187   for(Int_t i=-nx/2;i<nx/2;i++){
188     for(Int_t j=-ny/2;j<ny/2;j++){
189       Int_t pedestal = (Int_t)(gRandom->Gaus(50, 10));
190       fTresh->SetHit(i,j,pedestal);
191     }
192   }      
193 }//void AliRICHChamber::GenerateTresholds()
194 //______________________________________________________________________________
195 void AliRICHChamber::Print(Option_t *) const
196 {
197   Info(fName.Data(),"r=%8.3f theta=%5.1f phi=%5.1f x=%8.3f y=%8.3f z=%8.3f\n %5.2f,%5.2f %5.2f,%5.2f %5.2f,%5.2f",
198                      Rho(), Theta()*r2d,Phi()*r2d ,   X(),    Y(),    Z(),
199                      ThetaXd(),PhiXd(),ThetaYd(),PhiYd(),ThetaZd(),PhiZd());
200 }//void AliRICHChamber::Print(Option_t *option)const