ROOT logo
#ifndef ALITOFCLUSTERFINDERV1_H
#define ALITOFCLUSTERFINDERV1_H
/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 * See cxx source for full Copyright notice                               */
// AliTOFClusterFinderV1 Class
// Task: Transform digits/raw data to TOF Clusters, to fill TOF RecPoints
// and feed TOF tracking 

#include "TObject.h"
#include "TTask.h"

#include "AliTOFGeometry.h"
#include "AliTOFRawStream.h"

class TClonesArray;
class TTree;

class AliRunLoader;
class AliRawReader;

class AliTOFcluster;
class AliTOFcalib;
class AliTOFDigitMap;
class AliTOFRecoParam;

class  AliTOFselectedDigit : public TObject { 
 public:
  AliTOFselectedDigit() :
    fTDC(0.),fADC(0.),fTOT(0.),fWeight(0.),fIndex(-1) {
    for (Int_t ii=0; ii<5; ii++) fDetectorIndex[ii]=-1;
    for (Int_t ii=0; ii<3; ii++) fTrackLabel[ii]=-1;
  };
  AliTOFselectedDigit(Int_t * const ind, Double_t h1, Double_t h2, Double_t h3, Double_t h4, Int_t idx, Int_t * const l):
    TObject(),
    fTDC(h1),fADC(h2),fTOT(h3),fWeight(h4),fIndex(idx) {
    for (Int_t ii=0; ii<5; ii++) fDetectorIndex[ii]=ind[ii];
    for (Int_t ii=0; ii<3; ii++) fTrackLabel[ii]=l[ii];
  };
  AliTOFselectedDigit(const AliTOFselectedDigit & source) :
    TObject(source),
    fTDC(source.fTDC),fADC(source.fADC),fTOT(source.fTOT),fWeight(source.fWeight),fIndex(source.fIndex)
    {
      for (Int_t ii=0; ii<5; ii++) fDetectorIndex[ii]=source.fDetectorIndex[ii];
      for (Int_t ii=0; ii<3; ii++) fTrackLabel[ii]=source.fTrackLabel[ii];
    };
  AliTOFselectedDigit & operator=(const AliTOFselectedDigit & source)
    { if (this == &source) return *this;
      TObject::operator=(source);
      for (Int_t ii=0; ii<5; ii++) fDetectorIndex[ii]=source.fDetectorIndex[ii];
      fTDC=source.fTDC;fADC=source.fADC;fTOT=source.fTOT;fWeight=source.fWeight;fIndex=source.fIndex;
      for (Int_t ii=0; ii<3; ii++) fTrackLabel[ii]=source.fTrackLabel[ii];
      return *this; };

  Double_t GetTDC()    const {return fTDC;} // digit TOF
  Double_t GetADC()    const {return fADC;} // digit ADC
  Double_t GetTOT()    const {return fTOT;} // digit TOT
  Double_t GetWeight() const {return fWeight;} // digit weight
  Int_t GetTrackLabel(Int_t n)    const {return fTrackLabel[n];} // Labels of tracks in digit
  Int_t GetDetectorIndex(Int_t n) const {return fDetectorIndex[n];} // Digit Detector Index n
  Int_t GetIndex()     const {return fIndex;} // Digit Index

 private: 

  Int_t fDetectorIndex[5]; //digit detector indices (sector, plate, strip, padX, padZ) 
  Double_t fTDC; //TDC count
  Double_t fADC; //ADC count
  Double_t fTOT; //TOT count
  Double_t fWeight; //weight
  Int_t fIndex; //index of the digit in the TOF digit tree
  Int_t fTrackLabel[3]; //track labels

}; 


class AliTOFClusterFinderV1 : public TTask
{

  enum {kTofMaxCluster=77777}; //maximal number of the TOF clusters

 public:

  AliTOFClusterFinderV1(AliTOFcalib *calib);
  AliTOFClusterFinderV1(const AliTOFClusterFinderV1 &source); // copy constructor
  AliTOFClusterFinderV1& operator=(const AliTOFClusterFinderV1 &source); // ass. op.
  virtual ~AliTOFClusterFinderV1();

  void Digits2RecPoints(TTree* digitsTree, TTree* clusterTree);
  void Digits2RecPoints(AliRawReader *rawReader, TTree *clustersTree);
  void Raw2Digits(AliRawReader *rawReader, TTree* digitsTree); 

