]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDclusterizer.h
Making online tracklets usable in offline reconstruction
[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
35 class AliTRDclusterizer : public TNamed 
36 {
37
38  public:
39
40   // steering flags
41   enum{
42     kTrOwner= BIT(13)  //  toggle online tracklets ownership
43    ,kClOwner= BIT(14)  //  toggle cluster ownership
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
48   };
49
50   struct MaxStruct
51   {
52     Int_t       Row;
53     Int_t       Col;
54     Int_t       Time;
55     UChar_t     padStatus;
56     Short_t     Signals[3];
57     Bool_t      FivePad;
58   MaxStruct():Row(-1),Col(0),Time(0),padStatus(0),FivePad(kFALSE)
59       {memset(Signals, 0, 3*sizeof(Short_t));}
60     MaxStruct &operator=(const MaxStruct &a)
61     {Row=a.Row; Col=a.Col; Time=a.Time; padStatus=a.padStatus; FivePad=a.FivePad;
62      memcpy(Signals, a.Signals, 3*sizeof(Short_t)); return *this;}
63   };
64   
65   AliTRDclusterizer(const AliTRDReconstructor *const rec = 0x0);
66   AliTRDclusterizer(const Text_t* name, const Text_t* title, const AliTRDReconstructor *const rec = 0x0);
67   AliTRDclusterizer(const AliTRDclusterizer &c);
68   virtual         ~AliTRDclusterizer();
69   AliTRDclusterizer &operator=(const AliTRDclusterizer &c);
70
71   void     Copy(TObject &c) const;
72
73   Bool_t   Open(const Char_t *name, Int_t nEvent = 0);
74   Bool_t   OpenInput(Int_t nEvent = 0);
75   Bool_t   OpenOutput();
76   Bool_t   OpenOutput(TTree *clusterTree);
77
78   Bool_t   ReadDigits();
79   Bool_t   ReadDigits(AliRawReader *rawReader);
80   Bool_t   ReadDigits(TTree *digitsTree);
81
82   Bool_t   WriteClusters(Int_t det);
83   void     ResetRecPoints();
84   virtual TClonesArray    *RecPoints();
85   TClonesArray    *TrackletsArray();
86   Bool_t   WriteTracklets(Int_t det);
87
88   Bool_t   Raw2Clusters(AliRawReader *rawReader);
89   Bool_t   Raw2ClustersChamber(AliRawReader *rawReader);
90
91   Bool_t   MakeClusters();
92   Bool_t   MakeClusters(Int_t det);
93
94   Bool_t   AddLabels();
95   Bool_t   SetUseLabels(const Bool_t kset) { SetBit(kLabels, kset); return TestBit(kLabels);  } // should we assign labels to clusters
96   void     SetRawVersion(const Int_t iver) { fRawVersion = iver; } // set the expected raw data version
97   void             SetReconstructor(const AliTRDReconstructor *rec) {fReconstructor = rec;}
98   static UChar_t   GetStatus(Short_t &signal);
99   Int_t            GetAddedClusters() {return fNoOfClusters;}
100
101   Bool_t   IsClustersOwner() const {return TestBit(kClOwner);}
102   virtual void     SetClustersOwner(Bool_t own=kTRUE) {SetBit(kTrOwner, own); if(!own) {fRecPoints = 0x0; fNoOfClusters=0;} }
103   void     SetTrackletsOwner(Bool_t own=kTRUE) {SetBit(kTrOwner, own); if(!own) {fTracklets = 0x0; } }
104
105 protected:
106
107   void             DeConvExp (const Double_t *const source, Double_t *const target
108                              ,const Int_t nTimeTotal, const Int_t nexp);
109   void             TailCancelation();
110
111   Float_t  Unfold(Double_t eps, Int_t layer, Double_t *padSignal) const;
112   
113   void             SetPadStatus(const UChar_t status, UChar_t &encoding);
114   UChar_t          GetPadStatus(UChar_t encoding) const;
115   Int_t            GetCorruption(UChar_t encoding) const;
116
117   Bool_t           IsMaximum(const MaxStruct &Max, UChar_t &padStatus, Short_t *const Signals);       //for const correctness reasons not const parameters are given separately
118   Bool_t           FivePadCluster(MaxStruct &ThisMax, MaxStruct &NeighbourMax);
119   void             CreateCluster(const MaxStruct &Max); 
120   inline void      CalcAdditionalInfo(const MaxStruct &Max, Short_t *const signals, Int_t &nPadCount);
121   virtual void     AddClusterToArray(AliTRDcluster *cluster);
122   inline void      AddTrackletsToArray();
123
124   const AliTRDReconstructor *fReconstructor; //! reconstructor
125   AliRunLoader        *fRunLoader;           //! Run Loader
126   TTree               *fClusterTree;         //! Tree with the cluster
127   TClonesArray        *fRecPoints;           //! Array of clusters
128   TClonesArray        *fTracklets;           //! Array of online tracklets
129
130   TTree               *fTrackletTree;        //! Tree for tracklets
131
132   AliTRDdigitsManager *fDigitsManager;       //! TRD digits manager
133
134   UInt_t              **fTrackletContainer;  //! tracklet container
135
136   Int_t                fRawVersion;          //  Expected raw version of the data - default is 2
137
138   AliTRDtransform     *fTransform;           //! Transforms the reconstructed space points
139
140   AliTRDarrayADC      *fDigits;               // Array holding the digits
141   AliTRDSignalIndex   *fIndexes;              // Array holding the indexes to the digits
142   Float_t              fADCthresh;            // ADC thresholds: There is no ADC threshold anymore, and simParam should not be used in clusterizer. KO
143   Float_t              fMaxThresh;            // Threshold value for the maximum
144   Float_t              fSigThresh;            // Threshold value for the digit signal
145   Float_t              fMinMaxCutSigma;       // Threshold value for the maximum (cut noise)
146   Float_t              fMinLeftRightCutSigma; // Threshold value for the sum pad (cut noise)
147   Int_t                fLayer;                // Current layer of the detector
148   Int_t                fDet;                  // Current detecor
149   UShort_t             fVolid;                // Volume ID
150   Int_t                fColMax;               // Number of Colums in one detector
151   Int_t                fTimeTotal;            // Number of time bins
152   AliTRDCalROC        *fCalGainFactorROC;     // Calibration object with pad wise values for the gain factors
153   Float_t              fCalGainFactorDetValue;// Calibration value for chamber wise noise
154   AliTRDCalROC        *fCalNoiseROC;          // Calibration object with pad wise values for the noise
155   Float_t              fCalNoiseDetValue;     // Calibration value for chamber wise noise
156   AliTRDCalSingleChamberStatus *fCalPadStatusROC; // Calibration object with the pad status
157   Int_t                fClusterROC;           // The index to the first cluster of a given ROC
158   Int_t                firstClusterROC;       // The number of cluster in a given ROC
159   Int_t                fNoOfClusters;         // Number of Clusters already processed and still owned by the clusterizer
160
161   ClassDef(AliTRDclusterizer,6)               //  TRD clusterfinder
162
163 };
164
165 #endif