AliRoot Core  a565103 (a565103)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONSimpleClusterServer.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 "AliCodeTimer.h"
21 #include "AliLog.h"
22 #include "AliMUONCluster.h"
23 #include "AliMUONConstants.h"
25 #include "AliMUONPad.h"
27 #include "AliMUONVCluster.h"
28 #include "AliMUONVClusterFinder.h"
29 #include "AliMUONVClusterStore.h"
30 #include "AliMUONVDigitStore.h"
31 #include "AliMUONRecoParam.h"
32 #include "AliMpArea.h"
33 #include "AliMpDEIterator.h"
34 #include "AliMpDEManager.h"
35 #include "AliMpExMap.h"
36 #include "AliMpExMapIterator.h"
37 #include "AliMpPad.h"
38 #include "AliMpSegmentation.h"
39 #include "AliMpVSegmentation.h"
40 #include <Riostream.h>
41 #include <TObjArray.h>
42 #include <TString.h>
43 #include <float.h>
44 
51 
52 using std::endl;
53 using std::cout;
57 
58 namespace
59 {
60  TString AsString(const AliMpArea& area)
61  {
62  return Form("(X,Y)=(%7.3f,%7.3f) (DX,DY)=(%7.3f,%7.3f)",
63  area.GetPositionX(),
64  area.GetPositionY(),
65  area.GetDimensionX(),
66  area.GetDimensionY());
67  }
68 }
69 
70 //_____________________________________________________________________________
72  const AliMUONGeometryTransformer& transformer)
74  fDigitStore(0x0),
75  fClusterFinder(clusterFinder),
76  fkTransformer(transformer),
77  fPads(),
78  fTriggerTrackStore(0x0),
79  fBypass(0x0)
80 {
83 
84  fPads[0] = new AliMpExMap;
85  fPads[1] = new AliMpExMap;
86 
89 }
90 
91 //_____________________________________________________________________________
93 {
95  delete fClusterFinder;
96  delete fPads[0];
97  delete fPads[1];
98  delete fPadsIterator[0];
99  delete fPadsIterator[1];
100  delete fBypass;
101 }
102 
103 //_____________________________________________________________________________
104 Int_t
106  AliMUONVClusterStore& clusterStore,
107  const AliMpArea& area,
108  const AliMUONRecoParam* recoParam)
109 {
115 
116  AliCodeTimerAuto(Form("Chamber %d",chamberId),0);
117 
118  if ( fTriggerTrackStore && chamberId >= 6 )
119  {
120  return fBypass->GenerateClusters(chamberId,clusterStore);
121  }
122 
123  if (!recoParam) {
124  AliError("Reconstruction parameters are missing: unable to clusterize");
125  return 0;
126  }
127 
128  AliMpDEIterator it;
129 
130  it.First(chamberId);
131 
132  Int_t nofAddedClusters(0);
133  Int_t fNCluster = clusterStore.GetSize();
134 
135  AliDebug(1,Form("chamberId = %2d NofClusters before = %d searchArea=%s",
136  chamberId,fNCluster,AsString(area).Data()));
137 
138  while ( !it.IsDone() )
139  {
140  Int_t detElemId = it.CurrentDEId();
141 
142  TObjArray* pads[2] =
143  {
144  static_cast<TObjArray*>(fPads[0]->GetValue(detElemId)),
145  static_cast<TObjArray*>(fPads[1]->GetValue(detElemId))
146  };
147 
148  if ( ( pads[0] && pads[0]->GetLast()>=0 ) ||
149  ( pads[1] && pads[1]->GetLast()>=0 ) )
150  {
151  AliMpArea deArea; // area in DE-local-coordinates
152  Bool_t ok(kTRUE);
153 
154  if ( area.IsValid() )
155  {
156  ok = Overlap(detElemId,area,deArea);
157  }
158 
159  if ( ok )
160  {
161  const AliMpVSegmentation* seg[2] =
164  };
165 
167  recoParam->LowestClusterCharge());
168 
170  {
171  fClusterFinder->Prepare(detElemId,pads,deArea,seg);
172  }
173  else
174  {
175  fClusterFinder->Prepare(detElemId,pads,deArea);
176  }
177 
178  AliDebug(1,Form("Clusterizing DE %04d with %3d pads (cath0) and %3d pads (cath1)",
179  detElemId,
180  (pads[0] ? pads[0]->GetLast()+1 : 0),
181  (pads[1] ? pads[1]->GetLast()+1 : 0)));
182 
183  AliMUONCluster* cluster;
184 
185  while ( ( cluster = fClusterFinder->NextCluster() ) )
186  {
187  // add new cluster to the store with information to build its ID
188  // increment the number of clusters into the store
189  AliMUONVCluster* rawCluster = clusterStore.Add(chamberId, detElemId, fNCluster++);
190 
191  ++nofAddedClusters;
192 
193  // fill array of Id of digits attached to this cluster
194  Int_t nPad = cluster->Multiplicity();
195  if (nPad < 1) AliWarning("no pad attached to the cluster");
196 
197  for (Int_t iPad=0; iPad<nPad; iPad++)
198  {
199  AliMUONPad *pad = cluster->Pad(iPad);
200 
201  // skip virtual pads
202  if (!pad->IsReal()) continue;
203 
204  rawCluster->AddDigitId(pad->GetUniqueID());
205  }
206 
207  // fill charge and other cluster informations
208  rawCluster->SetCharge(cluster->Charge());
209  rawCluster->SetChi2(cluster->Chi2());
210 
211  Double_t xg, yg, zg;
212  fkTransformer.Local2Global(detElemId,
213  cluster->Position().X(), cluster->Position().Y(),
214  0, xg, yg, zg);
215  rawCluster->SetXYZ(xg, yg, zg);
216  rawCluster->SetErrXY(recoParam->GetDefaultNonBendingReso(chamberId),recoParam->GetDefaultBendingReso(chamberId));
217 
218  // Set MC label
220  {
221  rawCluster->SetMCLabel(FindMCLabel(*cluster, detElemId, seg));
222  }
223 
224  AliDebug(1,Form("Adding RawCluster detElemId %4d mult %2d charge %e (xl,yl,zl)=(%e,%e,%e) (xg,yg,zg)=(%e,%e,%e) label %d",
225  detElemId,rawCluster->GetNDigits(),rawCluster->GetCharge(),
226  cluster->Position().X(),cluster->Position().Y(),0.0,
227  xg,yg,zg,rawCluster->GetMCLabel()));
228  }
229  }
230  }
231  it.Next();
232  }
233 
234  AliDebug(1,Form("chamberId = %2d NofClusters after = %d",chamberId,fNCluster));
235 
236  return nofAddedClusters;
237 }
238 
239 
240 //_____________________________________________________________________________
241 void
242 AliMUONSimpleClusterServer::Global2Local(Int_t detElemId, const AliMpArea& globalArea,
243  AliMpArea& localArea) const
244 {
246 
247  Double_t xl,yl,zl;
248 
249  Int_t chamberId = AliMpDEManager::GetChamberId(detElemId);
250  if ( chamberId < 0 ) {
251  AliErrorStream() << "Cannot get chamberId from detElemId=" << detElemId << endl;
252  return;
253  }
254  Double_t zg = AliMUONConstants::DefaultChamberZ(chamberId);
255 
256  fkTransformer.Global2Local(detElemId,
257  globalArea.GetPositionX(),globalArea.GetPositionY(),zg,
258  xl,yl,zl);
259 
260  localArea = AliMpArea(xl,yl, globalArea.GetDimensionX(), globalArea.GetDimensionY());
261 }
262 
263 //_____________________________________________________________________________
264 Bool_t
266  const AliMpArea& area,
267  AliMpArea& deArea) const
268 {
272 
273  Bool_t overlap(kFALSE);
274 
275  AliMpArea* globalDEArea = fkTransformer.GetDEArea(detElemId);
276 
277  if (!globalDEArea) return kFALSE;
278 
279  AliMpArea overlapArea;
280 
281  if ( area.Overlap(*globalDEArea) )
282  {
283  overlapArea = area.Intersect(*globalDEArea);
284  Global2Local(detElemId,overlapArea,deArea);
285  overlap = kTRUE;
286  }
287  else
288  {
289  deArea = AliMpArea();
290  }
291 
292  AliDebug(1,Form("DE %04d area %s globalDEArea %s overlapArea %s deArea %s overlap=%d",
293  detElemId,
294  AsString(area).Data(),
295  AsString(*globalDEArea).Data(),
296  AsString(overlapArea).Data(),
297  AsString(deArea).Data(),
298  overlap));
299 
300  return overlap;
301 }
302 
303 //_____________________________________________________________________________
304 TObjArray*
305 AliMUONSimpleClusterServer::PadArray(Int_t detElemId, Int_t cathode) const
306 {
308 
309  return static_cast<TObjArray*>(fPads[cathode]->GetValue(detElemId));
310 }
311 
312 //_____________________________________________________________________________
313 Bool_t
315 {
317  fTriggerTrackStore = trackStore; // not owner
318  delete fBypass;
320  return kTRUE;
321 }
322 
323 //_____________________________________________________________________________
324 void
326 {
328 
329  fDigitStore = digitStore;
330 
331  // Clear pads arrays in the maps
332  for ( Int_t i=0; i<2; i++ ) {
333  fPadsIterator[i]->Reset();
334  Int_t key; TObject* obj;
335  while ( ( obj = fPadsIterator[i]->Next(key) ) ) {
336  //cout << "clearing array for detElemId " << key << " ";
337  obj->Clear();
338  }
339  }
340 
341  AliMUONVDigit* d;
342  while ( ( d = static_cast<AliMUONVDigit*>(next()) ) )
343  {
344  if ( ! (d->Charge() > 0.) ) continue; // skip void digits.
345  if ( ! d->IsTracker() ) continue; // skip trigger digits
346  Int_t ix = d->PadX();
347  Int_t iy = d->PadY();
348  Int_t cathode = d->Cathode();
349  Int_t detElemId = d->DetElemId();
351  GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode));
352  AliMpPad pad = seg->PadByIndices(ix,iy);
353 
354  TObjArray* padArray = PadArray(detElemId,cathode);
355  if (!padArray)
356  {
357  padArray = new TObjArray(100);
358  padArray->SetOwner(kTRUE);
359  fPads[cathode]->Add(detElemId,padArray);
360  }
361 
362  AliMUONPad* mpad = new AliMUONPad(detElemId,cathode,
363  ix,iy,pad.GetPositionX(),pad.GetPositionY(),
364  pad.GetDimensionX(),pad.GetDimensionY(),
365  d->Charge());
366  if ( d->IsSaturated() ) mpad->SetSaturated(kTRUE);
367  mpad->SetUniqueID(d->GetUniqueID());
368  padArray->Add(mpad);
369  }
370 }
371 
372 //_____________________________________________________________________________
373 Int_t
374 AliMUONSimpleClusterServer::FindMCLabel(const AliMUONCluster& cluster, Int_t detElemId, const AliMpVSegmentation* seg[2]) const
375 {
378 
379  // --- get the digit (if any) located at the cluster position on both cathods ---
380  Int_t nTracks[2] = {0, 0};
381  AliMUONVDigit* digit[2] = {0x0, 0x0};
382  for (Int_t iCath = 0; iCath < 2; iCath++) {
383  AliMpPad pad
384  = seg[AliMp::GetCathodType(iCath)]->PadByPosition(cluster.Position().X(), cluster.Position().Y(),kFALSE);
385  if (pad.IsValid()) {
386  digit[iCath] = fDigitStore->FindObject(detElemId, pad.GetManuId(), pad.GetManuChannel(), iCath);
387  if (digit[iCath]) nTracks[iCath] = digit[iCath]->Ntracks();
388  }
389  }
390 
391  if (nTracks[0] + nTracks[1] == 0) return -1;
392 
393  // --- build the list of contributing tracks and of the associated charge ---
394  Int_t* trackId = new Int_t[nTracks[0] + nTracks[1]];
395  Float_t* trackCharge = new Float_t[nTracks[0] + nTracks[1]];
396  Int_t nTracksTot = 0;
397 
398  // fill with contributing tracks on first cathod
399  for (Int_t iTrack1 = 0; iTrack1 < nTracks[0]; iTrack1++) {
400  trackId[iTrack1] = digit[0]->Track(iTrack1);
401  trackCharge[iTrack1] = digit[0]->TrackCharge(iTrack1);
402  }
403  nTracksTot = nTracks[0];
404 
405  // complement with contributing tracks on second cathod
406  for (Int_t iTrack2 = 0; iTrack2 < nTracks[1]; iTrack2++) {
407  Int_t trackId2 = digit[1]->Track(iTrack2);
408  // check if track exist
409  Bool_t trackExist = kFALSE;
410  for (Int_t iTrack1 = 0; iTrack1 < nTracks[0]; iTrack1++) {
411  if (trackId2 == trackId[iTrack1]) {
412  // complement existing track
413  trackCharge[iTrack1] += digit[1]->TrackCharge(iTrack2);
414  trackExist = kTRUE;
415  break;
416  }
417  }
418  // add the new track
419  if (!trackExist) {
420  trackId[nTracksTot] = trackId2;
421  trackCharge[nTracksTot] = digit[1]->TrackCharge(iTrack2);
422  nTracksTot++;
423  }
424  }
425 
426  // --- Find the most contributing track ---
427  Int_t mainTrackId = -1;
428  Float_t maxCharge = 0.;
429  for (Int_t iTrack = 0; iTrack < nTracksTot; iTrack++) {
430  if (trackCharge[iTrack] > maxCharge) {
431  mainTrackId = trackId[iTrack];
432  maxCharge = trackCharge[iTrack];
433  }
434  }
435 
436  delete[] trackId;
437  delete[] trackCharge;
438 
439  return mainTrackId;
440 }
441 
442 //_____________________________________________________________________________
443 void
445 {
447 
448  AliMpDEIterator it;
449 
450  it.First();
451 
452  while ( !it.IsDone() )
453  {
454  Int_t detElemId = it.CurrentDEId();
455 
456  // printout the number of pads / de, and number of used pads / de
457 
458  if ( ( PadArray(detElemId,0) && PadArray(detElemId,0)->GetLast() >= 0 ) ||
459  ( PadArray(detElemId,1) && PadArray(detElemId,1)->GetLast() >= 0 ) )
460  {
461  cout << Form("---- DE %04d",detElemId) << endl;
462 
463  for ( Int_t cathode = 0; cathode < 2; ++cathode )
464  {
465  cout << Form(" -- Cathode %1d",cathode) << endl;
466 
467  TObjArray* padArray = PadArray(detElemId,cathode);
468 
469  if (!padArray)
470  {
471  cout << "no pad array" << endl;
472  }
473  else if ( padArray->GetLast() < 0 )
474  {
475  cout << "no pads" << endl;
476  }
477  else
478  {
479  TIter next(padArray);
480  AliMUONPad* pad;
481  while ( ( pad = static_cast<AliMUONPad*>(next()) ) )
482  {
483  pad->Print("full");
484  }
485  }
486  }
487  }
488  it.Next();
489  }
490 }
491 
492 
Bool_t IsReal() const
Return info whether this is a real pad or a virtual one.
Definition: AliMUONPad.h:64
The iterator over detection elements.
Interface of a cluster finder.
const AliMpVSegmentation * GetMpSegmentation(Int_t detElemId, AliMp::CathodType cath, Bool_t warn=true) const
virtual void AddDigitId(UInt_t id)=0
Add a digit Id to the array of associated digits.
Double_t GetDimensionY() const
Return y dimensions.
Definition: AliMpArea.h:81
virtual Int_t PadY() const =0
The y-index of this digit (>=0)
virtual Float_t TrackCharge(Int_t) const
Return the i-th track charge.
Interface for a digit container.
Int_t GenerateClusters(Int_t iChamber, AliMUONVClusterStore &clusterStore) const
Double_t LowestPadCharge() const
Get the lowest charge we allow for pads.
Double_t GetPositionY() const
Return y position.
Definition: AliMpArea.h:77
AliMpArea * GetDEArea(Int_t detElemId) const
static AliMpSegmentation * Instance(Bool_t warn=true)
#define TObjArray
A group of adjacent pads.
Top container class for geometry transformations.
Int_t GetManuId() const
Definition: AliMpPad.cxx:256
Double_t GetDefaultNonBendingReso(Int_t iCh) const
Get the default non bending resolution of chamber iCh.
AliMUONVDigitStore * fDigitStore
! the digit store (not owner)
Bool_t IsDone() const
Interface of a cluster finder for combined tracking.
virtual Int_t GetSize() const =0
The number of objects stored.
Int_t FindMCLabel(const AliMUONCluster &cluster, Int_t detElemId, const AliMpVSegmentation *seg[2]) const
void SetSaturated(Bool_t val)
Set info whether this pad is saturated or not.
Definition: AliMUONPad.h:111
virtual Int_t Track(Int_t) const
Return the i-th track number.
A rectangle area positioned in plane..
Definition: AliMpArea.h:20
Int_t CurrentDEId() const
AliMpExMapIterator * fPadsIterator[2]
iterator for the map of TClonesArray of AliMUONPads
Bool_t Overlap(Int_t detElemId, const AliMpArea &area, AliMpArea &deArea) const
Class with MUON reconstruction parameters.
Int_t Multiplicity() const
virtual Float_t Charge() const =0
The charge of this digit, calibrated or not depending on IsCalibrated()
virtual void SetErrXY(Double_t errX, Double_t errY)=0
Set resolution (cm) on coordinates (X,Y)
virtual Bool_t Prepare(Int_t detElemId, TObjArray *pads[2], const AliMpArea &area)
virtual Bool_t NeedSegmentation() const
virtual AliMpPad PadByIndices(Int_t ix, Int_t iy, Bool_t warning=true) const =0
Find pad by indices.
virtual Int_t DetElemId() const =0
The detection element this digit belongs to.
Double_t LowestClusterCharge() const
Get the lowest possible cluster charge.
AliMUONVClusterFinder * fClusterFinder
! the cluster finder (owner)
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
Int_t GetManuChannel() const
Definition: AliMpPad.cxx:264
virtual Bool_t Add(TObject *object)
Add an object to the store.
virtual void SetXYZ(Double_t x, Double_t y, Double_t z)=0
Set coordinates (cm)
static Int_t GetChamberId(Int_t detElemId, Bool_t warn=true)
void Local2Global(Int_t detElemId, Float_t xl, Float_t yl, Float_t zl, Float_t &xg, Float_t &yg, Float_t &zg) const
return clusterFinder
abstract base class for clusters
Int_t Clusterize(Int_t chamberId, AliMUONVClusterStore &clusterStore, const AliMpArea &area, const AliMUONRecoParam *recoParam=0x0)
Find and add clusters from a given region of a given chamber to the store.
Implementation of AliMUONVClusterServer interface.
AliMUONTriggerTrackToTrackerClusters * fBypass
to convert trigger track into tracker clusters (owner)
Double_t GetDimensionX() const
Return x dimensions.
Definition: AliMpArea.h:79
virtual Int_t Cathode() const =0
Cathode number this digit is on (0 or 1)
AliMpArea Intersect(const AliMpArea &area) const
Definition: AliMpArea.cxx:217
virtual void SetMCLabel(Int_t label)=0
Set the corresponding MC track number.
Double_t GetPositionY() const
Return the pad x position (in cm)
Definition: AliMpPad.h:81
virtual Int_t GetNDigits() const =0
Return number of associated digits.
Interface of a cluster container.
TObject * GetValue(Int_t keyFirst, Int_t keySecond) const
Definition: AliMpExMap.cxx:365
AliMpExMap * fPads[2]
map of TClonesArray of AliMUONPads
Double_t GetDefaultBendingReso(Int_t iCh) const
Get the default bending resolution of chamber iCh.
virtual void SetChargeHints(Double_t, Double_t)
AliMp::CathodType GetCathodType(Int_t cathodNumber)
Convert integer number in enum;.
Base class of a trigger track store.
Double_t GetPositionX() const
Return x position.
Definition: AliMpArea.h:75
AliMUONVTriggerTrackStore * fTriggerTrackStore
trigger track store (if bypassing of St45 was requested) (not owner)
virtual Int_t PadX() const =0
The x-index of this digit (>=0)
void Add(Int_t keyFirst, Int_t keySecond, TObject *object)
Definition: AliMpExMap.cxx:292
virtual void SetChi2(Double_t chi2)=0
Set chi2 of cluster.
TVector2 Position() const
Return (x,y) of that cluster.
virtual Bool_t IsTracker() const
Whether this digit is a tracker digit (false if belongs to trigger)
TObjArray * PadArray(Int_t detElemId, Int_t cathode) const
Bool_t IsValid() const
Return validity.
Definition: AliMpPad.h:89
Float_t Charge() const
virtual AliMpPad PadByPosition(Double_t x, Double_t y, Bool_t warning=true) const =0
Find pad by position.
Convertor of trigger track to tracker clusters.
void Global2Local(Int_t detElemId, Float_t xg, Float_t yg, Float_t zg, Float_t &xl, Float_t &yl, Float_t &zl) const
virtual void SetCharge(Double_t charge)=0
Set the cluster charge.
void Print(Option_t *opt="") const
virtual AliMUONCluster * NextCluster()=0
The abstract base class for the segmentation.
void Global2Local(Int_t detElemId, const AliMpArea &globalArea, AliMpArea &localArea) const
Double_t GetDimensionY() const
Return the y pad dimension - half length (in cm)
Definition: AliMpPad.h:86
virtual Int_t Ntracks() const
Number of tracks contributing to this digit.
static Float_t * DefaultChamberZ()
Return pointer to array of positions.
Bool_t IsValid() const
Return validity.
Definition: AliMpArea.h:83
void UseDigits(TIter &next, AliMUONVDigitStore *digitStore=0x0)
Specify an iterator to loop over the digits needed to perform our job.
void Print(Option_t *opt="") const
Definition: AliMUONPad.cxx:420
ABC of a MUON digit.
Definition: AliMUONVDigit.h:18
Class which encapsuate all information about a pad.
Definition: AliMpPad.h:22
virtual Bool_t IsSaturated() const =0
Whether the ADC has saturated.
Bool_t Overlap(const AliMpArea &area) const
Definition: AliMpArea.cxx:231
Double_t GetPositionX() const
Return the pad x position (in cm)
Definition: AliMpPad.h:79
const AliMUONGeometryTransformer & fkTransformer
! the geometry transformer (not owner)
virtual AliMUONVDigit * FindObject(const TObject *object) const
Find an object (default is to forward to FindObject(object->GetUniqueID())
virtual Bool_t HasMCInformation() const =0
Whether we have any MC related information (e.g. at least one simulated digit)
virtual Double_t GetCharge() const =0
Set the cluster charge.
AliMUONSimpleClusterServer(AliMUONVClusterFinder *clusterFinder, const AliMUONGeometryTransformer &transformer)
AliMUONPad * Pad(Int_t index) const
Double_t GetDimensionX() const
Return the x pad dimension - half length (in cm)
Definition: AliMpPad.h:84
virtual Bool_t UseTriggerTrackStore(AliMUONVTriggerTrackStore *trackStore)
Use trigger tracks. Return kFALSE if not used.
Helper class making Root persistent TExMap.
Definition: AliMpExMap.h:28
Combination of digit and mppad informations.
Definition: AliMUONPad.h:25
AliMpExMapIterator * CreateIterator() const
Definition: AliMpExMap.cxx:357
Float_t Chi2() const
Return chi2 of the RawCharge fit (if any)
virtual Int_t GetMCLabel() const =0
Return the corresponding MC track number.