Be sure to load mapping when needed
[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
8eab6a01 16#include "AliTRDrawStream.h"
17
793ff80c 18class TFile;
bdbb05bb 19class TTree;
66f6bfd9 20class TClonesArray;
6d50f529 21
88cb7938 22class AliRunLoader;
3fe61b77 23class AliRawReader;
6d50f529 24
bdbb05bb 25class AliTRD;
c85a4951 26class AliTRDcluster;
b65e5048 27
28class AliTRDarrayADC;
29class AliTRDarraySignal;
3fe61b77 30class AliTRDdigitsManager;
31class AliTRDSignalIndex;
32class AliTRDtransform;
33class AliTRDCalROC;
3a039a31 34class AliTRDReconstructor;
1b3a719f 35class AliTRDCalSingleChamberStatus;
fc0882f3 36class AliTRDrecoParam;
e8e7f17e 37class AliTRDCalOnlineGainTableROC;
b65e5048 38
3a039a31 39class AliTRDclusterizer : public TNamed
40{
b65e5048 41
42 public:
43
66f6bfd9 44 // steering flags
4806451b 45 // bits from 0-13 are reserved by ROOT (see TObject.h)
66f6bfd9 46 enum{
4806451b 47 kTrOwner = BIT(14) // toggle online tracklets ownership
48 ,kClOwner= BIT(15) // toggle cluster ownership
49 ,kLabels = BIT(16) // toggle MC labels for clusters
d03bfe2b 50 ,kSkipTrafo = BIT(17) // skip the coordinate transformation of clusters?
4806451b 51 ,kLUT = BIT(18) // using look up table for cluster's r-phi position
52 ,kGAUS = BIT(19) // using gauss approx. for cluster's r-phi position
53 ,knewDM = BIT(20) // was the digitsmanger created by raw2clusters?
a1c095f1 54 ,kTracksOwner = BIT(21) // toggle GTU track ownership
66f6bfd9 55 };
486c2339 56
57 struct MaxStruct
58 {
4dab9275 59 Int_t row; // row of the current cluster candidate
60 Int_t col; // col of the current cluster candidate
61 Int_t time; // time -"-
62 Short_t signals[3]; // signals of the maximum pad and it's twon neigbours
63 UChar_t padStatus; // padStatus of the current cluster candidate
64 Bool_t fivePad; // is this cluster candidate part of a 5 pad cluster (two overlaping clusters)?
615f0826 65 MaxStruct():row(-1),col(0),time(0),padStatus(0),fivePad(kFALSE)
66 {memset(signals, 0, 3*sizeof(Short_t));}
486c2339 67 MaxStruct &operator=(const MaxStruct &a)
6b0d4ad5 68 {memcpy(this, &a, sizeof(MaxStruct)); return *this;}
486c2339 69 };
66f6bfd9 70
486c2339 71 AliTRDclusterizer(const AliTRDReconstructor *const rec = 0x0);
72 AliTRDclusterizer(const Text_t* name, const Text_t* title, const AliTRDReconstructor *const rec = 0x0);
dd9a6ee3 73 AliTRDclusterizer(const AliTRDclusterizer &c);
6d50f529 74 virtual ~AliTRDclusterizer();
dd9a6ee3 75 AliTRDclusterizer &operator=(const AliTRDclusterizer &c);
76
0ab5ff49 77 void Copy(TObject &c) const;
3fe61b77 78
6cd9a21f 79 Bool_t Open(const Char_t *name, Int_t nEvent = 0);
80 Bool_t OpenInput(Int_t nEvent = 0);
81 Bool_t OpenOutput();
e7295a3a 82 Bool_t OpenOutput(TTree *const clusterTree);
3fe61b77 83
6cd9a21f 84 Bool_t ReadDigits();
85 Bool_t ReadDigits(AliRawReader *rawReader);
86 Bool_t ReadDigits(TTree *digitsTree);
3fe61b77 87
cb8b99ee 88 Bool_t ReadTracklets();
89 Bool_t ReadTracks();
90
6cd9a21f 91 Bool_t WriteClusters(Int_t det);
3d0c7d6d 92 void ResetRecPoints();
93 virtual TClonesArray *RecPoints();
cb8b99ee 94 virtual TClonesArray *TrackletsArray(const TString &trkltype = "");
a1c095f1 95 virtual TClonesArray *TracksArray();
bdbb05bb 96
6cd9a21f 97 Bool_t Raw2Clusters(AliRawReader *rawReader);
98 Bool_t Raw2ClustersChamber(AliRawReader *rawReader);
3fe61b77 99
6cd9a21f 100 Bool_t MakeClusters();
101 Bool_t MakeClusters(Int_t det);
3fe61b77 102
6cd9a21f 103 Bool_t AddLabels();
b72f4eaf 104 Bool_t SetUseLabels(const Bool_t kset) { SetBit(kLabels, kset); return TestBit(kLabels); } // should we assign labels to clusters
6cd9a21f 105 void SetRawVersion(const Int_t iver) { fRawVersion = iver; } // set the expected raw data version
3a039a31 106 void SetReconstructor(const AliTRDReconstructor *rec) {fReconstructor = rec;}
66f6bfd9 107 static UChar_t GetStatus(Short_t &signal);
e7295a3a 108 Int_t GetAddedClusters() const {return fNoOfClusters;}
293e8ba7 109 Int_t GetNTimeBins() const {return fTimeTotal;}
66f6bfd9 110
8c499dbf 111 Bool_t IsClustersOwner() const {return TestBit(kClOwner);}
29f3223b 112 virtual void SetClustersOwner(Bool_t own=kTRUE) {SetBit(kClOwner, own); if(!own) {fRecPoints = 0x0; fNoOfClusters=0;} }
8c499dbf 113 void SetTrackletsOwner(Bool_t own=kTRUE) {SetBit(kTrOwner, own); if(!own) {fTracklets = 0x0; } }
a1c095f1 114 void SetTracksOwner(Bool_t own=kTRUE) {SetBit(kTracksOwner, own); if(!own) {fTracks = 0x0; } }
d03bfe2b 115 void SetSkipTransform(Bool_t b=kTRUE) {SetBit(kSkipTrafo, b); }
3a039a31 116
8eab6a01 117 Int_t GetTriggerFlags(const Int_t sector) const { return fRawStream->GetTriggerFlags(sector); }
118
b72f4eaf 119protected:
b65e5048 120
9dcc64cc 121 void ApplyTCTM(Short_t *const arr, const Int_t nTime, const Int_t nexp);
1ab4da8c 122 void DeConvExp (Short_t *const arr, const Int_t nTime, const Int_t nexp);
9dcc64cc 123 void ConvExp(Short_t *const arr, const Int_t nTime);
fc0882f3 124 void TailCancelation(const AliTRDrecoParam* const recoParam);
064d808d 125
8c499dbf 126 Float_t Unfold(Double_t eps, Int_t layer, const Double_t *const padSignal) const;
6d9e79cc 127
e7295a3a 128 void SetPadStatus(const UChar_t status, UChar_t &encoding) const;
064d808d 129 UChar_t GetPadStatus(UChar_t encoding) const;
130 Int_t GetCorruption(UChar_t encoding) const;
131
1b3a719f 132 Bool_t IsMaximum(const MaxStruct &Max, UChar_t &padStatus, Short_t *const Signals); //for const correctness reasons not const parameters are given separately
133 Bool_t FivePadCluster(MaxStruct &ThisMax, MaxStruct &NeighbourMax);
486c2339 134 void CreateCluster(const MaxStruct &Max);
8dbc94c7 135
e7295a3a 136 virtual void AddClusterToArray(AliTRDcluster* cluster);
3fe61b77 137
8dbc94c7 138private:
139 inline void CalcAdditionalInfo(const MaxStruct &Max, Short_t *const signals, Int_t &nPadCount);
140
141protected:
3d0c7d6d 142 const AliTRDReconstructor *fReconstructor; //! reconstructor
3fe61b77 143 AliRunLoader *fRunLoader; //! Run Loader
144 TTree *fClusterTree; //! Tree with the cluster
66f6bfd9 145 TClonesArray *fRecPoints; //! Array of clusters
a5b99acd 146 TClonesArray *fTracklets; //! Array of online tracklets
a1c095f1 147 TClonesArray *fTracks; //! Array of GTU tracks
3fe61b77 148
b65e5048 149 TTree *fTrackletTree; //! Tree for tracklets
9c7c9ec1 150
3fe61b77 151 AliTRDdigitsManager *fDigitsManager; //! TRD digits manager
152
b65e5048 153 UInt_t **fTrackletContainer; //! tracklet container
a1c095f1 154 // legacy code to avoid breakint AliHLTTRDClusterizer
155 // but it's useless
9c7c9ec1 156
3fe61b77 157 Int_t fRawVersion; // Expected raw version of the data - default is 2
158
3fe61b77 159 AliTRDtransform *fTransform; //! Transforms the reconstructed space points
f7336fa3 160
3d0c7d6d 161 AliTRDarrayADC *fDigits; // Array holding the digits
162 AliTRDSignalIndex *fIndexes; // Array holding the indexes to the digits
1ab4da8c 163 Short_t fMaxThresh; // Threshold value for the maximum
164 Short_t fMaxThreshTest; // Threshold value for the maximum to test agains
165 Short_t fSigThresh; // Threshold value for the digit signal
064d808d 166 Float_t fMinMaxCutSigma; // Threshold value for the maximum (cut noise)
167 Float_t fMinLeftRightCutSigma; // Threshold value for the sum pad (cut noise)
168 Int_t fLayer; // Current layer of the detector
169 Int_t fDet; // Current detecor
170 UShort_t fVolid; // Volume ID
171 Int_t fColMax; // Number of Colums in one detector
172 Int_t fTimeTotal; // Number of time bins
173 AliTRDCalROC *fCalGainFactorROC; // Calibration object with pad wise values for the gain factors
174 Float_t fCalGainFactorDetValue;// Calibration value for chamber wise noise
175 AliTRDCalROC *fCalNoiseROC; // Calibration object with pad wise values for the noise
176 Float_t fCalNoiseDetValue; // Calibration value for chamber wise noise
3d0c7d6d 177 AliTRDCalSingleChamberStatus *fCalPadStatusROC; // Calibration object with the pad status
e8e7f17e 178 AliTRDCalOnlineGainTableROC *fCalOnGainROC; // Calibration table of online gain factors
064d808d 179 Int_t fClusterROC; // The index to the first cluster of a given ROC
180 Int_t firstClusterROC; // The number of cluster in a given ROC
3d0c7d6d 181 Int_t fNoOfClusters; // Number of Clusters already processed and still owned by the clusterizer
615f0826 182 Int_t fBaseline; // Baseline of the ADC values
8df1f8f5 183 AliTRDrawStream *fRawStream; // Raw data streamer
064d808d 184
3d0c7d6d 185 ClassDef(AliTRDclusterizer,6) // TRD clusterfinder
f7336fa3 186
187};
188
f7336fa3 189#endif