AliRoot Core  3abf5b4 (3abf5b4)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONPreClusterFinderV3.cxx
Go to the documentation of this file.
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 
19 
20 #include "AliLog.h"
21 #include "AliMUONCluster.h"
22 #include "AliMpVSegmentation.h"
23 #include "TObjArray.h"
24 #include "AliMpArea.h"
25 #include "TVector2.h"
26 #include "AliMUONPad.h"
27 #include "AliMUONVDigit.h"
28 #include "AliMUONVDigitStore.h"
29 #include <Riostream.h>
30 //#include "AliCodeTimer.h"
31 
32 //-----------------------------------------------------------------------------
48 //-----------------------------------------------------------------------------
49 
50 using std::endl;
51 using std::cout;
53 
54 //_____________________________________________________________________________
57  fClusters(new TClonesArray("AliMUONCluster",10)),
58  fkSegmentations(0x0),
59  fPads(0x0),
60  fDetElemId(0),
61  fIterator(0x0)
62 {
64  AliInfo("");
65  for ( Int_t i = 0; i < 2; ++i )
66  {
67  fPreClusters[i] = new TClonesArray("AliMUONCluster",10);
68  }
69 }
70 
71 //_____________________________________________________________________________
73 {
75  delete fClusters;
76  for ( Int_t i = 0; i < 2; ++i )
77  {
78  delete fPreClusters[i];
79  }
80 }
81 
82 //_____________________________________________________________________________
83 Bool_t
85 {
87  if ( pad.DetElemId() != fDetElemId )
88  {
89  AliError(Form("Cannot add pad from DE %d to this cluster finder which is "
90  "currently dealing with DE %d",pad.DetElemId(),fDetElemId));
91  return kFALSE;
92  }
93 
94  AliMUONPad* p = new AliMUONPad(pad);
95  p->SetClusterId(-1);
96  fPads[pad.Cathode()]->Add(p);
97  return kTRUE;
98 }
99 
100 //_____________________________________________________________________________
101 Bool_t
103  TObjArray* pads[2],
104  const AliMpArea& area,
105  const AliMpVSegmentation* seg[2])
106 {
108 
109  if ( area.IsValid() )
110  {
111  AliError("Handling of area not yet implemented for this class. Please check.");
112  }
113 
114  fkSegmentations = seg;
115  fPads = pads;
116 
117  fClusters->Clear("C");
118  for ( Int_t i = 0; i < 2; ++i )
119  {
120  fPreClusters[i]->Clear("C");
121  }
122 
123  fDetElemId = detElemId;
124 
125  if ( fPads[0]->GetLast() < 0 && fPads[1]->GetLast() < 0 )
126  {
127  // no pad at all, nothing to do...
128  return kFALSE;
129  }
130 
133  MakeClusters();
134 
135  delete fIterator;
136  fIterator = fClusters->MakeIterator();
137 
138  return kTRUE;
139 }
140 
141 //_____________________________________________________________________________
142 void
144 {
146  AliMUONCluster *c;
147  TIter next0(fPreClusters[0]);
148  TIter next1(fPreClusters[1]);
149  cout << "Cath0" << endl;
150  while ( ( c = static_cast<AliMUONCluster*>(next0())) )
151  {
152  cout << c->AsString().Data() << endl;
153  }
154  cout << "Cath1" << endl;
155  while ( ( c = static_cast<AliMUONCluster*>(next1())) )
156  {
157  cout << c->AsString().Data() << endl;
158  }
159 }
160 
161 //_____________________________________________________________________________
162 void
164 {
166 
167  AliMUONCluster a(*preCluster);
168 
169  Int_t cathode = preCluster->Cathode();
170  if ( cathode < 0 ) {
171  AliError(Form("Cathod undefined: %d",cathode));
172  AliFatal("");
173  return;
174  }
175 
176  if ( cathode <=1 && !fPreClusters[cathode]->Remove(preCluster) )
177  {
178  AliError(Form("Could not remove %s from preclusters[%d]",
179  preCluster->AsString().Data(),cathode));
180  StdoutToAliDebug(1,DumpPreClusters());
181  AliFatal("");
182  return;
183  }
184 
185  cluster.AddCluster(a);
186 
187  // loop on the *other* cathode
188  TIter next(fPreClusters[1-cathode]);
189  AliMUONCluster* testCluster;
190 
191  while ( ( testCluster = static_cast<AliMUONCluster*>(next())))
192  {
193  if ( AliMUONCluster::AreOverlapping(a,*testCluster) )
194  {
195  AddPreCluster(cluster,testCluster);
196  }
197  }
198 }
199 
200 
201 //_____________________________________________________________________________
202 void
204 {
206  AliMUONPad* addedPad = cluster.AddPad(*pad);
207 
208  Int_t cathode = pad->Cathode();
209  TObjArray& padArray = *fPads[cathode];
210  delete padArray.Remove(pad);
211 
212  TIter next(&padArray);
213  AliMUONPad* testPad;
214 
215  while ( ( testPad = static_cast<AliMUONPad*>(next())))
216  {
217  if ( AliMUONPad::AreNeighbours(*testPad,*addedPad) )
218  {
219  AddPad(cluster,testPad);
220  }
221  }
222 }
223 
224 //_____________________________________________________________________________
227 {
229 
230  return static_cast<AliMUONCluster*>(fIterator->Next());
231 }
232 
233 //_____________________________________________________________________________
234 void
236 {
238 
239 // AliCodeTimerAuto("",0)
240 
241  for ( Int_t cathode = 0; cathode < 2; ++cathode )
242  {
243  TClonesArray& preclusters = *(fPreClusters[cathode]);
244 
245  TIter next(&preclusters);
246  AliMUONCluster* preCluster(0x0);
247 
248  while ( ( preCluster = static_cast<AliMUONCluster*>(next()) ) )
249  {
250  Int_t id(fClusters->GetLast()+1);
251  AliMUONCluster* cluster = new((*fClusters)[id]) AliMUONCluster;
252  cluster->SetUniqueID(id);
253  AddPreCluster(*cluster,preCluster);
254  }
255  }
256 }
257 
258 //_____________________________________________________________________________
259 void
261 {
263 
264 // AliCodeTimerAuto(Form("Cathode %d",cathode),0)
265 
266  while ( fPads[cathode]->GetLast() > 0 )
267  {
268  TIter next(fPads[cathode]);
269  AliMUONPad* pad = static_cast<AliMUONPad*>(next());
270 
271  if (!pad) AliFatal("");
272 
273  Int_t id = fPreClusters[cathode]->GetLast()+1;
274  AliMUONCluster* cluster = new ((*fPreClusters[cathode])[id]) AliMUONCluster;
275  cluster->SetUniqueID(id);
276 
277  // Builds (recursively) a cluster on first cathode only
278  AddPad(*cluster,pad);
279 
280  if ( cluster->Multiplicity() <= 1 )
281  {
282  if ( cluster->Multiplicity() == 0 )
283  {
284  // no pad is suspicious
285  AliWarning("Got an empty cluster...");
286  }
287  // else only 1 pad (not suspicious, but kind of useless, probably noise)
288  // so we remove it from our list
289  fPreClusters[cathode]->Remove(cluster);
290  // then proceed further
291  }
292  }
293 
294 }
TClonesArray * fPreClusters[2]
! the preclusters per cathode (owner)
void AddPreCluster(AliMUONCluster &cluster, AliMUONCluster *preCluster)
Interface of a cluster finder.
static Bool_t AreOverlapping(const AliMUONCluster &c1, const AliMUONCluster &c2)
const AliMpVSegmentation ** fkSegmentations
! segmentations (not owner)
#define TObjArray
Int_t fDetElemId
! which DE we're considering
A group of adjacent pads.
Int_t Cathode() const
TClonesArray * fClusters
! the clusters we've found (owner)
A rectangle area positioned in plane..
Definition: AliMpArea.h:20
void AddPad(AliMUONCluster &cluster, AliMUONPad *pad)
Int_t Multiplicity() const
static Bool_t AreNeighbours(const AliMUONPad &d1, const AliMUONPad &d2)
Definition: AliMUONPad.cxx:167
virtual Bool_t Prepare(Int_t detElemId, TObjArray *pads[2], const AliMpArea &area, const AliMpVSegmentation *seg[2])
virtual AliMUONCluster * NextCluster()
Int_t Cathode() const
Return cathode number.
Definition: AliMUONPad.h:43
TString AsString() const
A basic pre-cluster finder.
AliMUONPad * AddPad(const AliMUONPad &pad)
TObjArray ** fPads
! the pads corresponding to the digits (not owner)
The abstract base class for the segmentation.
Bool_t IsValid() const
Return validity.
Definition: AliMpArea.h:83
TIterator * fIterator
! iterator on fClusters
Int_t DetElemId() const
Return detection element id.
Definition: AliMUONPad.h:53
void SetClusterId(Int_t id)
Set cluster id this pad belongs to -1 if not attached to a cluster.
Definition: AliMUONPad.h:108
ClassImp(AliMUONPreClusterFinderV3) AliMUONPreClusterFinderV3
Combination of digit and mppad informations.
Definition: AliMUONPad.h:25
virtual Bool_t UsePad(const AliMUONPad &pad)
void AddCluster(const AliMUONCluster &cluster)