1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include "AliMUONClusterFinderCOG.h"
21 #include "AliMUONCluster.h"
22 #include "AliMUONVDigit.h"
23 #include "AliMUONPad.h"
24 #include "AliMpArea.h"
26 #include "AliMUONVDigitStore.h"
28 /// \class AliMUONClusterFinderCOG
30 /// A very basic (and mostly useless, probably) cluster finder.
32 /// We use AliMUONPreClusterFinder to actually build the cluster,
33 /// and then we simply use center-of-gravity to get the coordinates
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.
39 /// \author Laurent Aphecetche
42 ClassImp(AliMUONClusterFinderCOG)
45 //_____________________________________________________________________________
46 AliMUONClusterFinderCOG::AliMUONClusterFinderCOG(AliMUONVClusterFinder* clusterFinder)
47 : AliMUONVClusterFinder(),
48 fPreClusterFinder(clusterFinder)
53 //_____________________________________________________________________________
54 AliMUONClusterFinderCOG::~AliMUONClusterFinderCOG()
57 delete fPreClusterFinder;
60 //_____________________________________________________________________________
62 AliMUONClusterFinderCOG::Prepare(const AliMpVSegmentation* segmentations[2],
63 const AliMUONVDigitStore& digitStore)
65 /// Prepare for clustering
67 // Find out the DetElemId
70 TIter next(digitStore.CreateIterator());
73 d = static_cast<AliMUONVDigit*>(next());
77 detElemId = d->DetElemId();
82 AliWarning("Could not find DE. Probably no digits at all ?");
86 return fPreClusterFinder->Prepare(segmentations,digitStore);
89 //_____________________________________________________________________________
91 AliMUONClusterFinderCOG::NextCluster()
95 if ( !fPreClusterFinder ) return 0x0;
96 AliMUONCluster* cluster = fPreClusterFinder->NextCluster();
99 ComputePosition(*cluster);
101 if ( cluster->Charge() < 7 )
104 return NextCluster();
110 //_____________________________________________________________________________
112 AliMUONClusterFinderCOG::ComputePosition(AliMUONCluster& cluster)
114 /// Compute a first estimate of cluster position by a basic center-of-gravity
118 Double_t xmax = -1E9;
119 Double_t ymax = -1E9;
121 Double_t x[] = { 0.0, 0.0 };
122 Double_t y[] = { 0.0, 0.0 };
124 Double_t xsize[] = { 0.0, 0.0 } ;
125 Double_t ysize[] = { 0.0, 0.0 } ;
127 for ( Int_t cathode = 0; cathode < 2; ++cathode )
129 for ( Int_t i = 0; i < cluster.Multiplicity(); ++i )
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() )
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();
146 if ( cluster.Charge(cathode) )
148 x[cathode] /= cluster.Charge(cathode);
149 y[cathode] /= cluster.Charge(cathode);
151 if ( cluster.Multiplicity(cathode) )
153 xsize[cathode] /= cluster.Multiplicity(cathode);
154 ysize[cathode] /= cluster.Multiplicity(cathode);
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];
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]));
170 cluster.SetPosition(TVector2(xCOG,yCOG),cluster.Pad(0)->Dimensions()); // FIXME: what to put as an error here ?