+// $Id$
+
/**************************************************************************
* This file is property of and copyright by the ALICE HLT Project *
* All rights reserved. *
#include "AliHLTPHOSDataCorruptor.h"
#include "AliHLTPHOSPulseGenerator.h"
-
#include "TRandom.h"
-
#include <iostream>
using namespace std;
AliHLTPHOSDataCorruptor::AliHLTPHOSDataCorruptor():fPulseGeneratorPtr(0), fRandomGeneratorPtr(0)
{
- // cout << " AliHLTPHOSDataCorruptor::AliHLTPHOSDataCorruptor() creating new datacorruptor" << endl;
fPulseGeneratorPtr = new AliHLTPHOSPulseGenerator(100, 0, 300, 2, 10);
fRandomGeneratorPtr = new TRandom();
}
void
AliHLTPHOSDataCorruptor::MakeCorruptedDataTest(Double_t *dataArray, int N)
{
- // double testPulse[300];
- // dataArray[300];
int* quantisized = new int[N];
fPulseGeneratorPtr->SetSampleFreq(10);
fPulseGeneratorPtr->SetTZero(0);
fPulseGeneratorPtr->MakePulse(dataArray, N);
- cout <<endl <<endl;
- cout << "AliHLTPHOSDataCorruptor::MakeCorruptedDataTest: printing data array before corruption" <<endl;
for(int i=0; i< N; i++)
{
- cout << dataArray[i] <<"\t";
quantisized[i] = (int)(dataArray[i]);
}
- cout << endl;
- cout << "AliHLTPHOSDataCorruptor::MakeCorruptedDataTest: printing data after quantization" <<endl;
-
- for(int i=0; i< N; i++)
- {
- cout << quantisized[i] <<"\t";
- }
- cout << endl;
-
int bit = fRandomGeneratorPtr->Integer(10);
-
- cout << "AliHLTPHOSDataCorruptor::MakeCorruptedDataTest: printing data flipping sample 20, bit " << bit <<endl;
-
FlipBit(&quantisized[10], bit);
- cout << endl;
-
- for(int i=0; i< N; i++)
- {
- cout << quantisized[i] <<"\t";
- }
- cout << endl;
- cout << endl;
delete [] quantisized;
}
void
AliHLTPHOSDataCorruptor::FlipBit(int *sample, int n)
{
-
int mask = 1 << n;
- cout << "n = "<< n <<" mask = " << mask << endl;
- cout << "before flip"<< *sample << endl;
*sample = *sample ^ mask;
- cout <<"after flip" << *sample <<endl;
-
}