testShowGraphs.cxx 2.43 KB
Newer Older
Muzalevsky I.A's avatar
Muzalevsky I.A committed
1 2 3 4 5 6 7
#include <TTree.h>
#include <TGraph.h>
#include <TFile.h>
#include <TSystem.h>
#include <TCanvas.h>
#include "TStyle.h"

8 9
void testShowGraphs()
{
Muzalevsky I.A's avatar
Muzalevsky I.A committed
10 11 12 13 14 15
	using std::cout;
	using std::endl;

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

16 17 18
//	const char *foldername = "7_8";
	const char *foldername = "nustar_present";
	const char *ext = ".pdf";
19 20 21

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

22
	const Long64_t kFirstEvent = 140;
23

24
//	TFile fr("../data/dataDSR4/Neurad_7_08_NEW.root");
25
	TFile fr("../data/dataDSR4/analysis_07_8.root");
Kostyleva D.A's avatar
Kostyleva D.A committed
26 27 28

//	TFile fr("../data/dataDSR4/Neurad_081216_2NEW.root");

29
//	TFile fr("../data/dataTektronix/exp18.root");
Kostyleva D.A's avatar
Kostyleva D.A committed
30

31
	//TFile fr("../data/dataDSR4/analysis_07_8_smooth.root");
Muzalevsky I.A's avatar
Muzalevsky I.A committed
32

Muzalevsky I.A's avatar
Muzalevsky I.A committed
33
//	TFile fr("../data/dataDSR4/Neurad_081216_2NEW.root");
34
//	TFile fr("../data/dataTektronix/exp18.root");
Muzalevsky I.A's avatar
Muzalevsky I.A committed
35

36
//	TFile fr("../data/dataTektronix/analysisExp7.root");
37
	TTree *tr = (TTree*)fr.Get("atree");
38

39
	AEvent *revent = new AEvent();
Muzalevsky I.A's avatar
Muzalevsky I.A committed
40
	tr->SetBranchAddress("Ach0.",&revent);
41

42 43 44
	TGraph *gr[13];
	Double_t t10[13];
	Double_t t90[13];
45

46
	//loop over events
47
	for (Long64_t i = 0; i < 13; i++) {
48
		gr[i] = 0;
49 50
		t10[i] = 0;
		t90[i] = 0;
Muzalevsky I.A's avatar
Muzalevsky I.A committed
51

52
		tr->GetEntry(i+kFirstEvent);
Muzalevsky I.A's avatar
Muzalevsky I.A committed
53

54
		gr[i] = new TGraph(*revent->GetGraphSignal());
55 56 57 58 59 60 61
		t10[i] = revent->GetT_10();
		t90[i] = revent->GetT_90();

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


62
	}//for over events
63

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

66 67
	TCanvas *c1 = new TCanvas("c1","Signal shape",10,10,1000,600);
	//c1->Divide(3,4);
Kostyleva D.A's avatar
Kostyleva D.A committed
68

69 70
// four event picture
	c1->Divide(2,2);
Muzalevsky I.A's avatar
Muzalevsky I.A committed
71
	for (Int_t k = 0; k < 4; k++) {
72
		c1->cd(k+1);
Muzalevsky I.A's avatar
Muzalevsky I.A committed
73 74 75 76 77
		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();
78
		gr[k]->Draw("AL*");
Muzalevsky I.A's avatar
Muzalevsky I.A committed
79 80 81
		//cout << t10[k] << "\t" << t90[k] << endl;
		//f1->SetRange(t10[k], t90[k]);
		//gr[k]->Fit(f1, "RQ");
Kostyleva D.A's avatar
Kostyleva D.A committed
82
	}
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
	c1->Print(Form("../macros/picsDRS4/%s/Signal_shapes_bad%s", foldername, ext));

// one event picture
/*	gr[4]->GetXaxis()->SetRangeUser(130, 160);
	gr[4]->GetXaxis()->SetTitle("Time [ns]");
	gr[4]->GetXaxis()->CenterTitle();
	gr[4]->GetYaxis()->SetTitle("Signal [V]");
	gr[4]->GetYaxis()->CenterTitle();
	gr[4]->Draw("AL*");
	f1->SetRange(t10[4], t90[4]);
	gr[4]->Fit(f1, "RQ");
	c1->Print(Form("../macros/picsDRS4/%s/One_signal_shape%s", foldername, ext));




	//c1->Print(Form("../macros/picsDRS4/%s/Signal_shapes_with_fit%s", foldername, ext));
*/
101
}