read.cpp 2.97 KB
Newer Older
1 2 3
void read() {
	//Double_t N[5]; // массив для чисел ()
	//ifstream myfile;
4 5 6
	//Double_t string_to_double( const std::string& s );
	//const Int_t par1 = 5;
	//const Double_t par2 = 5.34;
7 8 9 10
	// ....
	// ....
	gSystem->Load("../libData.so");

11 12
	asdasd();

13 14
	Double_t A[1000];
	Double_t T[1000];
15 16 17
	Int_t i,j,n,p,Nchannel;
	TString line;
	Double_t amp,time;	
18

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

24

25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
	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; 	// открываю файл с названиями файлов с данными
42
	ifstream myfile1;
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
	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<<fileName.Data()<<" "<< p << " nchannel = "<<Nchannel<<endl;
			if ( fileName.BeginsWith("ch") || fileName.BeginsWith("//") ) continue; //есть строки ch1,2			

			myfile1.open( fileName.Data() );
			if (myfile1.is_open()) {
				//cout<<" I found data! number "<<endl;
				amp=time=0;
				
				while (!myfile1.eof()) {
					line.ReadLine(myfile1);		
					n=i/1000;			// if ((i==1002)||(i==900)||(i==2002)||(i==8002)) {cout<<i<<" "<<n<<endl;}
		
					time = 5e-013+ (i-1000*n)*1e-010;
					sscanf(line.Data(), "%lf", &amp);
					A[i-1000*n] = amp;
					T[i-1000*n] = time;

					Nevent[Nchannel-1]->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++;	
				}
87
			}
88 89 90 91
			else {
				cout<<" asdasdasd "<<endl;
				Error("read.cpp", "Some error when opening file %s", fileName.Data());
				return;
92
			}
93
			myfile1.close();
94
		}
95
		myfile.close();
96
	}
97
	else {Error("read.cpp", "Some error when opening file","infiles.dat");return;}
98

99
////////////////
100

101 102 103 104
	
	TString name;
	name.Form("../data/rawDataTektronix/ch%d2016.12.07-02.11.54.dat",1);
////////////
105

106 107 108 109 110
	ifstream myfile1;
	myfile1.open(name.Data());
	if (!myfile1.is_open()) {
		Error("read.c", "Some error when opening file");
		return;
111
	}
112 113 114 115

	i=0;
	
	myfile1.close();
116 117 118 119

	tree->Write();
	f1->Close();
}
120 121 122 123

Double_t asdasd() {
	cout << "Function called!!!!!!!!!!!" << endl;
}