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