read.c 1.83 KB
Newer Older
1 2 3 4 5 6 7 8
#include <iostream>
#include <fstream>

#include "TFile.h"
#include "TTree.h"

#include "../dataClasses/RawEvent.h"

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

	Double_t A[1000];
	Double_t T[1000];
	Int_t i,j,n;

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

	RawEvent *event = new RawEvent;
	rtree->Bronch("rawEvent", "RawEvent", &event);


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

	ifstream myfile1;
30 31 32 33 34 35 36
	myfile1.open("../data/rawDataTektronix/ch12016.12.07-02.11.54.dat");

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

37 38 39 40 41 42
	for(i = 0; i<100000; i++){	
		n=i/1000;			// if ((i==1002)||(i==900)||(i==2002)||(i==8002)) {cout<<i<<" "<<n<<endl;}
		myfile1 >> A[i-1000*n];	
		T[i-1000*n]=5e-013+ (i-1000*n)*1e-010;	

		if(i-1000*n ==999) {
43
			tree->Fill();
44 45 46 47

			for(j=0;j<1000;j++){
				T[j]=0;A[j]=0;
			}
48
		}
49 50
	}
	myfile1.close();
51

52 53 54 55 56 57
	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<<i<<" "<<n<<endl;}
		myfile2 >> A[i-1000*n];	
		T[i-1000*n]=5e-013+ (i-1000*n)*1e-010;	
58

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

			for(j=0;j<1000;j++){
				T[j]=0;A[j]=0;
			}
65
		}
66 67 68 69 70 71 72 73 74
	}
	myfile2.close();

	ifstream myfile3;
	myfile3.open("ch12016.12.07-10.03.01.dat");
	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;	
75

76 77 78 79 80 81
		if(i-1000*n ==999) {
			tree->Fill();

			for(j=0;j<1000;j++){
				T[j]=0;A[j]=0;
			}
82
		}
83 84 85 86 87 88
	}
	myfile3.close();

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