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 "AliMUONDigit.h"
23 #include "AliMUONPad.h"
24 #include "AliMUONPreClusterFinder.h"
25 #include "AliMpArea.h"
26 #include "TClonesArray.h"
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
43 ClassImp(AliMUONClusterFinderCOG)
46 //_____________________________________________________________________________
47 AliMUONClusterFinderCOG::AliMUONClusterFinderCOG()
48 : AliMUONVClusterFinder(),
49 fPreClusterFinder(0x0)
54 //_____________________________________________________________________________
55 AliMUONClusterFinderCOG::~AliMUONClusterFinderCOG()
58 delete fPreClusterFinder;
61 //_____________________________________________________________________________
63 AliMUONClusterFinderCOG::Prepare(const AliMpVSegmentation* segmentations[2],
64 TClonesArray* digits[2])
66 /// Prepare for clustering
68 // Find out the DetElemId
71 for ( Int_t i = 0; i < 2; ++i )
73 AliMUONDigit* d = static_cast<AliMUONDigit*>(digits[i]->First());
76 detElemId = d->DetElemId();
83 AliWarning("Could not find DE. Probably no digits at all ?");
87 delete fPreClusterFinder;
88 fPreClusterFinder = new AliMUONPreClusterFinder;
89 return fPreClusterFinder->Prepare(segmentations,digits);
92 //_____________________________________________________________________________
94 AliMUONClusterFinderCOG::NextCluster()
98 if ( !fPreClusterFinder ) return 0x0;
99 AliMUONCluster* cluster = fPreClusterFinder->NextCluster();
102 ComputePosition(*cluster);
104 if ( cluster->Charge() < 7 )
107 return NextCluster();
113 //_____________________________________________________________________________
115 AliMUONClusterFinderCOG::ComputePosition(AliMUONCluster& cluster)
117 /// Compute a first estimate of cluster position by a basic center-of-gravity
121 Double_t xmax = -1E9;
122 Double_t ymax = -1E9;
124 Double_t x[] = { 0.0, 0.0 };
125 Double_t y[] = { 0.0, 0.0 };
127 Double_t xsize[] = { 0.0, 0.0 } ;
128 Double_t ysize[] = { 0.0, 0.0 } ;
130 for ( Int_t cathode = 0; cathode < 2; ++cathode )
132 for ( Int_t i = 0; i < cluster.Multiplicity(); ++i )
134 AliMUONPad* pad = cluster.Pad(i);
135 TVector2 padPosition = pad->Position();
136 AliMpArea area(pad->Position(),pad->Dimensions());
137 xmin = TMath::Min(area.LeftBorder(),xmin);
138 xmax = TMath::Max(area.RightBorder(),xmax);
139 ymin = TMath::Min(area.DownBorder(),ymin);
140 ymax = TMath::Max(area.UpBorder(),ymax);
141 if ( cathode == pad->Cathode() )
143 x[cathode] += padPosition.X()*pad->Charge();
144 y[cathode] += padPosition.Y()*pad->Charge();
145 xsize[cathode] += pad->Dimensions().X();
146 ysize[cathode] += pad->Dimensions().Y();
149 if ( cluster.Charge(cathode) )
151 x[cathode] /= cluster.Charge(cathode);
152 y[cathode] /= cluster.Charge(cathode);
154 if ( cluster.Multiplicity(cathode) )
156 xsize[cathode] /= cluster.Multiplicity(cathode);
157 ysize[cathode] /= cluster.Multiplicity(cathode);
164 // take the positions from the direction with the better resolution
165 xCOG = ( xsize[0] < xsize[1] ) ? x[0] : x[1];
166 yCOG = ( ysize[0] < ysize[1] ) ? y[0] : y[1];
168 AliDebug(1,Form("Cluster mult %d (x,y)=(%e,%e) boundaries=(xmin,ymin,xmax,ymax)=(%e,%e,%e,%e)"
169 " (x0,y0,x1,y1)=(%e,%e,%e,%e) ",
170 cluster.Multiplicity(),xCOG,yCOG,xmin,ymin,xmax,ymax,
171 x[0],y[0],x[1],y[1]));
173 cluster.SetPosition(TVector2(xCOG,yCOG),cluster.Pad(0)->Dimensions()); // FIXME: what to put as an error here ?