  AliTOFClusterFinderV1(AliRunLoader* runLoader, AliTOFcalib *calib);
  void Digits2RecPoints(Int_t iEvent);
  void Digits2RecPoints(Int_t ievt, AliRawReader *rawReader);
  void Raw2Digits(Int_t ievt, AliRawReader *rawReader);

  void FillRecPoint();
  void ResetRecpoint();
  void ResetDigits();
  void SetVerbose(Int_t Verbose){fVerbose=Verbose;} // To set the verbose level
  void SetDecoderVersion(Int_t version){fDecoderVersion=version;} // To set the decoder version
  Bool_t GetDecoderVersion() const {return fDecoderVersion;} // To get the decoder version
  //UShort_t GetClusterVolIndex(Int_t *ind) const; //Volume Id getter
  void GetClusterPars(Int_t *ind, Double_t *pos, Double_t *cov) const; //cluster par getter
  void GetClusterPars(/*Bool_t check,*/ Int_t counter, Int_t **ind, Double_t *weight,
		      Double_t *pos, Double_t *cov) const; //cluster par getter

  void FindOnePadClusterPerStrip(Int_t nSector, Int_t nPlate, Int_t nStrip);
  void FindClustersWithoutTOT(Int_t nSector, Int_t nPlate, Int_t nStrip);
  void FindClustersPerStrip(Int_t nSector, Int_t nPlate, Int_t nStrip, Int_t group);

  void FindClusters34(Int_t nSector, Int_t nPlate, Int_t nStrip);
  void FindClusters23(Int_t nSector, Int_t nPlate, Int_t nStrip);
  void FindClusters24(Int_t nSector, Int_t nPlate, Int_t nStrip);

  void  SetMaxDeltaTime(Int_t a)   {fMaxDeltaTime = a;}; // to set deltaTime [bin number]
  void  SetMaxDeltaTime(Float_t a) {fMaxDeltaTime = (Int_t)(a/AliTOFGeometry::TdcBinWidth());}; // to set deltaTime [ps]
  Int_t GetMaxDeltaTime()     const {return fMaxDeltaTime;};
  Int_t GetNumberOfTOFclusters() const {return fNumberOfTofClusters;}
  Int_t GetNumberOfTOFtrgPads() const {return fNumberOfTofTrgPads;}


  void SetCalibrateFlag(Bool_t dummy) {fCalibrateTOFtimes = dummy;};
  Bool_t GetCalibrateFlag() const {return fCalibrateTOFtimes;};

 protected:

  AliRunLoader *fRunLoader;   // Pointer to Run Loader
  AliTOFcluster *fTofClusters[kTofMaxCluster];  // pointers to the TOF clusters
  TClonesArray *fDigits;      // List of digits
  TClonesArray *fRecPoints;   // List of reconstructed points
  Int_t fNumberOfTofClusters; // Number of TOF Clusters
  Int_t fNumberOfTofDigits;   // Number of TOF Digits
  Int_t fNumberOfTofTrgPads;  // Number of TOF trigger pads

 private:

  const AliTOFRecoParam* fkRecoParam; // pointer to TOF reconstruction parameters

  Int_t fMaxDeltaTime; // max time difference in between two tof
                       // measurements for two neighbouring pads

  Int_t InsertCluster(AliTOFcluster *tofCluster);    // Fills TofClusters Array
  Int_t FindClusterIndex(Double_t z) const; // Returns cluster index 
  Bool_t MakeSlewingCorrection(Int_t *detectorIndex, Int_t tofDigitToT, Int_t tofDigitTdc,
			       Int_t &tdcCorr);
  void TOFclusterError(/*Bool_t check,*/ Int_t counter, Int_t **ind, Double_t *weight,
		       Double_t ppos[], Double_t cov[]) const;

  void AverageCalculations(Int_t number, Float_t *interestingX,
			   Float_t *interestingY, Float_t *interestingZ,
			   Double_t *interestingTOF, Double_t *interestingTOT,
			   Double_t *interestingADC, Double_t *interestingWeight,
			   Int_t *parTOF, Double_t *posClus, Bool_t &check);

