LCOV - code coverage report
Current view: top level - HLT/TPCLib - AliHLTTPCClusterFinder.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 26 3.8 %
Date: 2016-06-14 17:26:59 Functions: 1 30 3.3 %

          Line data    Source code
       1             : //-*- Mode: C++ -*-
       2             : // $Id$
       3             : 
       4             : #ifndef ALIHLTTPCCLUSTERFINDER_H
       5             : #define ALIHLTTPCCLUSTERFINDER_H
       6             : //* This file is property of and copyright by the ALICE HLT Project        * 
       7             : //* ALICE Experiment at CERN, All rights reserved.                         *
       8             : //* See cxx source for full Copyright notice                               *
       9             : 
      10             : //  @file   AliHLTTPCClusterFinder.h
      11             : //  @author Anders Vestbo, Constantin Loizides
      12             : //          Kenneth Aamodt kenneth.aamodt@student.uib.no
      13             : //  @brief  HLT Cluster Finder for the TPC
      14             : //  @note
      15             : 
      16             : #include "AliHLTLogging.h"
      17             : #include <vector>
      18             : #include "AliHLTTPCGeometry.h"
      19             : #include "AliHLTTPCDigitData.h"
      20             : #include "AliHLTTPCDigitReader.h"
      21             : #include "AliTPCRecoParam.h"
      22             : #include "AliHLTTPCClusterMCData.h"
      23             : #include "AliHLTTPCRawCluster.h"
      24             : 
      25             : class AliHLTTPCPad;
      26             : struct AliHLTTPCSpacePointData;
      27             : class AliHLTTPCClusters;
      28             : class AliTPCTransform;
      29             : class AliTPCParam;
      30             : 
      31             : /**
      32             :  * @class AliHLTTPCClusterFinder
      33             :  *
      34             :  * The current cluster finder for HLT
      35             :  * (Based on STAR L3)
      36             :  *
      37             :  * Basically we have two versions for the cluster finder now.
      38             :  * The default version, reads the data pad by pad, and find the
      39             :  * clusters as it reads the data. The other version has now been
      40             :  * developed to cope with unsorted data. New methods for the unsorted
      41             :  * version can  be found at the end of the default one i the source file.
      42             :  * Currently the new version is only build to manage zero-suppressed data.
      43             :  * More functionality will be added later.
      44             :  * 
      45             :  * The cluster finder is initialized with the Init function, 
      46             :  * providing the slice and patch information to work on. 
      47             :  *
      48             :  * The input is a provided by the AliHLTTPCDigitReader class,
      49             :  * using the init() funktion, and the next() funktion in order 
      50             :  * to get the next bin. Either packed or unpacked data can be
      51             :  * processed, dependent if one uses AliHLTTPCDigitReaderPacked 
      52             :  * class or AliHLTTPCDigitReaderUnpacked class in the 
      53             :  * Clusterfinder Component.
      54             :  * The resulting space points will be in the
      55             :  * array given by the SetOutputArray function.
      56             :  * 
      57             :  * There are several setters which control the behaviour:
      58             :  *
      59             :  * - SetXYError(Float_t):   set fixed error in XY direction
      60             :  * - SetZError(Float_t):    set fixed error in Z  direction
      61             :  *                            (used if errors are not calculated) 
      62             :  * - SetDeconv(Bool_t):     switch on/off deconvolution
      63             :  * - SetThreshold(UInt_t):  set charge threshold for cluster
      64             :  * - SetMatchWidth(UInt_t): set the match distance in 
      65             :  *                            time for sequences to be merged 
      66             :  * - SetSTDOutput(Bool_t):  switch on/off output about found clusters   
      67             :  * - SetCalcErr(Bool_t):    switch on/off calculation of 
      68             :  *                          space point errors (or widths in raw system)
      69             :  * - SetRawSP(Bool_t):      switch on/off convertion to raw system
      70             :  *
      71             :  *
      72             :  * Example Usage:
      73             :  *
      74             :  * <pre>
      75             :  * AliHLTTPCFileHandler *file = new AliHLTTPCFileHandler();
      76             :  * file->SetAliInput(digitfile); //give some input file
      77             :  * for(int slice=0; slice<=35; slice++){
      78             :  *   for(int patch=0; pat<6; pat++){
      79             :  *     file->Init(slice,patch);
      80             :  *     UInt_t ndigits=0;
      81             :  *     UInt_t maxclusters=100000;
      82             :  *     UInt_t pointsize = maxclusters*sizeof(AliHLTTPCSpacePointData);
      83             :  *     AliHLTTPCSpacePointData *points = (AliHLTTPCSpacePointData*)memory->Allocate(pointsize);
      84             :  *     AliHLTTPCDigitRowData *digits = (AliHLTTPCDigitRowData*)file->AliAltroDigits2Memory(ndigits,event);
      85             :  *     AliHLTTPCClusterFinder *cf = new AliHLTTPCClusterFinder();
      86             :  *     cf->SetMatchWidth(2);
      87             :  *     cf->InitSlice( slice, patch, row[0], row[1], maxPoints );
      88             :  *     cf->SetSTDOutput(kTRUE);    //Some output to standard IO
      89             :  *     cf->SetRawSP(kFALSE);       //Convert space points to local system
      90             :  *     cf->SetThreshold(5);        //Threshold of cluster charge
      91             :  *     cf->SetDeconv(kTRUE);       //Deconv in pad and time direction
      92             :  *     cf->SetCalcErr(kTRUE);      //Calculate the errors of the spacepoints
      93             :  *     cf->SetOutputArray(points); //Move the spacepoints to the array
      94             :  *     cf->Read(iter->fPtr, iter->fSize ); //give the data to the cf
      95             :  *     cf->ProcessDigits();        //process the rows given by init
      96             :  *     Int_t npoints = cf->GetNumberOfClusters();
      97             :  *     AliHLTTPCMemHandler *out= new AliHLTTPCMemHandler();
      98             :  *     out->SetBinaryOutput(fname);
      99             :  *     out->Memory2Binary(npoints,points); //store the spacepoints
     100             :  *     out->CloseBinaryOutput();
     101             :  *     delete out;
     102             :  *     file->free();
     103             :  *     delete cf;
     104             :  *   }
     105             :  * }
     106             :  * </pre>
     107             :  * @ingroup alihlt_tpc
     108             :  */
     109             : class AliHLTTPCClusterFinder : public AliHLTLogging {
     110             : 
     111             :  public:
     112             :   struct AliClusterData
     113             :   {
     114             :     UInt_t fTotalCharge;   //tot charge of cluster
     115             :     UInt_t fPad;           //pad value
     116             :     UInt_t fTime;          //time value
     117             :     ULong64_t fPad2;       //for error in XY direction
     118             :     ULong64_t fTime2;      //for error in Z  direction
     119             :     UInt_t fMean;          //mean in time
     120             :     UInt_t fFlags;         //different flags
     121             :     UInt_t fChargeFalling; //for deconvolution
     122             :     UInt_t fLastCharge;    //for deconvolution
     123             :     UInt_t fLastMergedPad; //dont merge twice per pad
     124             :     Int_t fRow;             //row value
     125             :     UInt_t fQMax;           //qmax
     126             :   };
     127             :   typedef struct AliClusterData AliClusterData; //!
     128             : 
     129           0 :   static Bool_t CompareWeights( const AliHLTTPCClusterMCWeight &mc1,  const AliHLTTPCClusterMCWeight &mc2 ){ return mc1.fWeight > mc2.fWeight; }
     130             :   
     131             : 
     132             :   /** standard constructor */
     133             :   AliHLTTPCClusterFinder();
     134             : 
     135             :   /** destructor */
     136             :   virtual ~AliHLTTPCClusterFinder();
     137             : 
     138             :   /** Initialize the slice */
     139             :   void InitSlice(Int_t slice,Int_t patch,Int_t maxpoints);
     140             : 
     141             :   /** Initializes the pad array (vector)*/
     142             :   void InitializePadArray();
     143             : 
     144             :   /** Deinitialize the pad array (vector)*/
     145             :   Int_t DeInitializePadArray();
     146             : 
     147             :   /** Read the data in unsorted format, storing the clustercandidates */
     148             :   void ReadDataUnsorted(void* ptr,unsigned long size);
     149             : 
     150             :   /** Read the data in unsorted format, and deconvolute the signals for each pad in time direction */
     151             :   void ReadDataUnsortedDeconvoluteTime(void* ptr,unsigned long size);
     152             : 
     153             :   /** Loops over all rows finding the clusters */
     154             :   void FindClusters();
     155             : 
     156             :   /** Compare two neighbouring pads for matching clustercandidates */
     157             :   Bool_t ComparePads(AliHLTTPCPad *nextPad,AliHLTTPCClusters* candidate,Int_t nextPadToRead);
     158             :   
     159             :   /**  Fills the hw address list */
     160             :   Int_t FillHWAddressList(AliHLTUInt16_t *hwaddlist, Int_t maxHWAddress);
     161             : 
     162             :  /**  Fills the mc info */
     163             :   Int_t FillOutputMCInfo(AliHLTTPCClusterMCLabel * outputMCInfo, Int_t maxNumberOfClusterMCInfo);
     164             : 
     165             :   Int_t FillOutputRaw(AliHLTTPCRawCluster* rawClusters, unsigned sizeInByte) const;
     166             : 
     167             :   /** Set the pointer to the outputbuffer */
     168             :   void SetOutputArray(AliHLTTPCSpacePointData *pt);
     169             : 
     170             :   /** Returns the number of clusters */
     171           0 :   Int_t GetNumberOfClusters() const {return fNClusters;}
     172             : 
     173             :   /** Returns the Ocuppancy limit */
     174           0 :   Float_t GetOccupancyLimit() const {return fOccupancyLimit;}
     175             :   
     176             :   // setters
     177           0 :   void SetDeconv(Bool_t f) {fDeconvPad=f; fDeconvTime=f;}
     178           0 :   void SetDeconvPad(Bool_t f) {fDeconvPad=f;}
     179           0 :   void SetDeconvTime(Bool_t f) {fDeconvTime=f;}
     180           0 :   void SetUnsorted(Int_t unsorted){fUnsorted=unsorted;}
     181           0 :   void SetPatch(Int_t patch){fCurrentPatch=patch;}
     182           0 :   void SetDoPadSelection(Bool_t input){fDoPadSelection=input;}
     183           0 :   void SetLastTimeBin(Int_t ltb){fLastTimeBin=ltb;}
     184           0 :   void SetFirstTimeBin(Int_t ftb){fFirstTimeBin=ftb;}
     185           0 :   void SetReleaseMemory( Bool_t v ){ fReleaseMemory = v;}
     186           0 :   void UpdateLastTimeBin(){fLastTimeBin=AliHLTTPCGeometry::GetNTimeBins();}
     187             : 
     188             : //---------------------------------- Under this line the old sorted clusterfinder functions can be found --------------------------------
     189             :   void Read(void* ptr,unsigned long size);
     190             :   void ProcessDigits();
     191             :   void WriteClusters(Int_t n_clusters,AliClusterData *list);
     192             :   void WriteClusters(Int_t nclusters,AliHLTTPCClusters *list);
     193             :   void PrintClusters();
     194           0 :   void SetXYError(Float_t f) {fXYErr=f;}
     195           0 :   void SetZError(Float_t f) {fZErr=f;}
     196           0 :   void SetThreshold(UInt_t i) {fThreshold=i;}
     197           0 :   void SetOccupancyLimit(Float_t f) {fOccupancyLimit=f;}
     198           0 :   void SetMatchWidth(UInt_t i) {fMatch=i;}
     199           0 :   void SetSTDOutput(Bool_t f=kFALSE) {fStdout=f;}  
     200           0 :   void SetCalcErr(Bool_t f=kTRUE) {fCalcerr=f;}
     201           0 :   void SetFillRawClusters(Bool_t f=kFALSE) {fFillRawClusters=f;}
     202           0 :   void SetReader(AliHLTTPCDigitReader* f){fDigitReader = f;}
     203             : 
     204           0 :   void Set32BitFormat(Bool_t flag){f32BitFormat = flag;}
     205             : 
     206           0 :   void SetDoMC(Bool_t flag){fDoMC = flag;}
     207             :   
     208             :   vector<AliHLTUInt16_t> fClustersHWAddressVector;  //! transient
     209             :   
     210             :   typedef vector<AliHLTTPCPad*> AliHLTTPCPadVector;
     211             :   
     212             :   vector<AliHLTTPCPadVector> fRowPadVector;        //! transient
     213             :   
     214             :   void FillMCClusterVector(vector<AliHLTTPCDigitData> *digitData);
     215             : 
     216           0 :   vector<AliHLTTPCClusterMCWeight> GetClusterMCInfo() const {return fClusterMCVector;}
     217             : 
     218             :   Bool_t UpdateCalibDB();
     219             : 
     220             :  protected: 
     221             :   /** copy constructor prohibited */
     222             :   AliHLTTPCClusterFinder(const AliHLTTPCClusterFinder&);
     223             :   /** assignment operator prohibited */
     224             :   AliHLTTPCClusterFinder& operator=(const AliHLTTPCClusterFinder&);
     225             : 
     226             :   AliHLTTPCSpacePointData *fSpacePointData; //! array of space points
     227             :   AliHLTTPCDigitReader *fDigitReader;       //! reader instance
     228             : 
     229             :   UChar_t* fPtr;           //! pointer to packed block
     230             :   unsigned long fSize;     //! packed block size
     231             :   Bool_t fDeconvTime;      //! deconv in time direction
     232             :   Bool_t fDeconvPad;       //! deconv in pad direction
     233             :   Bool_t fStdout;          //! have print out in write clusters
     234             :   Bool_t fCalcerr;         //! calculate centroid sigmas
     235             :   Bool_t fFillRawClusters; //! store centroids in raw system in separate array
     236             : 
     237             : 
     238             :   Int_t fFirstRow;       //! first row
     239             :   Int_t fLastRow;        //! last row
     240             :   Int_t fCurrentRow;     //! current active row
     241             :   Int_t fCurrentSlice;   //! current slice
     242             :   Int_t fCurrentPatch;   //! current patch
     243             :   Int_t fMatch;          //! size of match
     244             :   UInt_t fThreshold;     //! threshold for clusters
     245             :   Int_t fNClusters;      //! number of found clusters
     246             :   Int_t fMaxNClusters;   //! max. number of clusters
     247             :   Float_t fXYErr;        //! fixed error in XY
     248             :   Float_t fZErr;         //! fixed error in Z
     249             :   
     250             :   Float_t fOccupancyLimit;    //! Occupancy Limit
     251             : 
     252             :   Int_t fUnsorted;            //! enable for processing of unsorted digit data
     253             :   Bool_t fVectorInitialized;  //! flag to check if pad vector is initialized
     254             :  
     255             :   vector<AliHLTTPCClusters> fClusters;                             //! transient
     256             : 
     257             :   vector<AliHLTTPCClusterMCLabel> fClustersMCInfo;                           //! transient
     258             : 
     259             :   vector<AliHLTTPCDigitData> fMCDigits;                            //! transient
     260             : 
     261             :   vector<AliHLTTPCRawCluster> fRawClusters;                        //! transient
     262             :   
     263             :   UInt_t* fNumberOfPadsInRow;                                      //! transient
     264             :   
     265             :   UInt_t fNumberOfRows;                                            //! transient
     266             :   
     267             :   UInt_t fRowOfFirstCandidate;                                     //! transient
     268             : 
     269             :   Bool_t fDoPadSelection;                                          //! transient
     270             : 
     271             :   Int_t fFirstTimeBin;                                             //! transient
     272             :   
     273             :   Int_t fLastTimeBin;                                              //! transient
     274             : 
     275             :   UInt_t fTotalChargeOfPreviousClusterCandidate;                   //! transient
     276             : 
     277             :   Bool_t fChargeOfCandidatesFalling;                               //! transient
     278             : 
     279             :   Bool_t f32BitFormat;                                             //! transient
     280             : 
     281             :   Bool_t fDoMC;                                                    //! transient
     282             : 
     283             :   vector<AliHLTTPCClusterMCWeight> fClusterMCVector;                               //! transient
     284             : 
     285             :   AliTPCTransform * fOfflineTransform;                             //! transient
     286             : 
     287             :   AliTPCParam   *fOfflineTPCParam;                                 //! transient
     288             : 
     289             :   AliTPCRecoParam fOfflineTPCRecoParam;                            //! transient
     290             : 
     291             :   Float_t fTimeMeanDiff;                                           //! transient
     292             : 
     293             :   Bool_t fReleaseMemory; //! flag to release the memory after each event
     294             : 
     295             : #ifdef do_mc
     296             :   void GetTrackID(Int_t pad,Int_t time,Int_t *trackID) const;
     297             : #endif
     298             :   
     299           6 :   ClassDef(AliHLTTPCClusterFinder, 0) //Fast cluster finder
     300             : };
     301             : #endif

Generated by: LCOV version 1.11