diff --git a/convertTektronix/read1.cpp b/convertTektronix/read1.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5009e5f6f0364998d694658cede9f5321421aeeb --- /dev/null +++ b/convertTektronix/read1.cpp @@ -0,0 +1,134 @@ +void read1() { + gSystem->Load("../libData.so"); + + Double_t A1[1000],A2[1000],A3[1000],A4[1000]; + Double_t T[1000]; + Int_t i,j,k,n,p,Nchannel,Nlines; + TString line1,line2,line3,line4,fileName; + Double_t amp1,amp2,amp3,amp4,time; + + TFile *f1 = new TFile("exp2.root","RECREATE"); + TTree *tree = new TTree("rtree","signal"); + tree->Branch("A1",A1,"A1[1000]/D"); + tree->Branch("A2",A2,"A2[1000]/D"); + tree->Branch("A3",A3,"A3[1000]/D"); + tree->Branch("A4",A4,"A4[1000]/D"); + tree->Branch("T",T,"T[1000]/D"); + + RawEvent *event1 = new RawEvent(1000); + tree->Bronch("ch0.", "RawEvent", &event1); + RawEvent *event2 = new RawEvent(1000); + tree->Bronch("ch1.", "RawEvent", &event2); + RawEvent *event3 = new RawEvent(1000); + tree->Bronch("ch2.", "RawEvent", &event3); + RawEvent *event4 = new RawEvent(1000); + tree->Bronch("ch3.", "RawEvent", &event4); +//////// + RawEvent **Nevent; + Nevent = new RawEvent *[4]; + Nevent[0] = event1; + Nevent[1] = event2; + Nevent[2] = event3; + Nevent[3] = event4; +///////// + ifstream myfile; + ifstream myfile1; + ifstream myfile2; + ifstream myfile3; + ifstream myfile4; + + myfile.open("../data/rawDataTektronix/infiles.dat"); // открываю файл с названиями файлов с данными для подсчёта общего количества файлов + if (myfile.is_open()) { /// для создания динамического массива с путями к файлам с данными + while(1){ + fileName.ReadLine(myfile); + if ( fileName.IsNull() ) break; + Nlines++; + } + myfile.close(); + } + else {Error("read.cpp", "Some error when opening file","infiles.dat");return;} + + TString *NameLines = new TString[Nlines]; // создание массива в котором хранятся строки из файла "infiles.dat" +// TString NameLines[Nlines]; + + myfile.open("../data/rawDataTektronix/infiles.dat"); + for(i=0;;i++){ + fileName.ReadLine(myfile); + NameLines[i] = fileName; + if ( fileName.IsNull() ) break; + } + myfile.close(); + + for(i=0;i<(-1+Nlines/4);i++){ + cout<SetAmp(amp1, j-1000*n); + event2->SetAmp(amp2, j-1000*n); + event3->SetAmp(amp3, j-1000*n); + event4->SetAmp(amp4, j-1000*n); + event1->SetTime(time, j-1000*n); + event2->SetTime(time, j-1000*n); + event3->SetTime(time, j-1000*n); + event4->SetTime(time, j-1000*n); + + if(j-1000*n == 999) { + tree->Fill(); + for(k=0;k<1000;k++){ + T[k]=0; + A1[k]=0;A2[k]=0;A3[k]=0;A4[k]=0; + } + event1->Reset(); + event2->Reset(); + event3->Reset(); + event4->Reset(); + } + j++; + } + myfile1.close(); + myfile2.close(); + myfile3.close(); + myfile4.close(); + } + else { + Error("read.cpp", "Some error when opening data file number of %d", i); + return; + } + }//for i + tree->Write(); + f1->Close(); +}