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 //-----------------------------------------------------------------------------
29 /// \class AliMUONClusterFinderCOG
31 /// A very basic (and mostly useless, probably) cluster finder.
33 /// We use AliMUONPreClusterFinder to actually build the cluster,
34 /// and then we simply use center-of-gravity to get the coordinates
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.
40 /// \author Laurent Aphecetche
41 //-----------------------------------------------------------------------------
44 ClassImp(AliMUONClusterFinderCOG)
47 //_____________________________________________________________________________
48 AliMUONClusterFinderCOG::AliMUONClusterFinderCOG(AliMUONVClusterFinder* clusterFinder)
49 : AliMUONVClusterFinder(),
50 fPreClusterFinder(clusterFinder)
55 //_____________________________________________________________________________
56 AliMUONClusterFinderCOG::~AliMUONClusterFinderCOG()
59 delete fPreClusterFinder;
62 //_____________________________________________________________________________
64 AliMUONClusterFinderCOG::Prepare(Int_t detElemId,
65 TClonesArray* pads[2],
66 const AliMpArea& area)
68 /// Prepare for clustering
70 return fPreClusterFinder->Prepare(detElemId,pads,area);
73 //_____________________________________________________________________________
75 AliMUONClusterFinderCOG::NextCluster()
79 if ( !fPreClusterFinder ) return 0x0;
80 AliMUONCluster* cluster = fPreClusterFinder->NextCluster();
83 ComputePosition(*cluster);
85 if ( cluster->Charge() < 7 )
94 //_____________________________________________________________________________
96 AliMUONClusterFinderCOG::ComputePosition(AliMUONCluster& cluster)
98 /// Compute a first estimate of cluster position by a basic center-of-gravity
102 Double_t xmax = -1E9;
103 Double_t ymax = -1E9;
105 Double_t x[] = { 0.0, 0.0 };
106 Double_t y[] = { 0.0, 0.0 };
108 Double_t xsize[] = { 0.0, 0.0 } ;
109 Double_t ysize[] = { 0.0, 0.0 } ;
111 for ( Int_t cathode = 0; cathode < 2; ++cathode )
113 for ( Int_t i = 0; i < cluster.Multiplicity(); ++i )
115 AliMUONPad* pad = cluster.Pad(i);
116 TVector2 padPosition = pad->Position();
117 AliMpArea area(pad->Position(),pad->Dimensions());
118 xmin = TMath::Min(area.LeftBorder(),xmin);
119 xmax = TMath::Max(area.RightBorder(),xmax);
120 ymin = TMath::Min(area.DownBorder(),ymin);
121 ymax = TMath::Max(area.UpBorder(),ymax);
122 if ( cathode == pad->Cathode() )
124 x[cathode] += padPosition.X()*pad->Charge();
125 y[cathode] += padPosition.Y()*pad->Charge();
126 xsize[cathode] += pad->Dimensions().X();
127 ysize[cathode] += pad->Dimensions().Y();
130 if ( cluster.Charge(cathode) )
132 x[cathode] /= cluster.Charge(cathode);
133 y[cathode] /= cluster.Charge(cathode);
135 if ( cluster.Multiplicity(cathode) )
137 xsize[cathode] /= cluster.Multiplicity(cathode);
138 ysize[cathode] /= cluster.Multiplicity(cathode);
145 // take the positions from the direction with the better resolution
146 xCOG = ( xsize[0] < xsize[1] ) ? x[0] : x[1];
147 yCOG = ( ysize[0] < ysize[1] ) ? y[0] : y[1];
149 AliDebug(1,Form("Cluster mult %d (x,y)=(%e,%e) boundaries=(xmin,ymin,xmax,ymax)=(%e,%e,%e,%e)"
150 " (x0,y0,x1,y1)=(%e,%e,%e,%e) ",
151 cluster.Multiplicity(),xCOG,yCOG,xmin,ymin,xmax,ymax,
152 x[0],y[0],x[1],y[1]));
154 cluster.SetPosition(TVector2(xCOG,yCOG),cluster.Pad(0)->Dimensions()); // FIXME: what to put as an error here ?