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

5
	TFile *f = new TFile("../data/dataTektronix/analysisExp7.root");
6 7 8 9 10 11 12 13
	TTree *tr = (TTree*)f->Get("atree");

	const Int_t noBranches = 4;
	Double_t ZeroTime[4];
	Int_t iZero[4],PosZero[4],deltaT[4]; 
	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++) {
14
		aevent[j] = new AEvent(1000);	//each raw event element is of class RawEvent()
15 16
		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
17
		//cout << tr->SetBranchAddress(bName.Data(), &aevent[j]) << endl;	//read the tree tr with raw data and fill array revent with raw data
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
	TH1F *hist0 = new TH1F("hist1", "h1 title", 2000, -100, 100);
	TH1F *hist1 = new TH1F("hist2", "h2 title", 2000, -100, 100);
	TH1F *hist2 = new TH1F("hist3", "h3 title", 2000, -100, 100);
	TH1F *hist3 = new TH1F("hist4", "h4 title", 2000, -100, 100);

	TF1 *fit1 = new TF1("fit1","-[0]*exp(-x*[1])");
	fit1->SetRange(-15,-5);
	fit1->SetParName(1,"tD");

	Long64_t nEntries = tr->GetEntries();

	//loop over events
	for (j = 0; j < nEntries; j++) {
		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; 
			if(j==0) { PosZero[k] = iZero[k]; }
			deltaT[k] = iZero[k] - PosZero[k];
		}
		
			for(Int_t i = 0; i<1000; i++){
				if( ((i+deltaT[0])>-1) && ((i+deltaT[0])<1000))	hist0->AddBinContent(i+500,aevent[0]->GetOnefAmpPos(i+deltaT[0]));	
				if( ((i+deltaT[1])>-1) && ((i+deltaT[1])<1000))	hist1->AddBinContent(i+500,aevent[1]->GetOnefAmpPos(i+deltaT[1]));
				hist2->AddBinContent(i+500,aevent[0]->GetOnefAmpPos(i));
				hist3->AddBinContent(i+500,aevent[1]->GetOnefAmpPos(i));
			}
	}

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

	c1->cd(1);
	hist0->Draw();
	//hist1->Fit("fit1","R","");

	c1->cd(2);
	//hist2->Draw();
	//hist2->Fit("fit1","R","");
	//tr->Draw("Ach1.fCFD");
	hist1->Draw();

	c1->cd(3);
	hist2->Draw();

	c1->cd(4);
	hist3->Draw();

}