]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONClusterFinderCOG.cxx
Fixed a bug in the Digit reader, moved clusterfinder to initialize from OCDB, Added...
[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
24935e58 64AliMUONClusterFinderCOG::Prepare(Int_t detElemId,
65 TClonesArray* pads[2],
66 const AliMpArea& area)
a224d738 67{
68 /// Prepare for clustering
69
24935e58 70 return fPreClusterFinder->Prepare(detElemId,pads,area);
a224d738 71}
72
73//_____________________________________________________________________________
74AliMUONCluster*
75AliMUONClusterFinderCOG::NextCluster()
76{
77 /// Get next cluster
78
79 if ( !fPreClusterFinder ) return 0x0;
80 AliMUONCluster* cluster = fPreClusterFinder->NextCluster();
81 if ( cluster )
82 {
83 ComputePosition(*cluster);
84
85 if ( cluster->Charge() < 7 )
86 {
87 // skip that one
88 return NextCluster();
89 }
90 }
91 return cluster;
92}
93
94//_____________________________________________________________________________
95void
96AliMUONClusterFinderCOG::ComputePosition(AliMUONCluster& cluster)
97{
98 /// Compute a first estimate of cluster position by a basic center-of-gravity
99
100 Double_t xmin = 1E9;
101 Double_t ymin = 1E9;
102 Double_t xmax = -1E9;
103 Double_t ymax = -1E9;
104
105 Double_t x[] = { 0.0, 0.0 };
106 Double_t y[] = { 0.0, 0.0 };
107
108 Double_t xsize[] = { 0.0, 0.0 } ;
109 Double_t ysize[] = { 0.0, 0.0 } ;
110
111 for ( Int_t cathode = 0; cathode < 2; ++cathode )
112 {
113 for ( Int_t i = 0; i < cluster.Multiplicity(); ++i )
114 {
115 AliMUONPad* pad = cluster.Pad(i);
116 TVector2 padPosition = pad->Position();
6e97fbb8 117 AliMpArea area(pad->X(), pad->Y(), pad->DX(), pad->DY());
1b36647b 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);
a224d738 122 if ( cathode == pad->Cathode() )
123 {
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();
128 }
129 }
130 if ( cluster.Charge(cathode) )
131 {
132 x[cathode] /= cluster.Charge(cathode);
133 y[cathode] /= cluster.Charge(cathode);
134 }
135 if ( cluster.Multiplicity(cathode) )
136 {
137 xsize[cathode] /= cluster.Multiplicity(cathode);
138 ysize[cathode] /= cluster.Multiplicity(cathode);
139 }
140 }
141
142 Double_t xCOG = 0;
143 Double_t yCOG = 0;
144
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];
148
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]));
153
154 cluster.SetPosition(TVector2(xCOG,yCOG),cluster.Pad(0)->Dimensions()); // FIXME: what to put as an error here ?
155}
156
157
158