1 #include "AliHLTPHOSDataCorruptor.h"
2 #include "AliHLTPHOSPulseGenerator.h"
11 AliHLTPHOSDataCorruptor::AliHLTPHOSDataCorruptor():fPulseGeneratorPtr(0), fRandomGeneratorPtr(0)
13 // cout << " AliHLTPHOSDataCorruptor::AliHLTPHOSDataCorruptor() creating new datacorruptor" << endl;
14 fPulseGeneratorPtr = new AliHLTPHOSPulseGenerator(100, 0, 300, 2, 10);
15 fRandomGeneratorPtr = new TRandom();
19 AliHLTPHOSDataCorruptor::AliHLTPHOSDataCorruptor(const AliHLTPHOSDataCorruptor & ):fPulseGeneratorPtr(0), fRandomGeneratorPtr(0)
25 AliHLTPHOSDataCorruptor::~AliHLTPHOSDataCorruptor()
27 delete fPulseGeneratorPtr;
32 * Takes as input good data from an altro and makes
33 * bad data from it by flipping bits in individual samples, adding noise
34 * add a double pulse.. etc
35 * @param dataArray data that should be corrupted
36 * @param N the number of samples in the array
39 AliHLTPHOSDataCorruptor::MakeCorruptedData(Double_t *dataArray, int N)
47 AliHLTPHOSDataCorruptor::MakeCorruptedDataTest(Double_t *dataArray, int N)
49 // double testPulse[300];
51 int* quantisized = new int[N];
53 fPulseGeneratorPtr->SetSampleFreq(10);
54 fPulseGeneratorPtr->SetAmplitude(100);
55 fPulseGeneratorPtr->SetTZero(0);
56 fPulseGeneratorPtr->MakePulse(dataArray, N);
59 cout << "AliHLTPHOSDataCorruptor::MakeCorruptedDataTest: printing data array before corruption" <<endl;
61 for(int i=0; i< N; i++)
63 cout << dataArray[i] <<"\t";
64 quantisized[i] = (int)(dataArray[i]);
68 cout << "AliHLTPHOSDataCorruptor::MakeCorruptedDataTest: printing data after quantization" <<endl;
70 for(int i=0; i< N; i++)
72 cout << quantisized[i] <<"\t";
76 int bit = fRandomGeneratorPtr->Integer(10);
78 cout << "AliHLTPHOSDataCorruptor::MakeCorruptedDataTest: printing data flipping sample 20, bit " << bit <<endl;
80 FlipBit(&quantisized[10], bit);
84 for(int i=0; i< N; i++)
86 cout << quantisized[i] <<"\t";
90 delete [] quantisized;
95 *Flipping a single bit in a sample from 0 if it is one, and 1 if it
96 *is zero. This emluates a situaion that can occur on the readout bus
97 *if the rcu driver is not able to drive the bus because of to low
99 *@param sample The samle the should have the bit(s) flipped
100 *@param n The number of bits to flip, the highest number is 10 (most significant) .
103 AliHLTPHOSDataCorruptor::FlipBit(int *sample, int n)
107 cout << "n = "<< n <<" mask = " << mask << endl;
108 cout << "before flip"<< *sample << endl;
109 *sample = *sample ^ mask;
110 cout <<"after flip" << *sample <<endl;