/* Call Library source file */ #include "extcode.h" #include "TCanvas.h" #include "TH1F.h" #include "TF1.h" #include "TF2.h" #include "TGraph.h" #include "TGraph2D.h" #include "TMath.h" #include "TLegend.h" #include #include #include #include "TFile.h" #include #include "TROOT.h" using namespace std; extern "C" { _declspec (dllexport) double plotCalibrationHeight(char path[]); } _declspec (dllexport) double plotCalibrationHeight(char path[]) { //gROOT->SetBatch(); TFile *rFile = new TFile(Form("%srout.root", path), "RECREATE"); rFile->cd(); vector cal_t, cal_z; string calFileName(path); calFileName = calFileName + "Z_calibration.txt"; string line, T, Z; ifstream calFile(calFileName.c_str()); if (calFile) while (getline(calFile, line)) { istringstream tokenizer(line); getline(tokenizer, T, '\t'); getline(tokenizer, Z); cal_t.push_back(atof(T.c_str())); cal_z.push_back(atof(Z.c_str())); } else return 1; TGraph *cal = new TGraph(); for (Int_t N = 0; NSetPoint(N, cal_t.at(N), cal_z.at(N)); cal->SetTitle("Calibration Heights;Time [min];Z [#mum]"); cal->GetXaxis()->SetTitleOffset(1.4); cal->GetYaxis()->SetTitleOffset(1.4); cal->SetMarkerStyle(20); TCanvas *cz = new TCanvas("cz", "", 0, 0, 720, 720); cz->SetDoubleBuffer(1); cz->Paint(); cz->RaiseWindow(); cal->Draw("AP"); //Trying to test other functions that might break the code /* ofstream primFile(Form("%sprimOutFile.txt", path)); ofstream outFile(Form("%soutFile.txt", path)); outFile << cz->GetDISPLAY() << endl; outFile << cz->GetDoubleBuffer() << endl; outFile << cz->GetEvent() << endl; outFile << cz->GetSelectedOpt() << endl; outFile << cz->GetShowEditor() << endl; outFile << cz->GetShowEventStatus() << endl; outFile << cz->GetWindowHeight() << endl; outFile << cz->GetXsizeUser() << endl; outFile << cz->IsRetained() << endl; outFile.close(); cal->SavePrimitive(primFile); primFile.close(); */ //These commands will cause a crash in Labview //cz->Print(Form("%sZ_calibration.png", path)); //cal->Write(); rFile->Write(); rFile->Close(); //delete cz; delete cal; return 0; }