New classes to fit signal shape (AliTPCCalibTCF)
[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
21#include <iostream>
22#include <stdlib.h>
23#include <stdio.h>
24#include <string.h>
25
26using namespace std;
27
28class AliTPCAltroEmulator{
29 public:
30 AliTPCAltroEmulator(int timebins, short* Channel);
31 AliTPCAltroEmulator(const AliTPCAltroEmulator &sig);
32 ~AliTPCAltroEmulator();
33 AliTPCAltroEmulator& operator = (const AliTPCAltroEmulator &source);
34
35 void ConfigAltro(int ONBaselineCorrection1, int ONTailcancellation, int ONBaselineCorrection2, int ONClipping, int ONZerosuppression, int ONDataFormatting);
36 void ConfigBaselineCorrection1(int mode, int ValuePeDestal, int *PedestalMem, int polarity);
37 void ConfigTailCancellationFilter(int K1, int K2, int K3, int L1, int L2, int L3);
38 void ConfigBaselineCorrection2(int HighThreshold, int LowThreshold, int Offset, int Presamples, int Postsamples);
39 void ConfigZerosuppression(int Threshold, int MinSamplesaboveThreshold, int Presamples, int Postsamples);
40 void PrintParameters();
41 void RunEmulation();
42 float CalculateCompression();
43
44 enum {
45 /**din - fpd*/ kDINxFPD,
46 /**din - f(t)*/ kDINxFT,
47 /**din - f(din)*/ kDINxFDIN,
48 /**din - f(din-vpd)*/ kDINxFDINxVPD,
49 /**din - vpd - fpd*/ kDINxVPDxFPD,
50 /**din - vpd - f(t)*/ kDINxVPDxFT,
51 /**din - vpd - f(din)*/ kDINxVPDxFDIN,
52 /**din - vpd - f(din - vpd)*/ kDINxVPDxFDINxVPD,
53 /**f(din) - fpd*/ kFDINxFPD,
54 /**f(din - vpd) - fpd*/ kFDINxVPDxFPD,
55 /**f(t) - fpd*/ kFTxFPD,
56 /**f(t) - f(t)*/ kFTxFT,
57 /**f(din) - f(din)*/ kFDINxFDIN,
58 /**f(din - vpd) - f(din - vpd)*/ kFDINxVPDxFDINxVPD,
59 /**din - fpd*/ kDINxFPD1,
60 /**din - fpd*/ kDINxFPD2
61 };
62
63 private:
64 int ftimebins; // timebins
65
66 short *fChannelIn; // ChannelIn
67 short *fChannelShort; // incoming signal in short format
68 short *fADCkeep; // ADCkeep
69
70 int fOnBSL1; // Baseline correction and substraction 1 on
71 int fOnTCF; // Tail Cancelation Filter on
72 int fOnBSL2; // Baseline correction and substraction 2 (MAF) on
73 int fOnClip; // Clipping on (to reverse the signal for ZSU if BSL2 is on)
74 int fOnZSU; // Zero Suppression on
75
76 int fConfiguredAltro; // ConfiguredAltro
77 int fConfiguredBSL1; // ConfiguredBSL1
78 int fConfiguredTCF; // ConfiguredTCF
79 int fConfiguredBSL2; // ConfiguredBSL2
80 int fConfiguredZSU; // ConfiguredZSU
81
82 int fBSL1mode; // BSL1mode
83 int fBSL1ValuePeDestal; // BSL1ValuePeDestal
84 int* fBSL1PedestalMem; // BSL1PedestalMem
85 int fBSL1polarity; // BSL1polarity
86
87 float fTCFK1; // K1
88 float fTCFK2; // K2
89 float fTCFK3; // K3
90 float fTCFL1; // L1
91 float fTCFL2; // L2
92 float fTCFL3; // L3
93
94 int fTCFK1Int; // K1Int
95 int fTCFK2Int; // K2Int
96 int fTCFK3Int; // K3Int
97 int fTCFL1Int; // L1Int
98 int fTCFL2Int; // L2Int
99 int fTCFL3Int; // L3Int
100
101 int fBSL2HighThreshold; // BSL2HighThreshold
102 int fBSL2LowThreshold; // BSL2LowThreshold
103 int fBSL2Offset; // BSL2Offset
104 int fBSL2Presamples; // BSL2Presamples;
105 int fBSL2Postsamples; // BSL2Postsamples
106
107 int fZSUThreshold; // ZSUThreshold
108 int fZSUMinSamplesaboveThreshold; // ZSUMinSamplesaboveThreshold
109 int fZSUPresamples; // ZSUPresamples
110 int fZSUPostsamples; // ZSUPostsamples
111
112 void BaselineCorrection1(int mode, int FixedPeDestal, int *PedestalMem, int polarity);
113 void TailCancellationFilterFixedPoint(int K1, int K2, int K3, int L1, int L2, int L3);
114 void BaselineCorrection2RTL(int HighThreshold, int LowThreshold, int Offset, int Presamples, int Postsamples);
115 void Clipping();
116 void Zerosuppression(int Threshold, int MinSamplesaboveThreshold, int Presamples, int Postsamples);
117 void DataFormater();
118
119 short GetElement(short* Array,int index);
120 void SetElement(short* Array,int index,short value);
121
122 int InBand(int ADC,int bsl, int LowThreshold, int HighThreshold);
123 int InRange(int parameter,int Low,int High,char *Module,char *ParameterName);
124 short GetShortChannel(int i);
125 short GetKeepChannel(int i);
126 int Multiply36(int P, int N);
127 long long Mask(long long in, int left, int right);
128 long long Maskandshift(long long in, int left, int right);
129};
130#endif