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