4 // Small script to test consistency of writing and reading raw data.
12 gRandom->SetSeed(12345);
14 Int_t channelWidth = 128;
15 Float_t shapingTime = 5;
16 UInt_t maxAdc = (1 << 10);
17 UInt_t threshold = (1 << 8);
18 TArrayI outData(sampleRate * channelWidth);
20 Float_t lastTotalCharge = 0;
22 for (Int_t channel = 0; channel < channelWidth; channel++) {
23 Float_t totalCharge = gRandom->Uniform(0, 1);
25 for (Int_t sample = 0; sample < sampleRate; sample++) {
26 Float_t time = Float_t(sample) / sampleRate;
27 Float_t charge = (totalCharge + (lastTotalCharge - totalCharge)
28 * TMath::Exp(-shapingTime * time));
29 UInt_t adc = UInt_t(maxAdc * charge);
30 outData[channel * sampleRate + sample] = adc;
31 if (adc > threshold) ok++;
33 lastTotalCharge = totalCharge;
35 std::cout << "Total of " << outData.fN << " samples of which "
36 << ok << " of them are above threshold (" << threshold
40 AliAltroBuffer buffer("FMD_4096.ddl", 1);
41 buffer.WriteDataHeader(kTRUE, kFALSE);
42 buffer.WriteChannel(0, 0, 0, outData.fN, outData.fArray, threshold);
44 buffer.WriteDataHeader(kFALSE, kFALSE);
47 AliRawReader* reader = new AliRawReaderFile(-1);
49 std::cerr << "Failed to make AliRawReader" << endl;
52 AliFMDRawStream input(reader, sampleRate);
53 reader->Select(AliFMDParameters::kBaseDDL >> 8);
57 UShort_t detector = 1; // Must be one here
58 UShort_t oldDetector = 0;
59 // Loop over data in file
67 TArrayI inputData(sampleRate * channelWidth);
73 Int_t channel = input.Strip();
74 Int_t sample = input.Sample();
75 inputData[channel * sampleRate + sample] = input.Count();
78 Int_t in = inputData[channel * sampleRate + sample];
79 Int_t out = outData[channel * sampleRate + sample];
80 std::cout << "[\t" << channel << ",\t" << sample << "]\t"
81 << out << "\t" << in << std::flush;
82 if (out >= threshold && in != out) std::cout << "\tBad" << std::flush;
83 std::cout << std::endl;
86 std::cout << "Read " << count << " values" << std::endl;
88 for (Int_t channel = channelWidth - 1; channel > 0; channel--) {
89 for (Int_t sample = sampleRate - 1; sample > 0; sample--) {
90 Int_t in = inputData[channel * sampleRate + sample];
91 Int_t out = outData[channel * sampleRate + sample];
92 std::cout << "[\t" << channel << ",\t" << sample << "]\t"
93 << out << "\t" << in << std::flush;
94 if (out >= threshold && in != out) std::cout << "\tBad" << std::flush;
95 std::cout << std::endl;
101 //____________________________________________________________________