]>
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" | |
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 | |
28 | /// \class AliMUONClusterFinderCOG | |
29 | /// | |
30 | /// A very basic (and mostly useless, probably) cluster finder. | |
31 | /// | |
32 | /// We use AliMUONPreClusterFinder to actually build the cluster, | |
33 | /// and then we simply use center-of-gravity to get the coordinates | |
34 | /// of the cluster. | |
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. | |
38 | /// | |
39 | /// \author Laurent Aphecetche | |
40 | ||
78649106 | 41 | /// \cond CLASSIMP |
a224d738 | 42 | ClassImp(AliMUONClusterFinderCOG) |
43 | /// \endcond | |
44 | ||
45 | //_____________________________________________________________________________ | |
b1a19e07 | 46 | AliMUONClusterFinderCOG::AliMUONClusterFinderCOG(AliMUONVClusterFinder* clusterFinder) |
a224d738 | 47 | : AliMUONVClusterFinder(), |
b1a19e07 | 48 | fPreClusterFinder(clusterFinder) |
a224d738 | 49 | { |
50 | /// ctor | |
51 | } | |
52 | ||
53 | //_____________________________________________________________________________ | |
54 | AliMUONClusterFinderCOG::~AliMUONClusterFinderCOG() | |
55 | { | |
56 | /// dtor | |
57 | delete fPreClusterFinder; | |
58 | } | |
59 | ||
60 | //_____________________________________________________________________________ | |
61 | Bool_t | |
62 | AliMUONClusterFinderCOG::Prepare(const AliMpVSegmentation* segmentations[2], | |
3887d11e | 63 | const AliMUONVDigitStore& digitStore) |
a224d738 | 64 | { |
65 | /// Prepare for clustering | |
66 | ||
67 | // Find out the DetElemId | |
68 | Int_t detElemId(-1); | |
69 | ||
3887d11e | 70 | TIter next(digitStore.CreateIterator()); |
71 | AliMUONVDigit* d; | |
72 | ||
73 | d = static_cast<AliMUONVDigit*>(next()); | |
74 | ||
75 | if (d) | |
a224d738 | 76 | { |
3887d11e | 77 | detElemId = d->DetElemId(); |
a224d738 | 78 | } |
79 | ||
80 | if ( detElemId < 0 ) | |
81 | { | |
82 | AliWarning("Could not find DE. Probably no digits at all ?"); | |
83 | return kFALSE; | |
84 | } | |
85 | ||
3887d11e | 86 | return fPreClusterFinder->Prepare(segmentations,digitStore); |
a224d738 | 87 | } |
88 | ||
89 | //_____________________________________________________________________________ | |
90 | AliMUONCluster* | |
91 | AliMUONClusterFinderCOG::NextCluster() | |
92 | { | |
93 | /// Get next cluster | |
94 | ||
95 | if ( !fPreClusterFinder ) return 0x0; | |
96 | AliMUONCluster* cluster = fPreClusterFinder->NextCluster(); | |
97 | if ( cluster ) | |
98 | { | |
99 | ComputePosition(*cluster); | |
100 | ||
101 | if ( cluster->Charge() < 7 ) | |
102 | { | |
103 | // skip that one | |
104 | return NextCluster(); | |
105 | } | |
106 | } | |
107 | return cluster; | |
108 | } | |
109 | ||
110 | //_____________________________________________________________________________ | |
111 | void | |
112 | AliMUONClusterFinderCOG::ComputePosition(AliMUONCluster& cluster) | |
113 | { | |
114 | /// Compute a first estimate of cluster position by a basic center-of-gravity | |
115 | ||
116 | Double_t xmin = 1E9; | |
117 | Double_t ymin = 1E9; | |
118 | Double_t xmax = -1E9; | |
119 | Double_t ymax = -1E9; | |
120 | ||
121 | Double_t x[] = { 0.0, 0.0 }; | |
122 | Double_t y[] = { 0.0, 0.0 }; | |
123 | ||
124 | Double_t xsize[] = { 0.0, 0.0 } ; | |
125 | Double_t ysize[] = { 0.0, 0.0 } ; | |
126 | ||
127 | for ( Int_t cathode = 0; cathode < 2; ++cathode ) | |
128 | { | |
129 | for ( Int_t i = 0; i < cluster.Multiplicity(); ++i ) | |
130 | { | |
131 | AliMUONPad* pad = cluster.Pad(i); | |
132 | TVector2 padPosition = pad->Position(); | |
133 | AliMpArea area(pad->Position(),pad->Dimensions()); | |
1b36647b | 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); | |
a224d738 | 138 | if ( cathode == pad->Cathode() ) |
139 | { | |
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(); | |
144 | } | |
145 | } | |
146 | if ( cluster.Charge(cathode) ) | |
147 | { | |
148 | x[cathode] /= cluster.Charge(cathode); | |
149 | y[cathode] /= cluster.Charge(cathode); | |
150 | } | |
151 | if ( cluster.Multiplicity(cathode) ) | |
152 | { | |
153 | xsize[cathode] /= cluster.Multiplicity(cathode); | |
154 | ysize[cathode] /= cluster.Multiplicity(cathode); | |
155 | } | |
156 | } | |
157 | ||
158 | Double_t xCOG = 0; | |
159 | Double_t yCOG = 0; | |
160 | ||
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]; | |
164 | ||
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])); | |
169 | ||
170 | cluster.SetPosition(TVector2(xCOG,yCOG),cluster.Pad(0)->Dimensions()); // FIXME: what to put as an error here ? | |
171 | } | |
172 | ||
173 | ||
174 |