// Stefan Rossegger, 8th february 2008 //
/////////////////////////////////////////////////////////////////////////////////////////////////////
-#include "AliTPCAltroEmulator.h"
+#include <AliTPCAltroEmulator.h>
+#include <TH1F.h>
+#include <TMath.h>
+#include <TSystem.h>
+#include <AliDAQ.h>
+#include <AliRawReader.h>
+#include <AliRawVEvent.h>
+#include <AliRawData.h>
+#include <AliRawVEquipment.h>
+#include <AliRawEquipmentHeader.h>
+#include <AliTPCRawStreamV3.h>
+#include <TCanvas.h>
+
/** @brief Consturctor of Altro Class
*
* Altro Processed Data in the Channel Pointer.\n
*
* @param timebins an <tt> int </tt> sets the length of the input Data (Channel)
- * @param Channel an <tt> short* </tt> Pointer to a 1d short Array with the input Data
+ * @param Channel an <tt> short* </tt> Pointer to a 1d Short_tArray with the input Data
*/
ClassImp(AliTPCAltroEmulator)
-AliTPCAltroEmulator::AliTPCAltroEmulator(int timebins, short* Channel) :
+AliTPCAltroEmulator::AliTPCAltroEmulator(Int_t timebins, short* Channel) :
TNamed(),
ftimebins(timebins),
// fChannelIn(Channel),
fConfiguredZSU(0), // ConfiguredZSU
fBSL1mode(0), // BSL1mode
fBSL1ValuePeDestal(0), // BSL1ValuePeDestal
- fBSL1PedestalMem(0), // BSL1PedestalMem
+ fBSL1PedestalMem(0), // BSL1PedestalMem
fBSL1polarity(0), // BSL1polarity
fTCFK1(0), // K1
fZSUMinSamplesaboveThreshold(0), // ZSUMinSamplesaboveThreshold
fZSUPresamples(0), // ZSUPresamples
- fZSUPostsamples(0) // ZSUPostsamples
-
-{
+ fZSUPostsamples(0), // ZSUPostsamples
+
+ fReader(0), // for Altro Emulation on Raw Reader
+ fDecoder(0),
+ fDDLFolderName("/tmp/"),
+ fOutputDateFileName("/tmp/tmp.date"),
+ fOutputRootFileName("/tmp/tmp.root"),
+ fIsRandom(kTRUE),
+ fChannels(0),
+ fCDHs(0),
+ fADCs(0),
+ fTrailers(0),
+ fRawData(0) {
//
// Constructor of Altro Class
//
/*
ftimebins = timebins;
- fChannelShort = Channel;
+ fChannelShort_T = Channel;
fOnBSL1 = 0;
fOnTCF = 0;
fZSUMinSamplesaboveThreshold(0), // ZSUMinSamplesaboveThreshold
fZSUPresamples(0), // ZSUPresamples
- fZSUPostsamples(0) // ZSUPostsamples
+ fZSUPostsamples(0), // ZSUPostsamples
-{
+ fReader(0), // for Altro Emulation on Raw Reader
+ fDecoder(0),
+ fDDLFolderName("/tmp/"),
+ fOutputDateFileName("/tmp/tmp.date"),
+ fOutputRootFileName("/tmp/tmp.root"),
+ fIsRandom(kTRUE),
+ fChannels(0),
+ fCDHs(0),
+ fADCs(0),
+ fTrailers(0),
+ fRawData(0) {
//
// copy constructor of Altro Class
//
*
* Destructor of Altro Class\n
*/
-AliTPCAltroEmulator::~AliTPCAltroEmulator(){
+AliTPCAltroEmulator::~AliTPCAltroEmulator() {
//
// Destructor of Altro Class
//
if(fConfiguredZSU == 1)
delete fADCkeep;
+
+ delete[] fChannels;
+ delete[] fCDHs ;
+ delete[] fADCs ;
+ delete[] fTrailers;
+ delete[] fRawData ;
+ delete fDecoder ;
+
}
//_____________________________________________________________________________
* which are configured to be on, have to be configured later before running
* the emulation!\n
*
- * @param ONBaselineCorrection1 an <tt> int </tt> Switch (0,1) to turn on the Base Line Correction 1 (BSL1) Module
- * @param ONTailcancellation an <tt> int </tt> Switch (0,1) to turn on the Tail Cancellation Filter (TCF) Module
- * @param ONBaselineCorrection2 an <tt> int </tt> Switch (0,1) to turn on the Moving Average Filter (BSL2) Module
- * @param ONClipping an <tt> int </tt> Switch (0,1) to turn on the Clipping Module. This is not possible in the real Altro, there it is always on.
- * @param ONZerosuppression an <tt> int </tt> Switch (0,1) to turn on the Zero Suppression (ZSU) Module
- * @param ONDataFormatting an <tt> int </tt> Switch (0,1) to turn on the Data Formatting on (not implemented)
+ * @param ONBaselineCorrection1 an <tt> Int_t </tt> Switch (0,1) to turn on the Base Line Correction 1 (BSL1) Module
+ * @param ONTailcancellation an <tt> Int_t </tt> Switch (0,1) to turn on the Tail Cancellation Filter (TCF) Module
+ * @param ONBaselineCorrection2 an <tt> Int_t </tt> Switch (0,1) to turn on the Moving Average Filter (BSL2) Module
+ * @param ONClipping an <tt> Int_t </tt> Switch (0,1) to turn on the Clipping Module. This is not possible in the real Altro, there it is always on.
+ * @param ONZerosuppression an <tt> Int_t </tt> Switch (0,1) to turn on the Zero Suppression (ZSU) Module
+ * @param ONDataFormatting an <tt> Int_t </tt> Switch (0,1) to turn on the Data Formatting on (not implemented)
*/
-void AliTPCAltroEmulator::ConfigAltro(int ONBaselineCorrection1, int ONTailcancellation, int ONBaselineCorrection2, int ONClipping, int ONZerosuppression, int ONDataFormatting){
+void AliTPCAltroEmulator::ConfigAltro(Int_t ONBaselineCorrection1, Int_t ONTailcancellation, Int_t ONBaselineCorrection2, Int_t ONClipping, Int_t ONZerosuppression, Int_t ONDataFormatting){
//
// Configures which modules of the Altro should be on
//
* All configurable values are "Range checked" and if out of the Range set to the nearest extreme.
* So the Emulation will work, but the result is maybe not the expected one.
*
- * @param mode an <tt> int </tt> sets the mode of the Baseline Correction. See the Altro manual for a description
- * @param ValuePeDestal an <tt> int </tt> this is the baseline of the Channel.
- * @param PedestalMem an <tt> *int </tt> Pointer to a 1d short Array with the pedestal memory Data
- * @param polarity an <tt> int </tt> Switch (0,1) for the polarity
+ * @param mode an <tt> Int_t </tt> sets the mode of the Baseline Correction. See the Altro manual for a description
+ * @param ValuePeDestal an <tt> Int_t </tt> this is the baseline of the Channel.
+ * @param PedestalMem an <tt> *Int_t </tt> Pointer to a 1d Short_t Array with the pedestal memory Data
+ * @param polarity an <tt> Int_t </tt> Switch (0,1) for the polarity
*/
-void AliTPCAltroEmulator::ConfigBaselineCorrection1(int mode, int ValuePeDestal, int *PedestalMem, int polarity){
+void AliTPCAltroEmulator::ConfigBaselineCorrection1(Int_t mode, Int_t ValuePeDestal, Int_t *PedestalMem, Int_t polarity){
//
// Configures the Base Line Correction 1 (BSL1) Module
//
*
* Configures the Tail Cancellation Filter (TCF) Module. You have to set the coefficients in the
* Integer version.\n
- * To convert from int to float use (int)*(pow(2,-16)-1)
- * To convert from float to int usw (float)*(pow(2,16)-1)
+ * To convert from Int_t to Float_t use (int)*(pow(2,-16)-1)
+ * To convert from Float_t to Int_t usw (Float_t)*(pow(2,16)-1)
* All configurable values are "Range checked" and if out of the Range set to the nearest extreme.
* So the Emulation will work, but the result is maybe not the expected one.
*
- * @param K1 an <tt> int </tt> sets the K1 coeeficient of the TCF
- * @param K2 an <tt> int </tt> sets the K2 coeeficient of the TCF
- * @param K3 an <tt> int </tt> sets the K3 coeeficient of the TCF
- * @param L1 an <tt> int </tt> sets the L1 coeeficient of the TCF
- * @param L2 an <tt> int </tt> sets the L2 coeeficient of the TCF
- * @param L3 an <tt> int </tt> sets the L3 coeeficient of the TCF
+ * @param K1 an <tt> Int_t </tt> sets the K1 coeeficient of the TCF
+ * @param K2 an <tt> Int_t </tt> sets the K2 coeeficient of the TCF
+ * @param K3 an <tt> Int_t </tt> sets the K3 coeeficient of the TCF
+ * @param L1 an <tt> Int_t </tt> sets the L1 coeeficient of the TCF
+ * @param L2 an <tt> Int_t </tt> sets the L2 coeeficient of the TCF
+ * @param L3 an <tt> Int_t </tt> sets the L3 coeeficient of the TCF
*/
-void AliTPCAltroEmulator::ConfigTailCancellationFilter(int K1, int K2, int K3, int L1, int L2, int L3){
+void AliTPCAltroEmulator::ConfigTailCancellationFilter(Int_t K1, Int_t K2, Int_t K3, Int_t L1, Int_t L2, Int_t L3){
//
// Configures the Tail Cancellation Filter (TCF) Module
//
- // conf from int to fp: (int)*(pow(2,-16)-1)
- // backway: (float)*(pow(2,16)-1)
+ // conf from Int_t to fp: (int)*(pow(2,-16)-1)
+ // backway: (Float_t)*(pow(2,16)-1)
fTCFK1Int = InRange(K1,0,65535,"AliTPCAltroEmulator::ConfigTailCancellationFilter","K1");
fTCFK2Int = InRange(K2,0,65535,"AliTPCAltroEmulator::ConfigTailCancellationFilter","K2");
fTCFK3Int = InRange(K3,0,65535,"AliTPCAltroEmulator::ConfigTailCancellationFilter","K3");
* All configurable values are "Range checked" and if out of the Range set to the nearest extreme.
* So the Emulation will work, but the result is maybe not the expected one.
*
- * @param HighThreshold an <tt> int </tt> sets the high Threshold
- * @param LowThreshold an <tt> int </tt> sets the low Theshold
- * @param Offset an <tt> int </tt> sets the the offset which is added to the Signal
- * @param Presamples an <tt> int </tt> sets the number of pre samples excluded from the moving average caclulation
- * @param Postsamples an <tt> int </tt> sets the number of post samples excluded from the moving average caclulation
+ * @param HighThreshold an <tt> Int_t </tt> sets the high Threshold
+ * @param LowThreshold an <tt> Int_t </tt> sets the low Theshold
+ * @param Offset an <tt> Int_t </tt> sets the the offset which is added to the Signal
+ * @param Presamples an <tt> Int_t </tt> sets the number of pre samples excluded from the moving average caclulation
+ * @param Postsamples an <tt> Int_t </tt> sets the number of post samples excluded from the moving average caclulation
*/
-void AliTPCAltroEmulator::ConfigBaselineCorrection2(int HighThreshold, int LowThreshold, int Offset, int Presamples, int Postsamples){
+void AliTPCAltroEmulator::ConfigBaselineCorrection2(Int_t HighThreshold, Int_t LowThreshold, Int_t Offset, Int_t Presamples, Int_t Postsamples){
//
// Configures the Moving Average Filter (BSL2) Module
//
* All configurable values are "Range checked" and if out of the Range set to the nearest extreme.
* So the Emulation will work, but the result is maybe not the expected one.
*
- * @param Threshold an <tt> int </tt> sets the Threshold
- * @param MinSamplesaboveThreshold an <tt> int </tt> sets the minimum number of samples which have to be greater than the threshold
- * @param Presamples an <tt> int </tt> sets the number of pre samples which are kept
- * @param Postsamples an <tt> int </tt> sets the number of post samples which are kept
+ * @param Threshold an <tt> Int_t </tt> sets the Threshold
+ * @param MinSamplesaboveThreshold an <tt> Int_t </tt> sets the minimum number of samples which have to be greater than the threshold
+ * @param Presamples an <tt> Int_t </tt> sets the number of pre samples which are kept
+ * @param Postsamples an <tt> Int_t </tt> sets the number of post samples which are kept
*/
-void AliTPCAltroEmulator::ConfigZerosuppression(int Threshold, int MinSamplesaboveThreshold, int Presamples, int Postsamples){
+void AliTPCAltroEmulator::ConfigZerosuppression(Int_t Threshold, Int_t MinSamplesaboveThreshold, Int_t Presamples, Int_t Postsamples){
//
// Configures the Zero Suppression Module (ZSU)
//
fZSUMinSamplesaboveThreshold = InRange(MinSamplesaboveThreshold,1,3,"AliTPCAltroEmulator::BaselineCorrection1","MinSamplesaboveThreshold");
fZSUPresamples = InRange(Presamples,0,3,"AliTPCAltroEmulator::BaselineCorrection1","Presamples");
fZSUPostsamples = InRange(Postsamples,0,7,"AliTPCAltroEmulator::BaselineCorrection1","Postsamples");
- fADCkeep = (short *)calloc(sizeof(short),ftimebins);
+ fADCkeep = (Short_t *)calloc(sizeof(short),ftimebins);
- for(int i = 0; i < ftimebins; i++){
+ for(Int_t i = 0; i < ftimebins; i++){
fADCkeep[i] = 0;
}
fConfiguredZSU = 1;
}
if(fConfiguredTCF == 1){
cout << "Parameters set in the TCF (TailCancellation Filter) Module:" << endl << endl;
- cout << "K1 (int|float) : " << fTCFK1Int << " | " << fTCFK1Int/(float)((1<<16)-1) << endl;
- cout << "K2 (int|float) : " << fTCFK2Int << " | " << fTCFK2Int/(float)((1<<16)-1) << endl;
- cout << "K3 (int|float) : " << fTCFK3Int << " | " << fTCFK3Int/(float)((1<<16)-1) << endl;
- cout << "L1 (int|float) : " << fTCFL1Int << " | " << fTCFL1Int/(float)((1<<16)-1) << endl;
- cout << "L2 (int|float) : " << fTCFL2Int << " | " << fTCFL2Int/(float)((1<<16)-1) << endl;
- cout << "L3 (int|float) : " << fTCFL3Int << " | " << fTCFL3Int/(float)((1<<16)-1) << endl << endl << endl;
+ cout << "K1 (int|Float_t) : " << fTCFK1Int << " | " << fTCFK1Int/(Float_t)((1<<16)-1) << endl;
+ cout << "K2 (int|Float_t) : " << fTCFK2Int << " | " << fTCFK2Int/(Float_t)((1<<16)-1) << endl;
+ cout << "K3 (int|Float_t) : " << fTCFK3Int << " | " << fTCFK3Int/(Float_t)((1<<16)-1) << endl;
+ cout << "L1 (int|Float_t) : " << fTCFL1Int << " | " << fTCFL1Int/(Float_t)((1<<16)-1) << endl;
+ cout << "L2 (int|Float_t) : " << fTCFL2Int << " | " << fTCFL2Int/(Float_t)((1<<16)-1) << endl;
+ cout << "L3 (int|Float_t) : " << fTCFL3Int << " | " << fTCFL3Int/(Float_t)((1<<16)-1) << endl << endl << endl;
}else{
cout << "TCF (TailCancellation Filter) Module not configured!" << endl << endl << endl;
}
}
}
+
+void AliTPCAltroEmulator::SetChannelData(Int_t timebins, Short_t* channelData) {
+ //
+ // Set channel data, for example a new channel
+ //
+
+ ftimebins = timebins;
+ fChannelShort = channelData;
+
+}
+
+
/** @brief Runs the emulation of all configured Modules.
*
* Runs the emulation of all configured Modules. This changes then the content of the
// Runs the emulation of all configured Modules.
//
+
+ if (!fChannelShort) {
+ printf("ERROR cant run Altro Emulation: Channel input not set.\nUse for example: SetChannelData(Int_t timebins, Short_t* Channel)\n");
+ return;
+ }
+
//cout << "AliTPCAltroEmulator::RunEmulation | start" << endl;
if(fConfiguredAltro == 0){
cout << "ERROR cant run Altro Emulation because not configured" << endl;
return;
}
}
+
+
+
}
-void AliTPCAltroEmulator::BaselineCorrection1(int mode, int ValuePeDestal, int *PedestalMem, int polarity){
+void AliTPCAltroEmulator::BaselineCorrection1(Int_t mode, Int_t ValuePeDestal, Int_t *PedestalMem, Int_t polarity){
//
// BaselineCorrection1
//
//VPD == 0 !!
- int fixedPeDestal = 0;
+ Int_t fixedPeDestal = 0;
if(polarity ==1){
- for(int i = 0; i < ftimebins; i++){
+ for(Int_t i = 0; i < ftimebins; i++){
fChannelShort[i] = 1023 - fChannelShort[i];
}
}
switch(mode) {
case kDINxFPD:
- for(int i = 0; i < ftimebins; i++)
+ for(Int_t i = 0; i < ftimebins; i++)
fChannelShort[i] = fChannelShort[i] - fixedPeDestal;
break;
case kDINxFT:
- for(int i = 0; i < ftimebins; i++)
+ for(Int_t i = 0; i < ftimebins; i++)
fChannelShort[i] = fChannelShort[i] - PedestalMem[i];
break;
case kDINxFDIN:
- for(int i = 0; i < ftimebins; i++)
+ for(Int_t i = 0; i < ftimebins; i++)
fChannelShort[i] = fChannelShort[i] - PedestalMem[ fChannelShort[i] ];
break;
case kDINxFDINxVPD:
- for(int i = 0; i < ftimebins; i++)
+ for(Int_t i = 0; i < ftimebins; i++)
fChannelShort[i] = fChannelShort[i] - PedestalMem[ fChannelShort[i] - ValuePeDestal];
break;
case kDINxVPDxFPD:
- for(int i = 0; i < ftimebins; i++)
+ for(Int_t i = 0; i < ftimebins; i++)
fChannelShort[i] = fChannelShort[i] - ValuePeDestal - fixedPeDestal;
break;
case kDINxVPDxFT:
- for(int i = 0; i < ftimebins; i++)
+ for(Int_t i = 0; i < ftimebins; i++)
fChannelShort[i] = fChannelShort[i] - ValuePeDestal - PedestalMem[i];
break;
case kDINxVPDxFDIN:
- for(int i = 0; i < ftimebins; i++)
+ for(Int_t i = 0; i < ftimebins; i++)
fChannelShort[i] = fChannelShort[i] - ValuePeDestal - PedestalMem[ fChannelShort[i] ];
break;
case kDINxVPDxFDINxVPD:
- for(int i = 0; i < ftimebins; i++)
+ for(Int_t i = 0; i < ftimebins; i++)
fChannelShort[i] = fChannelShort[i] - ValuePeDestal - PedestalMem[ fChannelShort[i] - ValuePeDestal ];
break;
case kFDINxFPD:
- for(int i = 0; i < ftimebins; i++)
+ for(Int_t i = 0; i < ftimebins; i++)
fChannelShort[i] = PedestalMem[ fChannelShort[i] ] - fixedPeDestal;
break;
case kFDINxVPDxFPD:
- for(int i = 0; i < ftimebins; i++)
+ for(Int_t i = 0; i < ftimebins; i++)
fChannelShort[i] = PedestalMem[ fChannelShort[i] - ValuePeDestal ] - fixedPeDestal;
break;
case kFTxFPD:
- for(int i = 0; i < ftimebins; i++)
+ for(Int_t i = 0; i < ftimebins; i++)
fChannelShort[i] = PedestalMem[i] - fixedPeDestal;
break;
}
}
-int AliTPCAltroEmulator::Multiply36(int P, int N){
+Int_t AliTPCAltroEmulator::Multiply36(Int_t P, Int_t N){
//
- // multiply function to emulate the 36 bit fixed point multiplication of the Altro.
+ // multiply function to emulate the 36 bit fixed poInt_t multiplication of the Altro.
//
long long retval =0;
long long temp = 0;
}
return retval;
}
-long long AliTPCAltroEmulator::Mask(long long in, int left, int right){
- //
+long long AliTPCAltroEmulator::Mask(long long in, Int_t left, Int_t right){
//
+ // mask
//
long long retval;
long long pattern;
return retval;
}
-long long AliTPCAltroEmulator::Maskandshift(long long in, int left, int right){
- //
+long long AliTPCAltroEmulator::Maskandshift(long long in, Int_t left, Int_t right){
//
+ // maskandshift
//
long long retval;
long long pattern;
return retval;
}
-void AliTPCAltroEmulator::TailCancellationFilterFixedPoint(int K1, int K2, int K3, int L1, int L2, int L3){
+void AliTPCAltroEmulator::TailCancellationFilterFixedPoint(Int_t K1, Int_t K2, Int_t K3, Int_t L1, Int_t L2, Int_t L3){
//
// TailCancellationFilterFixedPoint
//
- int c1n = 0, c2n = 0, c3n = 0;
- int c1o = 0, c2o = 0, c3o = 0;
- int d1 = 0, d2 = 0;
- int dout = 0;
- int din = 0;
- int bit = 0;
- for(int i = 0; i < ftimebins; i++){
+ Int_t c1n = 0, c2n = 0, c3n = 0;
+ Int_t c1o = 0, c2o = 0, c3o = 0;
+ Int_t d1 = 0, d2 = 0;
+ Int_t dout = 0;
+ Int_t din = 0;
+ Int_t bit = 0;
+ for(Int_t i = 0; i < ftimebins; i++){
din = fChannelShort[i];
din = (din<<2);
}
}
-void AliTPCAltroEmulator::BaselineCorrection2RTL(int HighThreshold, int LowThreshold, int Offset, int Presamples, int Postsamples){
+void AliTPCAltroEmulator::BaselineCorrection2RTL(Int_t HighThreshold, Int_t LowThreshold, Int_t Offset, Int_t Presamples, Int_t Postsamples){
//
// BaselineCorrection2RTL
//
//cout << "Altro::BaselineCorrection2RTL | HighThreshold: " << HighThreshold << " LowThreshold: " << LowThreshold << " Offset: " << Offset << " Presamples: " << Presamples << " Postsamples: " << Postsamples << endl;
//more or less direct "translation" of the hdl code.
//Input signals
- int din;
- int dout;
- int edges[6]; // = Postsamples*4 + Presamples;
- int offset = Offset;
- int thrlo = LowThreshold;//called thr_mau[19] ...
- int thrhi = HighThreshold;
+ Int_t din;
+ Int_t dout;
+ Int_t edges[6]; // = Postsamples*4 + Presamples;
+ Int_t offset = Offset;
+ Int_t thrlo = LowThreshold;//called thr_mau[19] ...
+ Int_t thrhi = HighThreshold;
// Variables
- int fOld[4]; //flag pipe
- int fNew[4]; //flag pipe
- int dOld[4]; //data pipe
- int dNew[4]; //data pipe
- int dxOld;
- int dxNew;
- int pstscnt; // Counter for Postsamples
- int zOld[9]; // Filter stages
- int zNew[9]; // Filter stages
- int zxOld; //Accumulator stage
- int zxNew; //Accumulator stage
- int valcntOld; //Valid sample counter
- int valcntNew = 0; //Valid sample counter
+ Int_t fOld[4]; //flag pipe
+ Int_t fNew[4]; //flag pipe
+ Int_t dOld[4]; //data pipe
+ Int_t dNew[4]; //data pipe
+ Int_t dxOld;
+ Int_t dxNew;
+ Int_t pstscnt; // Counter for Postsamples
+ Int_t zOld[9]; // Filter stages
+ Int_t zNew[9]; // Filter stages
+ Int_t zxOld; //Accumulator stage
+ Int_t zxNew; //Accumulator stage
+ Int_t valcntOld; //Valid sample counter
+ Int_t valcntNew = 0; //Valid sample counter
- int valid; //Valid flag
- int fx; //postsample flag
- //int s07; // differentiator result
- int s8; // Acc + Diff result
- int flag;
- //int bsth; //baseline threshold
- //int din_p; //Data input strictly positive
- int bsl;
- //int dx_bsls; // dx -bsl
- //int dx_clip; // dxbsl clipped
- //int bsl_of = 0;
+ Int_t valid; //Valid flag
+ Int_t fx; //postsample flag
+ //Int_t s07; // differentiator result
+ Int_t s8; // Acc + Diff result
+ Int_t flag;
+ //Int_t bsth; //baseline threshold
+ //Int_t din_p; //Data input strictly positive
+ Int_t bsl;
+ //Int_t dx_bsls; // dx -bsl
+ //Int_t dx_clip; // dxbsl clipped
+ //Int_t bsl_of = 0;
//initialisation
- for(int i = 0; i < 9 ; i++)
+ for(Int_t i = 0; i < 9 ; i++)
zOld[i] = 0;
- for(int i = 0; i < 4 ; i++){
+ for(Int_t i = 0; i < 4 ; i++){
fOld[i] = 0;
dOld[i] = 0;
}
zxOld = 0;
valcntOld = 0;
valid = 0;
- for(int i = 0; i < 2 ; i++){
+ for(Int_t i = 0; i < 2 ; i++){
edges[i] = (Presamples&(1<<i))>>i;
}
- for(int i = 0; i < 4 ; i++){
+ for(Int_t i = 0; i < 4 ; i++){
edges[(3-i)+2] = (Postsamples&(1<<i))>>i;
}
/*cout << "edges :";
- for(int i = 0; i < 6 ; i++)
+ for(Int_t i = 0; i < 6 ; i++)
cout << edges[i] << ":";
cout << " Presamples: " << Presamples << " Postsamples: " << Postsamples << endl;*/
//Loop
//cout << "AliTPCAltroEmulator::BaselineCorrection2_RTL | starting Loop" << endl;
- for(int timebin = -12; timebin < ftimebins+10; timebin++){
+ for(Int_t timebin = -12; timebin < ftimebins+10; timebin++){
//cout << "AliTPCAltroEmulator::BaselineCorrection2_RTL | in Loop timebin: " << timebin << endl;
din = GetElement(fChannelShort,timebin);
fNew[0] = 0;
dxNew = dOld[0];
- for(int i = 0; i < 3; i++)
+ for(Int_t i = 0; i < 3; i++)
dNew[i] = dOld[i+1];
dNew[3] = din;
valcntNew = ++valcntOld;
zxNew = s8;
- for(int i = 0; i < 8; i++)
+ for(Int_t i = 0; i < 8; i++)
zNew[i] = zOld[i+1];
zNew[8] = dOld[0];
}else{
zxNew = zxOld;
- for(int i = 0; i < 9; i++)
+ for(Int_t i = 0; i < 9; i++)
zNew[i] = zOld[i];
}
dout = dxOld - (bsl - offset);
SetElement(fChannelShort,timebin-5,(short)dout);
//sim clockschange
- for(int i = 0; i < 9 ; i++)
+ for(Int_t i = 0; i < 9 ; i++)
zOld[i] = zNew[i];
zxOld = zxNew;
- for(int i = 0; i < 4 ; i++){
+ for(Int_t i = 0; i < 4 ; i++){
fOld[i] = fNew[i];
dOld[i] = dNew[i];
}
//
// implement if no BC2 clipping has to run
//
- for(int i = 0; i < ftimebins; i++){
+ for(Int_t i = 0; i < ftimebins; i++){
if(fChannelShort[i] < 0)
fChannelShort[i] = 0;
}
}
-void AliTPCAltroEmulator::Zerosuppression(int Threshold, int MinSamplesaboveThreshold, int Presamples, int Postsamples){
+void AliTPCAltroEmulator::Zerosuppression(Int_t Threshold, Int_t MinSamplesaboveThreshold, Int_t Presamples, Int_t Postsamples){
//
// add again altro feature
//
//TODO: Implement "Altro zsu merging"
- //int Postsamplecounter = 0;
- //int setPostsample = 0;
- for(int i = 0; i < ftimebins; i++){
+ //Int_t Postsamplecounter = 0;
+ //Int_t setPostsample = 0;
+ for(Int_t i = 0; i < ftimebins; i++){
if(fChannelShort[i] >= Threshold){
fADCkeep[i] = 1;
}
}
+
+ Int_t startofclustersequence = -1;
+ Int_t endofClustersInSequence = -1;
- int startofclustersequence = -1;
- int endofClustersInSequence = -1;
-
- for(int i = 0; i < ftimebins; i++){
+ for(Int_t i = 0; i < ftimebins; i++){
if( (fADCkeep[i] == 1) && (GetElement(fADCkeep,i-1) == 0) ){
startofclustersequence = i;
}
if( (startofclustersequence != -1) && (endofClustersInSequence != -1) ){
//cout << " found! " << (endofClustersInSequence - startofclustersequence + 1);
if ( (endofClustersInSequence - startofclustersequence + 1) < MinSamplesaboveThreshold ){
- for(int j = startofclustersequence; j <= endofClustersInSequence ; j++){
+ for(Int_t j = startofclustersequence; j <= endofClustersInSequence ; j++){
fADCkeep[j] = 0;
}
}
//cout << endl;
}
- /*for(int i = 0; i < ftimebins; i++){
+ /*for(Int_t i = 0; i < ftimebins; i++){
if( (GetElement(fADCkeep,i-1) == 1) && (GetElement(fADCkeep,i) == 0) && (GetElement(fADCkeep,i+1) == 1) ){
SetElement(fADCkeep,i,1);
}
}*/
- for(int i = 0; i < ftimebins; i++){
+ for(Int_t i = 0; i < ftimebins; i++){
if( (fADCkeep[i] == 1) && (GetElement(fADCkeep,i-1) == 0) ){
- for(int j = i-Presamples ; j <= i; j++){
+ for(Int_t j = i-Presamples ; j <= i; j++){
SetElement(fADCkeep,j,1);
}
}
}
- for(int i = ftimebins; i >= 0; i--){
+ for(Int_t i = ftimebins; i >= 0; i--){
if( (fADCkeep[i] == 1) && (GetElement(fADCkeep,i+1) == 0) ){
- for(int j = i ; j <= i+Postsamples; j++){
+ for(Int_t j = i ; j <= i+Postsamples; j++){
SetElement(fADCkeep,j,1);
}
}
}
/*cout << " Postsamplecounter: " << Postsamplecounter;
- for(int j = i+1 ; j <= i+Postsamples; j++){
+ for(Int_t j = i+1 ; j <= i+Postsamples; j++){
SetElement(fADCkeep,j,1);
i+=Postsamples;
}
cout << i << " ADCK: " << GetElement(fADCkeep,i);
cout << " Postsam: " << Postsamplecounter << " ADCK: " << GetElement(fADCkeep,i);*/
- for(int i = 0; i < ftimebins; i++){
+ for(Int_t i = 0; i < ftimebins; i++){
if( (fADCkeep[i] == 1) && (GetElement(fADCkeep,i+1) == 0) && ( (GetElement(fADCkeep,i+3) == 1) || (GetElement(fADCkeep,i+2) == 1) ) ){
SetElement(fADCkeep,i+1,1);
SetElement(fADCkeep,i+2,1);
}
}
+
+ for(Int_t i = 0; i < ftimebins; i++){
+ if( !GetKeepChannel(i) ) {
+ SetElement(fChannelShort,i+1,-1); // set non relevant data to -1
+ }
+ }
+
+
}
/** @brief formats the data like the ALTRO. Result is a 64 bit array
*
* calculates the compression out of the bitmask with the set adc values
*
- * @return \c float consisting of the compression factor
+ * @return \c Float_t consisting of the compression factor
*/
-float AliTPCAltroEmulator::CalculateCompression(){
+Float_t AliTPCAltroEmulator::CalculateCompression() {
//
// calculates the compression out of the bitmask
//
// calculation is based on altro 10 bit words ..
- int sample = 0;
- int cluster = 0;
- int data = 0;
- float retval = 0.0;
+ Int_t sample = 0;
+ Int_t cluster = 0;
+ Int_t data = 0;
+ Float_t retval = 0.0;
- for(int i = 0; i < ftimebins; i++){
+ for(Int_t i = 0; i < ftimebins; i++){
if(fADCkeep[i] == 1){
sample++;
}
data = sample + cluster*2;
data = data + data%4 + 4;
if(data >0){
- retval = ftimebins / (float)data;//num of timebins is equal to max number of samples
+ retval = ftimebins / (Float_t)data;//num of timebins is equal to max number of samples
}else{
retval = 1.0;
}
return retval;
}
-short AliTPCAltroEmulator::GetElement(short* Array,int index){
- //
+Short_t AliTPCAltroEmulator::GetElement(short* Array,Int_t index){
//
+ // GetElement of array
//
if (index < 0)
return 0;
return Array[index];
}
-void AliTPCAltroEmulator::SetElement(short* Array,int index,short value){
- //
+void AliTPCAltroEmulator::SetElement(short* Array,Int_t index,Short_t value){
//
+ // SetElement of array
//
if (index < 0)
return;
Array[index] = value;
}
-int AliTPCAltroEmulator::InBand(int ADC,int bsl, int LowThreshold, int HighThreshold){
+Int_t AliTPCAltroEmulator::InBand(Int_t ADC,Int_t bsl, Int_t LowThreshold, Int_t HighThreshold){
//
+ // check if it's within the band of search
//
- //
- int fLow = bsl - LowThreshold;
- int fHigh = bsl + HighThreshold;
+ Int_t fLow = bsl - LowThreshold;
+ Int_t fHigh = bsl + HighThreshold;
if( (ADC <= fHigh) && (ADC >= fLow) )
return 1;
else
return 0;
}
-int AliTPCAltroEmulator::InRange(int parameter,int Low,int High,const char *Module,const char *ParameterName){
- //
+Int_t AliTPCAltroEmulator::InRange(Int_t parameter,Int_t Low,Int_t High,const char *Module,const char *ParameterName){
//
+ // checks it it's within the range
//
char out[255];
- int retval;
+ Int_t retval;
if(parameter > High){
sprintf(out,"Error | %s | Parameter %s is to big, has to be %d <= %s <= %d, is %d, now set to %d",Module,ParameterName,Low,ParameterName,High,parameter,High);
cout << out << endl;
return retval;
}
-short AliTPCAltroEmulator::GetShortChannel(int i){
- //
+Short_t AliTPCAltroEmulator::GetShortChannel(Int_t i){
//
+ // GetElement of channel
//
return GetElement(fChannelShort,i);
}
-short AliTPCAltroEmulator::GetKeepChannel(int i){
- //
+Short_t AliTPCAltroEmulator::GetKeepChannel(Int_t i){
//
+ // GetElement of Keep Channel
//
return GetElement(fADCkeep,i);
}
+
+Bool_t AliTPCAltroEmulator::WriteEvent(Int_t ievent) {
+ //
+ // Write event to the DDL data folders
+ //
+
+ for (Int_t ddlID=0;ddlID<216;++ddlID) {
+ Bool_t *channelsDDL=fChannels+ddlID*4096 ;
+ Short_t *adcsDDL =fADCs +ddlID*4096*1024;
+ UInt_t *cdhDDL =fCDHs +ddlID*8 ;
+ UInt_t *trailerDDL =fTrailers+ddlID*9 ;
+
+ FILE *file=fopen(Form("%s/raw%d/TPC_%03d.ddl",
+ fDDLFolderName.Data(),ievent,768+ddlID),
+ "wb");
+ if (!file) return kFALSE;
+ Int_t i32;
+ // write CDH (first word to be altered later)
+ for (i32=0;i32<8;++i32)
+ fRawData[i32]=cdhDDL[i32];
+
+ // process payload
+ for (Int_t hwaddr=0;hwaddr<4096;++hwaddr) if (channelsDDL[hwaddr]) {
+ Short_t *adcsChannel=adcsDDL+hwaddr*1024;
+ // merge custers
+ // TODO: acqusition window
+ for (Int_t it=0;it<1024-3;++it) {
+ if (adcsChannel[it]>=0&&adcsChannel[it+3]>=0) {
+ if (adcsChannel[it+1]<0) {
+ // printf("merge");
+ adcsChannel[it+1]=0;
+ }
+ if (adcsChannel[it+2]<0) {
+ // printf("merge");
+ adcsChannel[it+2]=0;
+ }
+ }
+ }
+ Int_t i10=3;
+ Int_t icw=0;
+ Int_t its=1;
+ Int_t cw =0;
+ Int_t ts =0;
+ for (Int_t it=1023;it>=0;--it) {
+ Short_t w10=adcsChannel[it];
+ if (w10>=0) {
+ if (cw<0) {
+ icw=i10++;
+ its=i10++;
+ cw =0 ;
+ ts=it ;
+ }
+ fRawData[i32+i10/3]|=w10<<(10*(2-i10%3));
+ ++i10;
+ ++cw;
+ }
+ else {
+ if (cw>=0) {
+ cw+=2;
+ fRawData[i32+icw/3]|=cw <<(10*(2-icw%3));
+ fRawData[i32+its/3]|=ts <<(10*(2-its%3));
+ cw=-1;
+ }
+ }
+ }
+ fRawData[i32]=0x1<<30|(i10-3)<<16|hwaddr;
+ i32+=(i10+2)/3;
+
+ // clean up
+ for (Int_t i=0;i<1024;++i) adcsChannel[i]=-1;
+ channelsDDL[hwaddr]=kFALSE;
+ }
+
+ // write RCU trailer
+ fRawData[i32]=0x2<<30|(i32-8);i32++;
+ for (Int_t i=0;i<8;++i)
+ fRawData[i32++]=trailerDDL[i];
+
+ // write first word of CDH
+ fRawData[0]=i32*4;
+
+ Int_t nwritten=fwrite(fRawData,sizeof(UInt_t),i32,file);
+ if (nwritten!=i32) return kFALSE;
+
+ // clean up
+ do {fRawData[--i32]=0;} while (i32>0);
+
+ fclose(file);
+ }
+ return kTRUE;
+}
+
+Bool_t AliTPCAltroEmulator::GDC2DDLs(AliRawVEvent *gdc,Int_t ievent) {
+ //
+ // Converte GDC data to DDL format
+ //
+ for(Int_t iLDC=0;iLDC<gdc->GetNSubEvents();++iLDC) {
+ AliRawVEvent *ldc=gdc->GetSubEvent(iLDC);
+ for(Int_t iEq=0;iEq<ldc->GetNEquipments();++iEq) {
+ AliRawVEquipment *eq=ldc->GetEquipment(iEq);
+ AliRawEquipmentHeader *eqHeader=eq->GetEquipmentHeader();
+ Int_t eqSize=eqHeader->GetEquipmentSize();
+ if (eqSize>0) {
+ Int_t ddlIndex;
+ Int_t detId=AliDAQ::DetectorIDFromDdlID(eqHeader->GetId(),ddlIndex);
+ Int_t nwritten=0;
+ FILE *ddlFile=fopen(Form("%s/raw%d/%s",
+ fDDLFolderName.Data(),
+ ievent,
+ AliDAQ::DdlFileName(detId,ddlIndex)),
+ "wb");
+ AliRawData *rawData=eq->GetRawData();
+ if (ddlFile) {
+ nwritten=fwrite(rawData->GetBuffer(),1,rawData->GetSize(),ddlFile);
+ fclose(ddlFile);
+ }
+ if (nwritten<rawData->GetSize()) return kFALSE;
+ }
+ }
+ }
+ return kTRUE;
+}
+
+
+Bool_t AliTPCAltroEmulator::ConvertRawFilesToDate(Int_t nevents) {
+ //
+ // Convertes Raw files to Date format
+ //
+
+ // from $ALICE_ROOT/STEER/AliSimulation.cxx
+
+ char command[100];
+ FILE *pipe;
+ if (fReader->GetRunNumber()>0)
+ pipe=gSystem->OpenPipe(Form("dateStream -c -s -D -o %s -C -# %d -run %d",
+ fOutputDateFileName.Data(),
+ nevents,
+ fReader->GetRunNumber()),
+ "w");
+ else
+ pipe=gSystem->OpenPipe(Form("dateStream -c -s -D -o %s -C -# %d",
+ fOutputDateFileName.Data(),
+ nevents),
+ "w");
+ if (!pipe) {
+ fprintf(stderr,"error: cannot execute command: %s",command);
+ return kFALSE;
+ }
+
+ for (Int_t ievent=0;ievent<nevents;++ievent) {
+ UInt_t detectorPattern = 0xFFFFFFFF;
+ fprintf(pipe, "GDC DetectorPattern %u\n", detectorPattern);
+
+ Float_t ldc = 0;
+ Int_t prevLDC = -1;
+
+ // loop over detectors and DDLs
+ for (Int_t iDet = 0; iDet < AliDAQ::kNDetectors; iDet++) {
+ if (!(iDet<=5 || iDet==17 )) continue;
+ for (Int_t iDDL = 0; iDDL < AliDAQ::NumberOfDdls(iDet); iDDL++) {
+ // printf("iDet=%d, iDDL=%d, filenmae=%s\n",iDet,iDDL,filename);
+ Int_t ddlID = AliDAQ::DdlID(iDet,iDDL);
+ Int_t ldcID = Int_t(ldc + 0.0001);
+ ldc += AliDAQ::NumberOfLdcs(iDet) / AliDAQ::NumberOfDdls(iDet);
+
+ // check existence and size of raw data file
+ FILE* file = fopen(Form("%s/raw%d/%s",
+ fDDLFolderName.Data(),
+ ievent,
+ AliDAQ::DdlFileName(iDet,iDDL)),
+ "rb");
+ if (!file) continue;
+ fseek(file, 0, SEEK_END);
+ unsigned long size = ftell(file);
+ fclose(file);
+ if (!size) continue;
+
+ if (ldcID != prevLDC) {
+ fprintf(pipe, " LDC Id %d\n", ldcID);
+ prevLDC = ldcID;
+ }
+ fprintf(pipe,Form(" Equipment Id %d Payload %s/raw%d/%s\n",
+ ddlID,
+ fDDLFolderName.Data(),
+ ievent,
+ AliDAQ::DdlFileName(iDet,iDDL))
+ );
+ }
+ }
+ }
+ Int_t result = gSystem->ClosePipe(pipe);
+ return (result == 0);
+}
+
+void AliTPCAltroEmulator::InitBuffers() {
+ //
+ // Initialization of the Buffers
+ //
+ if (!fChannels) fChannels=new Bool_t [216*4096 ];
+ if (!fCDHs ) fCDHs =new UInt_t [216*8 ];
+ if (!fADCs ) fADCs =new Short_t[216*4096*1024];
+ if (!fTrailers) fTrailers=new UInt_t [216*9 ];
+ if (!fRawData ) fRawData =new UInt_t [ 1*4096*1024]; // be save...
+
+ for (Int_t i=0;i<216*4096 ;++i) fChannels[i]=kFALSE;
+ // no need to init CDHs
+ for (Int_t i=0;i<216*4096*1024;++i) fADCs [i]=-1 ;
+ // no need to init trailers
+ for (Int_t i=0;i< 1*4096*1024;++i) fRawData [i]= 0 ;
+}
+
+Bool_t AliTPCAltroEmulator::ConvertDateToRoot() {
+ //
+ // convert a DATE file to a root file with the program "alimdc"
+ //
+
+ // from $ALICE_ROOT/STEER/AliSimulation.cxx
+
+ // ALIMDC setup
+ const Int_t kDBSize = 2000000000; //2GB
+ const Int_t kTagDBSize = 1000000000;
+ const Bool_t kFilter = kFALSE;
+ const Int_t kCompression = 1;
+
+ // AliInfo(Form("converting DATE file %s to root file %s",
+ // dateFileName, rootFileName));
+
+ const char* rawDBFS[2] = { "/tmp/mdc1", "/tmp/mdc2" };
+ const char* tagDBFS = "/tmp/mdc1/tags";
+
+ // User defined file system locations
+ if (gSystem->Getenv("ALIMDC_RAWDB1"))
+ rawDBFS[0] = gSystem->Getenv("ALIMDC_RAWDB1");
+ if (gSystem->Getenv("ALIMDC_RAWDB2"))
+ rawDBFS[1] = gSystem->Getenv("ALIMDC_RAWDB2");
+ if (gSystem->Getenv("ALIMDC_TAGDB"))
+ tagDBFS = gSystem->Getenv("ALIMDC_TAGDB");
+
+ gSystem->Exec(Form("rm -rf %s",rawDBFS[0]));
+ gSystem->Exec(Form("rm -rf %s",rawDBFS[1]));
+ gSystem->Exec(Form("rm -rf %s",tagDBFS));
+
+ gSystem->Exec(Form("mkdir %s",rawDBFS[0]));
+ gSystem->Exec(Form("mkdir %s",rawDBFS[1]));
+ gSystem->Exec(Form("mkdir %s",tagDBFS));
+
+ Int_t result = gSystem->Exec(Form("alimdc %d %d %d %d %s",
+ kDBSize, kTagDBSize, kFilter, kCompression, fOutputDateFileName.Data()));
+ gSystem->Exec(Form("mv %s/*.root %s", rawDBFS[0],fOutputRootFileName.Data()));
+
+ gSystem->Exec(Form("rm -rf %s",rawDBFS[0]));
+ gSystem->Exec(Form("rm -rf %s",rawDBFS[1]));
+ gSystem->Exec(Form("rm -rf %s",tagDBFS));
+
+ return (result == 0);
+}
+
+void AliTPCAltroEmulator::RunEmulationOnRAWdata(AliRawReader *reader, Int_t plotFlag) {
+ //
+ // Run the Altro Emulation on a full Raw data set (AliRawReader)
+ // plus write the outcome in a RAW data format
+ //
+
+ if (!reader) {
+ printf("ERROR cant run Altro Emulation: AliRawReader is zero. No RAW data file.\n");
+ return;
+ }
+
+ fReader=reader;
+ if (fDecoder) delete fDecoder;
+ fDecoder=new AliTPCRawStreamV3(reader);
+
+ InitBuffers();
+
+ TH1F hisO("DINO","DINO",1014,0,1014);
+ TH1F his("DIN","DIN",1014,0,1014);
+ TCanvas c1("c1","c1");
+ Int_t chanCount=0;
+ his.GetYaxis()->SetRangeUser(-20,90);
+ Short_t *data = new Short_t[1014];
+
+
+ // event loop
+ Int_t ievent=0;
+ while (fReader->NextEvent()) {
+
+ gSystem->Exec(Form("mkdir -p %s/raw%d/",fDDLFolderName.Data(),ievent));
+ GDC2DDLs(const_cast<AliRawVEvent*>(fReader->GetEvent()),ievent);
+
+ Int_t ddlC =0;
+ while (fDecoder->NextDDL()) {
+ Int_t ddlID=fDecoder->GetDDLNumber();
+ printf("ddl: %d (%d)\n",ddlID,ddlC++);
+
+ Bool_t *channelsDDL=fChannels+ddlID*4096 ;
+ Short_t *adcsDDL =fADCs +ddlID*4096*1024;
+ UInt_t *cdhDDL =fCDHs +ddlID*8 ;
+ UInt_t *trailerDDL =fTrailers+ddlID*9 ;
+
+ // CDH
+ for (Int_t i=0;i<8;++i)
+ // just to show how ugly it is...
+ cdhDDL[i]=reinterpret_cast<UInt_t*>(const_cast<AliRawDataHeader*>(fReader->GetDataHeader()))[i];
+
+ // PAYLOAD
+ while (fDecoder->NextChannel()) {
+ Int_t hwaddr=fDecoder->GetHWAddress();
+ Short_t *adcsChannel=adcsDDL+hwaddr*1024;
+ while (fDecoder->NextBunch()) {
+ UInt_t ts =fDecoder->GetStartTimeBin();
+ Int_t cw =fDecoder->GetBunchLength() ;
+ const UShort_t *signals=fDecoder->GetSignals() ;
+ for (Int_t ci=0;ci<cw;++ci) {
+ Short_t s=signals[ci];
+ Int_t t=ts-ci;
+ // TODO aqcuisition window
+ if (20<=t&&t<=1014) {
+ channelsDDL[hwaddr]=kTRUE;
+ if (adcsChannel[t]<0)
+ adcsChannel[t]=s;
+ else
+ adcsChannel[t]+=s;
+ if (adcsChannel[t]>0x3ff)
+ adcsChannel[t]=0x3ff;
+ }
+ }
+ }
+
+
+ if (1) {
+
+ // search start of aquisition
+ Int_t t0 = 0; while (adcsChannel[t0]==-1) t0++;
+ // search end of aquisition
+ Int_t tE = 1014; while (adcsChannel[tE]==-1) tE--;
+ // printf("S:%d E:%d\n",t0,tE);
+
+ // SR TEST:
+ // channel is complete - Perform Altro Emulation
+ if (plotFlag && !(chanCount%1000)) {
+ for (Int_t t=0; t<1014; t++) {
+ his.SetBinContent(t+1,adcsChannel[t]);
+ }
+ his.SetStats(0); his.GetXaxis()->SetTitle("timebin");
+ his.DrawCopy();
+ }
+ // FEED THE ALTRO EMULATOR WITH CLEAN SIGNAL (not aquisition window ghosts)
+ Int_t timebins = tE-t0;
+
+ for (Int_t t=t0;t<(t0+timebins);t++)
+ data[t-t0]=adcsChannel[t];
+ //SetChannelData(timebins, adcsChannel);//data);
+ SetChannelData(timebins,data);
+ RunEmulation(); // emulation on single channel
+ for (Int_t t=t0;t<(t0+timebins);t++)
+ adcsChannel[t]=data[t-t0];
+
+ // SR TEST:
+ if (plotFlag && !(chanCount%1000) ) {
+ for (Int_t t=0; t<1014; t++)
+ hisO.SetBinContent(t+1,adcsChannel[t]);
+ hisO.SetStats(0); hisO.SetLineColor(2);
+ hisO.DrawCopy("same");
+
+ c1.SaveAs(Form("/tmp/chanCount_%07d.png",chanCount));
+
+ his.Reset();
+ hisO.Reset();
+
+ }
+ chanCount++;
+ }
+
+ }
+
+ // TRAILER
+ UChar_t *rcuTrailer;
+ fDecoder->GetRCUTrailerData(rcuTrailer);
+ for (Int_t i=0;i<= /* (!) */ fDecoder->GetRCUTrailerSize()/4;++i)
+ trailerDDL[i]=reinterpret_cast<UInt_t*>(rcuTrailer)[i]; // again: UGLY!
+
+ }
+
+ WriteEvent(ievent++);
+ }
+
+ delete data; // free space
+
+ // convert to date and back
+ ConvertRawFilesToDate(ievent);
+ ConvertDateToRoot();
+
+
+}
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <AliRawReader.h>
+#include <AliTPCRawStreamV3.h>
+
using namespace std;
class AliTPCAltroEmulator : public TNamed {
-public:
- AliTPCAltroEmulator(int timebins, short* Channel);
- AliTPCAltroEmulator(const AliTPCAltroEmulator &sig);
- ~AliTPCAltroEmulator();
- AliTPCAltroEmulator& operator = (const AliTPCAltroEmulator &source);
-
- void ConfigAltro(int ONBaselineCorrection1, int ONTailcancellation, int ONBaselineCorrection2, int ONClipping, int ONZerosuppression, int ONDataFormatting);
- void ConfigBaselineCorrection1(int mode, int ValuePeDestal, int *PedestalMem, int polarity);
- void ConfigTailCancellationFilter(int K1, int K2, int K3, int L1, int L2, int L3);
- void ConfigBaselineCorrection2(int HighThreshold, int LowThreshold, int Offset, int Presamples, int Postsamples);
- void ConfigZerosuppression(int Threshold, int MinSamplesaboveThreshold, int Presamples, int Postsamples);
- void PrintParameters();
- void RunEmulation();
- float CalculateCompression();
-
- enum {
- /**din - fpd*/ kDINxFPD,
- /**din - f(t)*/ kDINxFT,
- /**din - f(din)*/ kDINxFDIN,
- /**din - f(din-vpd)*/ kDINxFDINxVPD,
- /**din - vpd - fpd*/ kDINxVPDxFPD,
- /**din - vpd - f(t)*/ kDINxVPDxFT,
- /**din - vpd - f(din)*/ kDINxVPDxFDIN,
- /**din - vpd - f(din - vpd)*/ kDINxVPDxFDINxVPD,
- /**f(din) - fpd*/ kFDINxFPD,
- /**f(din - vpd) - fpd*/ kFDINxVPDxFPD,
- /**f(t) - fpd*/ kFTxFPD,
- /**f(t) - f(t)*/ kFTxFT,
- /**f(din) - f(din)*/ kFDINxFDIN,
- /**f(din - vpd) - f(din - vpd)*/ kFDINxVPDxFDINxVPD,
- /**din - fpd*/ kDINxFPD1,
- /**din - fpd*/ kDINxFPD2
- };
-
- private:
- int ftimebins; // timebins
-
- // short *fChannelIn; // ChannelIn
- short *fChannelShort; // incoming signal in short format
- short *fADCkeep; // ADCkeep
-
- int fOnBSL1; // Baseline correction and substraction 1 on
- int fOnTCF; // Tail Cancelation Filter on
- int fOnBSL2; // Baseline correction and substraction 2 (MAF) on
- int fOnClip; // Clipping on (to reverse the signal for ZSU if BSL2 is on)
- int fOnZSU; // Zero Suppression on
-
- int fConfiguredAltro; // ConfiguredAltro
- int fConfiguredBSL1; // ConfiguredBSL1
- int fConfiguredTCF; // ConfiguredTCF
- int fConfiguredBSL2; // ConfiguredBSL2
- int fConfiguredZSU; // ConfiguredZSU
-
- int fBSL1mode; // BSL1mode
- int fBSL1ValuePeDestal; // BSL1ValuePeDestal
- int* fBSL1PedestalMem; // BSL1PedestalMem
- int fBSL1polarity; // BSL1polarity
-
- float fTCFK1; // K1
- float fTCFK2; // K2
- float fTCFK3; // K3
- float fTCFL1; // L1
- float fTCFL2; // L2
- float fTCFL3; // L3
-
- int fTCFK1Int; // K1Int
- int fTCFK2Int; // K2Int
- int fTCFK3Int; // K3Int
- int fTCFL1Int; // L1Int
- int fTCFL2Int; // L2Int
- int fTCFL3Int; // L3Int
-
- int fBSL2HighThreshold; // BSL2HighThreshold
- int fBSL2LowThreshold; // BSL2LowThreshold
- int fBSL2Offset; // BSL2Offset
- int fBSL2Presamples; // BSL2Presamples;
- int fBSL2Postsamples; // BSL2Postsamples
-
- int fZSUThreshold; // ZSUThreshold
- int fZSUMinSamplesaboveThreshold; // ZSUMinSamplesaboveThreshold
- int fZSUPresamples; // ZSUPresamples
- int fZSUPostsamples; // ZSUPostsamples
-
- void BaselineCorrection1(int mode, int FixedPeDestal, int *PedestalMem, int polarity);
- void TailCancellationFilterFixedPoint(int K1, int K2, int K3, int L1, int L2, int L3);
- void BaselineCorrection2RTL(int HighThreshold, int LowThreshold, int Offset, int Presamples, int Postsamples);
- void Clipping();
- void Zerosuppression(int Threshold, int MinSamplesaboveThreshold, int Presamples, int Postsamples);
- void DataFormater();
-
- short GetElement(short* Array,int index);
- void SetElement(short* Array,int index,short value);
-
- int InBand(int ADC,int bsl, int LowThreshold, int HighThreshold);
- int InRange(int parameter,int Low,int High,const char *Module,const char *ParameterName);
- short GetShortChannel(int i);
- short GetKeepChannel(int i);
- int Multiply36(int P, int N);
- long long Mask(long long in, int left, int right);
- long long Maskandshift(long long in, int left, int right);
- ClassDef(AliTPCAltroEmulator,0)
+ public:
+ AliTPCAltroEmulator(Int_t timebins=0, Short_t* Channel=0);
+ AliTPCAltroEmulator(const AliTPCAltroEmulator &sig);
+ ~AliTPCAltroEmulator();
+ AliTPCAltroEmulator& operator = (const AliTPCAltroEmulator &source);
+
+ void ConfigAltro(Int_t ONBaselineCorrection1, Int_t ONTailcancellation, Int_t ONBaselineCorrection2, Int_t ONClipping, Int_t ONZerosuppression, Int_t ONDataFormatting);
+ void ConfigBaselineCorrection1(Int_t mode, Int_t ValuePeDestal, Int_t *PedestalMem, Int_t polarity);
+ void ConfigTailCancellationFilter(Int_t K1, Int_t K2, Int_t K3, Int_t L1, Int_t L2, Int_t L3);
+ void ConfigBaselineCorrection2(Int_t HighThreshold, Int_t LowThreshold, Int_t Offset, Int_t Presamples, Int_t Postsamples);
+ void ConfigZerosuppression(Int_t Threshold, Int_t MinSamplesaboveThreshold, Int_t Presamples, Int_t Postsamples);
+
+ void SetChannelData(Int_t timebins, Short_t* Channel);
+ void PrintParameters();
+ void RunEmulation();
+ Float_t CalculateCompression();
+
+ // perform altro emulation on raw-reader level
+
+ void RunEmulationOnRAWdata(AliRawReader *reader, Int_t plotFlag=0);
+
+ TString GetDDLFolderName() const {return fDDLFolderName ;}
+ TString GetOutputDateFileName() const {return fOutputDateFileName;}
+ TString GetOutputRootFileName() const {return fOutputRootFileName;}
+ void SetDDLFolderName (const TString &name) {fDDLFolderName =name;}
+ void SetOutputDateFileName(const TString &name) {fOutputDateFileName=name;}
+ void SetOutputRootFileName(const TString &name) {fOutputRootFileName=name;}
+
+
+
+
+ enum {
+ /**din - fpd*/ kDINxFPD,
+ /**din - f(t)*/ kDINxFT,
+ /**din - f(din)*/ kDINxFDIN,
+ /**din - f(din-vpd)*/ kDINxFDINxVPD,
+ /**din - vpd - fpd*/ kDINxVPDxFPD,
+ /**din - vpd - f(t)*/ kDINxVPDxFT,
+ /**din - vpd - f(din)*/ kDINxVPDxFDIN,
+ /**din - vpd - f(din - vpd)*/ kDINxVPDxFDINxVPD,
+ /**f(din) - fpd*/ kFDINxFPD,
+ /**f(din - vpd) - fpd*/ kFDINxVPDxFPD,
+ /**f(t) - fpd*/ kFTxFPD,
+ /**f(t) - f(t)*/ kFTxFT,
+ /**f(din) - f(din)*/ kFDINxFDIN,
+ /**f(din - vpd) - f(din - vpd)*/ kFDINxVPDxFDINxVPD,
+ /**din - fpd*/ kDINxFPD1,
+ /**din - fpd*/ kDINxFPD2
+ };
+
+ private:
+
+ Int_t ftimebins; // timebins
+
+ // Short_t *fChannelIn; // ChannelIn
+ Short_t *fChannelShort; // incoming signal in Short_t format
+ Short_t *fADCkeep; // ADCkeep
+
+ Int_t fOnBSL1; // Baseline correction and substraction 1 on
+ Int_t fOnTCF; // Tail Cancelation Filter on
+ Int_t fOnBSL2; // Baseline correction and substraction 2 (MAF) on
+ Int_t fOnClip; // Clipping on (to reverse the signal for ZSU if BSL2 is on)
+ Int_t fOnZSU; // Zero Suppression on
+
+ Int_t fConfiguredAltro; // ConfiguredAltro
+ Int_t fConfiguredBSL1; // ConfiguredBSL1
+ Int_t fConfiguredTCF; // ConfiguredTCF
+ Int_t fConfiguredBSL2; // ConfiguredBSL2
+ Int_t fConfiguredZSU; // ConfiguredZSU
+
+ Int_t fBSL1mode; // BSL1mode
+ Int_t fBSL1ValuePeDestal; // BSL1ValuePeDestal
+ Int_t* fBSL1PedestalMem; // BSL1PedestalMem
+ Int_t fBSL1polarity; // BSL1polarity
+
+ Float_t fTCFK1; // K1
+ Float_t fTCFK2; // K2
+ Float_t fTCFK3; // K3
+ Float_t fTCFL1; // L1
+ Float_t fTCFL2; // L2
+ Float_t fTCFL3; // L3
+
+ Int_t fTCFK1Int; // K1Int
+ Int_t fTCFK2Int; // K2Int
+ Int_t fTCFK3Int; // K3Int
+ Int_t fTCFL1Int; // L1Int
+ Int_t fTCFL2Int; // L2Int
+ Int_t fTCFL3Int; // L3Int
+
+ Int_t fBSL2HighThreshold; // BSL2HighThreshold
+ Int_t fBSL2LowThreshold; // BSL2LowThreshold
+ Int_t fBSL2Offset; // BSL2Offset
+ Int_t fBSL2Presamples; // BSL2Presamples;
+ Int_t fBSL2Postsamples; // BSL2Postsamples
+
+ Int_t fZSUThreshold; // ZSUThreshold
+ Int_t fZSUMinSamplesaboveThreshold; // ZSUMinSamplesaboveThreshold
+ Int_t fZSUPresamples; // ZSUPresamples
+ Int_t fZSUPostsamples; // ZSUPostsamples
+
+ void BaselineCorrection1(Int_t mode, Int_t FixedPeDestal, Int_t *PedestalMem, Int_t polarity);
+ void TailCancellationFilterFixedPoint(Int_t K1, Int_t K2, Int_t K3, Int_t L1, Int_t L2, Int_t L3);
+ void BaselineCorrection2RTL(Int_t HighThreshold, Int_t LowThreshold, Int_t Offset, Int_t Presamples, Int_t Postsamples);
+ void Clipping();
+ void Zerosuppression(Int_t Threshold, Int_t MinSamplesaboveThreshold, Int_t Presamples, Int_t Postsamples);
+ void DataFormater();
+
+ Short_t GetElement(short* Array,Int_t index);
+ void SetElement(short* Array,Int_t index,Short_t value);
+
+ Int_t InBand(Int_t ADC,Int_t bsl, Int_t LowThreshold, Int_t HighThreshold);
+ Int_t InRange(Int_t parameter,Int_t Low,Int_t High,const char *Module,const char *ParameterName);
+ Short_t GetShortChannel(Int_t i);
+ Short_t GetKeepChannel(Int_t i);
+ Int_t Multiply36(Int_t P, Int_t N);
+ long long Mask(long long in, Int_t left, Int_t right);
+ long long Maskandshift(long long in, Int_t left, Int_t right);
+
+
+
+ void InitBuffers();
+ Bool_t AddEvent(Int_t dt,Bool_t isFirst);
+ Bool_t CreateEvent(Int_t ievent);
+ Bool_t GDC2DDLs(AliRawVEvent *gdc,Int_t ievent);
+ Bool_t ConvertRawFilesToDate(Int_t nevents);
+ Bool_t ConvertDateToRoot();
+ Bool_t WriteEvent(Int_t ievent);
+
+ AliRawReader *fReader ; // RAW reader
+ AliTPCRawStreamV3 *fDecoder; // ALTRO decoder
+
+ TString fDDLFolderName; // folder name for ddl files
+ TString fOutputDateFileName; // filename for date output
+ TString fOutputRootFileName; // filename for root output
+
+ Float_t fP[2047] ; // Interaction probabilities for times (T-1023,...T,...T+1023)
+ Bool_t fIsRandom; // Indicates if fP are treated as probabilities (in terms of Possionian statistics), or fixed numbers
+ Bool_t *fChannels; //! field of active channels
+ UInt_t *fCDHs ; //! CDHs
+ Short_t *fADCs ; //! field of ADC counts
+ UInt_t *fTrailers; //! RCU trailers
+ UInt_t *fRawData ; //! Raw Data
+
+
+ ClassDef(AliTPCAltroEmulator,1);
};
#endif