]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/TRDbase/AliTRDclusterizer.h
Add macro for local gain table OCDB entry
[u/mrichter/AliRoot.git] / TRD / TRDbase / 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 #include "AliTRDgeometry.h"
17
18 class TFile;
19 class TTree;
20 class TClonesArray;
21
22 class AliRunLoader;
23 class AliRawReader;
24
25 class AliTRD;
26 class AliTRDcluster;
27
28 class AliTRDrawStream;
29 class AliTRDarrayADC;
30 class AliTRDarraySignal;
31 class AliTRDdigitsManager;
32 class AliTRDSignalIndex;
33 class AliTRDtransform;
34 class AliTRDCalROC;
35 class AliTRDReconstructor;
36 class AliTRDCalSingleChamberStatus;
37 class AliTRDrecoParam;
38 class AliTRDCalOnlineGainTableROC;
39
40 class AliTRDclusterizer : public TNamed 
41 {
42
43  public:
44
45   // steering flags
46   // bits from 0-13 are reserved by ROOT (see TObject.h)
47   enum{
48     kTrOwner = BIT(14)  //  toggle online tracklets ownership
49     ,kClOwner= BIT(15)  //  toggle cluster ownership
50     ,kLabels = BIT(16)  //  toggle MC labels for clusters
51     ,kSkipTrafo = BIT(17)  //  skip the coordinate transformation of clusters?
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?
55     ,kTracksOwner = BIT(21) //  toggle GTU track ownership
56     ,kRawSignal = BIT(22) //  toggle storage of raw signals in clusters
57   };
58
59   struct MaxStruct
60   {
61     Int_t       row;           // row of the current cluster candidate
62     Int_t       col;           // col of the current cluster candidate
63     Int_t       time;          // time -"-
64     Float_t     signals[3];    // signals of the maximum pad and it's twon neigbours
65     UChar_t     padStatus;     // padStatus of the current cluster candidate
66     Bool_t      fivePad;       // is this cluster candidate part of a 5 pad cluster (two overlaping clusters)?
67   MaxStruct():row(-1),col(0),time(0),padStatus(0),fivePad(kFALSE)
68       {memset(signals, 0, 3*sizeof(Float_t));}
69     MaxStruct &operator=(const MaxStruct &a)
70     {memcpy(this, &a, sizeof(MaxStruct)); return *this;}
71   };
72   
73   AliTRDclusterizer(const AliTRDReconstructor *const rec = 0x0);
74   AliTRDclusterizer(const Text_t* name, const Text_t* title, const AliTRDReconstructor *const rec = 0x0);
75   AliTRDclusterizer(const AliTRDclusterizer &c);
76   virtual         ~AliTRDclusterizer();
77   AliTRDclusterizer &operator=(const AliTRDclusterizer &c);
78
79   void     Copy(TObject &c) const;
80
81   Bool_t   Open(const Char_t *name, Int_t nEvent = 0);
82   Bool_t   OpenInput(Int_t nEvent = 0);
83   Bool_t   OpenOutput();
84   Bool_t   OpenOutput(TTree *const clusterTree);
85
86   Bool_t   ReadDigits();
87   Bool_t   ReadDigits(AliRawReader *rawReader);
88   Bool_t   ReadDigits(TTree *digitsTree);
89
90   Bool_t   ReadTracklets();
91   Bool_t   ReadTracks();
92
93   Bool_t   WriteClusters(Int_t det);
94   void     ResetRecPoints()                { fNoOfClusters = 0;}
95   virtual TClonesArray    *RecPoints();
96   virtual TClonesArray    *TrackletsArray(const TString &trkltype = "");
97   virtual TClonesArray    *TracksArray();
98
99   Bool_t   Raw2Clusters(AliRawReader *rawReader);
100   Bool_t   Raw2ClustersChamber(AliRawReader *rawReader);
101
102   Bool_t   MakeClusters();
103   Bool_t   MakeClusters(Int_t det);
104
105   Bool_t   AddLabels();
106   Bool_t   SetUseLabels(const Bool_t kset) { SetBit(kLabels, kset); return TestBit(kLabels);  } // should we assign labels to clusters
107   void     SetRawVersion(const Int_t iver) { fRawVersion = iver; } // set the expected raw data version
108   void             SetReconstructor(const AliTRDReconstructor *rec) {fReconstructor = rec;}
109   static UChar_t   GetStatus(Short_t &signal);
110   Int_t            GetAddedClusters() const {return fNoOfClusters;}
111   Int_t            GetNTimeBins() const {return fTimeTotal;}
112   Int_t            GetNTimeBinsDCS() const {return fTimeBinsDCS;}
113
114   Bool_t           IsClustersOwner() const {return TestBit(kClOwner);}
115   virtual void     SetClustersOwner(Bool_t own=kTRUE) {SetBit(kClOwner, own); if(!own) {fRecPoints = 0x0; fNoOfClusters=0;} }
116   void             SetTrackletsOwner(Bool_t own=kTRUE) {SetBit(kTrOwner, own); if(!own) {fTracklets = 0x0; } }
117   void             SetTracksOwner(Bool_t own=kTRUE) {SetBit(kTracksOwner, own); if(!own) {fTracks = 0x0; } }
118   void             SetSkipTransform(Bool_t b=kTRUE) {SetBit(kSkipTrafo, b); }
119   void             SetStoreRawSignals(Bool_t b=kTRUE) {SetBit(kRawSignal, b); }
120
121   UInt_t   GetTriggerFlags(const Int_t sector) const { return fTrgFlags[sector]; }
122
123 protected:
124
125   void             ApplyTCTM(Short_t *const arr, const Int_t nTime, const Int_t nexp);
126   void             DeConvExp (Short_t *const arr, const Int_t nTime, const Int_t nexp);
127   void             ConvExp(Short_t *const arr, const Int_t nTime);
128   void             TailCancelation(const AliTRDrecoParam* const recoParam);
129
130   Float_t          Unfold(Double_t eps, Int_t layer, const Double_t *const padSignal) const;
131   
132   void             SetPadStatus(const UChar_t status, UChar_t &encoding) const;
133   UChar_t          GetPadStatus(UChar_t encoding) const;
134   Int_t            GetCorruption(UChar_t encoding) const;
135
136   Bool_t           IsMaximum(const MaxStruct &Max, UChar_t &padStatus, Float_t *const Signals);       //for const correctness reasons not const parameters are given separately
137   Bool_t           FivePadCluster(MaxStruct &ThisMax, MaxStruct &NeighbourMax);
138   void             CreateCluster(const MaxStruct &Max); 
139
140   virtual void     AddClusterToArray(AliTRDcluster* cluster);
141
142   const AliTRDReconstructor *fReconstructor;     //! reconstructor
143   AliRunLoader        *fRunLoader;                //! Run Loader
144   TTree               *fClusterTree;              //! Tree with the cluster
145   TClonesArray        *fRecPoints;                //! Array of clusters
146   TClonesArray        *fTracklets;                //! Array of online tracklets
147   TClonesArray        *fTracks;                   //! Array of GTU tracks
148
149   AliTRDdigitsManager *fDigitsManager;            //! TRD digits manager
150
151   Int_t                fRawVersion;               //  Expected raw version of the data - default is 2
152
153   AliTRDtransform     *fTransform;                //! Transforms the reconstructed space points
154
155   AliTRDarrayADC      *fDigits;                   // Array holding the digits
156   AliTRDarrayADC      *fDigitsRaw;                // Array holding the raw digits if requested
157   AliTRDSignalIndex   *fIndexes;                  // Array holding the indexes to the digits
158   Float_t              fMaxThresh;                // Threshold value for the maximum
159   Float_t              fMaxThreshTest;            // Threshold value for the maximum to test agains
160   Float_t              fSigThresh;                // Threshold value for the digit signal
161   Float_t              fMinMaxCutSigma;           // Threshold value for the maximum (cut noise)
162   Float_t              fMinLeftRightCutSigma;     // Threshold value for the sum pad (cut noise)
163   Int_t                fLayer;                    // Current layer of the detector
164   Int_t                fDet;                      // Current detecor
165   UShort_t             fVolid;                    // Volume ID
166   Int_t                fColMax;                   // Number of Colums in one detector
167   Int_t                fTimeTotal;                // Number of time bins
168   Int_t                fTimeBinsDCS;              // number or time bins from DCS (OCDB)
169   Int_t                fRun;                      // last run processed (to update cached OCDB params if run changes)
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 *fCalOnlGainROC;     // 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   UInt_t               fTrgFlags[AliTRDgeometry::kNsector]; // trigger flags
182 private:
183   inline void      CalcAdditionalInfo(const MaxStruct &Max, Short_t *const signals, Int_t &nPadCount);
184
185   ClassDef(AliTRDclusterizer,7)                   //  TRD clusterfinder
186
187 };
188
189 #endif