00001
00002
00003
00004
00005
00009 void
00010 RawTest()
00011 {
00012 gRandom->SetSeed(12345);
00013 Int_t sampleRate = 3;
00014 Int_t channelWidth = 128;
00015 Float_t shapingTime = 5;
00016 UInt_t maxAdc = (1 << 10);
00017 UInt_t threshold = (1 << 8);
00018 TArrayI outData(sampleRate * channelWidth);
00019
00020 Float_t lastTotalCharge = 0;
00021 Int_t ok = 0;
00022 for (Int_t channel = 0; channel < channelWidth; channel++) {
00023 Float_t totalCharge = gRandom->Uniform(0, 1);
00024
00025 for (Int_t sample = 0; sample < sampleRate; sample++) {
00026 Float_t time = Float_t(sample) / sampleRate;
00027 Float_t charge = (totalCharge + (lastTotalCharge - totalCharge)
00028 * TMath::Exp(-shapingTime * time));
00029 UInt_t adc = UInt_t(maxAdc * charge);
00030 outData[channel * sampleRate + sample] = adc;
00031 if (adc > threshold) ok++;
00032 }
00033 lastTotalCharge = totalCharge;
00034 }
00035 std::cout << "Total of " << outData.fN << " samples of which "
00036 << ok << " of them are above threshold (" << threshold
00037 << ")" << std::endl;
00038
00039 {
00040 AliAltroBuffer buffer("FMD_4096.ddl", 1);
00041 buffer.WriteDataHeader(kTRUE, kFALSE);
00042 buffer.WriteChannel(0, 0, 0, outData.fN, outData.fArray, threshold);
00043 buffer.Flush();
00044 buffer.WriteDataHeader(kFALSE, kFALSE);
00045 }
00046
00047 AliRawReader* reader = new AliRawReaderFile(-1);
00048 if (!reader) {
00049 std::cerr << "Failed to make AliRawReader" << endl;
00050 return 0;
00051 }
00052 AliFMDRawStream input(reader, sampleRate);
00053 reader->Select(AliFMDParameters::kBaseDDL >> 8);
00054
00055 Int_t oldDDL = -1;
00056 Int_t count = 0;
00057 UShort_t detector = 1;
00058 UShort_t oldDetector = 0;
00059
00060 Bool_t next = kTRUE;
00061
00062
00063 TArrayI counts(10);
00064 counts.Reset(-1);
00065 Int_t offset = 0;
00066
00067 TArrayI inputData(sampleRate * channelWidth);
00068 while (next) {
00069 next = input.Next();
00070
00071 if (!next) break;
00072
00073 Int_t channel = input.Strip();
00074 Int_t sample = input.Sample();
00075 inputData[channel * sampleRate + sample] = input.Count();
00076 count++;
00077
00078 Int_t in = inputData[channel * sampleRate + sample];
00079 Int_t out = outData[channel * sampleRate + sample];
00080 std::cout << "[\t" << channel << ",\t" << sample << "]\t"
00081 << out << "\t" << in << std::flush;
00082 if (out >= threshold && in != out) std::cout << "\tBad" << std::flush;
00083 std::cout << std::endl;
00084 }
00085
00086 std::cout << "Read " << count << " values" << std::endl;
00087 #if 1
00088 for (Int_t channel = channelWidth - 1; channel > 0; channel--) {
00089 for (Int_t sample = sampleRate - 1; sample > 0; sample--) {
00090 Int_t in = inputData[channel * sampleRate + sample];
00091 Int_t out = outData[channel * sampleRate + sample];
00092 std::cout << "[\t" << channel << ",\t" << sample << "]\t"
00093 << out << "\t" << in << std::flush;
00094 if (out >= threshold && in != out) std::cout << "\tBad" << std::flush;
00095 std::cout << std::endl;
00096 }
00097 }
00098 #endif
00099 }
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112