Commit bf84b293 authored by Vratislav Chudoba's avatar Vratislav Chudoba

Branch with class RawEvent added in read_binary_DRS application.

parent 7b3acf5f
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
for time measurements. for time measurements.
$Id: read_binary.cpp 22290 2016-04-27 14:51:37Z ritt $ $Id: read_binary.cpp 22290 2016-04-27 14:51:37Z ritt $
*/ */
#include <stdio.h> #include <stdio.h>
#include <fcntl.h> #include <fcntl.h>
...@@ -31,6 +31,9 @@ ...@@ -31,6 +31,9 @@
#include "TTree.h" #include "TTree.h"
#include "TH1F.h" #include "TH1F.h"
//our code
#include "../dataClasses/RawData.h"
typedef struct { typedef struct {
char tag[3]; char tag[3];
char version; char version;
...@@ -104,7 +107,7 @@ int main(int argc, const char * argv[]) ...@@ -104,7 +107,7 @@ int main(int argc, const char * argv[])
return -1; return -1;
} }
// ---------------for ROOT // ---------------for ROOT
TFile* rfile = new TFile(outroot, "RECREATE"); TFile* rfile = new TFile(outroot, "RECREATE");
TTree* rtree = new TTree("rtree", "tree for drs4 analysis"); TTree* rtree = new TTree("rtree", "tree for drs4 analysis");
...@@ -113,18 +116,21 @@ int main(int argc, const char * argv[]) ...@@ -113,18 +116,21 @@ int main(int argc, const char * argv[])
int ncell; int ncell;
const int ncellMax = 1030; const int ncellMax = 1030;
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];
rtree->Branch("ncell", &ncell, "ncell/I"); rtree->Branch("ncell", &ncell, "ncell/I");
rtree->Branch("amp_ch1", amp_ch1, "amp_ch1[ncell]/D"); rtree->Branch("amp_ch1", amp_ch1, "amp_ch1[ncell]/D");
rtree->Branch("time_ch1", time_ch1, "time_ch1[ncell]/D"); rtree->Branch("time_ch1", time_ch1, "time_ch1[ncell]/D");
//------for other channels RawData *event = new RawData();
// rtree->Branch("amp_ch2", amp_ch2, "amp_ch2[ncell]/D"); rtree->Bronch("rawEvent", "RawData", &event);
// rtree->Branch("time_ch2", time_ch2, "time_ch2[ncell]/D");
//------for other channels
// rtree->Branch("amp_ch2", amp_ch2, "amp_ch2[ncell]/D");
// rtree->Branch("time_ch2", time_ch2, "time_ch2[ncell]/D");
//---------------- //----------------
// open the binary waveform file // open the binary waveform file
FILE *f = fopen(filename, "r"); FILE *f = fopen(filename, "r");
...@@ -244,7 +250,10 @@ int main(int argc, const char * argv[]) ...@@ -244,7 +250,10 @@ int main(int argc, const char * argv[])
//for ROOT //for ROOT
ncell = i; ncell = i;
if(chn_index == 0) {amp_ch1[i] = waveform[b][chn_index][i];} if(chn_index == 0) {
amp_ch1[i] = waveform[b][chn_index][i];
event->SetAmp(waveform[b][chn_index][i], i);
}
// if(chn_index == 1) {amp_ch2[i] = waveform[b][chn_index][i];} // if(chn_index == 1) {amp_ch2[i] = waveform[b][chn_index][i];}
// calculate time for this cell // calculate time for this cell
...@@ -260,7 +269,7 @@ int main(int argc, const char * argv[]) ...@@ -260,7 +269,7 @@ int main(int argc, const char * argv[])
// printf("t1 %1.6lf \n",time[b][0][(1024-tch.trigger_cell) % 1024]); // printf("t1 %1.6lf \n",time[b][0][(1024-tch.trigger_cell) % 1024]);
for (chn=1 ; chn<4 ; chn++) { for (chn=1 ; chn<4 ; chn++) {
t2 = time[b][chn][(1024-tch.trigger_cell) % 1024]; t2 = time[b][chn][(1024-tch.trigger_cell) % 1024];
//adding channels 3 and 4 //adding channels 3 and 4
t3 = time[b][chn][(1024-tch.trigger_cell) % 1024]; t3 = time[b][chn][(1024-tch.trigger_cell) % 1024];
t4 = time[b][chn][(1024-tch.trigger_cell) % 1024]; t4 = time[b][chn][(1024-tch.trigger_cell) % 1024];
//my prinf //my prinf
...@@ -324,6 +333,9 @@ int main(int argc, const char * argv[]) ...@@ -324,6 +333,9 @@ int main(int argc, const char * argv[])
rfile->Write(); rfile->Write();
rfile->Close(); rfile->Close();
delete event;
return 1; return 1;
} }
...@@ -20,7 +20,7 @@ RawData::~RawData() { ...@@ -20,7 +20,7 @@ RawData::~RawData() {
void RawData::Reset() { void RawData::Reset() {
for (Int_t i = 0; i < 1024; i++) { for (Int_t i = 0; i < NCELLS; i++) {
Amp[i] = 0; Amp[i] = 0;
Time[i] = 0; Time[i] = 0;
} }
...@@ -29,7 +29,7 @@ void RawData::Reset() { ...@@ -29,7 +29,7 @@ void RawData::Reset() {
} }
void RawData::Print() { void RawData::Print() {
for (Int_t i = 0; i < 1024; i++) { for (Int_t i = 0; i < NCELLS; i++) {
cout << Amp[i] << endl; cout << Amp[i] << endl;
// Time[i] = 0; // Time[i] = 0;
} }
......
...@@ -15,11 +15,13 @@ ...@@ -15,11 +15,13 @@
using std::cout; using std::cout;
using std::endl; using std::endl;
#define NCELLS 1024
class RawData { class RawData {
private: private:
Double_t Amp[1024]; Double_t Amp[NCELLS];
Double_t Time[1024]; Double_t Time[NCELLS];
public: public:
RawData(); RawData();
...@@ -36,6 +38,15 @@ public: ...@@ -36,6 +38,15 @@ public:
return Time; return Time;
} }
void SetAmp(Double_t a, Int_t i) {
if (i >=NCELLS) {
cout << "chren'" << endl;
return;
}
Amp[i] = a;
return;
}
void Print(); void Print();
}; };
......
...@@ -59,11 +59,11 @@ libData.so: $(DATAOBJS) ...@@ -59,11 +59,11 @@ libData.so: $(DATAOBJS)
@echo 'Finished building target: $@' @echo 'Finished building target: $@'
@echo ' ' @echo ' '
read_binary_DRS4: $(CONVERTDRS4)/read_binary.cpp read_binary_DRS4: libData.so $(CONVERTDRS4)/read_binary.cpp
@echo 'Building target: $@' @echo 'Building target: $@'
@echo 'Invoking: GCC C++ Linker' @echo 'Invoking: GCC C++ Linker'
# $(CC) -L $(ROOTLIBS) -shared -o"libData.so" $(DATAOBJS) $(DATALIBS) # $(CC) -L $(ROOTLIBS) -shared -o"libData.so" $(DATAOBJS) $(DATALIBS)
$(CC) -o $(CONVERTDRS4)/read_binary_DRS4 $(CONVERTDRS4)/read_binary.cpp -lm `root-config --cflags --libs` $(CC) -o $(CONVERTDRS4)/read_binary_DRS4 $(CONVERTDRS4)/read_binary.cpp -lm `root-config --cflags --libs` -L $(PWD) -lData -Wl,-rpath,$(PWD)
@echo 'Finished building target: $@' @echo 'Finished building target: $@'
@echo ' ' @echo ' '
......
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