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