LCOV - code coverage report
Current view: top level - MUON/MUONrec - AliMUONClusterFinderCOG.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 50 2.0 %
Date: 2016-06-14 17:26:59 Functions: 1 9 11.1 %

          Line data    Source code
       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 "AliMUONVDigit.h"
      23             : #include "AliMUONPad.h"
      24             : #include "AliMpArea.h"
      25             : #include "TVector2.h"
      26             : #include "AliMUONVDigitStore.h"
      27             : 
      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             : 
      43             : /// \cond CLASSIMP
      44          18 : ClassImp(AliMUONClusterFinderCOG)
      45             : /// \endcond
      46             : 
      47             : //_____________________________________________________________________________
      48             : AliMUONClusterFinderCOG::AliMUONClusterFinderCOG(AliMUONVClusterFinder* clusterFinder)
      49           0 : : AliMUONVClusterFinder(),
      50           0 : fPreClusterFinder(clusterFinder)
      51           0 : {
      52             :   /// ctor
      53           0 : }
      54             : 
      55             : //_____________________________________________________________________________
      56             : AliMUONClusterFinderCOG::~AliMUONClusterFinderCOG()
      57           0 : {
      58             :   /// dtor
      59           0 :   delete fPreClusterFinder;
      60           0 : }
      61             : 
      62             : //_____________________________________________________________________________
      63             : Bool_t 
      64             : AliMUONClusterFinderCOG::Prepare(Int_t detElemId,
      65             :                                  TObjArray* pads[2],
      66             :                                  const AliMpArea& area)
      67             : {
      68             :   /// Prepare for clustering
      69             :   
      70           0 :   return fPreClusterFinder->Prepare(detElemId,pads,area);
      71             : }
      72             : 
      73             : //_____________________________________________________________________________
      74             : AliMUONCluster* 
      75             : AliMUONClusterFinderCOG::NextCluster()
      76             : {
      77             :   /// Get next cluster
      78             :   
      79           0 :   if ( !fPreClusterFinder ) return 0x0;
      80           0 :   AliMUONCluster* cluster = fPreClusterFinder->NextCluster();
      81           0 :   if ( cluster )
      82             :   {
      83           0 :     ComputePosition(*cluster);
      84             : 
      85           0 :     if ( cluster->Charge() < 1.0675 ) // JC: adc -> fc
      86             :     {
      87             :       // skip that one
      88           0 :       return NextCluster();
      89             :     }    
      90             :   }
      91           0 :   return cluster;
      92           0 : }
      93             : 
      94             : //_____________________________________________________________________________
      95             : void 
      96             : AliMUONClusterFinderCOG::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           0 :   Double_t x[] = { 0.0, 0.0 };
     106           0 :   Double_t y[] = { 0.0, 0.0 };
     107             :   
     108           0 :   Double_t xsize[] = { 0.0, 0.0 } ;
     109           0 :   Double_t ysize[] = { 0.0, 0.0 } ;
     110             :   
     111           0 :   for ( Int_t cathode = 0; cathode < 2; ++cathode )
     112             :   {
     113           0 :     for ( Int_t i = 0; i < cluster.Multiplicity(); ++i )
     114             :     {
     115           0 :       AliMUONPad* pad = cluster.Pad(i);
     116           0 :       TVector2 padPosition = pad->Position();
     117           0 :       AliMpArea area(pad->X(), pad->Y(), pad->DX(), pad->DY());
     118           0 :       xmin = TMath::Min(area.LeftBorder(),xmin);
     119           0 :       xmax = TMath::Max(area.RightBorder(),xmax);
     120           0 :       ymin = TMath::Min(area.DownBorder(),ymin);
     121           0 :       ymax = TMath::Max(area.UpBorder(),ymax);
     122           0 :       if ( cathode == pad->Cathode() )
     123             :       {
     124           0 :         x[cathode] += padPosition.X()*pad->Charge();
     125           0 :         y[cathode] += padPosition.Y()*pad->Charge();
     126           0 :         xsize[cathode] += pad->Dimensions().X();
     127           0 :         ysize[cathode] += pad->Dimensions().Y();
     128           0 :       }
     129           0 :     }
     130           0 :     if ( cluster.Charge(cathode) )
     131             :     {
     132           0 :       x[cathode] /= cluster.Charge(cathode);
     133           0 :       y[cathode] /= cluster.Charge(cathode);
     134           0 :     }
     135           0 :     if ( cluster.Multiplicity(cathode) )
     136             :     {
     137           0 :       xsize[cathode] /= cluster.Multiplicity(cathode);
     138           0 :       ysize[cathode] /= cluster.Multiplicity(cathode);
     139           0 :     }
     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           0 :   xCOG = ( xsize[0] < xsize[1] ) ? x[0] : x[1];
     147           0 :   yCOG = ( ysize[0] < ysize[1] ) ? y[0] : y[1];
     148             :   
     149           0 :   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           0 :   cluster.SetPosition(TVector2(xCOG,yCOG),cluster.Pad(0)->Dimensions()); // FIXME: what to put as an error here ?
     155           0 : }
     156             : 
     157             : 
     158             : 

Generated by: LCOV version 1.11