#include #include #include "Riostream.h" #include "TString.h" #include "TFile.h" #include "TNtuple.h" #include "TSystem.h" #include "TProfile.h" #include #include "TTree.h" #include "TF1.h" using namespace std; void plotProfile(TH2F *Dh,double sf){ TProfile *p = Dh->ProfileX(); p->GetYaxis()->SetRangeUser(p->GetMinimum()-sf,p->GetMaximum()+sf ); TF1 *fitpol1 = new TF1("fitpol1","pol1",0,46000); fitpol1->SetLineColor(2); p->Fit("fitpol1"); p->Draw(); } int main() { // Read data from an ascii file and create a root file with an histogram and an ntuple. //TString dir = gSystem->UnixPathName(__FILE__); //dir.ReplaceAll("basichist.C",""); //dir.ReplaceAll("/./","/"); ifstream in; in.open("/afs/cern.ch/user/t/tlepota/19-03-16-2.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-16-2.root","RECREATE"); TTree * tree=new TTree("ntuple","ntuple"); tree->Branch("Time",&Time,"Time/I"); tree->Branch("Vi_Brick1",&Vi_Brick1,"Vi_Brick1/F"); tree->Branch("Io_Brick1",&Io_Brick1,"Io_Brick1/F"); tree->Branch("Vo_Brick1",&Vo_Brick1,"Vo_Brick1/F"); tree->Branch("Vi_Brick2",&Vi_Brick2,"Vi_Brick2/F"); tree->Branch("Io_Brick2",&Io_Brick2,"Io_Brick2/F"); tree->Branch("Vo_Brick2",&Vo_Brick2,"Vo_Brick2/F"); tree->Branch("Vi_Brick3",&Vi_Brick3,"Vi_Brick3/F"); tree->Branch("Io_Brick3",&Io_Brick3,"Io_Brick3/F"); tree->Branch("Vo_Brick3",&Vo_Brick3,"Vo_Brick3/F"); tree->Branch("Vi_Brick4",&Vi_Brick4,"Vi_Brick4/F"); tree->Branch("Io_Brick4",&Io_Brick4,"Io_Brick4/F"); tree->Branch("Vo_Brick4",&Vo_Brick4,"Vo_Brick4/F"); //Creating the 2D histogram TH2F *h2 = new TH2F("h2","2D Histogram for input voltage over time for irradiation test R1 12h;time (s);Vi (V)", 200,0,43200,200,180,220);//40,0,46000,40,187,216); TH2F *h3 = new TH2F("h3","2D Histogram for output current over time for irradiation test R1 12h;time (s);Io (A)",200,0,43200,200,2,2.5); TH2F *h4 = new TH2F("h4","2D Histogram for output voltage over time for irradiation test R1 2nd 12h;time (s);Vo (V)",200,0,43200,200,10,13);//40,0,46000,40,10,12); TH2F *h5 = new TH2F("h5","2D Histogram for input voltage over time for irradiation test R1 2nd 12h;time (s); Vi (V)",200,0,43200,200,180,220); TH2F *h6 = new TH2F("h6","2D Histogram for output current over time for irradiation test R1 2nd 12h;time (s);Io (A)",200,0,43200,200,2,2.5); TH2F *h7 = new TH2F("h7","2D Histogram for output voltage over time for irradiation test R1 12h;time (s);Vo (V)",200,0,43200,200,10,13); TH2F *h8 = new TH2F("h8","2D Histogram for input voltage over time for irradiation test R1 12h;time (s);Vi (V)",200,0,43200,200,180,220); TH2F *h9 = new TH2F("h9","2D Histogram for output current over time for irradiation test R1 12h;time (s);Io (A)",200,0,43200,200,2,2.5); TH2F *h10 = new TH2F("h10","2D Histogram for for output voltage over time for irradiation test R1 12h;time (s);Vo (V)",200,0,43200,200,10,13); TH2F *h11 = new TH2F("h11","2D Histogram for input voltage over time for irradiation test R1 12h;time (s) Vi (V)",200,0,43200,200,180,220); TH2F *h12 = new TH2F("h12","2D Histogram for output current over time for irradiation test R1-19 12h;time (s);Io (A)",200,0,43200,200,2,2.5); TH2F *h13 = new TH2F("h13","2D Histogram for output voltage over time for irradiation test R1 12h;time (s);Vo (V)",200,0,43200,200,10,13); 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=%i, 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); 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); tree->Fill(); nlines++; } printf(" found %d points\n",nlines); plotProfile(h2,0.3); plotProfile(h3,0.003); plotProfile(h4,0.03); plotProfile(h5,0.3); plotProfile(h6,0.003); plotProfile(h7,0.03); plotProfile(h8,0.3); plotProfile(h9,0.003); plotProfile(h10,0.03); plotProfile(h11,0.3); plotProfile(h12,0.003); plotProfile(h13,0.03); in.close(); f->Write(); }