From cdd6d9f8e7a63e82cc6956c36496cf1029d1a826 Mon Sep 17 00:00:00 2001 From: "Muzalevsky I.A" Date: Fri, 30 Dec 2016 17:43:07 +0300 Subject: [PATCH] script for filling tree of class objects with data from all 4 channels added --- convertTektronix/read.cpp | 175 ++++++++++++++++++++------------------ 1 file changed, 94 insertions(+), 81 deletions(-) diff --git a/convertTektronix/read.cpp b/convertTektronix/read.cpp index 551bde1..ef595f8 100644 --- a/convertTektronix/read.cpp +++ b/convertTektronix/read.cpp @@ -1,110 +1,123 @@ -//#include -//#include -// -//#include "TFile.h" -//#include "TTree.h" -// -//#include "../dataClasses/RawEvent.h" - void read() { //Double_t N[5]; // массив для чисел () //ifstream myfile; - - const Int_t par1 = 5; - const Double_t par2 = 5.34; + //Double_t string_to_double( const std::string& s ); + //const Int_t par1 = 5; + //const Double_t par2 = 5.34; // .... // .... - - gSystem->Load("../libData.so"); + asdasd(); + Double_t A[1000]; Double_t T[1000]; - Int_t i,j,n; + Int_t i,j,n,p,Nchannel; + TString line; + Double_t amp,time; TFile *f1 = new TFile("exp2.root","RECREATE"); TTree *tree = new TTree("tree","signal"); tree->Branch("A",A,"A[1000]/D"); tree->Branch("T",T,"T[1000]/D"); - RawEvent *event = new RawEvent(); - tree->Bronch("rawEvent", "RawEvent", &event); - - - //std::vector *A = new std::vector(); - //tree->Branch("mybranch","vector",A); + RawEvent *event1 = new RawEvent(); + tree->Bronch("rawEvent1", "RawEvent", &event1); + RawEvent *event2 = new RawEvent(); + tree->Bronch("rawEvent2", "RawEvent", &event2); + RawEvent *event3 = new RawEvent(); + tree->Bronch("rawEvent3", "RawEvent", &event3); + RawEvent *event4 = new RawEvent(); + tree->Bronch("rawEvent4", "RawEvent", &event4); + + RawEvent **Nevent; + Nevent = new RawEvent *[4]; + Nevent[0] = event1; + Nevent[1] = event2; + Nevent[2] = event3; + Nevent[3] = event4; +///////// + ifstream myfile; // открываю файл с названиями файлов с данными ifstream myfile1; - myfile1.open("../data/rawDataTektronix/ch12016.12.07-02.11.54.dat"); - - if (!myfile1.is_open()) { - Error("read.c", "Some error when opening file"); - return; - } - - Double_t amp = 0; - Double_t time = 0; - - //rewrite using while-loop - for(i = 0; i<100000; i++){ - n=i/1000; // if ((i==1002)||(i==900)||(i==2002)||(i==8002)) {cout<> amp; - time = 5e-013+ (i-1000*n)*1e-010; - - A[i-1000*n] = amp; - T[i-1000*n] = time; - - event->SetAmp(amp, i-1000*n); - event->SetTime(time, i-1000*n); - - if(i-1000*n ==999) { - tree->Fill(); - - for(j=0;j<1000;j++){ - T[j]=0; - A[j]=0; + myfile.open("../data/rawDataTektronix/infiles.dat"); + if (myfile.is_open()) { + TString fileName; + while (!myfile.eof()) {p++; + + fileName.ReadLine(myfile); + if ( fileName.IsNull() ) break; + + if ( fileName.EqualTo("ch1") ) {Nchannel = 1; } + if ( fileName.EqualTo("ch2") ) {Nchannel = 2; } + if ( fileName.EqualTo("ch3") ) {Nchannel = 3; } + if ( fileName.EqualTo("ch4") ) {Nchannel = 4; } + + cout<SetAmp(amp, i-1000*n); + Nevent[Nchannel-1]->SetTime(time, i-1000*n); + + if(i-1000*n ==999) { + tree->Fill(); + + for(j=0;j<1000;j++){ + T[j]=0; + A[j]=0; + } + Nevent[Nchannel-1]->Reset(); + } + i++; + } } - - event->Reset(); - } - } - myfile1.close(); - - ifstream myfile2; - myfile2.open("ch12016.12.07-08.48.05.dat"); - for(i = 0; i<100000; i++){ - n=i/1000; // if ((i==1002)||(i==900)||(i==2002)||(i==8002)) {cout<> A[i-1000*n]; - T[i-1000*n]=5e-013+ (i-1000*n)*1e-010; - - if(i-1000*n ==999){ - tree->Fill(); - - for(j=0;j<1000;j++){ - T[j]=0;A[j]=0; + else { + cout<<" asdasdasd "<> A[i-1000*n]; - T[i-1000*n]=5e-013+ (i-1000*n)*1e-010; +//////////////// - if(i-1000*n ==999) { - tree->Fill(); + + TString name; + name.Form("../data/rawDataTektronix/ch%d2016.12.07-02.11.54.dat",1); +//////////// - for(j=0;j<1000;j++){ - T[j]=0;A[j]=0; - } - } + ifstream myfile1; + myfile1.open(name.Data()); + if (!myfile1.is_open()) { + Error("read.c", "Some error when opening file"); + return; } - myfile3.close(); + + i=0; + + myfile1.close(); tree->Write(); f1->Close(); } + +Double_t asdasd() { + cout << "Function called!!!!!!!!!!!" << endl; +} -- 2.18.1