]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONRawCluster.cxx
Fixes for #86059: Install data when ALICE_ROOT does not point to source (Christian)
[u/mrichter/AliRoot.git] / MUON / AliMUONRawCluster.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 //-----------------------------------------------------------------------------
19 // Class AliMUONRawCluster
20 // -------------------------
21 // Class for the MUON RecPoint
22 // It contains the properties of the physics cluters found in the tracking chambers
23 // RawCluster contains also the information from the both cathode of the chambers.
24 //-----------------------------------------------------------------------------
25
26
27 #include "Riostream.h"
28
29 #include <TArrayF.h>
30 #include <TString.h>
31
32 #include "AliMUONRawCluster.h"
33
34 /// \cond CLASSIMP
35 ClassImp(AliMUONRawCluster)
36 /// \endcond
37
38
39 //____________________________________________________
40 AliMUONRawCluster::AliMUONRawCluster() 
41   : AliMUONVCluster(),
42     fClusterType(0),
43     fGhost(0),
44     fDetElemId(0)   
45 {
46 /// Constructor
47     fTracks[0]=fTracks[1]=fTracks[2]=-1; 
48     for (int j=0;j<2;j++) {
49         fQ[j]=0;
50         fX[j]=0;
51         fY[j]=0;
52       fZ[j]=0;
53         fMultiplicity[j]=0;
54         fPeakSignal[j]=-1;
55         fChi2[j]=-1;
56         
57         for (int k=0;k<50;k++) {
58             fIndexMap[k][j]=-1;
59             fOffsetMap[k][j]=0;
60             fContMap[k][j]=0;
61             fPhysicsMap[k]=-1;
62         }
63     }
64     fNcluster[0]=fNcluster[1]=-1;
65     fErrXY[0] = FLT_MAX;
66     fErrXY[1] = FLT_MAX;
67 }
68
69 //____________________________________________________
70 AliMUONRawCluster::~AliMUONRawCluster() 
71 {
72 /// Destructor
73 }
74
75 //____________________________________________________
76 void AliMUONRawCluster::SetDigitsId(Int_t nDigits, const UInt_t *digitsId)
77 {
78   /// Set the array of digit Id
79   /// if digitsId is not given the array is filled with id=0
80   
81   fMultiplicity[0] = (nDigits < 50) ? nDigits : 50;
82   
83   if (fMultiplicity[0] == 0) return;
84   if (digitsId == 0)
85     for (Int_t i=0; i<fMultiplicity[0]; i++) fIndexMap[i][0] = 0;
86   else
87     for (Int_t i=0; i<fMultiplicity[0]; i++) fIndexMap[i][0] = (Int_t) digitsId[i];
88 }
89
90 //____________________________________________________
91 Int_t AliMUONRawCluster::Compare(const TObject *obj) const
92 {
93 /// Compare
94
95   /*
96          AliMUONRawCluster *raw=(AliMUONRawCluster *)obj;
97          Float_t r=GetRadius();
98          Float_t ro=raw->GetRadius();
99          if (r>ro) return 1;
100          else if (r<ro) return -1;
101          else return 0;
102   */
103   /*
104          AliMUONRawCluster *raw=(AliMUONRawCluster *)obj;
105          Float_t y=fY[0];
106          Float_t yo=raw->fY[0];
107          if (y>yo) return 1;
108          else if (y<yo) return -1;
109          else return 0;
110    */
111   
112   const AliMUONRawCluster* raw = static_cast<const AliMUONRawCluster*>(obj);
113   if ( GetCharge() > raw->GetCharge() ) 
114   {
115     return 1;
116   }
117   else if ( GetCharge() < raw->GetCharge() ) 
118   {
119     return -1;
120   }
121   return 0;
122 }
123
124 //____________________________________________________
125 Int_t AliMUONRawCluster::BinarySearch(Float_t y, TArrayF coord, Int_t from, Int_t upto)
126 {
127 /// Find object using a binary search. Array must first have been sorted.
128 /// Search can be limited by setting upto to desired index.
129
130    Int_t low=from, high=upto-1, half;
131    while(high-low>1) {
132         half=(high+low)/2;
133         if(y>coord[half]) low=half;
134         else high=half;
135    }
136    return low;
137 }
138 //____________________________________________________
139 void AliMUONRawCluster::SortMin(Int_t *idx,Float_t *xdarray,Float_t *xarray,Float_t *yarray,Float_t *qarray, Int_t ntr)
140 {
141 /// Get the 3 closest points(cog) one can find on the second cathode 
142 /// starting from a given cog on first cathode
143   
144   //
145   //  Loop over deltax, only 3 times
146   //
147   
148     Float_t xmin;
149     Int_t jmin;
150     Int_t id[3] = {-2,-2,-2};
151     Float_t jx[3] = {0.,0.,0.};
152     Float_t jy[3] = {0.,0.,0.};
153     Float_t jq[3] = {0.,0.,0.};
154     Int_t jid[3] = {-2,-2,-2};
155     Int_t i,j,imax;
156   
157     if (ntr<3) imax=ntr;
158     else imax=3;
159     for(i=0;i<imax;i++){
160         xmin=1001.;
161         jmin=0;
162     
163         for(j=0;j<ntr;j++){
164             if ((i == 1 && j == id[i-1]) 
165                   ||(i == 2 && (j == id[i-1] || j == id[i-2]))) continue;
166            if (TMath::Abs(xdarray[j]) < xmin) {
167               xmin = TMath::Abs(xdarray[j]);
168               jmin=j;
169            }       
170         } // j
171         if (xmin != 1001.) {    
172            id[i]=jmin;
173            jx[i]=xarray[jmin]; 
174            jy[i]=yarray[jmin]; 
175            jq[i]=qarray[jmin]; 
176            jid[i]=idx[jmin];
177         } 
178     
179     }  // i
180   
181     for (i=0;i<3;i++){
182         if (jid[i] == -2) {
183             xarray[i]=1001.;
184             yarray[i]=1001.;
185             qarray[i]=1001.;
186             idx[i]=-1;
187         } else {
188             xarray[i]=jx[i];
189             yarray[i]=jy[i];
190             qarray[i]=jq[i];
191             idx[i]=jid[i];
192         }
193     }
194
195 }
196
197 //____________________________________________________
198 Int_t AliMUONRawCluster::PhysicsContribution() const
199 {
200 /// Evaluate physics contribution to cluster
201   Int_t iPhys=0;
202   Int_t iBg=0;
203   Int_t iMixed=0;
204   for (Int_t i=0; i<fMultiplicity[0]; i++) {
205     if (fPhysicsMap[i]==2) iPhys++;
206     if (fPhysicsMap[i]==1) iMixed++;
207     if (fPhysicsMap[i]==0) iBg++;
208   }
209   if (iMixed==0 && iBg==0) {
210     return 2;
211   } else if ((iPhys != 0 && iBg !=0) || iMixed != 0) {
212     return 1;
213   } else {
214     return 0;
215   }
216 }
217
218 //____________________________________________________
219 void AliMUONRawCluster::Print(Option_t* opt) const
220 {
221   ///
222   /// Printing Raw Cluster (Rec Point) information 
223   /// "full" option for printing all the information about the raw cluster
224   ///
225   TString sopt(opt);
226   sopt.ToUpper();
227  
228   cout << Form("<AliMUONRawCluster>: DetEle=%4d (x,y,z)=(%7.4f,%7.4f,%7.4f) cm"
229                " Chi2=%7.2f Q=%7.2f",
230                GetDetElemId(),GetX(),GetY(),GetZ(),GetChi2(),
231                GetCharge());
232                
233   if ( sopt.Contains("FULL") )
234   {
235     cout << ", Hit=" << setw(4)  << GetTrack(0) <<
236     ", Track1=" <<  setw(4)  << GetTrack(1) <<
237     ", Track2=" <<  setw(4)  << GetTrack(2);
238   }
239   cout << endl;
240 }
241
242 //____________________________________________________
243 void AliMUONRawCluster::DumpIndex(void)
244 {
245 /// Dumping IdexMap of the cluster
246     printf ("-----\n");
247     for (Int_t icat=0;icat<2;icat++) {
248         printf ("Mult %d\n",fMultiplicity[icat]);
249         for (Int_t idig=0;idig<fMultiplicity[icat];idig++){
250             printf("Index %d",fIndexMap[idig][icat]);
251         }
252         printf("\n");
253     }
254 }
255 //____________________________________________________
256 Int_t AliMUONRawCluster::AddCharge(Int_t i, Float_t Q)
257 {
258 /// Adding Q to the fQ value
259   if (i==0 || i==1) {
260     fQ[i]+=Q;
261     return 1;
262   }
263   else  return 0;
264 }
265 //____________________________________________________
266 Int_t AliMUONRawCluster::AddX(Int_t i, Float_t X)
267 {
268 /// Adding X to the fX value
269   if (i==0 || i==1) {
270     fX[i]+=X;
271     return 1;
272   }
273   else  return 0;
274 }
275 //____________________________________________________
276 Int_t AliMUONRawCluster::AddY(Int_t i, Float_t Y)
277 {
278 /// Adding Y to the fY value 
279   if (i==0 || i==1) {
280     fY[i]+=Y;
281     return 1;
282   }
283   else return 0;
284 }
285 //____________________________________________________
286 Int_t AliMUONRawCluster::AddZ(Int_t i, Float_t Z)
287 {
288 /// Adding Z to the fZ value
289   if (i==0 || i==1) {
290     fZ[i]+=Z;
291     return 1;
292   }
293   else return 0;
294 }
295 //____________________________________________________
296 Float_t AliMUONRawCluster::GetCharge(Int_t i) const
297 {
298 /// Getting the charge of the cluster
299   if (i==0 || i==1) return fQ[i];
300   else  return 99999;
301 }
302 //____________________________________________________
303 Float_t AliMUONRawCluster::GetX(Int_t i)  const
304 {
305 /// Getting X value of the cluster
306   if (i==0 || i==1) return fX[i];
307   else  return 99999.;
308 }
309 //____________________________________________________
310 Float_t AliMUONRawCluster::GetY(Int_t i) const 
311 {
312 /// Getting Y value of the cluster
313   if (i==0 || i==1) return fY[i];
314   else  return 99999.;
315 }
316 //____________________________________________________
317 Float_t AliMUONRawCluster::GetZ(Int_t i) const 
318 {
319 /// Getting Z value of the cluster
320   if (i==0 || i==1) return fZ[i];
321   else  return 99999.;
322 }
323 //____________________________________________________
324 Int_t AliMUONRawCluster::GetTrack(Int_t i) const 
325 {
326 /// Getting track i contributing to the cluster
327   if (i==0 || i==1 || i==2) return fTracks[i];
328   else  return 99999;
329 }
330 //____________________________________________________
331 Float_t AliMUONRawCluster::GetPeakSignal(Int_t i) const 
332 {
333 /// Getting cluster peaksignal
334   if (i==0 || i==1 ) return fPeakSignal[i];
335   else  return 99999;
336 }
337 //____________________________________________________
338 Int_t AliMUONRawCluster::GetMultiplicity(Int_t i) const 
339 {
340 /// Getting cluster multiplicity
341   if (i==0 || i==1 ) return fMultiplicity[i];
342   else  return 99999;
343 }
344 //____________________________________________________
345 Int_t AliMUONRawCluster::GetClusterType() const 
346 {
347 /// Getting Cluster Type
348   return fClusterType;
349 }
350 //____________________________________________________
351 Int_t AliMUONRawCluster::GetGhost() const 
352 {
353 /// Getting Ghost
354   return fGhost;
355 }
356 //____________________________________________________
357 Int_t AliMUONRawCluster::GetNcluster(Int_t i) const 
358 {
359 /// Getting number of clusters
360   if (i==0 || i==1 ) return fNcluster[i];
361   else  return 99999;
362 }
363 //____________________________________________________
364 Float_t AliMUONRawCluster::GetChi2(Int_t i) const 
365 {
366 /// Getting chi2 value of the cluster
367   if (i==0 || i==1) return fChi2[i];
368   else  return 99999.;
369 }
370 //____________________________________________________
371 Int_t AliMUONRawCluster::SetCharge(Int_t i, Float_t Q)
372 {
373 /// Setting Charge of the cluster
374   if (i==0 || i==1) {
375     fQ[i]=Q;
376     return 1;
377   }
378   else  return 0;
379 }
380 //____________________________________________________
381 Int_t AliMUONRawCluster::SetX(Int_t i, Float_t X)
382 {
383 /// Setting X value of the cluster
384   if (i==0 || i==1) {
385     fX[i]=X;
386     return 1;
387   }
388   else  return 0;
389 }
390 //____________________________________________________
391 Int_t AliMUONRawCluster::SetY(Int_t i, Float_t Y)
392 {
393 /// Setting Y value of the cluster
394   if (i==0 || i==1) {
395     fY[i]=Y;
396     return 1;
397   }
398   else return 0;
399 }
400 //____________________________________________________
401 Int_t AliMUONRawCluster::SetZ(Int_t i, Float_t Z)
402 {
403 /// Setting Z value of the cluste
404   if (i==0 || i==1) {
405     fZ[i]=Z;
406     return 1;
407   }
408   else return 0;
409 }
410 //____________________________________________________
411 Int_t AliMUONRawCluster::SetTrack(Int_t i, Int_t track)
412 {
413 /// Setting tracks contributing to the cluster
414   if (i==0 || i==1 || i==2) {
415     fTracks[i]=track;
416     return 1;
417   }
418   else return 0;
419 }
420 //____________________________________________________
421 Int_t AliMUONRawCluster::SetPeakSignal(Int_t i, Float_t peaksignal)
422 {
423 /// Setting PeakSignal of the cluster
424   if (i==0 || i==1 ) {
425     fPeakSignal[i]=peaksignal;
426     return 1;
427   }
428   else return 0;
429 }
430 //____________________________________________________
431 Int_t AliMUONRawCluster::SetMultiplicity(Int_t i, Int_t mul)
432 {
433 /// Setting multiplicity of the cluster
434   if (i==0 || i==1 ) {
435     fMultiplicity[i]=mul;
436     return 1;
437   }
438   else return 0;
439 }
440 //____________________________________________________
441 Int_t AliMUONRawCluster::SetClusterType(Int_t type)
442 {
443 /// Setting the cluster type
444   fClusterType=type;
445   return 1;
446 }
447 //____________________________________________________
448 Int_t AliMUONRawCluster::SetGhost(Int_t ghost)
449 {
450 /// Setting the ghost
451   fGhost=ghost;
452   return 1;
453 }
454 //____________________________________________________
455 Int_t AliMUONRawCluster::SetNcluster(Int_t i, Int_t ncluster)
456 {
457 /// Setting number the cluster
458   if (i==0 || i==1 ) {
459     fNcluster[i]=ncluster;
460     return 1;
461   }
462   else return 0;
463 }
464 //____________________________________________________
465 Int_t AliMUONRawCluster::SetChi2(Int_t i, Float_t chi2)
466 {
467 /// Setting chi2 of the cluster
468   if (i==0 || i==1) {
469     fChi2[i]=chi2;
470     return 1;
471   }
472   else return 0;
473 }
474
475