]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/DataStructures.cxx
Cleaned up version.
[u/mrichter/AliRoot.git] / RICH / DataStructures.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.2  2000/05/26 17:31:04  jbarbosa
19   New data member (cerenkov angle) in Cerenkov data structure.
20
21   Revision 1.1  2000/04/19 13:32:48  morsch
22   Data classes for RICH (completely updated) (JB,AM)
23
24 */
25
26
27 #include "DataStructures.h"
28 #include "AliRun.h"
29 #include <TObjArray.h>
30 #include <TParticle.h>
31
32 ClassImp(AliRICHPadHit)
33
34 ClassImp(AliRICHHit)
35     
36 //___________________________________________
37 AliRICHHit::AliRICHHit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits):
38     AliHit(shunt, track)
39 {
40     fChamber=vol[0];
41     fParticle=hits[0];
42     fX=hits[1];
43     fY=hits[2];
44     fZ=hits[3];
45     fTheta=hits[4];
46     fPhi=hits[5];
47     fTlength=hits[6];
48     fEloss=hits[7];
49     fPHfirst=(Int_t) hits[8];
50     fPHlast=(Int_t) hits[9];
51     fLoss=hits[13];
52     fMomX=hits[14];
53     fMomY=hits[15];
54     fMomZ=hits[16];
55     fNPads=hits[17];
56 }
57
58 ClassImp(AliRICHCerenkov)
59 //___________________________________________
60 AliRICHCerenkov::AliRICHCerenkov(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits):
61     AliHit(shunt, track)
62 {
63     fChamber=vol[0];
64     fX=hits[1];
65     fY=hits[2];
66     fZ=hits[3];
67     fTheta=hits[4];
68     fPhi=hits[5];
69     fEloss=hits[7];
70     fPHfirst=(Int_t) hits[8];
71     fPHlast=(Int_t) hits[9];
72     fCMother=Int_t(hits[10]);
73     fIndex = hits[11];
74     fProduction = hits[12];  
75     fLoss=hits[13];
76     fMomX=hits[14];
77     fMomY=hits[15];
78     fMomZ=hits[16];
79     fNPads=hits[17];
80     fCerenkovAngle=hits[18];
81 }
82
83 //___________________________________________
84 AliRICHPadHit::AliRICHPadHit(Int_t *clhits)
85 {
86     fHitNumber=clhits[0];
87     fCathode=clhits[1];
88     fQ=clhits[2];
89     fPadX=clhits[3];
90     fPadY=clhits[4];
91     fQpad=clhits[5];
92     fRSec=clhits[6];
93 }
94
95 ClassImp(AliRICHDigit)
96 //_____________________________________________________________________________
97 AliRICHDigit::AliRICHDigit(Int_t *digits)
98 {
99     //
100     // Creates a RICH digit object to be updated
101     //
102     fPadX        = digits[0];
103     fPadY        = digits[1];
104     fSignal      = digits[2];
105     
106 }
107 //_____________________________________________________________________________
108 AliRICHDigit::AliRICHDigit(Int_t *tracks, Int_t *charges, Int_t *digits)
109 {
110     //
111     // Creates a RICH digit object
112     //
113     fPadX        = digits[0];
114     fPadY        = digits[1];
115     fSignal      = digits[2];
116     for(Int_t i=0; i<100; i++) {
117         fTcharges[i]  = charges[i];
118         fTracks[i]    = tracks[i];
119     }
120 }
121
122 ClassImp(AliRICHTransientDigit)
123     
124 //____________________________________________________________________________
125 AliRICHTransientDigit::AliRICHTransientDigit(Int_t ich, Int_t *digits): 
126     AliRICHDigit(digits)
127 {
128     //
129     // Creates a RICH digit list object
130     //
131     
132     fChamber = ich;
133     fTrackList   = new TObjArray;
134     
135 }
136 //_____________________________________________________________________________
137
138
139 ClassImp(AliRICHRawCluster)
140 Int_t AliRICHRawCluster::Compare(TObject *obj)
141 {
142          AliRICHRawCluster *raw=(AliRICHRawCluster *)obj;
143          Float_t y=fY;
144          Float_t yo=raw->fY;
145          if (y>yo) return 1;
146          else if (y<yo) return -1;
147          else return 0;
148
149 }
150
151 Int_t AliRICHRawCluster::
152 BinarySearch(Float_t y, TArrayF coord, Int_t from, Int_t upto)
153 {
154    // Find object using a binary search. Array must first have been sorted.
155    // Search can be limited by setting upto to desired index.
156
157    Int_t low=from, high=upto-1, half;
158    while(high-low>1) {
159         half=(high+low)/2;
160         if(y>coord[half]) low=half;
161         else high=half;
162    }
163    return low;
164 }
165
166 void AliRICHRawCluster::SortMin(Int_t *idx,Float_t *xdarray,Float_t *xarray,Float_t *yarray,Float_t *qarray, Int_t ntr)
167 {
168   //
169   // Get the 3 closest points(cog) one can find on the second cathode 
170   // starting from a given cog on first cathode
171   //
172   
173   //
174   //  Loop over deltax, only 3 times
175   //
176   
177     Float_t xmin;
178     Int_t jmin;
179     Int_t id[3] = {-2,-2,-2};
180     Float_t jx[3] = {0.,0.,0.};
181     Float_t jy[3] = {0.,0.,0.};
182     Float_t jq[3] = {0.,0.,0.};
183     Int_t jid[3] = {-2,-2,-2};
184     Int_t i,j,imax;
185   
186     if (ntr<3) imax=ntr;
187     else imax=3;
188     for(i=0;i<imax;i++){
189         xmin=1001.;
190         jmin=0;
191     
192         for(j=0;j<ntr;j++){
193             if ((i == 1 && j == id[i-1]) 
194                   ||(i == 2 && (j == id[i-1] || j == id[i-2]))) continue;
195            if (TMath::Abs(xdarray[j]) < xmin) {
196               xmin = TMath::Abs(xdarray[j]);
197               jmin=j;
198            }       
199         } // j
200         if (xmin != 1001.) {    
201            id[i]=jmin;
202            jx[i]=xarray[jmin]; 
203            jy[i]=yarray[jmin]; 
204            jq[i]=qarray[jmin]; 
205            jid[i]=idx[jmin];
206         } 
207     
208     }  // i
209   
210     for (i=0;i<3;i++){
211         if (jid[i] == -2) {
212             xarray[i]=1001.;
213             yarray[i]=1001.;
214             qarray[i]=1001.;
215             idx[i]=-1;
216         } else {
217             xarray[i]=jx[i];
218             yarray[i]=jy[i];
219             qarray[i]=jq[i];
220             idx[i]=jid[i];
221         }
222     }
223
224 }
225
226
227 Int_t AliRICHRawCluster::PhysicsContribution()
228 {
229     Int_t iPhys=0;
230     Int_t iBg=0;
231     Int_t iMixed=0;
232     for (Int_t i=0; i<fMultiplicity; i++) {
233         if (fPhysicsMap[i]==2) iPhys++;
234         if (fPhysicsMap[i]==1) iMixed++;
235         if (fPhysicsMap[i]==0) iBg++;
236     }
237     if (iMixed==0 && iBg==0) {
238         return 2;
239     } else if ((iPhys != 0 && iBg !=0) || iMixed != 0) {
240         return 1;
241     } else {
242         return 0;
243     }
244 }
245 //_____________________________________________________________________________
246
247
248 ClassImp(AliRICHRecHit)
249
250
251 //_____________________________________________________________________________
252 AliRICHRecHit::AliRICHRecHit(Int_t id, Float_t *rechit)
253 {
254     //
255     // Creates a RICH rec. hit object
256     //
257     Theta        = rechit[0];
258     Phi          = rechit[1];
259     Omega        = rechit[2];
260     fX           = rechit[3];
261     fY           = rechit[4];
262 }