Add test for sector-by-sector fits from CE calibration. Fail CE entry production
[u/mrichter/AliRoot.git] / TPC / AliTPCAltroEmulator.h
CommitLineData
eb7e0771 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
b479e253 21#include "TSystem.h"
22
23
eb7e0771 24#include <iostream>
25#include <stdlib.h>
26#include <stdio.h>
27#include <string.h>
338e0dd9 28#include <AliRawReader.h>
29#include <AliTPCRawStreamV3.h>
30
eb7e0771 31
32using namespace std;
33
b479e253 34class AliTPCAltroEmulator : public TNamed {
35
338e0dd9 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);
cd10c6cd 45 void ConfigTailCancellationFilterForRAWfiles(Int_t* K1, Int_t* K2, Int_t* K3, Int_t* L1, Int_t* L2, Int_t* L3);
338e0dd9 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();
cd10c6cd 51 void RunEmulation(Int_t roc=-1); // if -1, the standard "single" TCF is used
338e0dd9 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 };
86
87 private:
88
89 Int_t ftimebins; // timebins
90
91 // Short_t *fChannelIn; // ChannelIn
92 Short_t *fChannelShort; // incoming signal in Short_t format
93 Short_t *fADCkeep; // ADCkeep
94
95 Int_t fOnBSL1; // Baseline correction and substraction 1 on
96 Int_t fOnTCF; // Tail Cancelation Filter on
97 Int_t fOnBSL2; // Baseline correction and substraction 2 (MAF) on
98 Int_t fOnClip; // Clipping on (to reverse the signal for ZSU if BSL2 is on)
99 Int_t fOnZSU; // Zero Suppression on
100
101 Int_t fConfiguredAltro; // ConfiguredAltro
102 Int_t fConfiguredBSL1; // ConfiguredBSL1
103 Int_t fConfiguredTCF; // ConfiguredTCF
cd10c6cd 104 Int_t fConfiguredTCFraw; // ConfiguredTCF for RAW data files
338e0dd9 105 Int_t fConfiguredBSL2; // ConfiguredBSL2
106 Int_t fConfiguredZSU; // ConfiguredZSU
107
108 Int_t fBSL1mode; // BSL1mode
109 Int_t fBSL1ValuePeDestal; // BSL1ValuePeDestal
110 Int_t* fBSL1PedestalMem; // BSL1PedestalMem
111 Int_t fBSL1polarity; // BSL1polarity
112
113 Float_t fTCFK1; // K1
114 Float_t fTCFK2; // K2
115 Float_t fTCFK3; // K3
116 Float_t fTCFL1; // L1
117 Float_t fTCFL2; // L2
118 Float_t fTCFL3; // L3
119
120 Int_t fTCFK1Int; // K1Int
121 Int_t fTCFK2Int; // K2Int
122 Int_t fTCFK3Int; // K3Int
123 Int_t fTCFL1Int; // L1Int
124 Int_t fTCFL2Int; // L2Int
125 Int_t fTCFL3Int; // L3Int
126
cd10c6cd 127 Int_t fTCFK1IntROC[2]; // K1Int (IROC/OROC)
128 Int_t fTCFK2IntROC[2]; // K2Int (IROC/OROC)
129 Int_t fTCFK3IntROC[2]; // K3Int (IROC/OROC)
130 Int_t fTCFL1IntROC[2]; // L1Int (IROC/OROC)
131 Int_t fTCFL2IntROC[2]; // L2Int (IROC/OROC)
132 Int_t fTCFL3IntROC[2]; // L3Int (IROC/OROC)
133
338e0dd9 134 Int_t fBSL2HighThreshold; // BSL2HighThreshold
135 Int_t fBSL2LowThreshold; // BSL2LowThreshold
136 Int_t fBSL2Offset; // BSL2Offset
137 Int_t fBSL2Presamples; // BSL2Presamples;
138 Int_t fBSL2Postsamples; // BSL2Postsamples
139
140 Int_t fZSUThreshold; // ZSUThreshold
141 Int_t fZSUMinSamplesaboveThreshold; // ZSUMinSamplesaboveThreshold
142 Int_t fZSUPresamples; // ZSUPresamples
143 Int_t fZSUPostsamples; // ZSUPostsamples
144
145 void BaselineCorrection1(Int_t mode, Int_t FixedPeDestal, Int_t *PedestalMem, Int_t polarity);
146 void TailCancellationFilterFixedPoint(Int_t K1, Int_t K2, Int_t K3, Int_t L1, Int_t L2, Int_t L3);
147 void BaselineCorrection2RTL(Int_t HighThreshold, Int_t LowThreshold, Int_t Offset, Int_t Presamples, Int_t Postsamples);
148 void Clipping();
149 void Zerosuppression(Int_t Threshold, Int_t MinSamplesaboveThreshold, Int_t Presamples, Int_t Postsamples);
150 void DataFormater();
151
152 Short_t GetElement(short* Array,Int_t index);
153 void SetElement(short* Array,Int_t index,Short_t value);
154
155 Int_t InBand(Int_t ADC,Int_t bsl, Int_t LowThreshold, Int_t HighThreshold);
156 Int_t InRange(Int_t parameter,Int_t Low,Int_t High,const char *Module,const char *ParameterName);
157 Short_t GetShortChannel(Int_t i);
158 Short_t GetKeepChannel(Int_t i);
159 Int_t Multiply36(Int_t P, Int_t N);
160 long long Mask(long long in, Int_t left, Int_t right);
161 long long Maskandshift(long long in, Int_t left, Int_t right);
162
163
164
165 void InitBuffers();
166 Bool_t AddEvent(Int_t dt,Bool_t isFirst);
167 Bool_t CreateEvent(Int_t ievent);
168 Bool_t GDC2DDLs(AliRawVEvent *gdc,Int_t ievent);
169 Bool_t ConvertRawFilesToDate(Int_t nevents);
170 Bool_t ConvertDateToRoot();
171 Bool_t WriteEvent(Int_t ievent);
172
173 AliRawReader *fReader ; // RAW reader
174 AliTPCRawStreamV3 *fDecoder; // ALTRO decoder
175
176 TString fDDLFolderName; // folder name for ddl files
177 TString fOutputDateFileName; // filename for date output
178 TString fOutputRootFileName; // filename for root output
179
180 Float_t fP[2047] ; // Interaction probabilities for times (T-1023,...T,...T+1023)
181 Bool_t fIsRandom; // Indicates if fP are treated as probabilities (in terms of Possionian statistics), or fixed numbers
182 Bool_t *fChannels; //! field of active channels
183 UInt_t *fCDHs ; //! CDHs
184 Short_t *fADCs ; //! field of ADC counts
185 UInt_t *fTrailers; //! RCU trailers
186 UInt_t *fRawData ; //! Raw Data
187
188
189 ClassDef(AliTPCAltroEmulator,1);
eb7e0771 190};
191#endif