#include "Riostream.h" #include "TString.h" #include "TFile.h" #include "TNtuple.h" #include "TSystem.h" void basichist() { ifstream in; in.open("19-03-13.txt");; Float_t Time,Vi_Brick1,Io_Brick1,Vo_Brick1,Vi_Brick2,Io_Brick2,Vo_Brick2,Vi_Brick3,Io_Brick3,Vo_Brick3,Vi_Brick4,Io_Brick4,Vo_Brick4; Int_t nlines = 0; auto f = TFile::Open("19-03-20-2.root","RECREATE"); //Creating the 2D histogram TH1D *h1 = new TH1D("h1","x distribution",100,0,43200); TH2D *h2 = new TH2D("h2","2D Histogram for input voltage over time for irradiation test R1-19-03-20 2nd 12h;time (s);Vi (V)",200,0,43200,200,180,220); TH2D *h3 = new TH2D("h3","2D Histogram for output current over time for irradiation test R1-19-03-20 2nd 12h;time (s);Io (A)",200,0,43200,200,2,3); TH2D *h4 = new TH2D("h4","2D Histogram for output voltage over time for irradiation test R1-19-03-20 2nd 12h;time (s);Vo (V)",200,0,43200,200,10,14); TH2D *h5 = new TH2D("h5","2D Histogram for input voltage over time for irradiation test R1-19-03-20 2nd 12h;time (s); Vi (V)",200,0,43200,200,180,220); TH2D *h6 = new TH2D("h6","2D Histogram for output current over time for irradiation test R1-19-03-20 2nd 12h;time (s);Io (A)",200,0,43200,200,2,3); TH2D *h7 = new TH2D("h7","2D Histogram for output voltage over time for irradiation test R1-19-03-20 2nd 12h;time (s);Vo (V)",200,0,43200,200,10,14); TH2D *h8 = new TH2D("h8","2D Histogram for input voltage over time for irradiation test R1-19-03-20 2nd 12h;time (s);Vi (V)",200,0,43200,200,180,220); TH2D *h9 = new TH2D("h9","2D Histogram for output current over time for irradiation test R1-19-03-20 2nd 12h;time (s);Io (A)",200,0,43200,200,2,3); TH2D *h10 = new TH2D("h10","2D Histogram for for output voltage over time for irradiation test R1-19-03-20 2nd 12h;time (s);Vo (V)",200,0,43200,200,10,14); TH2D *h11 = new TH2D("h11","2D Histogram for input voltage over time for irradiation test R1-19-03-20 2nd 12h;time (s) Vi (V)",200,0,43200,200,180,220); TH2D *h12 = new TH2D("h12","2D Histogram for output current over time for irradiation test R1-19-03-20 2nd 12h;time (s);Io (A)",200,0,43200,200,2,3); TH2D *h13 = new TH2D("h13","2D Histogram for output voltage over time for irradiation test R1-19-03-19 2nd 12h;time (s);Vo (V)",200,0,43200,200,10,14); TNtuple ntuple("ntuple","data from ascii file","Time:Vi_Brick1:Io_Brick1:Vo_Brick1:Vi_Brick2:Io_Brick2:Vo_Brick2:Vi_Brick3:Io_Brick3:Vo_Brick3:Vi_Brick4:Io_Brick4:Vo_Brick4"); while (1) { in >> Time >> Vi_Brick1 >> Io_Brick1 >> Vo_Brick1 >> Vi_Brick2 >> Io_Brick2 >> Vo_Brick2 >> Vi_Brick3 >> Io_Brick3 >> Vo_Brick3 >> Vi_Brick4 >> Io_Brick4 >> Vo_Brick4; if (!in.good()) break; if (nlines < 13) printf("Time=%f, Vi_Brick1=%f, Io_Brick1=%f, Vo_Brick1=%f, Vi_Brick2=%f, Io_Brick2=%f, Vo_Brick2=%f, Vi_Brick3=%f, Io_Brick3=%f, Vo_Brick3=%f, Vi_Brick4=%f, Io_Brick4=%f, Vo_Brick4=%f", Time, Vi_Brick1, Io_Brick1, Vo_Brick1, Vi_Brick2, Io_Brick2, Vo_Brick2, Vi_Brick3, Io_Brick3, Vo_Brick3, Vi_Brick4, Io_Brick4, Vo_Brick4); //h2.Fill(Time,Vi_Brick1); <<< Add this line h1->Fill(Time); h2->Fill(Time,Vi_Brick1); h3->Fill(Time,Io_Brick1); h4->Fill(Time,Vo_Brick1); h5->Fill(Time,Vi_Brick2); h6->Fill(Time,Io_Brick2); h7->Fill(Time,Vo_Brick2); h8->Fill(Time,Vi_Brick3); h9->Fill(Time,Io_Brick3); h10->Fill(Time,Vo_Brick3); h11->Fill(Time,Vi_Brick4); h12->Fill(Time,Io_Brick4); h13->Fill(Time,Vo_Brick4); ntuple.Fill(Time, Vi_Brick1,Io_Brick1,Vo_Brick1,Vi_Brick2,Io_Brick2,Vo_Brick2,Vi_Brick3,Io_Brick3,Vo_Brick3,Vi_Brick4,Io_Brick4,Vo_Brick4); nlines++; } printf(" found %d points\n",nlines); gStyle->SetOptFit(1011); TCanvas *c1 = new TCanvas("c1", "c1",600,400); h2->Fit("pol1"); c1->Update(); TF1 *f2 = h2->GetFunction("pol1"); if (f2) f2->Draw(); else std::cout << "Function not found." << std::endl; TCanvas *c2 = new TCanvas("c2", "c2",600,400); h3->Fit("pol1"); h3->Draw(); c2->Update(); TF1 *f3 = h3->GetFunction("pol1"); if (f3) f3->Draw(); else std::cout << "Function not found." << std::endl; TCanvas *c3 = new TCanvas("c3", "c3",600,400); h4->Fit("pol1"); h4->Draw(); c3->Update(); TF1 *f4 = h4->GetFunction("pol1"); if (f4) f4->Draw(); else std::cout << "Function not found." << std::endl; TCanvas *c4 = new TCanvas("c4", "c4",600,400); h5->Fit("pol1"); h5->Draw(); c4->Update(); TF1 *f5 = h5->GetFunction("pol1"); if (f5) f5->Draw(); else std::cout << "Function not found." << std::endl; TCanvas *c5 = new TCanvas("c5", "c5",600,400); h6->Fit("pol1"); h6->Draw(); c5->Update(); TF1 *f6 = h6->GetFunction("pol1"); if (f6) f6->Draw(); else std::cout << "Function not found." << std::endl; TCanvas *c6 = new TCanvas("c6", "c6",600,400); h7->Fit("pol1"); h7->Draw(); c6->Update(); TF1 *f7 = h7->GetFunction("pol1"); if (f7) f7->Draw(); else std::cout << "Function not found." << std::endl; TCanvas *c7 = new TCanvas("c7", "c7",600,400); h8->Fit("pol1"); h8->Draw(); c7->Update(); TF1 *f8 = h8->GetFunction("pol1"); if (f8) f8->Draw(); else std::cout << "Function not found." << std::endl; TCanvas *c8 = new TCanvas("c8", "c8",600,400); h9->Fit("pol1"); h9->Draw(); c8->Update(); TF1 *f9 = h9->GetFunction("pol1"); if (f9) f9->Draw(); else std::cout << "Function not found." << std::endl; TCanvas *c9 = new TCanvas("c9", "c9",600,400); h10->Fit("pol1"); h10->Draw(); c9->Update(); TF1 *f10 = h10->GetFunction("pol1"); if (f10) f10->Draw(); else std::cout << "Function not found." << std::endl; TCanvas *c10 = new TCanvas("c10", "c10",600,400); h11->Fit("pol1"); h11->Draw(); c10->Update(); TF1 *f11 = h11->GetFunction("pol1"); if (f11) f11->Draw(); else std::cout << "Function not found." << std::endl; TCanvas *c11 = new TCanvas("c11", "c11",600,400); h12->Fit("pol1"); h12->Draw(); c11->Update(); TF1 *f12 = h12->GetFunction("pol1"); if (f12) f12->Draw(); else std::cout << "Function not found." << std::endl; TCanvas *c12 = new TCanvas("c12", "c12",600,400); h13->Fit("pol1"); c12->Update(); TF1 *f13 = h13->GetFunction("pol1"); if (f13) f13->Draw(); else std::cout << "Function not found." << std::endl; in.close(); f->Write(); }