integralFormSignal.cpp 3.87 KB
Newer Older
1 2 3
{
	gSystem->Load("../libData.so");

4
	TFile *f = new TFile("../data/dataDSR4/analysis_07_8.root");
5
	TTree *tr = (TTree*)f->Get("atree");
6 7
	
	const Int_t nP = 1024;
8 9

	const Int_t noBranches = 4;
10
	Double_t ZeroTime[4],mh[4],RisTime[4],decayT[4],tmax[4],timestep,time;
11
	Int_t iZero[4],PosZero[4],deltaT[4],Eh[4],Bh[4]; 
12 13 14
	TString bName;
	AEvent *aevent[noBranches];	// pointer to the array (of RawEvent class) in which raw data for each channel will be put
	for (Int_t j = 0; j<noBranches; j++) {
15
		aevent[j] = new AEvent();	//each raw event element is of class RawEvent()
16 17 18
		bName.Form("Ach%d.", j);
		tr->SetBranchAddress(bName.Data(), &aevent[j]);	//read the tree tr with raw data and fill array revent with raw data
	}
19 20 21

	TString hname,Chname;
	TH1F *hist[4];
22
	TGraph *gr[4];
23 24
	for (Int_t i = 0; i < 4; i++) {
		hname.Form("hist%d",i);
25
		Chname.Form("CHANNEL%d",i+1);
26 27 28 29
		hist[i] = new TH1F(hname.Data(), Chname.Data(), 2000, -100, 100);
	}

	TH1F *hist01 = new TH1F("hist11", "h1 raw", 2000, -100, 100);
30

31
	//TH1(const char* name, const char* title, Int_t nbinsx, Double_t xlow, Double_t xup)
32

33 34 35 36
	Long64_t nEntries = tr->GetEntries();	
	TH1F *hSumm = new TH1F("hSumm", "integral signal", nP-1, 0, 199);
	for(Int_t j=0;j<(nP-1);j++) {hSumm->SetBitContent(j,0);}
	timestep = 199/1022; 	//!!!!!!!!!!! не 1023 а 1022. промежутков меньше на 1 чем точек
37
	//loop over events
38
	for (Int_t j = 0; j < nEntries; j++) {
39 40 41 42
		tr->GetEntry(j);
		for(Int_t k=0;k<4;k++) { // loop for channels
			ZeroTime[k] = aevent[k]->GetfCFD(); // get fCFD for channel №k
			iZero[k] = ZeroTime[k]*10; 
43 44 45 46
			//if(j==0) { PosZero[k] = iZero[k]; }
			//deltaT[k] = iZero[k] - PosZero[k]; // количество точек !!! 
			if(j==0) { PosZero[k] = ZeroTime[k]; }
			deltaT[k] = ZeroTime[k] - PosZero[k]; // время в нс
47
		}
48

49 50 51 52 53 54
		gr[0] = new TGraph(*aevent[0]->GetGraphSignal());
		for(Int_t i = 0; i<(nP-1); i++){	
			//if( ((i+deltaT[0])>-1) && ((i+deltaT[0])<nP))	hist[0]->AddBinContent(i+500,aevent[0]->GetOnefAmpPos(i+deltaT[0]));	
			//hist01->AddBinContent(i+500,aevent[0]->GetOnefAmpPos(i));
			if( ((timestep*i + deltaT[0])>=0) && ((timestep*i + deltaT[0])<tmax[0])) { 
				hSumm->AddBinContent( i, fGraphCFD->Eval(timestep*i + deltaT[0]) ); 
55
			}
56
		}
57
	}
58 59 60
		
	//t->Draw("Ach2.fAmpMax: ( Ach0.fTimeCFD - Ach2.fTimeCFD ) >> h4","","col");
	/*for(j=0;j<4;j++) {
61

62 63 64 65 66 67 68 69
		mh[j] = hist[j]->GetBinContent(hist[j]->GetMaximumBin());

		for(i = hist[j].GetMaximumBin(); i>0;i--) {	// finding the 
			if( hist[j]->GetBinContent(i)<0.9*mh[j] ) {
				Eh[j] = i+1;
				break;
			}
		}
70

71 72 73 74 75 76 77 78
		for(i = hist[j].GetMaximumBin(); i>0;i--) {	// finding the 
			if( hist[j]->GetBinContent(i)<0.1*mh[j] ) {
				Bh[j] = i+1;
				break;
			}
		}
		RisTime[j] = (Eh[j] - Bh[j])*0.1; // время нарастания 
	}
79
*/
80 81
	Double_t rMin[4];
	Double_t rMax[4];
82 83 84 85
	rMin[0]=22.5; rMax[0] = 27.3;
	rMin[1]=26.6; rMax[1] = 31.7;
	rMin[2]=19.3; rMax[2] = 24.;
	rMin[3]= 26.5; rMax[3] = 29.6;
86

87 88
	TF1 *fit1 = new TF1("fit1","[0]*exp(-x*[1])");
	fit1->SetParName(1,"tD");
89

90
	/*TCanvas *c1 = new TCanvas("c1","run 071216_8",10,10,1000,600);
91 92 93
	c1->Divide(2,2);
	for(i=0;i<4;i++) {
		c1->cd(i+1);
94
		hist[i]->GetXaxis()->SetRangeUser(10, 50);
95
		hist[i]->Draw();
96
		fit1->SetParLimits(1,0.1,1);
97
		fit1->SetRange(rMin[i],rMax[i]);
98 99
		//hist[i]->Fit("fit1","R");
		//decayT[i] = 1/(fit1->GetParameter(1));
100 101 102 103 104
	}
	
	for(i=0;i<4;i++) {
		cout<<decayT[i]<<" that's decay time  of channel number "<<i<<endl;
		cout<<RisTime[i]<< " that's a RiseTime for this channel "<<i<<endl;
105 106 107 108 109 110
	}*/
///////////////////////

	TCanvas *c2 = new TCanvas("c2","RAW",10,10,1000,600);
	//c2->Divide(2,2);
	//c2->cd(1);
111

112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
	//hist01->GetXaxis()->SetRangeUser(10, 55);
	//hist01->Draw();
	
	//c2->cd(2);
	hSumm->Draw();
	/*
	c2->cd(2);
	hist11->GetXaxis()->SetRangeUser(10, 55);
	hist11->Draw();

	c2->cd(3);
	hist21->GetXaxis()->SetRangeUser(10, 55);
	hist21->Draw();

	c2->cd(4);
	hist31->GetXaxis()->SetRangeUser(10, 55);
	hist31->Draw();*/
129
}