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