Commit f6a3f0c4 authored by Vratislav Chudoba's avatar Vratislav Chudoba

convertDRS4 extended to 4 channels.

parent 9c11fb9e
...@@ -123,8 +123,18 @@ int main(int argc, const char * argv[]) ...@@ -123,8 +123,18 @@ int main(int argc, const char * argv[])
// 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");
RawEvent *event = new RawEvent(); // RawEvent *event = new RawEvent();
rtree->Bronch("rawEvent", "RawEvent", &event); // rtree->Bronch("rawEvent", "RawEvent", &event);
TString bName;
RawEvent *event[4];
for (Int_t i = 0; i<4; i++) {
event[i] = new RawEvent();
bName.Form("ch%d", i);
rtree->Bronch(bName.Data(), "RawEvent", &event[i]);
}
//------for other channels //------for other channels
// rtree->Branch("amp_ch2", amp_ch2, "amp_ch2[ncell]/D"); // rtree->Branch("amp_ch2", amp_ch2, "amp_ch2[ncell]/D");
...@@ -200,7 +210,9 @@ int main(int argc, const char * argv[]) ...@@ -200,7 +210,9 @@ 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();
//reset Events
for (Int_t noChannel = 0; noChannel < 4; noChannel++) { event[noChannel]->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)
...@@ -251,14 +263,10 @@ int main(int argc, const char * argv[]) ...@@ -251,14 +263,10 @@ int main(int argc, const char * argv[])
//for ROOT //for ROOT
//ncell = i; //ncell = i;
if(chn_index == 0) { // if(chn_index == 0) {
//amp_ch1[i] = waveform[b][chn_index][i]; // event[0]->SetAmp(waveform[b][chn_index][i], i);
event->SetAmp(waveform[b][chn_index][i], i); // }
// event->InvertAmp(waveform[b][chn_index][i], i); event[chn_index]->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];}
// calculate time for this cell // calculate time for this cell
...@@ -270,6 +278,7 @@ int main(int argc, const char * argv[]) ...@@ -270,6 +278,7 @@ int main(int argc, const char * argv[])
// align cell #0 of all channels // align cell #0 of all channels
t1 = time[b][0][(1024-tch.trigger_cell) % 1024]; t1 = time[b][0][(1024-tch.trigger_cell) % 1024];
// event[0]->SetTime(time[b][chn][i],i);
//my print; //my print;
// 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++) {
...@@ -285,6 +294,7 @@ int main(int argc, const char * argv[]) ...@@ -285,6 +294,7 @@ int main(int argc, const char * argv[])
time[b][chn][i] += dt; //each element of time gets dt correction time[b][chn][i] += dt; //each element of time gets dt correction
//my print; //my print;
// printf("time %1.6lf for %d %d %d \n",time[b][chn][i], b, chn, i); // printf("time %1.6lf for %d %d %d \n",time[b][chn][i], b, chn, i);
// event[chn]->SetTime(time[b][chn][i],i);
} }
} }
...@@ -295,12 +305,7 @@ int main(int argc, const char * argv[]) ...@@ -295,12 +305,7 @@ 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]; for (Int_t chNum = 0; chNum < 4; chNum++) { event[chNum]->SetTime(time[b][chNum][i],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(); //event->Print();
// find peak in channel 1 above threshold // find peak in channel 1 above threshold
...@@ -345,7 +350,8 @@ int main(int argc, const char * argv[]) ...@@ -345,7 +350,8 @@ int main(int argc, const char * argv[])
rfile->Write(); rfile->Write();
rfile->Close(); rfile->Close();
delete event; // delete event;
// delete[] event;
return 1; return 1;
} }
......
...@@ -10,11 +10,13 @@ ...@@ -10,11 +10,13 @@
RawEvent::RawEvent() : fNPoints(1024) { RawEvent::RawEvent() : fNPoints(1024) {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
Init(); Init();
Reset();
} }
RawEvent::RawEvent(const Int_t npoints) : fNPoints(npoints) { RawEvent::RawEvent(const Int_t npoints) : fNPoints(npoints) {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
Init(); Init();
Reset();
} }
RawEvent::~RawEvent() { RawEvent::~RawEvent() {
......
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