Bug fix for the case of more than 30 timebins
[u/mrichter/AliRoot.git] / TRD / AliTRDclusterizer.h
CommitLineData
8230f242 1#ifndef ALITRDCLUSTERIZER_H
2#define ALITRDCLUSTERIZER_H
f7336fa3 3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
5
6/* $Id$ */
7
6d50f529 8////////////////////////////////////////////////////////////////////////////
9// //
3fe61b77 10// TRD cluster finder //
6d50f529 11// //
12////////////////////////////////////////////////////////////////////////////
13
f7336fa3 14#include <TNamed.h>
793ff80c 15
16class TFile;
bdbb05bb 17class TTree;
66f6bfd9 18class TClonesArray;
6d50f529 19
88cb7938 20class AliRunLoader;
3fe61b77 21class AliRawReader;
6d50f529 22
bdbb05bb 23class AliTRD;
c85a4951 24class AliTRDcluster;
b65e5048 25
26class AliTRDarrayADC;
27class AliTRDarraySignal;
3fe61b77 28class AliTRDdigitsManager;
29class AliTRDSignalIndex;
30class AliTRDtransform;
31class AliTRDCalROC;
3a039a31 32class AliTRDReconstructor;
1b3a719f 33class AliTRDCalSingleChamberStatus;
b65e5048 34
3a039a31 35class AliTRDclusterizer : public TNamed
36{
b65e5048 37
38 public:
39
66f6bfd9 40 // steering flags
41 enum{
a5b99acd 42 kTrOwner= BIT(13) // toggle online tracklets ownership
43 ,kClOwner= BIT(14) // toggle cluster ownership
b72f4eaf 44 ,kLabels = BIT(15) // toggle MC labels for clusters
45 ,kHLT = BIT(16) // HLT mode
46 ,kLUT = BIT(17) // using look up table for cluster's r-phi position
47 ,kGAUS = BIT(18) // using gauss approx. for cluster's r-phi position
66f6bfd9 48 };
486c2339 49
50 struct MaxStruct
51 {
52 Int_t Row;
53 Int_t Col;
54 Int_t Time;
55 UChar_t padStatus;
c96d03ba 56 Short_t Signals[3];
1b3a719f 57 Bool_t FivePad;
58 MaxStruct():Row(-1),Col(0),Time(0),padStatus(0),FivePad(kFALSE)
c96d03ba 59 {memset(Signals, 0, 3*sizeof(Short_t));}
486c2339 60 MaxStruct &operator=(const MaxStruct &a)
1b3a719f 61 {Row=a.Row; Col=a.Col; Time=a.Time; padStatus=a.padStatus; FivePad=a.FivePad;
c96d03ba 62 memcpy(Signals, a.Signals, 3*sizeof(Short_t)); return *this;}
486c2339 63 };
66f6bfd9 64
486c2339 65 AliTRDclusterizer(const AliTRDReconstructor *const rec = 0x0);
66 AliTRDclusterizer(const Text_t* name, const Text_t* title, const AliTRDReconstructor *const rec = 0x0);
dd9a6ee3 67 AliTRDclusterizer(const AliTRDclusterizer &c);
6d50f529 68 virtual ~AliTRDclusterizer();
dd9a6ee3 69 AliTRDclusterizer &operator=(const AliTRDclusterizer &c);
70
6cd9a21f 71 void Copy(TObject &c) const;
3fe61b77 72
6cd9a21f 73 Bool_t Open(const Char_t *name, Int_t nEvent = 0);
74 Bool_t OpenInput(Int_t nEvent = 0);
75 Bool_t OpenOutput();
e7295a3a 76 Bool_t OpenOutput(TTree *const clusterTree);
11d0be11 77 Bool_t OpenTrackletOutput();
3fe61b77 78
6cd9a21f 79 Bool_t ReadDigits();
80 Bool_t ReadDigits(AliRawReader *rawReader);
81 Bool_t ReadDigits(TTree *digitsTree);
3fe61b77 82
6cd9a21f 83 Bool_t WriteClusters(Int_t det);
3d0c7d6d 84 void ResetRecPoints();
85 virtual TClonesArray *RecPoints();
e7295a3a 86 virtual TClonesArray *TrackletsArray();
6cd9a21f 87 Bool_t WriteTracklets(Int_t det);
bdbb05bb 88
6cd9a21f 89 Bool_t Raw2Clusters(AliRawReader *rawReader);
90 Bool_t Raw2ClustersChamber(AliRawReader *rawReader);
3fe61b77 91
6cd9a21f 92 Bool_t MakeClusters();
93 Bool_t MakeClusters(Int_t det);
3fe61b77 94
6cd9a21f 95 Bool_t AddLabels();
b72f4eaf 96 Bool_t SetUseLabels(const Bool_t kset) { SetBit(kLabels, kset); return TestBit(kLabels); } // should we assign labels to clusters
6cd9a21f 97 void SetRawVersion(const Int_t iver) { fRawVersion = iver; } // set the expected raw data version
3a039a31 98 void SetReconstructor(const AliTRDReconstructor *rec) {fReconstructor = rec;}
66f6bfd9 99 static UChar_t GetStatus(Short_t &signal);
e7295a3a 100 Int_t GetAddedClusters() const {return fNoOfClusters;}
66f6bfd9 101
a5b99acd 102 Bool_t IsClustersOwner() const {return TestBit(kClOwner);}
29f3223b 103 virtual void SetClustersOwner(Bool_t own=kTRUE) {SetBit(kClOwner, own); if(!own) {fRecPoints = 0x0; fNoOfClusters=0;} }
a5b99acd 104 void SetTrackletsOwner(Bool_t own=kTRUE) {SetBit(kTrOwner, own); if(!own) {fTracklets = 0x0; } }
3a039a31 105
b72f4eaf 106protected:
b65e5048 107
064d808d 108 void DeConvExp (const Double_t *const source, Double_t *const target
109 ,const Int_t nTimeTotal, const Int_t nexp);
110 void TailCancelation();
111
e7295a3a 112 Float_t Unfold(Double_t eps, Int_t layer, const Double_t *const padSignal) const;
6d9e79cc 113
e7295a3a 114 void SetPadStatus(const UChar_t status, UChar_t &encoding) const;
064d808d 115 UChar_t GetPadStatus(UChar_t encoding) const;
116 Int_t GetCorruption(UChar_t encoding) const;
117
1b3a719f 118 Bool_t IsMaximum(const MaxStruct &Max, UChar_t &padStatus, Short_t *const Signals); //for const correctness reasons not const parameters are given separately
119 Bool_t FivePadCluster(MaxStruct &ThisMax, MaxStruct &NeighbourMax);
486c2339 120 void CreateCluster(const MaxStruct &Max);
3d0c7d6d 121 inline void CalcAdditionalInfo(const MaxStruct &Max, Short_t *const signals, Int_t &nPadCount);
e7295a3a 122 virtual void AddClusterToArray(AliTRDcluster* cluster);
123 virtual void AddTrackletsToArray();
3fe61b77 124
3d0c7d6d 125 const AliTRDReconstructor *fReconstructor; //! reconstructor
3fe61b77 126 AliRunLoader *fRunLoader; //! Run Loader
127 TTree *fClusterTree; //! Tree with the cluster
66f6bfd9 128 TClonesArray *fRecPoints; //! Array of clusters
a5b99acd 129 TClonesArray *fTracklets; //! Array of online tracklets
3fe61b77 130
b65e5048 131 TTree *fTrackletTree; //! Tree for tracklets
9c7c9ec1 132
3fe61b77 133 AliTRDdigitsManager *fDigitsManager; //! TRD digits manager
134
b65e5048 135 UInt_t **fTrackletContainer; //! tracklet container
9c7c9ec1 136
3fe61b77 137 Int_t fRawVersion; // Expected raw version of the data - default is 2
138
3fe61b77 139 AliTRDtransform *fTransform; //! Transforms the reconstructed space points
f7336fa3 140
3d0c7d6d 141 AliTRDarrayADC *fDigits; // Array holding the digits
142 AliTRDSignalIndex *fIndexes; // Array holding the indexes to the digits
064d808d 143 Float_t fADCthresh; // ADC thresholds: There is no ADC threshold anymore, and simParam should not be used in clusterizer. KO
144 Float_t fMaxThresh; // Threshold value for the maximum
145 Float_t fSigThresh; // Threshold value for the digit signal
146 Float_t fMinMaxCutSigma; // Threshold value for the maximum (cut noise)
147 Float_t fMinLeftRightCutSigma; // Threshold value for the sum pad (cut noise)
148 Int_t fLayer; // Current layer of the detector
149 Int_t fDet; // Current detecor
150 UShort_t fVolid; // Volume ID
151 Int_t fColMax; // Number of Colums in one detector
152 Int_t fTimeTotal; // Number of time bins
153 AliTRDCalROC *fCalGainFactorROC; // Calibration object with pad wise values for the gain factors
154 Float_t fCalGainFactorDetValue;// Calibration value for chamber wise noise
155 AliTRDCalROC *fCalNoiseROC; // Calibration object with pad wise values for the noise
156 Float_t fCalNoiseDetValue; // Calibration value for chamber wise noise
3d0c7d6d 157 AliTRDCalSingleChamberStatus *fCalPadStatusROC; // Calibration object with the pad status
064d808d 158 Int_t fClusterROC; // The index to the first cluster of a given ROC
159 Int_t firstClusterROC; // The number of cluster in a given ROC
3d0c7d6d 160 Int_t fNoOfClusters; // Number of Clusters already processed and still owned by the clusterizer
064d808d 161
3d0c7d6d 162 ClassDef(AliTRDclusterizer,6) // TRD clusterfinder
f7336fa3 163
164};
165
f7336fa3 166#endif