Commit ff68d4c9 authored by Kostyleva D.A's avatar Kostyleva D.A

Functions converting DRS4 data are added to class RawData

parent bf84b293
......@@ -114,7 +114,7 @@ int main(int argc, const char * argv[])
//rtree->Branch("t1", &t1, "t1/D"); //br for time of threshold crossing signal in 1 ch
// rtree->Branch("t2", &t2, "t2/D"); //br for time of threshold crossing signal in 2 ch
int ncell;
const int ncellMax = 1030;
const int ncellMax = 1024;
double amp_ch1[ncellMax], time_ch1[ncellMax]; //variable size array
//------for other channels
// double amp_ch2[ncellMax], time_ch2[ncellMax];
......@@ -200,6 +200,7 @@ int main(int argc, const char * argv[])
// loop over all events in the data file
for (n=0 ; ; n++) {
event->Reset();
// read event header
i = (int)fread(&eh, sizeof(eh), 1, f);
if (i < 1)
......@@ -253,6 +254,9 @@ int main(int argc, const char * argv[])
if(chn_index == 0) {
amp_ch1[i] = waveform[b][chn_index][i];
event->SetAmp(waveform[b][chn_index][i], i);
/*printf("old ampl %f ",amp_ch1[i]);
event->PrintAmp(i);
printf("\n");*/
}
// if(chn_index == 1) {amp_ch2[i] = waveform[b][chn_index][i];}
......@@ -291,9 +295,13 @@ int main(int argc, const char * argv[])
//for ROOT
for(i=0 ; i<1024 ; i++) {
time_ch1[i] = time[b][0][i];
event->SetTime(time[b][0][i],i);
/*printf("old time %f ",time_ch1[i]);
event->PrintTime(i);
printf("\n");*/
// time_ch2[i] = time[b][1][i];
}
//event->Print();
// find peak in channel 1 above threshold
for (i=0 ; i<1022 ; i++) {
......@@ -324,7 +332,6 @@ int main(int argc, const char * argv[])
sumdt2 += dt*dt;
}
} //end of the boards loop
rtree->Fill();
} // end of the events loop
......
......@@ -25,12 +25,31 @@ void RawData::Reset() {
Time[i] = 0;
}
}
void RawData::PrintTime(Int_t i) {
cout << Time[i] << endl;
}
void RawData::Print() {
for (Int_t i = 0; i < NCELLS; i++) {
void RawData::PrintAmp(Int_t i) {
cout << Amp[i] << endl;
// Time[i] = 0;
}
void RawData::SetAmp(Double_t a, Int_t i) {
if (i >=NCELLS) {
cout << "Error: array with raw amplitudes is overloaded!" << endl;
return;
}
Amp[i] = a;
return;
}
void RawData::SetTime(Double_t t, Int_t i) {
if (i >=NCELLS) {
cout << "Error: array with raw times is overloaded!" << endl;
return;
}
Time[i] = t;
return;
}
......@@ -7,21 +7,18 @@
#ifndef DATACLASSES_RAWDATA_H_
#define DATACLASSES_RAWDATA_H_
#include <iostream>
#include "TGraph.h"
#define NCELLS 1024
using std::cout;
using std::endl;
#define NCELLS 1024
class RawData {
private:
Double_t Amp[NCELLS];
Double_t Time[NCELLS];
Double_t Amp[NCELLS]; //array for raw amplitudes
Double_t Time[NCELLS]; //array for raw times
public:
RawData();
......@@ -29,6 +26,7 @@ public:
ClassDef(RawData,1);
void Reset();
//Resets arrays to zeros
const Double_t* GetAmp() const {
return Amp;
......@@ -38,16 +36,16 @@ public:
return Time;
}
void SetAmp(Double_t a, Int_t i) {
if (i >=NCELLS) {
cout << "chren'" << endl;
return;
}
Amp[i] = a;
return;
}
void SetAmp(Double_t a, Int_t i);
//Takes amplitude (raw data, voltage from binary file)
//and places it in the array Amp[NCELLS]
void SetTime(Double_t t, Int_t i);
//Takes time (raw data, times from binary file)
//and places it in the array Time[NCELLS]
void Print();
void PrintAmp(Int_t i);
void PrintTime(Int_t i);
};
#endif /* DATACLASSES_RAWDATA_H_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment