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