]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCAltroEmulator.h
1. Added epoxy with incresed density.
[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
39   ~AliTPCAltroEmulator();
40
41   void ConfigAltro(Int_t ONBaselineCorrection1, Int_t ONTailcancellation, Int_t ONBaselineCorrection2, Int_t ONClipping, Int_t ONZerosuppression, Int_t ONDataFormatting);
42   void ConfigBaselineCorrection1(Int_t mode, Int_t ValuePeDestal, Int_t *PedestalMem, Int_t polarity);
43   void ConfigTailCancellationFilter(Int_t K1, Int_t K2, Int_t K3, Int_t L1, Int_t L2, Int_t L3);
44   void ConfigTailCancellationFilterForRAWfiles(const Int_t* K1, const Int_t* K2, const Int_t* K3, 
45                                                const Int_t* L1, const Int_t* L2, const Int_t* L3);
46   void ConfigBaselineCorrection2(Int_t HighThreshold, Int_t LowThreshold, Int_t Offset, Int_t Presamples, Int_t Postsamples);
47   void ConfigZerosuppression(Int_t Threshold, Int_t MinSamplesaboveThreshold, Int_t Presamples, Int_t Postsamples);
48
49   void SetChannelData(Int_t timebins, Short_t* Channel);
50   void PrintParameters();
51   void RunEmulation(Int_t roc=-1); // if -1, the standard "single" TCF is used
52   Float_t CalculateCompression();
53
54   // perform altro emulation on raw-reader level
55
56   void RunEmulationOnRAWdata(AliRawReader *reader, Int_t plotFlag=0);
57
58   TString GetDDLFolderName()      const {return fDDLFolderName     ;}
59   TString GetOutputDateFileName() const {return fOutputDateFileName;}
60   TString GetOutputRootFileName() const {return fOutputRootFileName;}
61   void SetDDLFolderName     (const TString &name) {fDDLFolderName     =name;}
62   void SetOutputDateFileName(const TString &name) {fOutputDateFileName=name;}
63   void SetOutputRootFileName(const TString &name) {fOutputRootFileName=name;}
64
65
66
67
68   enum {
69     /**din - fpd*/                      kDINxFPD,
70     /**din - f(t)*/                     kDINxFT,
71     /**din - f(din)*/                   kDINxFDIN,
72     /**din - f(din-vpd)*/               kDINxFDINxVPD,
73     /**din - vpd - fpd*/                kDINxVPDxFPD,
74     /**din - vpd - f(t)*/               kDINxVPDxFT,
75     /**din - vpd - f(din)*/             kDINxVPDxFDIN,
76     /**din - vpd - f(din - vpd)*/       kDINxVPDxFDINxVPD,
77     /**f(din) - fpd*/                   kFDINxFPD,
78     /**f(din - vpd) - fpd*/             kFDINxVPDxFPD,
79     /**f(t) - fpd*/                     kFTxFPD,
80     /**f(t) - f(t)*/                    kFTxFT,
81     /**f(din) - f(din)*/                kFDINxFDIN,
82     /**f(din - vpd) - f(din - vpd)*/    kFDINxVPDxFDINxVPD,
83     /**din - fpd*/                      kDINxFPD1,
84     /**din - fpd*/                      kDINxFPD2,
85     /** 16. din-mean*/                  kDINxMPD
86   };
87
88  private:
89
90   AliTPCAltroEmulator(const AliTPCAltroEmulator &sig);
91   AliTPCAltroEmulator& operator = (const  AliTPCAltroEmulator &source);
92
93   Int_t ftimebins;          // timebins
94
95   //    Short_t *fChannelIn;      // ChannelIn
96   Short_t *fChannelShort;   // incoming signal in Short_t format
97   Short_t *fADCkeep;        // ADCkeep
98
99   Int_t fOnBSL1;            // Baseline correction and substraction 1 on
100   Int_t fOnTCF;             // Tail Cancelation Filter on
101   Int_t fOnBSL2;            // Baseline correction and substraction 2 (MAF) on
102   Int_t fOnClip;            // Clipping on (to reverse the signal for ZSU if BSL2 is on)
103   Int_t fOnZSU;             // Zero Suppression on
104
105   Int_t fConfiguredAltro;   // ConfiguredAltro
106   Int_t fConfiguredBSL1;    // ConfiguredBSL1
107   Int_t fConfiguredTCF;     // ConfiguredTCF
108   Int_t fConfiguredTCFraw;  // ConfiguredTCF for RAW data files
109   Int_t fConfiguredBSL2;    // ConfiguredBSL2
110   Int_t fConfiguredZSU;     // ConfiguredZSU
111
112   Int_t fBSL1mode;          // BSL1mode
113   Int_t fBSL1ValuePeDestal; // BSL1ValuePeDestal
114   Int_t* fBSL1PedestalMem;  // BSL1PedestalMem
115   Int_t fBSL1polarity;      // BSL1polarity
116
117   Float_t fTCFK1; // K1
118   Float_t fTCFK2; // K2
119   Float_t fTCFK3; // K3
120   Float_t fTCFL1; // L1
121   Float_t fTCFL2; // L2
122   Float_t fTCFL3; // L3
123
124   Int_t fTCFK1Int; // K1Int
125   Int_t fTCFK2Int; // K2Int
126   Int_t fTCFK3Int; // K3Int
127   Int_t fTCFL1Int; // L1Int
128   Int_t fTCFL2Int; // L2Int
129   Int_t fTCFL3Int; // L3Int
130
131   Int_t fTCFK1IntROC[2]; // K1Int (IROC/OROC)
132   Int_t fTCFK2IntROC[2]; // K2Int (IROC/OROC)
133   Int_t fTCFK3IntROC[2]; // K3Int (IROC/OROC)
134   Int_t fTCFL1IntROC[2]; // L1Int (IROC/OROC)
135   Int_t fTCFL2IntROC[2]; // L2Int (IROC/OROC)
136   Int_t fTCFL3IntROC[2]; // L3Int (IROC/OROC)
137
138   Int_t fBSL2HighThreshold; // BSL2HighThreshold
139   Int_t fBSL2LowThreshold;  // BSL2LowThreshold
140   Int_t fBSL2Offset;        // BSL2Offset
141   Int_t fBSL2Presamples;    // BSL2Presamples;
142   Int_t fBSL2Postsamples;   // BSL2Postsamples
143
144   Int_t fZSUThreshold;      // ZSUThreshold
145   Int_t fZSUMinSamplesaboveThreshold; // ZSUMinSamplesaboveThreshold
146   Int_t fZSUPresamples;     // ZSUPresamples
147   Int_t fZSUPostsamples;    // ZSUPostsamples
148
149   void BaselineCorrection1(Int_t mode, Int_t FixedPeDestal, Int_t *PedestalMem, Int_t polarity);
150   void TailCancellationFilterFixedPoint(Int_t K1, Int_t K2, Int_t K3, Int_t L1, Int_t L2, Int_t L3);
151   void BaselineCorrection2RTL(Int_t HighThreshold, Int_t LowThreshold, Int_t Offset, Int_t Presamples, Int_t Postsamples);
152   void Clipping();
153   void Zerosuppression(Int_t Threshold, Int_t MinSamplesaboveThreshold, Int_t Presamples, Int_t Postsamples);
154   void DataFormater();
155
156   Short_t GetElement(short* Array,Int_t index);
157   void SetElement(short* Array,Int_t index,Short_t value);
158
159   Int_t InBand(Int_t ADC,Int_t bsl, Int_t LowThreshold, Int_t HighThreshold);
160   Int_t InRange(Int_t parameter,Int_t Low,Int_t High,const char *Module,const char *ParameterName);
161   Short_t GetShortChannel(Int_t i);
162   Short_t GetKeepChannel(Int_t i);
163   Int_t Multiply36(Int_t P, Int_t N);
164   long long Mask(long long in, Int_t left, Int_t right);
165   long long Maskandshift(long long in, Int_t left, Int_t right);
166
167   
168   
169   void InitBuffers();
170   Bool_t AddEvent(Int_t dt,Bool_t isFirst);
171   Bool_t CreateEvent(Int_t ievent);
172   Bool_t GDC2DDLs(AliRawVEvent *gdc,Int_t ievent);
173   Bool_t ConvertRawFilesToDate(Int_t nevents);
174   Bool_t ConvertDateToRoot();
175   Bool_t WriteEvent(Int_t ievent);
176
177   AliRawReader      *fReader ; // RAW reader
178   AliTPCRawStreamV3 *fDecoder; // ALTRO decoder
179
180   Int_t fRunNumber;            // Run Number
181
182   TString fDDLFolderName;      // folder name for ddl files
183   TString fOutputDateFileName; // filename for date output
184   TString fOutputRootFileName; // filename for root output
185
186   //  Float_t  fP[2047] ; // Interaction probabilities for times (T-1023,...T,...T+1023)
187   Bool_t   fIsRandom; // Indicates if fP are treated as probabilities (in terms of Possionian statistics), or fixed numbers
188   Bool_t  *fChannels; //! field of active channels
189   UInt_t  *fCDHs    ; //! CDHs
190   Short_t *fADCs    ; //! field of ADC counts
191   UInt_t  *fTrailers; //! RCU trailers
192   UInt_t  *fRawData ; //! Raw Data
193
194
195   ClassDef(AliTPCAltroEmulator,1);
196 };
197 #endif