DrawElNoizeSignal.cxx 3.14 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
#include <TTree.h>
#include <TGraph.h>
#include <TFile.h>
#include <TSystem.h>
#include <TCanvas.h>
#include "TStyle.h"

void testShowGraphs()
{
	using std::cout;
	using std::endl;

	gStyle->SetCanvasDefH(900);
	gStyle->SetCanvasDefW(1500);

	const char *foldername = "7_8";
	const char *ext = ".gif";

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

	const Long64_t kFirstEvent = 0;

//	 TFile fr("../data/dataDSR4/analysis_08_2.root");
	//TFile fr("../data/dataTektronix/GSItests/1000V_trigg40mv/30_60_10_50_GSI.root");
	//TFile fr("../data/dataTektronix/GSItests/1000V_trigg20mv/analyze.root");
//	 /data/dataTektronix/GSItests/1000V_trigg5mv
	 TFile fr("../data/dataTektronix/GSItests/1000V_trigg5mv/analize1.root");

	TTree *tr = (TTree*)fr.Get("atree");

	AEvent *revent = new AEvent(1000);
	AEvent *revent1 = new AEvent(1000);
	tr->SetBranchAddress("Ach0.",&revent);
	tr->SetBranchAddress("Ach1.",&revent1);

	TGraph *gr[16];
	TGraph *gr1[16];
	Double_t t10[16];
	Double_t t90[16];
	Double_t charge0, charge1;
	Int_t counter = 0;
	Long64_t nEntries = tr->GetEntries();

	TCanvas *c1 = new TCanvas("c1","test",10,10,1000,600);
	c1->Divide(4,4);

	//loop over events
	for (Int_t j = 0 + kFirstEvent; j < nEntries; j++) {
		tr->GetEntry(j);
		charge0 = revent->GetfChargeCFD();
		charge1 = revent1->GetfChargeCFD();
		if( ((charge0 - charge1) < 0.1) && ((charge0 - charge1) > -0.1) ) continue; // отбор по событиям по заряду

		gr[counter] = new TGraph(*revent->GetGraphSignal());
		gr1[counter] = new TGraph(*revent1->GetGraphSignal());
		if(counter == 7) break;
		counter++;
	}
//	cout<<counter<<endl;
//	return;
	for (Int_t k = 0; k < 8; k++)
	{
		gr[k]->GetXaxis()->SetTitle("Time [ns]");
		gr[k]->GetXaxis()->CenterTitle();
		gr[k]->GetYaxis()->SetTitle("Signal [V]");
		gr[k]->GetYaxis()->CenterTitle();

		gr1[k]->GetXaxis()->SetTitle("Time1 [ns]");
		gr1[k]->GetXaxis()->CenterTitle();
		gr1[k]->GetYaxis()->SetTitle("Signal1 [V]");
		gr1[k]->GetYaxis()->CenterTitle();

		c1->cd(k+1);
		gr[k]->Draw("AL*");

		c1->cd(k+9);
		gr1[k]->Draw("AL*");
	}
//return;
}
	//loop over events
	/*for (Long64_t i = 0; i < 8; i++) {
		gr[i] = 0;
//		t10[i] = 0;
//		t90[i] = 0;
		tr->GetEntry(i+kFirstEvent);
		gr[i] = new TGraph(*revent->GetGraphSignal());
//		t10[i] = revent->GetT_10();
//		t90[i] = revent->GetT_90();

//		cout << t10[i] << "\t" << t90[i] << endl;
//		cout << revent->GetEdgeSlope() << endl;

	}//for over events

	for (Long64_t i = 8; i < 16; i++) {
		gr[i] = 0;
		tr->GetEntry(i+kFirstEvent-8);
		gr[i] = new TGraph(*revent1->GetGraphSignal());
	}//for over events





//	TF1 *f1 = new TF1("f1name", "[0]+x*[1]");
//	TF1 *f1 = new TF1("pol1", );

//k=0;
	for (Int_t k = 0; k < 16; k++)
	{
		c1->cd(k+1);
		//gr[k]->GetXaxis()->SetRangeUser(130, 175);
		gr[k]->GetXaxis()->SetTitle("Time [ns]");
		gr[k]->GetXaxis()->CenterTitle();
		gr[k]->GetYaxis()->SetTitle("Signal [V]");
		gr[k]->GetYaxis()->CenterTitle();
		gr[k]->Draw("AL*");
		//cout << t10[k] << "\t" << t90[k] << endl;
		//f1->SetRange(t10[k], t90[k]);
		//gr[k]->Fit(f1, "RQ");
	}
	//c1->Print(Form("../macros/picsDRS4/file%s/signals%s", foldername, ext));
//	c1->cd(2);
//	tr->Draw("gAmp.Draw()","","goff",1,124);*/
//}