]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHChamber.cxx
288e5899af369f729d81581fac53760f8671e82e
[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 /*
17   $Log$
18   Revision 1.3  2000/06/12 15:17:58  jbarbosa
19   Cleaned up version.
20
21   Revision 1.2  2000/05/18 13:45:57  jbarbosa
22   Fixed feedback photon origin coordinates
23
24   Revision 1.1  2000/04/19 12:57:20  morsch
25   Newly structured and updated version (JB, AM)
26
27 */
28
29
30 #include "AliRICHChamber.h"
31
32 #include <TLorentzVector.h>
33 #include <TParticle.h>
34 #include <TRandom.h>
35
36 ClassImp(AliRICHChamber)        
37     
38 AliRICHChamber::AliRICHChamber() 
39 {
40
41 //
42 // Chamber object constructor
43
44     fSegmentation = 0;
45     fResponse = 0;
46     fGeometry = 0;
47     fTresh = 0;
48     frMin = 0.1;
49     frMax = 140;
50     fnsec = 1;
51     fIndexMap[50] = 0;
52 }
53
54 AliRICHChamber::AliRICHChamber(const AliRICHChamber& Chamber)
55 {
56 // Copy Constructor
57 }
58
59
60 AliRICHResponse* AliRICHChamber::GetResponseModel()
61 {
62 //  
63 //  Get reference to response model
64     return fResponse;
65 }
66
67 void   AliRICHChamber::ResponseModel(AliRICHResponse* thisResponse)
68 {
69 // Configure response model
70     fResponse=thisResponse;
71 }
72
73 void AliRICHChamber::Init()
74 {
75 // Initialise chambers
76     fSegmentation->Init(this);
77 }
78
79 void AliRICHChamber::LocaltoGlobal(Float_t pos[3],Float_t Globalpos[3])
80 {
81
82 // Local coordinates to global coordinates transformation
83
84     Double_t *fMatrix;
85     fMatrix =  fChamberMatrix->GetMatrix();
86     Globalpos[0]=pos[0]*fMatrix[0]+pos[1]*fMatrix[3]+pos[2]*fMatrix[6];
87     Globalpos[1]=pos[0]*fMatrix[1]+pos[1]*fMatrix[4]+pos[2]*fMatrix[7];
88     Globalpos[2]=pos[0]*fMatrix[2]+pos[1]*fMatrix[5]+pos[2]*fMatrix[8];
89     Globalpos[0]+=fChamberTrans[0];
90     Globalpos[1]+=fChamberTrans[1];
91     Globalpos[2]+=fChamberTrans[2];
92 }
93
94 void AliRICHChamber::GlobaltoLocal(Float_t pos[3],Float_t Localpos[3])
95 {
96
97 // Global coordinates to local coordinates transformation
98
99     Double_t *fMatrixOrig;
100     TMatrix fMatrixCopy(3,3);
101     fMatrixOrig = fChamberMatrix->GetMatrix();
102     for(Int_t i=0;i<3;i++)
103       {
104         for(Int_t j=0;j<3;j++)
105           fMatrixCopy(j,i)=fMatrixOrig[j+3*i];
106       }
107     fMatrixCopy.Invert();
108     //Int_t elements=fMatrixCopy.GetNoElements();
109     //printf("Elements:%d\n",elements);
110     //fMatrixOrig= (Double_t*) fMatrixCopy;
111     Localpos[0] = pos[0] - fChamberTrans[0];
112     Localpos[1] = pos[1] - fChamberTrans[1];
113     Localpos[2] = pos[2] - fChamberTrans[2];
114     //printf("r1:%f, r2:%f, r3:%f\n",Localpos[0],Localpos[1],Localpos[2]);
115     //printf("t1:%f t2:%f t3:%f\n",fChamberTrans[0],fChamberTrans[1],fChamberTrans[2]);
116     Localpos[0]=Localpos[0]*fMatrixCopy(0,0)+Localpos[1]*fMatrixCopy(0,1)+Localpos[2]*fMatrixCopy(0,2);
117     Localpos[1]=Localpos[0]*fMatrixCopy(1,0)+Localpos[1]*fMatrixCopy(1,1)+Localpos[2]*fMatrixCopy(1,2);
118     Localpos[2]=Localpos[0]*fMatrixCopy(2,0)+Localpos[1]*fMatrixCopy(2,1)+Localpos[2]*fMatrixCopy(2,2);
119     //Localpos[0]-=fChamberTrans[0];
120     //Localpos[1]-=fChamberTrans[1];
121     //Localpos[2]-=fChamberTrans[2];
122
123
124
125 void AliRICHChamber::DisIntegration(Float_t eloss, Float_t xhit, Float_t yhit,
126                                     Int_t& nnew,Float_t newclust[6][500],ResponseType res) 
127 {
128 //    
129 //  Generates pad hits (simulated cluster) 
130 //  using the segmentation and the response model
131     
132     Float_t dx, dy;
133     Float_t local[3];
134     //Float_t source[3];
135     Float_t global[3];
136     //
137     // Width of the integration area
138     //
139     dx=(fResponse->SigmaIntegration())*(fResponse->ChargeSpreadX());
140     dy=(fResponse->SigmaIntegration())*(fResponse->ChargeSpreadY());
141     //
142     // Get pulse height from energy loss and generate feedback photons
143     Float_t qtot=0;
144
145     local[0]=xhit;
146     // z-position of the wires relative to the RICH mother volume 
147     // (2 mmm before CsI) old value: 6.076
148     local[1]=1.276 + fGeometry->GetGapThickness()/2  - .2;
149     //printf("AliRICHChamber feedback origin:%f",local[1]);
150     local[2]=yhit;
151
152     LocaltoGlobal(local,global);
153
154     Int_t nFp=0;
155     
156     if (res==kMip) {
157         qtot = fResponse->IntPH(eloss);
158         nFp  = fResponse->FeedBackPhotons(global,qtot);
159     } else if (res==kCerenkov) {
160         qtot = fResponse->IntPH();
161         nFp  = fResponse->FeedBackPhotons(global,qtot);
162     }
163
164     //printf("Feedbacks:%d\n",nFp);
165     
166     //
167     // Loop Over Pads
168     
169     Float_t qcheck=0, qp=0;
170     
171     nnew=0;
172     for (Int_t i=1; i<=fnsec; i++) {
173         qcheck=0;
174         for (fSegmentation->FirstPad(xhit, yhit, dx, dy); 
175              fSegmentation->MorePads(); 
176              fSegmentation->NextPad()) 
177         {
178             qp= fResponse->IntXY(fSegmentation);
179             qp= TMath::Abs(qp);
180
181             //printf("Qp:%f\n",qp);
182
183             if (qp > 1.e-4) {
184                 qcheck+=qp;
185                 //
186                 // --- store signal information
187                 newclust[0][nnew]=qtot;
188                 newclust[1][nnew]=fSegmentation->Ix();
189                 newclust[2][nnew]=fSegmentation->Iy();
190                 newclust[3][nnew]=qp * qtot;
191                 newclust[4][nnew]=fSegmentation->ISector();
192                 newclust[5][nnew]=(Float_t) i;
193                 nnew++; 
194                 //printf("Newcluster:%d\n",i);
195             }
196         } // Pad loop
197     } // Cathode plane loop
198     //if (fSegmentation->ISector()==2)
199       //printf("Nnew:%d\n\n\n\n",nnew);
200 }
201
202
203 AliRICHChamber& AliRICHChamber::operator=(const AliRICHChamber& rhs)
204 {
205 // Assignment operator
206     return *this;
207     
208 }
209
210
211 void AliRICHChamber::GenerateTresholds()
212 {
213
214 // Generates random treshold charges for all pads 
215
216   //printf("Pads : %dx%d\n",fSegmentation->Npx(),fSegmentation->Npy());
217
218   Int_t nx = fSegmentation->Npx();
219   Int_t ny = fSegmentation->Npy();
220
221   //Int_t size=nx*ny;
222
223   //printf("Size:%d\n",size);
224
225   fTresh = new AliRICHTresholdMap(fSegmentation);
226
227   //printf("Generating tresholds...\n");
228
229   for(Int_t i=-nx/2;i<nx/2;i++)
230     {
231       for(Int_t j=-ny/2;j<ny/2;j++)
232         {
233           Int_t pedestal = (Int_t)(gRandom->Gaus(50, 10));
234           //Int_t pedestal =0;
235           fTresh->SetHit(i,j,pedestal);
236           //printf("Pad %d %d has pedestal %d.\n",i,j,pedestal);
237         }
238     }
239       
240 }