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