]>
Commit | Line | Data |
---|---|---|
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" | |
22 | #include "AliMUONDigit.h" | |
23 | #include "AliMUONPad.h" | |
24 | #include "AliMUONPreClusterFinder.h" | |
25 | #include "AliMpArea.h" | |
26 | #include "TClonesArray.h" | |
27 | #include "TVector2.h" | |
28 | ||
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 | |
41 | ||
42 | /// \nocond CLASSIMP | |
43 | ClassImp(AliMUONClusterFinderCOG) | |
44 | /// \endcond | |
45 | ||
46 | //_____________________________________________________________________________ | |
47 | AliMUONClusterFinderCOG::AliMUONClusterFinderCOG() | |
48 | : AliMUONVClusterFinder(), | |
49 | fPreClusterFinder(0x0) | |
50 | { | |
51 | /// ctor | |
52 | } | |
53 | ||
54 | //_____________________________________________________________________________ | |
55 | AliMUONClusterFinderCOG::~AliMUONClusterFinderCOG() | |
56 | { | |
57 | /// dtor | |
58 | delete fPreClusterFinder; | |
59 | } | |
60 | ||
61 | //_____________________________________________________________________________ | |
62 | Bool_t | |
63 | AliMUONClusterFinderCOG::Prepare(const AliMpVSegmentation* segmentations[2], | |
64 | TClonesArray* digits[2]) | |
65 | { | |
66 | /// Prepare for clustering | |
67 | ||
68 | // Find out the DetElemId | |
69 | Int_t detElemId(-1); | |
70 | ||
71 | for ( Int_t i = 0; i < 2; ++i ) | |
72 | { | |
73 | AliMUONDigit* d = static_cast<AliMUONDigit*>(digits[i]->First()); | |
74 | if (d) | |
75 | { | |
76 | detElemId = d->DetElemId(); | |
77 | break; | |
78 | } | |
79 | } | |
80 | ||
81 | if ( detElemId < 0 ) | |
82 | { | |
83 | AliWarning("Could not find DE. Probably no digits at all ?"); | |
84 | return kFALSE; | |
85 | } | |
86 | ||
87 | delete fPreClusterFinder; | |
88 | fPreClusterFinder = new AliMUONPreClusterFinder; | |
89 | return fPreClusterFinder->Prepare(segmentations,digits); | |
90 | } | |
91 | ||
92 | //_____________________________________________________________________________ | |
93 | AliMUONCluster* | |
94 | AliMUONClusterFinderCOG::NextCluster() | |
95 | { | |
96 | /// Get next cluster | |
97 | ||
98 | if ( !fPreClusterFinder ) return 0x0; | |
99 | AliMUONCluster* cluster = fPreClusterFinder->NextCluster(); | |
100 | if ( cluster ) | |
101 | { | |
102 | ComputePosition(*cluster); | |
103 | ||
104 | if ( cluster->Charge() < 7 ) | |
105 | { | |
106 | // skip that one | |
107 | return NextCluster(); | |
108 | } | |
109 | } | |
110 | return cluster; | |
111 | } | |
112 | ||
113 | //_____________________________________________________________________________ | |
114 | void | |
115 | AliMUONClusterFinderCOG::ComputePosition(AliMUONCluster& cluster) | |
116 | { | |
117 | /// Compute a first estimate of cluster position by a basic center-of-gravity | |
118 | ||
119 | Double_t xmin = 1E9; | |
120 | Double_t ymin = 1E9; | |
121 | Double_t xmax = -1E9; | |
122 | Double_t ymax = -1E9; | |
123 | ||
124 | Double_t x[] = { 0.0, 0.0 }; | |
125 | Double_t y[] = { 0.0, 0.0 }; | |
126 | ||
127 | Double_t xsize[] = { 0.0, 0.0 } ; | |
128 | Double_t ysize[] = { 0.0, 0.0 } ; | |
129 | ||
130 | for ( Int_t cathode = 0; cathode < 2; ++cathode ) | |
131 | { | |
132 | for ( Int_t i = 0; i < cluster.Multiplicity(); ++i ) | |
133 | { | |
134 | AliMUONPad* pad = cluster.Pad(i); | |
135 | TVector2 padPosition = pad->Position(); | |
136 | AliMpArea area(pad->Position(),pad->Dimensions()); | |
137 | xmin = std::min(area.LeftBorder(),xmin); | |
138 | xmax = std::max(area.RightBorder(),xmax); | |
139 | ymin = std::min(area.DownBorder(),ymin); | |
140 | ymax = std::max(area.UpBorder(),ymax); | |
141 | if ( cathode == pad->Cathode() ) | |
142 | { | |
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(); | |
147 | } | |
148 | } | |
149 | if ( cluster.Charge(cathode) ) | |
150 | { | |
151 | x[cathode] /= cluster.Charge(cathode); | |
152 | y[cathode] /= cluster.Charge(cathode); | |
153 | } | |
154 | if ( cluster.Multiplicity(cathode) ) | |
155 | { | |
156 | xsize[cathode] /= cluster.Multiplicity(cathode); | |
157 | ysize[cathode] /= cluster.Multiplicity(cathode); | |
158 | } | |
159 | } | |
160 | ||
161 | Double_t xCOG = 0; | |
162 | Double_t yCOG = 0; | |
163 | ||
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]; | |
167 | ||
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])); | |
172 | ||
173 | cluster.SetPosition(TVector2(xCOG,yCOG),cluster.Pad(0)->Dimensions()); // FIXME: what to put as an error here ? | |
174 | } | |
175 | ||
176 | ||
177 |