#include "Riostream.h" void histkalibpro() { // this file has 5 columns: t[s] U[mV] Tr[°C] Tf[°C] Ta[°C] TString dir = "C:/root/myroot/TMP/"; TString filename; cout << "Filename:"; cin >> filename; ifstream in; in.open (dir + filename); Float_t p[5]; Int_t nmin = 0; Int_t nmax = 30000; Int_t nlines = 0; TFile *f = new TFile(Form("%sTMP32.root",dir.Data()),"RECREATE"); TNtuple *ntuple = new TNtuple("ntuple","Pyro kalib","t:U:Tr:Tf:Ta"); Float_t t = 0; while (1) { in >> p[0] >> p[1] >> p[2] >> p[3] >> p[4]; if (!in.good() || nlines >= nmax) break; if (nlines >= nmin) { ntuple->Fill(p[0],p[1],p[2],p[3],p[4]); } nlines++; } nlines=nlines+1; cout <<"Found " << nlines << " lines." << endl; in.close(); // fill histogramms Double_t xmin,xmax,dx; Double_t d2x; Double_t ymin,ymax,y2min,y2max; Double_t h[5],h2[5],eh[5]; Int_t nrebin = 5; Int_t nbins = (Int_t) ntuple->GetEntries(); Int_t hbins = nbins/nrebin; ntuple->SetBranchAddress("t",&p[0]); ntuple->SetBranchAddress("U",&p[1]); ntuple->SetBranchAddress("Tr",&p[2]); ntuple->SetBranchAddress("Tf",&p[3]); ntuple->SetBranchAddress("Ta",&p[4]); ntuple->GetEntry(0); xmax = p[1]; ntuple->GetEntry(nbins-1); xmin = p[1]; ymin=0; ymax=100; y2min=0; y2max=10000; dx = (xmax-xmin)/(1000); d2x = (xmax-xmin)/hbins; //creating the histgrams hist_U = new TH2D("hist_U",";voltage in mV;voltage in mV",nbins,xmin,xmax,nbins,y2min,y2max); hist_Tr = new TH2D("hist_Tr",";voltage in mV;TMP rotor temperature in #circC",nbins,xmin,xmax,nbins,ymin,ymax); hist_Ta = new TH2D("hist_Ta",";voltage in mV;heat temperature in #circC",nbins,xmin,xmax,nbins,ymin,ymax); hist_Tf = new TH2D("hist_Tf",";voltage in mV;flansch temperature in #circC",nbins,xmin,xmax,nbins,ymin,ymax); hist2_U = new TH2D("hist_2U",";voltage in mV;voltage in mV",hbins,xmin,xmax,hbins,y2min,y2max); hist2_Tr = new TProfile("hist_2Tr",";voltage in mV;TMP rotor temperature in #circC",hbins,xmin,xmax); hist2_Tf = new TH1D("hist_2Tf",";voltage in mV;flansch temperature in #circC",hbins,xmin,xmax); hist2_Ta = new TProfile("hist_2Ta",";voltage in mV;heat temperature in #circC",hbins,xmin,xmax); Int_t j=0; hbins = nbins/nrebin; for(int i=0; i < 5; i++){ h[i] =0.; h2[i]=0.; } //filling the histograms for(int i=0; i < nbins; i++) { ntuple->GetEntry(i); hist_U->Fill(p[1],p[1]); hist_Tr->Fill(p[1],p[2]); hist_Tf->Fill(p[1],p[3]); hist_Ta->Fill(p[1],p[4]); for(int k=0; k < 5; k++){ h[k] = h[k] + p[k]; h2[k]= h2[k]+ p[k]*p[k]; } j++; if(j >= nrebin){ hbins--; for(int k=0; k < 5; k++){ h[k] = h[k]/nrebin; h2[k]= h2[k]/nrebin; eh[k]= sqrt((h2[k] - h[k]*h[k])/(nrebin-1.)); } hist2_U->Fill(h[1],h[1]); hist2_Tr->Fill(h[1],h[2]); hist2_Tf->SetBinContent(hbins,h[3]); hist2_Ta->Fill(h[1],h[4]); j = 0; for(int k=0; k < 5; k++){ h[k] =0; h2[k]=0; } } } f->Write(); f->Close(); }