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