#include "TH1.h" #include "TF1.h" #include "TLegend.h" #include "TCanvas.h" #include "TPaveLabel.h" #include "iostream.h" #include "fstream.h" #include "stdlib.h" int runnum, totevnum; float curr; char target[10]; void TDC_veto_table() { cout << "Enter run number:" << endl; cin >> runnum; cout << "Enter total number of events:" << endl; cin >> totevnum; cout << "Enter target (without blank spaces):" << endl; cin >> target; cout << "Enter current in microAmp:" << endl; cin >> curr; TString file = Form("%dTDC-veto-rates.tex",runnum); TString rootfile = Form("/work/halla/e02013/disk1/kolarkar/replay/e01015/n20test_%d.root",runnum); // ofstream texfile("2288TDC-veto-rates.tex"); ofstream texfile(file); if (!texfile) Bark(); texfile << "\\documentclass{article}" << endl; texfile << "\\begin{document}" << endl; texfile << "\\begin{itemize}" << endl; texfile << "\\item Run Number = " << runnum << endl; texfile << "\\item Target = " << target << endl; texfile << "\\item Current = " << curr << endl; texfile << "\\end{itemize}" << endl; texfile << "\\begin{tabular}{|c|c|c|}" << endl; TCanvas *c1 = new TCanvas("c1","TDC",10,10,700,900); c1->SetFillColor(33); c1->SetFrameFillColor(42); c1->SetGrid(); c1->Divide(2,8); TFile *_file0 = TFile::Open(rootfile); for(int i=1;i<5;i++){ c1->cd(2*i-1); TString dummy=Form("na.nd.v1.LT[%d]",i-1); TString counter=Form("na.nd.v1.LTcounter[%d]==1",i-1); T->Draw(dummy,counter); TF1 *myfit = new TF1("myfit","[0]+[1]*(exp(-((x-[2])/[3])**2))",-0.6e-6,0.4e-6); //myfit->SetParameters(200,1,-8e-8,1e-7); myfit->SetParName(0,"Mean Events"); myfit->SetParameter(0,2000); myfit->SetParName(1,"Peak Events"); myfit->SetParameter(1,6000); myfit->SetParName(2,"Peak"); myfit->SetParameter(2,-9.2e-8); myfit->SetParName(3,"Width"); myfit->SetParameter(3,1e-8); htemp->Fit("myfit","r"); char mystuff[100]; Double_t par0 = myfit->GetParameter(0); //value of 1st parameter Double_t mu = 85*par0/totevnum; cout << "The event rate for V1-0"<SetFillColor(45); label1->Draw(); texfile << mu << "&L-V1-0"<cd(2*i); TString dummy=Form("na.nd.v1.RT[%d]",i-1); TString counter=Form("na.nd.v1.RTcounter[%d]==1",i-1); T->Draw(dummy,counter); TF1 *myfit = new TF1("myfit","[0]+[1]*(exp(-((x-[2])/[3])**2))",-0.6e-6,0.4e-6); //myfit->SetParameters(200,1,-8e-8,1e-7); myfit->SetParName(0,"Mean Events"); myfit->SetParameter(0,2000); myfit->SetParName(1,"Peak Events"); myfit->SetParameter(1,6000); myfit->SetParName(2,"Peak"); myfit->SetParameter(2,-9.2e-8); myfit->SetParName(3,"Width"); myfit->SetParameter(3,1e-8); htemp->Fit("myfit","r"); char mystuff[100]; Double_t par0 = myfit->GetParameter(0); //value of 1st parameter Double_t mu = 85*par0/totevnum; cout << "The event rate for V-0"<SetFillColor(45); label1->Draw(); texfile << mu << "\\\\" << endl; } //The following code for V2 detectors for(int i=1;i<5;i++){ c1->cd(2*i+7); TString dummy=Form("na.nd.v2.LT[%d]",i-1); TString counter=Form("na.nd.v2.LTcounter[%d]==1",i-1); T->Draw(dummy,counter); TF1 *myfit = new TF1("myfit","[0]+[1]*(exp(-((x-[2])/[3])**2))",-0.6e-6,0.4e-6); //myfit->SetParameters(200,1,-8e-8,1e-7); myfit->SetParName(0,"Mean Events"); myfit->SetParameter(0,2000); myfit->SetParName(1,"Peak Events"); myfit->SetParameter(1,6000); myfit->SetParName(2,"Peak"); myfit->SetParameter(2,-9.2e-8); myfit->SetParName(3,"Width"); myfit->SetParameter(3,1e-8); htemp->Fit("myfit","r"); char mystuff[100]; Double_t par0 = myfit->GetParameter(0); //value of 1st parameter Double_t mu = 85*par0/totevnum; cout << "The event rate for V2-0"<SetFillColor(45); label1->Draw(); texfile << mu << "&L-V2-0"<cd(2*i+8); TString dummy=Form("na.nd.v2.RT[%d]",i-1); TString counter=Form("na.nd.v2.RTcounter[%d]==1",i-1); T->Draw(dummy,counter); TF1 *myfit = new TF1("myfit","[0]+[1]*(exp(-((x-[2])/[3])**2))",-0.6e-6,0.4e-6); //myfit->SetParameters(200,1,-8e-8,1e-7); myfit->SetParName(0,"Mean Events"); myfit->SetParameter(0,2000); myfit->SetParName(1,"Peak Events"); myfit->SetParameter(1,6000); myfit->SetParName(2,"Peak"); myfit->SetParameter(2,-9.2e-8); myfit->SetParName(3,"Width"); myfit->SetParameter(3,1e-8); htemp->Fit("myfit","r"); char mystuff[100]; Double_t par0 = myfit->GetParameter(0); //value of 1st parameter Double_t mu = 85*par0/totevnum; cout << "The event rate for V2-0"<SetFillColor(45); label1->Draw(); texfile << mu << "\\\\" << endl; } texfile << "\\end{tabular}" << endl; texfile << "\\end{document}" << endl; texfile.close(); }