]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONClusterFinderCOG.cxx
Adding author in the class description
[u/mrichter/AliRoot.git] / MUON / AliMUONClusterFinderCOG.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 #include "AliMUONClusterFinderCOG.h"
19
20 #include "AliLog.h"
21 #include "AliMUONCluster.h"
22 #include "AliMUONVDigit.h"
23 #include "AliMUONPad.h"
24 #include "AliMpArea.h"
25 #include "TVector2.h"
26 #include "AliMUONVDigitStore.h"
27
28 /// \class AliMUONClusterFinderCOG
29 ///
30 /// A very basic (and mostly useless, probably) cluster finder.
31 /// 
32 /// We use AliMUONPreClusterFinder to actually build the cluster,
33 /// and then we simply use center-of-gravity to get the coordinates
34 /// of the cluster.
35 /// Only point to note is that we compute separately both
36 /// cathodes when doing, in order to take the positions from the 
37 /// direction with the better resolution.
38 ///
39 /// \author Laurent Aphecetche
40
41 /// \cond CLASSIMP
42 ClassImp(AliMUONClusterFinderCOG)
43 /// \endcond
44
45 //_____________________________________________________________________________
46 AliMUONClusterFinderCOG::AliMUONClusterFinderCOG(AliMUONVClusterFinder* clusterFinder)
47 : AliMUONVClusterFinder(),
48 fPreClusterFinder(clusterFinder)
49 {
50   /// ctor
51 }
52
53 //_____________________________________________________________________________
54 AliMUONClusterFinderCOG::~AliMUONClusterFinderCOG()
55 {
56   /// dtor
57   delete fPreClusterFinder;
58 }
59
60 //_____________________________________________________________________________
61 Bool_t 
62 AliMUONClusterFinderCOG::Prepare(const AliMpVSegmentation* segmentations[2],
63                                  const AliMUONVDigitStore& digitStore)
64 {
65   /// Prepare for clustering
66   
67   // Find out the DetElemId
68   Int_t detElemId(-1);
69   
70   TIter next(digitStore.CreateIterator());
71   AliMUONVDigit* d;
72
73   d = static_cast<AliMUONVDigit*>(next());
74
75   if (d)
76   {
77     detElemId = d->DetElemId();
78   }
79   
80   if ( detElemId < 0 )
81   {
82     AliWarning("Could not find DE. Probably no digits at all ?");
83     return kFALSE;
84   }
85   
86   return fPreClusterFinder->Prepare(segmentations,digitStore);
87 }
88
89 //_____________________________________________________________________________
90 AliMUONCluster* 
91 AliMUONClusterFinderCOG::NextCluster()
92 {
93   /// Get next cluster
94   
95   if ( !fPreClusterFinder ) return 0x0;
96   AliMUONCluster* cluster = fPreClusterFinder->NextCluster();
97   if ( cluster )
98   {
99     ComputePosition(*cluster);
100
101     if ( cluster->Charge() < 7 )
102     {
103       // skip that one
104       return NextCluster();
105     }    
106   }
107   return cluster;
108 }
109
110 //_____________________________________________________________________________
111 void 
112 AliMUONClusterFinderCOG::ComputePosition(AliMUONCluster& cluster)
113 {
114   /// Compute a first estimate of cluster position by a basic center-of-gravity
115   
116   Double_t xmin = 1E9;
117   Double_t ymin = 1E9;
118   Double_t xmax = -1E9;
119   Double_t ymax = -1E9;
120   
121   Double_t x[] = { 0.0, 0.0 };
122   Double_t y[] = { 0.0, 0.0 };
123   
124   Double_t xsize[] = { 0.0, 0.0 } ;
125   Double_t ysize[] = { 0.0, 0.0 } ;
126   
127   for ( Int_t cathode = 0; cathode < 2; ++cathode )
128   {
129     for ( Int_t i = 0; i < cluster.Multiplicity(); ++i )
130     {
131       AliMUONPad* pad = cluster.Pad(i);
132       TVector2 padPosition = pad->Position();
133       AliMpArea area(pad->Position(),pad->Dimensions());
134       xmin = TMath::Min(area.LeftBorder(),xmin);
135       xmax = TMath::Max(area.RightBorder(),xmax);
136       ymin = TMath::Min(area.DownBorder(),ymin);
137       ymax = TMath::Max(area.UpBorder(),ymax);
138       if ( cathode == pad->Cathode() )
139       {
140         x[cathode] += padPosition.X()*pad->Charge();
141         y[cathode] += padPosition.Y()*pad->Charge();
142         xsize[cathode] += pad->Dimensions().X();
143         ysize[cathode] += pad->Dimensions().Y();
144       }
145     }
146     if ( cluster.Charge(cathode) )
147     {
148       x[cathode] /= cluster.Charge(cathode);
149       y[cathode] /= cluster.Charge(cathode);
150     }
151     if ( cluster.Multiplicity(cathode) )
152     {
153       xsize[cathode] /= cluster.Multiplicity(cathode);
154       ysize[cathode] /= cluster.Multiplicity(cathode);
155     }
156   }
157   
158   Double_t xCOG = 0;
159   Double_t yCOG = 0;
160
161   // take the positions from the direction with the better resolution
162   xCOG = ( xsize[0] < xsize[1] ) ? x[0] : x[1];
163   yCOG = ( ysize[0] < ysize[1] ) ? y[0] : y[1];
164   
165   AliDebug(1,Form("Cluster mult %d (x,y)=(%e,%e) boundaries=(xmin,ymin,xmax,ymax)=(%e,%e,%e,%e)"
166                   " (x0,y0,x1,y1)=(%e,%e,%e,%e) ",
167                   cluster.Multiplicity(),xCOG,yCOG,xmin,ymin,xmax,ymax,
168                   x[0],y[0],x[1],y[1]));
169   
170   cluster.SetPosition(TVector2(xCOG,yCOG),cluster.Pad(0)->Dimensions()); // FIXME: what to put as an error here ?
171 }
172
173
174