]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHChamber.cxx
Code cleaning, all wranings removed with new Makefile options
[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  // 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 //______________________________________________________________________________
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& nnew,Float_t newclust[5][500],ResponseType res) 
126 {
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
146     local[1]=1.276 + fGeometry->GetGapThickness()/2  - .2;
147     //printf("AliRICHChamber feedback origin:%f",local[1]);
148     local[2]=yhit;
149
150     LocaltoGlobal(local,global);
151
152     Int_t nFp=0;
153     
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     
163     if (res==kMip) {
164         qtot = fResponse->IntPH(eloss, newy);
165         nFp  = fResponse->FeedBackPhotons(global,qtot);
166         //printf("feedbacks:%d\n",nFp);
167     } else if (res==kCerenkov) {
168         qtot = fResponse->IntPH(newy);
169         nFp  = fResponse->FeedBackPhotons(global,qtot);
170         //printf("feedbacks:%d\n",nFp);
171     }
172
173     //printf("Feedbacks:%d\n",nFp);
174     
175     //
176     // Loop Over Pads
177     
178     Float_t qcheck=0, qp=0;
179     
180     nnew=0;
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         
188         //printf("Qp:%f Qtot %f\n",qp,qtot);
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
202 }//void AliRICHChamber::DisIntegration(...
203 //______________________________________________________________________________
204 void AliRICHChamber::GenerateTresholds()
205 {//Generates random treshold charges for all pads 
206   Int_t nx = fSegmentation->Npx();
207   Int_t ny = fSegmentation->Npy();
208
209   fTresh = new AliRICHTresholdMap(fSegmentation);
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);
214     }
215   }      
216 }//void AliRICHChamber::GenerateTresholds()
217 //______________________________________________________________________________
218 void AliRICHChamber::Print(Option_t *) 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