read.cpp 2.12 KB
Newer Older
1 2 3 4 5 6 7
//#include <iostream>
//#include <fstream>
//
//#include "TFile.h"
//#include "TTree.h"
//
//#include "../dataClasses/RawEvent.h"
8

9 10 11 12
void read() {
	//Double_t N[5]; // массив для чисел ()
	//ifstream myfile;

13 14 15 16 17 18 19 20
	const Int_t par1 = 5;
	const Double_t par2 = 5.34;
	// ....
	// ....


	gSystem->Load("../libData.so");

21 22 23 24
	Double_t A[1000];
	Double_t T[1000];
	Int_t i,j,n;

25
	TFile *f1 = new TFile("exp2.root","RECREATE");
26 27
	TTree *tree = new TTree("tree","signal");
	tree->Branch("A",A,"A[1000]/D");
28 29
	tree->Branch("T",T,"T[1000]/D");

30
	RawEvent *event = new RawEvent();
31
	tree->Bronch("rawEvent", "RawEvent", &event);
32 33 34 35


	//std::vector<Double_t> *A = new std::vector<Double_t>();
	//tree->Branch("mybranch","vector<Double_t>",A);
36

37
	ifstream myfile1;
38 39 40 41 42 43
	myfile1.open("../data/rawDataTektronix/ch12016.12.07-02.11.54.dat");

	if (!myfile1.is_open()) {
		Error("read.c", "Some error when opening file");
		return;
	}
44

45 46 47 48 49
	Double_t amp = 0;
	Double_t time = 0;

	//rewrite using while-loop
	for(i = 0; i<100000; i++){
50
		n=i/1000;			// if ((i==1002)||(i==900)||(i==2002)||(i==8002)) {cout<<i<<" "<<n<<endl;}
51 52 53 54 55 56 57 58 59

		myfile1 >> 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);
60 61

		if(i-1000*n ==999) {
62
			tree->Fill();
63 64

			for(j=0;j<1000;j++){
65 66
				T[j]=0;
				A[j]=0;
67
			}
68 69

			event->Reset();
70
		}
71
	}
72
	myfile1.close();
73

74 75
	ifstream myfile2;
	myfile2.open("ch12016.12.07-08.48.05.dat");
76 77 78 79
	for(i = 0; i<100000; i++){	
		n=i/1000;			// if ((i==1002)||(i==900)||(i==2002)||(i==8002)) {cout<<i<<" "<<n<<endl;}
		myfile2 >> A[i-1000*n];	
		T[i-1000*n]=5e-013+ (i-1000*n)*1e-010;	
80

81 82 83 84 85 86
		if(i-1000*n ==999){
			tree->Fill();

			for(j=0;j<1000;j++){
				T[j]=0;A[j]=0;
			}
87
		}
88
	}
89 90
	myfile2.close();

91 92
	ifstream myfile3;
	myfile3.open("ch12016.12.07-10.03.01.dat");
93 94 95 96
	for(i = 0; i<29000; i++){	
		n=i/1000;// if ((i==1002)||(i==900)||(i==2002)||(i==8002)) {cout<<i<<" "<<n<<endl;}
		myfile3 >> A[i-1000*n];	
		T[i-1000*n]=5e-013+ (i-1000*n)*1e-010;	
97

98 99 100 101 102 103
		if(i-1000*n ==999) {
			tree->Fill();

			for(j=0;j<1000;j++){
				T[j]=0;A[j]=0;
			}
104
		}
105
	}
106 107 108 109 110
	myfile3.close();

	tree->Write();
	f1->Close();
}