]>
Commit | Line | Data |
---|---|---|
56673b84 | 1 | /************************************************************************** |
2 | * This file is property of and copyright by the ALICE HLT Project * | |
3 | * All rights reserved. * | |
4 | * * | |
5 | * Primary Author: Per Thomas Hille <perthi@fys.uio.no> * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
f809259d | 16 | #include "AliHLTPHOSDataCorruptor.h" |
17 | #include "AliHLTPHOSPulseGenerator.h" | |
f809259d | 18 | #include "TRandom.h" |
f809259d | 19 | #include <iostream> |
20 | ||
21 | using namespace std; | |
22 | ||
23 | ||
24 | AliHLTPHOSDataCorruptor::AliHLTPHOSDataCorruptor():fPulseGeneratorPtr(0), fRandomGeneratorPtr(0) | |
25 | { | |
f809259d | 26 | fPulseGeneratorPtr = new AliHLTPHOSPulseGenerator(100, 0, 300, 2, 10); |
27 | fRandomGeneratorPtr = new TRandom(); | |
28 | } | |
29 | ||
30 | ||
31 | AliHLTPHOSDataCorruptor::AliHLTPHOSDataCorruptor(const AliHLTPHOSDataCorruptor & ):fPulseGeneratorPtr(0), fRandomGeneratorPtr(0) | |
32 | { | |
33 | ||
34 | } | |
35 | ||
36 | ||
37 | AliHLTPHOSDataCorruptor::~AliHLTPHOSDataCorruptor() | |
38 | { | |
39 | delete fPulseGeneratorPtr; | |
40 | } | |
41 | ||
42 | ||
43 | /** | |
44 | * Takes as input good data from an altro and makes | |
45 | * bad data from it by flipping bits in individual samples, adding noise | |
46 | * add a double pulse.. etc | |
47 | * @param dataArray data that should be corrupted | |
48 | * @param N the number of samples in the array | |
49 | */ | |
50 | void | |
1804b020 | 51 | AliHLTPHOSDataCorruptor::MakeCorruptedData(Double_t * /*dataArray*/, int /*N*/) |
f809259d | 52 | { |
53 | ||
54 | ||
55 | } | |
56 | ||
57 | ||
58 | void | |
59 | AliHLTPHOSDataCorruptor::MakeCorruptedDataTest(Double_t *dataArray, int N) | |
60 | { | |
2f2c023b | 61 | int* quantisized = new int[N]; |
f809259d | 62 | |
63 | fPulseGeneratorPtr->SetSampleFreq(10); | |
64 | fPulseGeneratorPtr->SetAmplitude(100); | |
65 | fPulseGeneratorPtr->SetTZero(0); | |
66 | fPulseGeneratorPtr->MakePulse(dataArray, N); | |
67 | ||
f809259d | 68 | |
69 | for(int i=0; i< N; i++) | |
70 | { | |
f809259d | 71 | quantisized[i] = (int)(dataArray[i]); |
72 | } | |
73 | ||
f809259d | 74 | int bit = fRandomGeneratorPtr->Integer(10); |
f809259d | 75 | FlipBit(&quantisized[10], bit); |
76 | ||
2f2c023b | 77 | delete [] quantisized; |
f809259d | 78 | } |
79 | ||
80 | ||
81 | /** | |
82 | *Flipping a single bit in a sample from 0 if it is one, and 1 if it | |
83 | *is zero. This emluates a situaion that can occur on the readout bus | |
84 | *if the rcu driver is not able to drive the bus because of to low | |
85 | *impedance. | |
86 | *@param sample The samle the should have the bit(s) flipped | |
87 | *@param n The number of bits to flip, the highest number is 10 (most significant) . | |
88 | */ | |
89 | void | |
90 | AliHLTPHOSDataCorruptor::FlipBit(int *sample, int n) | |
91 | { | |
f809259d | 92 | int mask = 1 << n; |
f809259d | 93 | *sample = *sample ^ mask; |
f809259d | 94 | } |