using namespace std; void graphToHist() { TFile fr("calGraphs680.root"); TGraph *fGraph[64]; TList *gList = fr.GetListOfKeys(); const Int_t nEntries = gList->GetEntries(); if (nEntries!=64) { Error("cls_Calibrator::ImportGraphs", "Something wrong, only %d graphs found instead of 64", nEntries); return; } TString gName; for (Int_t i = 0; i < nEntries; i++) { gName.Form("gcal%d", i); fGraph[i] = (TGraph*)fr.Get(gName.Data()); if ( fGraph[i] == 0) { Error("cls_Calibrator::ImportGraphs", "Graph %s was not found in file %s", gName.Data(), fr.GetName()); fr.Close(); return; } }//for fr.Close(); TH1D* fLUT[64]; //LUT function TString hName; TString hTitle; const Double_t minX = -50.; const Double_t maxX = 4096.; Double_t xmin = 0; Double_t xmax = 0; Double_t ymin = 0; Double_t ymax = 0; for (Int_t i = 0; i < 64; i++) { hName.Form("calHist%d", i); hTitle.Form("do we need it for channel %d?", i); fLUT[i] = new TH1D(hName.Data(), hTitle.Data(), maxX - minX, minX, maxX); // fGraph[i]->ComputeRange(&xmin, &ymin, &xmax, &ymax); fGraph[i]->ComputeRange(xmin, ymin, xmax, ymax); cout << xmin << "\t" << xmax << endl; for (Int_t j = xmin; j <= xmax; j++) { fLUT[i]->SetBinContent(j, fGraph[i]->Eval(j) ); } }//for }