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