  Int_t fVerbose;           // Verbose level (0:no msg, 1:msg, 2:digits in txt files)
  Bool_t fDecoderVersion;   // setting whether to use the new decoder version 
                            //  -true -> new version
                            //  -false ->old version  (default value!!)
  AliTOFcalib *fTOFcalib;        // pointer to the TOF calibration info
  AliTOFDigitMap* fTOFdigitMap;  // TOF digit map pointer
  AliTOFGeometry *fTOFGeometry;  // pointer to the TOF geometry
  TTree *fTOFdigits;             // pointer to the TOF digit tree

  AliTOFRawStream fTOFRawStream; // AliTOFRawStream variable

  Bool_t fCalibrateTOFtimes;     // used for check

  ClassDef(AliTOFClusterFinderV1,6) // To run TOF clustering
};
#endif

 AliTOFClusterFinderV1.h:1
 AliTOFClusterFinderV1.h:2
 AliTOFClusterFinderV1.h:3
 AliTOFClusterFinderV1.h:4
 AliTOFClusterFinderV1.h:5
 AliTOFClusterFinderV1.h:6
 AliTOFClusterFinderV1.h:7
 AliTOFClusterFinderV1.h:8
 AliTOFClusterFinderV1.h:9
 AliTOFClusterFinderV1.h:10
 AliTOFClusterFinderV1.h:11
 AliTOFClusterFinderV1.h:12
 AliTOFClusterFinderV1.h:13
 AliTOFClusterFinderV1.h:14
 AliTOFClusterFinderV1.h:15
 AliTOFClusterFinderV1.h:16
 AliTOFClusterFinderV1.h:17
 AliTOFClusterFinderV1.h:18
 AliTOFClusterFinderV1.h:19
 AliTOFClusterFinderV1.h:20
 AliTOFClusterFinderV1.h:21
 AliTOFClusterFinderV1.h:22
 AliTOFClusterFinderV1.h:23
 AliTOFClusterFinderV1.h:24
 AliTOFClusterFinderV1.h:25
 AliTOFClusterFinderV1.h:26
 AliTOFClusterFinderV1.h:27
 AliTOFClusterFinderV1.h:28
 AliTOFClusterFinderV1.h:29
 AliTOFClusterFinderV1.h:30
 AliTOFClusterFinderV1.h:31
 AliTOFClusterFinderV1.h:32
 AliTOFClusterFinderV1.h:33
 AliTOFClusterFinderV1.h:34
 AliTOFClusterFinderV1.h:35
 AliTOFClusterFinderV1.h:36
 AliTOFClusterFinderV1.h:37
 AliTOFClusterFinderV1.h:38
 AliTOFClusterFinderV1.h:39
 AliTOFClusterFinderV1.h:40
 AliTOFClusterFinderV1.h:41
 AliTOFClusterFinderV1.h:42
 AliTOFClusterFinderV1.h:43
 AliTOFClusterFinderV1.h:44
 AliTOFClusterFinderV1.h:45
 AliTOFClusterFinderV1.h:46
 AliTOFClusterFinderV1.h:47
 AliTOFClusterFinderV1.h:48
 AliTOFClusterFinderV1.h:49
 AliTOFClusterFinderV1.h:50
 AliTOFClusterFinderV1.h:51
 AliTOFClusterFinderV1.h:52
 AliTOFClusterFinderV1.h:53
 AliTOFClusterFinderV1.h:54
 AliTOFClusterFinderV1.h:55
 AliTOFClusterFinderV1.h:56
 AliTOFClusterFinderV1.h:57
 AliTOFClusterFinderV1.h:58
 AliTOFClusterFinderV1.h:59
 AliTOFClusterFinderV1.h:60
 AliTOFClusterFinderV1.h:61
 AliTOFClusterFinderV1.h:62
 AliTOFClusterFinderV1.h:63
 AliTOFClusterFinderV1.h:64
 AliTOFClusterFinderV1.h:65
 AliTOFClusterFinderV1.h:66
 AliTOFClusterFinderV1.h:67
 AliTOFClusterFinderV1.h:68
 AliTOFClusterFinderV1.h:69
 AliTOFClusterFinderV1.h:70
 AliTOFClusterFinderV1.h:71
 AliTOFClusterFinderV1.h:72
 AliTOFClusterFinderV1.h:73
 AliTOFClusterFinderV1.h:74
 AliTOFClusterFinderV1.h:75
 AliTOFClusterFinderV1.h:76
 AliTOFClusterFinderV1.h:77
 AliTOFClusterFinderV1.h:78
 AliTOFClusterFinderV1.h:79
 AliTOFClusterFinderV1.h:80
 AliTOFClusterFinderV1.h:81
 AliTOFClusterFinderV1.h:82
 AliTOFClusterFinderV1.h:83
 AliTOFClusterFinderV1.h:84
 AliTOFClusterFinderV1.h:85
 AliTOFClusterFinderV1.h:86
 AliTOFClusterFinderV1.h:87
 AliTOFClusterFinderV1.h:88
 AliTOFClusterFinderV1.h:89
 AliTOFClusterFinderV1.h:90
 AliTOFClusterFinderV1.h:91
 AliTOFClusterFinderV1.h:92
 AliTOFClusterFinderV1.h:93
 AliTOFClusterFinderV1.h:94
 AliTOFClusterFinderV1.h:95
 AliTOFClusterFinderV1.h:96
 AliTOFClusterFinderV1.h:97
 AliTOFClusterFinderV1.h:98
 AliTOFClusterFinderV1.h:99
 AliTOFClusterFinderV1.h:100
 AliTOFClusterFinderV1.h:101
 AliTOFClusterFinderV1.h:102
 AliTOFClusterFinderV1.h:103
 AliTOFClusterFinderV1.h:104
 AliTOFClusterFinderV1.h:105
 AliTOFClusterFinderV1.h:106
 AliTOFClusterFinderV1.h:107
 AliTOFClusterFinderV1.h:108
 AliTOFClusterFinderV1.h:109
 AliTOFClusterFinderV1.h:110
 AliTOFClusterFinderV1.h:111
 AliTOFClusterFinderV1.h:112
 AliTOFClusterFinderV1.h:113
 AliTOFClusterFinderV1.h:114
 AliTOFClusterFinderV1.h:115
 AliTOFClusterFinderV1.h:116
 AliTOFClusterFinderV1.h:117
 AliTOFClusterFinderV1.h:118
 AliTOFClusterFinderV1.h:119
 AliTOFClusterFinderV1.h:120
 AliTOFClusterFinderV1.h:121
 AliTOFClusterFinderV1.h:122
 AliTOFClusterFinderV1.h:123
 AliTOFClusterFinderV1.h:124
 AliTOFClusterFinderV1.h:125
 AliTOFClusterFinderV1.h:126
 AliTOFClusterFinderV1.h:127
 AliTOFClusterFinderV1.h:128
 AliTOFClusterFinderV1.h:129
 AliTOFClusterFinderV1.h:130
 AliTOFClusterFinderV1.h:131
 AliTOFClusterFinderV1.h:132
 AliTOFClusterFinderV1.h:133
 AliTOFClusterFinderV1.h:134
 AliTOFClusterFinderV1.h:135
 AliTOFClusterFinderV1.h:136
 AliTOFClusterFinderV1.h:137
 AliTOFClusterFinderV1.h:138
 AliTOFClusterFinderV1.h:139
 AliTOFClusterFinderV1.h:140
 AliTOFClusterFinderV1.h:141
 AliTOFClusterFinderV1.h:142
 AliTOFClusterFinderV1.h:143
 AliTOFClusterFinderV1.h:144
 AliTOFClusterFinderV1.h:145
 AliTOFClusterFinderV1.h:146
 AliTOFClusterFinderV1.h:147
 AliTOFClusterFinderV1.h:148
 AliTOFClusterFinderV1.h:149
 AliTOFClusterFinderV1.h:150
 AliTOFClusterFinderV1.h:151
 AliTOFClusterFinderV1.h:152
 AliTOFClusterFinderV1.h:153
 AliTOFClusterFinderV1.h:154
 AliTOFClusterFinderV1.h:155
 AliTOFClusterFinderV1.h:156
 AliTOFClusterFinderV1.h:157
 AliTOFClusterFinderV1.h:158
 AliTOFClusterFinderV1.h:159
 AliTOFClusterFinderV1.h:160
 AliTOFClusterFinderV1.h:161
 AliTOFClusterFinderV1.h:162
 AliTOFClusterFinderV1.h:163
 AliTOFClusterFinderV1.h:164
 AliTOFClusterFinderV1.h:165
 AliTOFClusterFinderV1.h:166
 AliTOFClusterFinderV1.h:167
 AliTOFClusterFinderV1.h:168
 AliTOFClusterFinderV1.h:169
 AliTOFClusterFinderV1.h:170
 AliTOFClusterFinderV1.h:171