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