]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCAltroEmulator.h
new class for PbPb cut analysis
[u/mrichter/AliRoot.git] / TPC / AliTPCAltroEmulator.h
1 #ifndef ALI_TPC_ALTRO_EMULATOR_H
2 #define ALI_TPC_ALTRO_EMULATOR_H
3
4
5 /**             @file AliTPCAltroEmulator.h
6         *       @brief This the header File for the Altro class
7         *
8         *       @author Roland Bramm
9         *       @version $LastChangedRevision: 688 $
10         *       @date    $LastChangedDate: 2005-12-16 14:07:11 +0100 (Fri, 16 Dec 2005) $
11         *
12         *       \verbinclude Altro/Altro.h.log
13 */
14
15
16 ///////////////////////////////////////////////////////////////////////////////
17 //                        Class AliTPCAltroEmulator                          //
18 //  Class for emulation of the ALTRO chip (Altro digital Chain) in C++       //
19 ///////////////////////////////////////////////////////////////////////////////
20
21 #include "TSystem.h"
22
23
24 #include <iostream>
25 #include <stdlib.h>
26 #include <stdio.h>
27 #include <string.h>
28 #include <AliRawReader.h>
29 #include <AliTPCRawStreamV3.h>
30
31
32 using namespace std;
33
34 class AliTPCAltroEmulator : public TNamed {
35
36  public:
37   AliTPCAltroEmulator(Int_t timebins=0, Short_t* Channel=0);
38   AliTPCAltroEmulator(const AliTPCAltroEmulator &sig);
39   ~AliTPCAltroEmulator();
40   AliTPCAltroEmulator& operator = (const  AliTPCAltroEmulator &source);
41
42   void ConfigAltro(Int_t ONBaselineCorrection1, Int_t ONTailcancellation, Int_t ONBaselineCorrection2, Int_t ONClipping, Int_t ONZerosuppression, Int_t ONDataFormatting);
43   void ConfigBaselineCorrection1(Int_t mode, Int_t ValuePeDestal, Int_t *PedestalMem, Int_t polarity);
44   void ConfigTailCancellationFilter(Int_t K1, Int_t K2, Int_t K3, Int_t L1, Int_t L2, Int_t L3);
45   void ConfigBaselineCorrection2(Int_t HighThreshold, Int_t LowThreshold, Int_t Offset, Int_t Presamples, Int_t Postsamples);
46   void ConfigZerosuppression(Int_t Threshold, Int_t MinSamplesaboveThreshold, Int_t Presamples, Int_t Postsamples);
47
48   void SetChannelData(Int_t timebins, Short_t* Channel);
49   void PrintParameters();
50   void RunEmulation();
51   Float_t CalculateCompression();
52
53   // perform altro emulation on raw-reader level
54
55   void RunEmulationOnRAWdata(AliRawReader *reader, Int_t plotFlag=0);
56
57   TString GetDDLFolderName()      const {return fDDLFolderName     ;}
58   TString GetOutputDateFileName() const {return fOutputDateFileName;}
59   TString GetOutputRootFileName() const {return fOutputRootFileName;}
60   void SetDDLFolderName     (const TString &name) {fDDLFolderName     =name;}
61   void SetOutputDateFileName(const TString &name) {fOutputDateFileName=name;}
62   void SetOutputRootFileName(const TString &name) {fOutputRootFileName=name;}
63
64
65
66
67   enum {
68     /**din - fpd*/                      kDINxFPD,
69     /**din - f(t)*/                     kDINxFT,
70     /**din - f(din)*/                   kDINxFDIN,
71     /**din - f(din-vpd)*/               kDINxFDINxVPD,
72     /**din - vpd - fpd*/                kDINxVPDxFPD,
73     /**din - vpd - f(t)*/               kDINxVPDxFT,
74     /**din - vpd - f(din)*/             kDINxVPDxFDIN,
75     /**din - vpd - f(din - vpd)*/       kDINxVPDxFDINxVPD,
76     /**f(din) - fpd*/                   kFDINxFPD,
77     /**f(din - vpd) - fpd*/             kFDINxVPDxFPD,
78     /**f(t) - fpd*/                     kFTxFPD,
79     /**f(t) - f(t)*/                    kFTxFT,
80     /**f(din) - f(din)*/                kFDINxFDIN,
81     /**f(din - vpd) - f(din - vpd)*/    kFDINxVPDxFDINxVPD,
82     /**din - fpd*/                      kDINxFPD1,
83     /**din - fpd*/                      kDINxFPD2
84   };
85
86  private:
87
88   Int_t ftimebins;          // timebins
89
90   //    Short_t *fChannelIn;      // ChannelIn
91   Short_t *fChannelShort;   // incoming signal in Short_t format
92   Short_t *fADCkeep;        // ADCkeep
93
94   Int_t fOnBSL1;            // Baseline correction and substraction 1 on
95   Int_t fOnTCF;             // Tail Cancelation Filter on
96   Int_t fOnBSL2;            // Baseline correction and substraction 2 (MAF) on
97   Int_t fOnClip;            // Clipping on (to reverse the signal for ZSU if BSL2 is on)
98   Int_t fOnZSU;             // Zero Suppression on
99
100   Int_t fConfiguredAltro;   // ConfiguredAltro
101   Int_t fConfiguredBSL1;    // ConfiguredBSL1
102   Int_t fConfiguredTCF;     // ConfiguredTCF
103   Int_t fConfiguredBSL2;    // ConfiguredBSL2
104   Int_t fConfiguredZSU;     // ConfiguredZSU
105
106   Int_t fBSL1mode;          // BSL1mode
107   Int_t fBSL1ValuePeDestal; // BSL1ValuePeDestal
108   Int_t* fBSL1PedestalMem;  // BSL1PedestalMem
109   Int_t fBSL1polarity;      // BSL1polarity
110
111   Float_t fTCFK1; // K1
112   Float_t fTCFK2; // K2
113   Float_t fTCFK3; // K3
114   Float_t fTCFL1; // L1
115   Float_t fTCFL2; // L2
116   Float_t fTCFL3; // L3
117
118   Int_t fTCFK1Int; // K1Int
119   Int_t fTCFK2Int; // K2Int
120   Int_t fTCFK3Int; // K3Int
121   Int_t fTCFL1Int; // L1Int
122   Int_t fTCFL2Int; // L2Int
123   Int_t fTCFL3Int; // L3Int
124
125   Int_t fBSL2HighThreshold; // BSL2HighThreshold
126   Int_t fBSL2LowThreshold;  // BSL2LowThreshold
127   Int_t fBSL2Offset;        // BSL2Offset
128   Int_t fBSL2Presamples;    // BSL2Presamples;
129   Int_t fBSL2Postsamples;   // BSL2Postsamples
130
131   Int_t fZSUThreshold;      // ZSUThreshold
132   Int_t fZSUMinSamplesaboveThreshold; // ZSUMinSamplesaboveThreshold
133   Int_t fZSUPresamples;     // ZSUPresamples
134   Int_t fZSUPostsamples;    // ZSUPostsamples
135
136   void BaselineCorrection1(Int_t mode, Int_t FixedPeDestal, Int_t *PedestalMem, Int_t polarity);
137   void TailCancellationFilterFixedPoint(Int_t K1, Int_t K2, Int_t K3, Int_t L1, Int_t L2, Int_t L3);
138   void BaselineCorrection2RTL(Int_t HighThreshold, Int_t LowThreshold, Int_t Offset, Int_t Presamples, Int_t Postsamples);
139   void Clipping();
140   void Zerosuppression(Int_t Threshold, Int_t MinSamplesaboveThreshold, Int_t Presamples, Int_t Postsamples);
141   void DataFormater();
142
143   Short_t GetElement(short* Array,Int_t index);
144   void SetElement(short* Array,Int_t index,Short_t value);
145
146   Int_t InBand(Int_t ADC,Int_t bsl, Int_t LowThreshold, Int_t HighThreshold);
147   Int_t InRange(Int_t parameter,Int_t Low,Int_t High,const char *Module,const char *ParameterName);
148   Short_t GetShortChannel(Int_t i);
149   Short_t GetKeepChannel(Int_t i);
150   Int_t Multiply36(Int_t P, Int_t N);
151   long long Mask(long long in, Int_t left, Int_t right);
152   long long Maskandshift(long long in, Int_t left, Int_t right);
153
154
155   
156   void InitBuffers();
157   Bool_t AddEvent(Int_t dt,Bool_t isFirst);
158   Bool_t CreateEvent(Int_t ievent);
159   Bool_t GDC2DDLs(AliRawVEvent *gdc,Int_t ievent);
160   Bool_t ConvertRawFilesToDate(Int_t nevents);
161   Bool_t ConvertDateToRoot();
162   Bool_t WriteEvent(Int_t ievent);
163
164   AliRawReader      *fReader ; // RAW reader
165   AliTPCRawStreamV3 *fDecoder; // ALTRO decoder
166
167   TString fDDLFolderName;      // folder name for ddl files
168   TString fOutputDateFileName; // filename for date output
169   TString fOutputRootFileName; // filename for root output
170
171   Float_t  fP[2047] ; // Interaction probabilities for times (T-1023,...T,...T+1023)
172   Bool_t   fIsRandom; // Indicates if fP are treated as probabilities (in terms of Possionian statistics), or fixed numbers
173   Bool_t  *fChannels; //! field of active channels
174   UInt_t  *fCDHs    ; //! CDHs
175   Short_t *fADCs    ; //! field of ADC counts
176   UInt_t  *fTrailers; //! RCU trailers
177   UInt_t  *fRawData ; //! Raw Data
178
179
180   ClassDef(AliTPCAltroEmulator,1);
181 };
182 #endif