#include "TGDockableFrame.h" #include "TGMenu.h" #include "TGMdiDecorFrame.h" #include "TG3DLine.h" #include "TGMdiFrame.h" #include "TGMdiMainFrame.h" #include "TGuiBldHintsButton.h" #include "TGMdiMenu.h" #include "TGColorDialog.h" #include "TGListBox.h" #include "TGNumberEntry.h" #include "TGScrollBar.h" #include "TGuiBldHintsEditor.h" #include "TGFrame.h" #include "TGFileDialog.h" #include "TGShutter.h" #include "TGButtonGroup.h" #include "TGCanvas.h" #include "TGFSContainer.h" #include "TGButton.h" #include "TGuiBldEditor.h" #include "TGFSComboBox.h" #include "TGLabel.h" #include "TGProgressBar.h" #include "TGMsgBox.h" #include "TRootGuiBuilder.h" #include "TGTab.h" #include "TGListView.h" #include "TGSplitter.h" #include "TGStatusBar.h" #include "TGToolTip.h" #include "TGToolBar.h" #include "TRootEmbeddedCanvas.h" #include "TCanvas.h" #include "TGuiBldDragManager.h" #include "Riostream.h" #include "TCutG.h" #include "TDatime.h" #include "TH2F.h" #include "TH1F.h" #include "TAxis.h" #include "TNtuple.h" #include "TImage.h" #include "TASImage.h" #include "TRotation.h" #include "TVector3.h" #include "TFile.h" #include "fstream" #include "iostream" #include "iomanip" #include #include #include using namespace std; class TList; enum ColorName { black, red, green, brown, blue, magenta, cyan, lightgray, darkgray, lightred, lightgreen, yellow, lightblue, lightmagenta, lightcyan, white }; struct color { color(ColorName f = white, ColorName b = black) :fore(f),back(b) {} ColorName fore; ColorName back; }; struct gotoxy { gotoxy(int x_, int y_) : x(x_), y(y_) {} int x; int y; }; const int DATANT = 20; const char *filetypesin[] = { "All files", "*", 0, 0 }; const char *filetypesout[] = { "All files", "*", 0, 0 }; const char *numlabel[] = { "Min. Cluster adu", "Max. Cluster adu", "# of Pix in clust", "Rotate by degree", "Bottom left x, y", "Top right x, y" }; const Double_t numinit[] = { 0, 3000, 3, 0.0, 0.0, 0.0, 1241.0, 1152.0 }; enum EMenuIds { M_FILE_OPEN, M_FILE_CLOSE, M_FILE_EXIT, M_FILE_QUICK_OPEN, M_WINDOW_HOR, M_WINDOW_VERT, M_WINDOW_OPAQUE, M_WINDOW_ARRANGE, M_ANAL_CLUST, M_CONVERT_TIFF, M_HELP_CONTENTS, M_HELP_ABOUT, M_SAVE_IMG, M_SAVE_TXT, M_CUT_DATA, M_CLUSINT_DIST }; class TGAppMainFrame { RQ_OBJECT("TGAppMainFrame") public: TGAppMainFrame(const TGWindow *p, int w, int h); ~TGAppMainFrame(); void HandleMenu(Int_t id); void InitMenu(); void InitMenuPlot(); void InitPlot(); void InitTGMDI(); void CloseWindow(); void SetStatusText(const char *txt, Int_t pi); void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected); TList *fCleanup; TGMainFrame *fMain; TGMdiMainFrame *fMainFrame; TGMdiMenuBar *fMenuBar; TGMdiMenuBar *fMenuBar_plot; TGLayoutHints *fMenuBarItemLayout; TGLayoutHints *fMenuBarItemLayout_plot; TGPopupMenu *fMenuFile, *fMenuConv, *fMenuWindow, *fMenuHelp; TGPopupMenu *fMenuFile_plot, *fMenuAnal_plot; TGFont *ufont; // will reflect user font changes TGGC *uGC; // will reflect user GC changes ULong_t ucolor; // will reflect user color changes TGNumberEntry *fNumericEntries[13]; TGLabel *fLabel[13]; TGCheckButton * fCheckButton_rotate; TGCheckButton * fCheckButton_cut; TGCheckButton * fCheckButton_bin; // TGMdiFrame ** plot; TGMdiFrame * plot_alldata; TRootEmbeddedCanvas ** fRootEmbeddedCanvas; TRootEmbeddedCanvas * fRootEmbeddedCanvas_alldata; TGStatusBar * fSStatusBar; GCValues_t valButton; Int_t wfRootEmbeddedCanvas; // TGMainFrame *fMainFrame; TGNumberEntry * fNumberEntry3916; TGNumberEntry * fNumberEntry_flagcut; TGNumberEntry * fNumberEntry_frame; TGNumberEntry * fNumberEntry_prepix; // TGHProgressBar *fHProgressBar3920; TGCheckButton * fCheckButtonClusterize; TGCheckButton * fCheckButton3912; TGCheckButton * fCheckButton3913; TGCheckButton * fCheckButton_flag; TGCompositeFrame *fCompositeFrame3911; TGVerticalFrame *fMainFrame3910_0; TGHorizontalFrame *fMainFrame3910_01; TGVerticalFrame *fMainFrame3910_1; TGVerticalFrame *fMainFrame3910_2; TGVerticalFrame *fMainFrame3910_3; TGTextButton *fTextButton3925_0; TGTextButton *fTextButton3926; TGShutter *fShutter; TGMdiFrame * tgmdiFrame; public: //_________________________________________________________ //Declarations for Tiff conversion feature void InitRoot(); void BuffData(char * buff); void DrawAlldata(); void DrawData(char * filename); void SetValues(); void Run(); void Empty(); char * itoa(int x); char * ftoa(float x); void LogTxt(); void HandleCheckButton1(); void HandleCheckButton2(); void HandleCheckButton3(); void HandleCheckButton4(); void HandleCheckButtonRotate(); void HandleCheckButtonCut(); void HandleCheckButtonBin(); void OpenFile(); void OpenBgFile(); void DoNothing(){cout << "nothin" << endl;}; void DrawNoise(); void SetValuesConvert(); int BuffSingleTiff(char * tiffile); int ReadMultiTiff(char * tiffile); void AddShutterItem1(const char *name); void AddShutterItem2(const char *name); char * filename; string tiff_filename; char * bgfilename; int mac_flag, pc_flag; string s_Clust; string s_Predisc; string s_Prepix; string s_Flag; string s_Frame; string s_FlagCut; string s_doNoiseShift; int m_NoClus; int m_Predisc; int m_Prepix; int m_Clusterize; int m_Binarize; int m_Flag;//do we want noise txt file?Yes (1), No (0) int m_FlagCut;//we must cut the noise at some low value, otherwise the noise int m_doNoiseShift; //do we want noise back shift?Yes (1), No (0) //txt file will be too big int m_Frame;//noise cut for which frame? Only in case of multiple frame tiff file int m_graph_cut; string BGFilename; //color things... ULong_t ucolor; // will reflect user color changes ULong_t bcolor; // bg ULong_t wcolor; // white ULong_t tcolor; // text ULong_t tbgcolor; // textbg Float_t X0; //1241.0/2.0 Float_t Y0; //1151.0/2.0 Float_t PI; string fname; string BGFilename; string BGdir; int Subtract_background; int data_i; int draw_i; int alldata_drawn; int Zero; string logdmyname; int CLUST_PIX; Float_t CLUST_INT_MIN; Float_t CLUST_INT_MAX; int r_Flag;//do we want rotation? Yes (1), No (0) Float_t ROTATE_FRAME;//angle of rotation - can be +/- Float_t x, y, inten, clust; TNtuple * alldata_nt; TH2F * alldata_h2; TH1F * alldata_h1; TH1I * pixeldist; TH1F * intendist; TH1F * intendistcut; TH1I * pixeldistcut; // TCanvas ** c123; TCanvas * c_alldata; TCanvas * c_distcut; }; //---------------------------------------------------------------------- TGAppMainFrame::TGAppMainFrame(const TGWindow *p, int w, int h) { gStyle->SetCanvasColor(0); gStyle->SetCanvasBorderMode(0); gStyle->SetPadColor(0); gStyle->SetPadBorderMode(0); gStyle->SetFrameBorderMode(0); //intialization filename = NULL; bgfilename = NULL; fNumberEntry3916 = NULL; fNumberEntry_flagcut = NULL; fNumberEntry_frame = NULL; fNumberEntry_prepix = NULL; // fHProgressBar3920 = NULL; fCheckButtonClusterize = NULL; fCheckButton3912 = NULL; fCheckButton3913 = NULL; fCheckButton_flag = NULL; fCompositeFrame3911 = NULL; fMainFrame3910_0 = NULL; fMainFrame3910_01 = NULL; fMainFrame3910_1 = NULL; fMainFrame3910_2 = NULL; fMainFrame3910_3 = NULL; fTextButton3925_0 = NULL; fTextButton3926 = NULL; fShutter = NULL; tgmdiFrame = NULL; alldata_nt= NULL; alldata_h2= NULL; alldata_h1= NULL; pixeldist= NULL; intendist= NULL; intendistcut= NULL; pixeldistcut= NULL; // c123= NULL; c_alldata= NULL; c_distcut= NULL; fMain= NULL; fMainFrame= NULL; fMenuBar= NULL; fMenuBar_plot= NULL; fMenuBarItemLayout= NULL; fMenuBarItemLayout_plot= NULL; fMenuFile = NULL; fMenuConv = NULL; fMenuWindow = NULL; fMenuHelp= NULL; fMenuFile_plot = NULL; fMenuAnal_plot= NULL; ufont= NULL; uGC= NULL; fCheckButton_rotate= NULL; fCheckButton_cut= NULL; fCheckButton_bin= NULL; // plot= NULL; plot_alldata= NULL; fRootEmbeddedCanvas= NULL; fRootEmbeddedCanvas_alldata= NULL; fSStatusBar= NULL; // end initialization // Memory management isn't the best in this class, but make a half // hearted attempts not to gush too much.... fCleanup = new TList; fMain = new TGMainFrame(p, w, h, kVerticalFrame); fCleanup->Add(fMain); fMenuBar = new TGMdiMenuBar(fMain, 10, 10); fMain->AddFrame(fMenuBar, new TGLayoutHints(kLHintsTop | kLHintsExpandX)); fMainFrame = new TGMdiMainFrame(fMain, fMenuBar, 300, 300); fMain->AddFrame(fMainFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY)); InitPlot(); InitMenuPlot(); InitRoot(); InitMenu(); InitTGMDI(); fMain->SetWindowName("Tiff View"); // fMain->Resize(800, 600); fMain->MapSubwindows(); fMain->MapWindow(); fMain->Move(300, 300); fMain->MoveResize(300, 300, 800, 600); fMain->Layout(); fMain->DontCallClose(); } TGAppMainFrame::~TGAppMainFrame(){ fMain->Clear(); delete fMain; fCleanup->Delete(); delete fCleanup; } void TGAppMainFrame::HandleMenu(Int_t id){ // Handle menu items. switch (id) { case M_FILE_OPEN: static TString dir("/Users/larry/data/"); TGFileInfo fi1; fi1.fIniDir = StrDup(dir); fi1.SetMultipleSelection(kTRUE); new TGFileDialog(gClient->GetDefaultRoot(), fMainFrame, kFDOpen,&fi1); int namei = 0; if(fi1.fMultipleSelection && fi1.fFileNamesList){ char * buff = NULL; TObjString *el1 = NULL; TIter next(fi1.fFileNamesList); cout << color(green, white) << "|------" << flush; cout << color(black, white) << " Loading event list file(s): " << flush; cout << color(blue, white) << flush; while((el1 = (TObjString *) next())){ TString t1 = el1->GetString(); buff = t1.Data(); BuffData(buff); cout << t1.Data() << ", "; } cout << endl; cout << color(black, white) << flush; DrawAlldata(); Zero = 1; }else if(fi1.fFilename){ char * buff = NULL; cout << color(green, white) << "|------" << flush; cout << color(black, white) << " Loading event list file: " << flush; cout << color(blue, white) << flush; buff = fi1.fFilename; BuffData(buff); cout << buff; cout << endl; cout << color(black, white) << flush; DrawAlldata(); Zero = 1; }else{ } break; case M_FILE_QUICK_OPEN: static TString dir("/Users/larry/data/"); TGFileInfo fi1; fi1.fIniDir = StrDup(dir); // fi1.SetMultipleSelection(kTRUE); fi1.fFilename = NULL; new TGFileDialog(gClient->GetDefaultRoot(), fMainFrame, kFDOpen,&fi1); if(fi1.fFilename){ Zero = 1; DrawData(fi1.fFilename); }else{ } break; case M_FILE_CLOSE: fMainFrame->Close(fMainFrame->GetCurrent()); break; case M_FILE_EXIT: CloseWindow(); break; case M_CONVERT_TIFF: break; case M_ANAL_CLUST: // analize->SetWindowName("Analize"); // analize->MapSubwindows(); // analize->Layout(); // analize->DontCallClose(); // } break; case M_WINDOW_HOR: fMainFrame->TileHorizontal(); break; case M_WINDOW_VERT: fMainFrame->TileVertical(); break; case M_WINDOW_ARRANGE: fMainFrame->ArrangeMinimized(); break; case M_WINDOW_OPAQUE: if (fMenuWindow->IsEntryChecked(M_WINDOW_OPAQUE)) { fMenuWindow->UnCheckEntry(M_WINDOW_OPAQUE); fMainFrame->SetResizeMode(kMdiNonOpaque); } else { fMenuWindow->CheckEntry(M_WINDOW_OPAQUE); fMainFrame->SetResizeMode(kMdiOpaque); } break; case M_HELP_ABOUT: TGMdiFrame * plot_b = new TGMdiFrame(fMainFrame, 150, 150); TRootEmbeddedCanvas * fRECanvas = new TRootEmbeddedCanvas(0,plot_b,200,150,kSunkenFrame, ucolor); Int_t wfRECanvas = fRECanvas->GetCanvasWindowId(); TCanvas * bjpg = new TCanvas("bjpg", 1, 1, wfRECanvas); fRECanvas->AdoptCanvas(bjpg); bjpg->SetBorderMode(0); bjpg->cd()->SetBorderMode(0); bjpg->cd()->GetFrame()->SetBorderMode(0); plot_b->AddFrame(fRECanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,0,0,0,0)); plot_b->SetMdiHints(kMdiDefaultHints | kMdiHelp); plot_b->SetWindowName("Balinto"); plot_b->MapSubwindows(); plot_b->Layout(); TImage * im = TImage::Open("btiff.jpg"); bjpg->cd(); im->Draw(); break; case M_CLUSINT_DIST: if(Zero == 1){ SetValues(); /// cout << "All Entries: " << alldata_nt->GetEntries() << endl; pixeldist = (TH1I*)gROOT->FindObject("pixeldist"); if(pixeldist)delete pixeldist; pixeldist = new TH1I("pixeldist", "", 20, 0, 20); pixeldist->GetXaxis()->SetTitle("# of pixels in cluster"); pixeldist->GetXaxis()->CenterTitle(); pixeldist->GetYaxis()->SetTitle("Events"); pixeldist->GetYaxis()->CenterTitle(); intendist = (TH1F*)gROOT->FindObject("intendist"); if(intendist)delete intendist; intendist = new TH1F("intendist", "", 250.0, 0.0, 500.0); intendist->GetXaxis()->SetTitle("Pulse height of cluster"); intendist->GetXaxis()->CenterTitle(); intendist->GetYaxis()->SetTitle("Events"); intendist->GetYaxis()->CenterTitle(); int cur, next, step; Float_t fcur, fnext, fnexti, inten_norm; int fi = -1; Float_t xt, yt, intent, clustt, sigtag, sigtag_count; alldata_nt->SetBranchAddress("x", &xt); alldata_nt->SetBranchAddress("y", &yt); alldata_nt->SetBranchAddress("inten", &intent); alldata_nt->SetBranchAddress("clust", &clustt); alldata_nt->SetBranchAddress("sigtag", &sigtag); alldata_nt->SetBranchAddress("sigtag_count", &sigtag_count); while(fi < alldata_nt->GetEntries()){ fi++; alldata_nt->GetEntry(fi); if(sigtag == -999 || sigtag == -1){//nonclusterized data or non candidate intendist->Fill(intent); pixeldist->Fill(clustt); } if(sigtag == 1){//clusterized data and maybe candidates inten_norm = 0; for(int i = 0 ; i < clustt; i++){ alldata_nt->GetEntry(fi+i); inten_norm += intent; } intendist->Fill(inten_norm); pixeldist->Fill(clustt); fi = fi + clustt - 1; } } TGMdiFrame * plot_dist = new TGMdiFrame(fMainFrame, 400, 400); TRootEmbeddedCanvas * fRECanvas_dist = new TRootEmbeddedCanvas(0,plot_dist,380,380,kSunkenFrame, ucolor); Int_t wfRECanvas_dist = fRECanvas_dist->GetCanvasWindowId(); TCanvas * c_dist = new TCanvas("Distributions", 1, 1, wfRECanvas_dist); c_dist->Divide(1,2); fRECanvas_dist->AdoptCanvas(c_dist); c_dist->SetBorderMode(0); c_dist->cd()->SetBorderMode(0); c_dist->cd()->GetFrame()->SetBorderMode(0); plot_dist->AddFrame(fRECanvas_dist, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,0,0,0,0)); plot_dist->SetMdiHints(kMdiDefaultHints | kMdiHelp); plot_dist->SetWindowName("Distributions"); plot_dist->MapSubwindows(); plot_dist->Layout(); // plot_->Move(150, 140); c_dist->cd(1); pixeldist->SetStats(kFALSE); pixeldist->Draw(); c_dist->cd(2); intendist->SetStats(kFALSE); intendist->Draw(); c_dist->Update(); alldata_nt->ResetBranchAddresses(); }else{ cout << endl; cout << "No data, please load an event list file!" << endl; } break; case M_CUT_DATA: pixeldistcut = (TH1I*)gROOT->FindObject("pixeldistcut"); if(pixeldistcut)delete pixeldistcut; pixeldistcut = new TH1I("pixeldistcut", "", 20, 0, 20); pixeldistcut->GetXaxis()->SetTitle("# of pixels in cluster"); pixeldistcut->GetXaxis()->CenterTitle(); pixeldistcut->GetYaxis()->SetTitle("Events"); pixeldistcut->GetYaxis()->CenterTitle(); intendistcut = (TH1F*)gROOT->FindObject("intendistcut"); if(intendistcut)delete intendistcut; intendistcut = new TH1F("intendistcut", "", 250.0, 0.0, 500.0); intendistcut->GetXaxis()->SetTitle("Pulse height of cluster"); intendistcut->GetXaxis()->CenterTitle(); intendistcut->GetYaxis()->SetTitle("Events"); intendistcut->GetYaxis()->CenterTitle(); cout << "Cutting process...." << endl; TCutG *tmpcut = (TCutG*)gROOT->FindObject("cutarea"); TCutG *gcat = NULL; if (tmpcut == NULL){ Float_t cutareax[5] = {100, 100, 150, 150, 100}; Float_t cutareay[5] = {50, 1100, 1100, 50, 50}; gcat = new TCutG("cutarea", 5, cutareax, cutareay); gcat->SetLineColor(2); Double_t * tmp_x = gcat->GetX(); Double_t * tmp_y = gcat->GetY(); fNumericEntries[4]->SetNumber(tmp_x[0]); fNumericEntries[5]->SetNumber(tmp_y[0]); fNumericEntries[6]->SetNumber(tmp_x[2]); fNumericEntries[7]->SetNumber(tmp_y[2]); }else{ if(m_graph_cut == 1){ Float_t cutareax[5] = {fNumericEntries[4]->GetNumber(), fNumericEntries[4]->GetNumber(), fNumericEntries[6]->GetNumber(), fNumericEntries[6]->GetNumber(), fNumericEntries[4]->GetNumber()}; Float_t cutareay[5] = {fNumericEntries[5]->GetNumber(),fNumericEntries[7]->GetNumber(),fNumericEntries[7]->GetNumber(), fNumericEntries[5]->GetNumber(), fNumericEntries[5]->GetNumber() }; gcat = new TCutG("cutarea", 5, cutareax, cutareay); gcat->SetLineColor(2); }else{ cout << "Keeping existing cut area" << endl; Double_t * tmp_x = tmpcut->GetX(); Double_t * tmp_y = tmpcut->GetY(); fNumericEntries[4]->SetNumber(tmp_x[0]); fNumericEntries[5]->SetNumber(tmp_y[0]); fNumericEntries[6]->SetNumber(tmp_x[2]); fNumericEntries[7]->SetNumber(tmp_y[2]); gcat = tmpcut; } } c_alldata->cd(1); gcat->Draw(); c_alldata->Update(); intendistcut->Reset(); pixeldistcut->Reset(); Float_t xt, yt, intent, clustt, sigtag, sigtag_count; alldata_nt->SetBranchAddress("x", &xt); alldata_nt->SetBranchAddress("y", &yt); alldata_nt->SetBranchAddress("inten", &intent); alldata_nt->SetBranchAddress("clust", &clustt); alldata_nt->SetBranchAddress("sigtag", &sigtag); alldata_nt->SetBranchAddress("sigtag_count", &sigtag_count); int cur, next, step; Float_t fcur, fnext, fnexti, inten_norm; int ci = -1; while(ci < alldata_nt->GetEntries()){ ci++; //cout << "ci: " << ci << endl; alldata_nt->GetEntry(ci); fcur = sigtag_count; alldata_nt->GetEntry(ci+1); fnext = sigtag_count; inten_norm = 0; alldata_nt->GetEntry(ci); if(sigtag == -999 || sigtag == -1){//nonclusterized data or non candidate if (gcat->IsInside(xt, yt)){ intendistcut->Fill(intent); pixeldistcut->Fill(clustt); } } if(sigtag == 1){//clust.data, candidate // || sigtag == -1)//clust. data, else //cout << "starting normalizing" << endl; for(int i = 0 ; i < clustt; i++){ alldata_nt->GetEntry(ci+i); inten_norm += intent; } if (gcat->IsInside(xt, yt)){ intendistcut->Fill(inten_norm); pixeldistcut->Fill(clustt); } ci = ci + clustt - 1; } } if(c_distcut != NULL){ c_distcut->cd(1); pixeldistcut->Draw(); c_distcut->cd(2); intendistcut->Draw(); c_distcut->Update(); }else if(c_distcut == NULL){ TGMdiFrame * plot_distcut = new TGMdiFrame(fMainFrame, 400, 400); TRootEmbeddedCanvas * fRECanvas_distcut = new TRootEmbeddedCanvas(0,plot_distcut,380,380,kSunkenFrame, ucolor); Int_t wfRECanvas_distcut = fRECanvas_distcut->GetCanvasWindowId(); c_distcut = new TCanvas("Graphical Cut", 1, 1, wfRECanvas_distcut); c_distcut->Divide(1,2); fRECanvas_distcut->AdoptCanvas(c_distcut); c_distcut->SetBorderMode(0); c_distcut->cd()->SetBorderMode(0); c_distcut->cd()->GetFrame()->SetBorderMode(0); plot_distcut->AddFrame(fRECanvas_distcut, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,0,0,0,0)); plot_distcut->SetMdiHints(kMdiDefaultHints | kMdiHelp); plot_distcut->SetWindowName("Graphical Cut"); plot_distcut->MapSubwindows(); plot_distcut->Layout(); plot_distcut->Move(150, 140); plot_distcut->DontCallClose(); c_distcut->cd(1); pixeldistcut->SetStats(kFALSE); pixeldistcut->Draw(); c_distcut->cd(2); intendistcut->SetStats(kFALSE); intendistcut->Draw(); c_distcut->Update(); } break; case M_SAVE_TXT: static TString dir("/Users/larry/data/"); TGFileInfo fis; fis.fFilename = NULL; fis.fIniDir = StrDup(dir); new TGFileDialog(gClient->GetDefaultRoot(), fMainFrame, kFDSave,&fis); string otempname = string(fis.fFilename); if(fis.fFilename){ ofstream of; of.open(otempname.c_str()); Int_t nx = alldata_h1->GetNbinsX(); for (Int_t i=0;iGetBinContent(i+1) << endl; } of.close(); ofstream log; log.open(logdmyname.c_str(), ios_base::app); TDatime * datime = new TDatime(); string hour = string(itoa(datime->GetHour())); string min = string(itoa(datime->GetMinute())); string sec = string(itoa(datime->GetSecond())); string time = hour + ":" + min + ":" + sec; log << "[_____] At " << time << " [______________] " << endl; cout << endl; cout << color(red, white) << "[_____] At " << time << " [______________] " << endl; cout << "Saving TXT column sum" << endl; cout << color(black, white) << flush; log << "Saving TXT column sum" << endl; if(m_Binarize == 0){ log << "\t" << "Eventization: No" << endl; cout << "\t" << "Eventization: No" << endl; } if(m_Binarize == 1){ log << "\t" << "Eventization: Yes" << endl; cout << "\t" << "Eventization: Yes" << endl; } log << "\t" << "Min. cluster adu: " << string(itoa(CLUST_INT_MIN)) << endl; cout << "\t" << "Min. cluster adu: " << string(itoa(CLUST_INT_MIN)) << endl; log << "\t" << "Max. cluster adu: " << string(itoa(CLUST_INT_MAX)) << endl; cout << "\t" << "Max. cluster adu: " << string(itoa(CLUST_INT_MAX)) << endl; log << "\t" << "Max. number of pixels in cluster: " << string(itoa(CLUST_PIX)) << endl; cout << "\t" << "Max. number of pixels in cluster: " << string(itoa(CLUST_PIX)) << endl; }else{ } break; case M_SAVE_IMG: static TString dir("/Users/larry/data/"); TGFileInfo fis; fis.fFilename = NULL; fis.fIniDir = StrDup(dir); new TGFileDialog(gClient->GetDefaultRoot(), fMainFrame, kFDSave,&fis); string otempname = string(fis.fFilename) + "__temp_h2.txt"; if(fis.fFilename){ Int_t nx = alldata_h2->GetNbinsX(); Int_t ny = alldata_h2->GetNbinsY(); //unsigned short * array1 = new unsigned short[nx*ny]; ofstream of; of.open(otempname.c_str()); for (Int_t j=0;jGetCellContent(i+1,j+1); if(alldata_h2->GetCellContent(i+1,j+1) > 0){ of << setw(10) << i << setw(10) << j << setw(10) << alldata_h2->GetCellContent(i+1, j+1) << endl; } } } of.close(); ofstream log; log.open(logdmyname.c_str(), ios_base::app); TDatime * datime = new TDatime(); string hour = string(itoa(datime->GetHour())); string min = string(itoa(datime->GetMinute())); string sec = string(itoa(datime->GetSecond())); string time = hour + ":" + min + ":" + sec; log << "[_____] At " << time << " [______________] " << endl; cout << endl; cout << color(red, white) << "[_____] At " << time << " [______________] " << endl; cout << "Saving TIFF image" << endl; cout << color(black, white) << flush; log << "Saving TIFF image" << endl; if(m_Binarize == 0){ log << "\t" << "Eventization: No" << endl; cout << "\t" << "Eventization: No" << endl; } if(m_Binarize == 1){ log << "\t" << "Eventization: Yes" << endl; cout << "\t" << "Eventization: Yes" << endl; } log << "\t" << "Min. cluster adu: " << string(itoa(CLUST_INT_MIN)) << endl; cout << "\t" << "Min. cluster adu: " << string(itoa(CLUST_INT_MIN)) << endl; log << "\t" << "Max. cluster adu: " << string(itoa(CLUST_INT_MAX)) << endl; cout << "\t" << "Max. cluster adu: " << string(itoa(CLUST_INT_MAX)) << endl; log << "\t" << "Max. number of pixels in cluster: " << string(itoa(CLUST_PIX)) << endl; cout << "\t" << "Max. number of pixels in cluster: " << string(itoa(CLUST_PIX)) << endl; string command = "tiffwrite '" + otempname + "' '"; string ofile = string(fis.fFilename); command = command + ofile + "'"; if((m_Binarize == 1 || m_Binarize == 0) && (m_NoClus == 1)){ command = command + " 0"; }elseif(m_Binarize == 1 && m_NoClus == 0){//clusterized and binarized, so multiply by thousand command = command + " 1"; } gSystem->Exec(command.c_str()); //cout << command << endl; // gSystem->Exec("rm 'temp_h2.txt'"); log << "\t" << "Output TIFF filename: " << ofile << endl; cout << "\t" << "Output TIFF filename: " << ofile << endl; log.close(); }else{ } break; default: fMainFrame->SetCurrent(id); break; } } void TGAppMainFrame::InitMenu() { fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0); fMenuFile = new TGPopupMenu(gClient->GetRoot()); fMenuFile->AddEntry(new TGHotString("&Load Event list file(s)"), M_FILE_OPEN); fMenuFile->AddEntry(new TGHotString("&View Event list File"), M_FILE_QUICK_OPEN); fMenuFile->AddSeparator(); fMenuFile->AddEntry(new TGHotString("E&xit"), M_FILE_EXIT); // fMenuFile->AddEntry(new TGHotString("&Close Window"), M_FILE_CLOSE); fMenuConv = new TGPopupMenu(gClient->GetRoot()); fMenuConv->AddEntry(new TGHotString("Generate Event list"), M_CONVERT_TIFF); // fMenuConv->AddSeparator(); // fMenuConv->AddEntry(new TGHotString("E&xit"), M_FILE_EXIT); // fMenuConv->CheckEntry(M_CONVERT_TIFF); fMenuWindow = new TGPopupMenu(gClient->GetRoot()); fMenuWindow->AddEntry(new TGHotString("Tile &Horizontally"), M_WINDOW_HOR); fMenuWindow->AddEntry(new TGHotString("Tile &Vertically"), M_WINDOW_VERT); fMenuWindow->AddSeparator(); fMenuWindow->AddPopup(new TGHotString("&Windows"), fMainFrame->GetWinListMenu()); fMenuWindow->AddSeparator(); fMenuWindow->AddEntry(new TGHotString("&Arrange icons"), M_WINDOW_ARRANGE); fMenuWindow->AddSeparator(); fMenuWindow->AddEntry(new TGHotString("&Opaque resize"), M_WINDOW_OPAQUE); fMenuWindow->CheckEntry(M_WINDOW_OPAQUE); fMenuHelp = new TGPopupMenu(gClient->GetRoot()); fMenuHelp->AddEntry(new TGHotString("&Contents"), M_HELP_CONTENTS); fMenuHelp->AddSeparator(); fMenuHelp->AddEntry(new TGHotString("&About"), M_HELP_ABOUT); fMenuHelp->DisableEntry(M_HELP_CONTENTS); // fMenuHelp->DisableEntry(M_HELP_ABOUT); // menu message are handled by the class' HandleMenu() method fMenuFile->Connect("Activated(Int_t)", "TGAppMainFrame", this,"HandleMenu(Int_t)"); fMenuConv->Connect("Activated(Int_t)", "TGAppMainFrame", this,"HandleMenu(Int_t)"); fMenuWindow->Connect("Activated(Int_t)", "TGAppMainFrame", this,"HandleMenu(Int_t)"); fMenuHelp->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)"); // fMenuBar->AddPopup(new TGHotString("&Exit"), fMenuConv, fMenuBarItemLayout); fMenuBar->AddPopup(new TGHotString("&Event list"), fMenuFile, fMenuBarItemLayout); fMenuBar->AddPopup(new TGHotString("&Windows"),fMenuWindow,fMenuBarItemLayout); fMenuBar->AddPopup(new TGHotString("&Help"), fMenuHelp, fMenuBarItemLayout); //Activate default menu options - it is always there so it is not visible!!! fMenuConv->Activated(M_ANAL_CLUST); fMenuConv->Activated(M_CONVERT_TIFF); } void TGAppMainFrame::InitMenuPlot(){ fMenuBarItemLayout_plot = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0); fMenuFile_plot = new TGPopupMenu(gClient->GetRoot()); fMenuFile_plot->AddEntry(new TGHotString("&Save img as tiff"), M_SAVE_IMG); fMenuFile_plot->AddEntry(new TGHotString("&Save col.sum as txt"), M_SAVE_TXT); // fMenuFile_plot->AddSeparator(); fMenuAnal_plot = new TGPopupMenu(gClient->GetRoot()); fMenuAnal_plot->AddEntry(new TGHotString("Pulse height histogram"), M_CLUSINT_DIST); fMenuAnal_plot->AddEntry(new TGHotString("Spatial ROI"), M_CUT_DATA); fMenuFile_plot->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)"); fMenuAnal_plot->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)"); fMenuBar_plot->AddPopup(new TGHotString("&Save"), fMenuFile_plot, fMenuBarItemLayout_plot); fMenuBar_plot->AddPopup(new TGHotString("&Analize"), fMenuAnal_plot, fMenuBarItemLayout_plot); } Bool_t TGAppMainFrame::CloseWindow(){ Int_t ret = 0; new TGMsgBox(gClient->GetRoot(), fMain, fMain->GetWindowName(), "Really want to close the window?", kMBIconExclamation, kMBYes | kMBNo, &ret); // if (ret == kMBYes) return fMain->CloseWindow(); if (ret == kMBYes){ gApplication->Terminate(0); } return kFALSE; } void TGAppMainFrame::InitRoot(){ X0 = 620.5; //1241.0/2.0 Y0 = 575.5; //1151.0/2.0 PI = TMath::Pi(); Zero = 0; //data is buffered? 1 - yes m_graph_cut = 0;//no user graph cut initially // c123 = new TCanvas*[DATANT]; alldata_nt = new TNtuple("alldata_nt", "alldata", "x:y:inten:clust:sigtag:sigtag_count"); alldata_h2 = new TH2F("alldata_h2", "alldata", 1242, 0.0, 1242.0, 1152, 0.0, 1152.0); alldata_h1 = new TH1F("alldata_h1", "alldata", 1242, 0.0, 1242.0); data_i = 0; draw_i = 0; r_Flag = 0; Subtract_background = 1; //if 1 subtract bg, if 0 not. CLUST_PIX = 100; //default number of pixels in cluster CLUST_INT_MIN = 0.0; //default min. cluster int CLUST_INT_MAX = 3000.0; //default max. cluster int //Root init for Tiff conversion m_Clusterize = 1; m_Binarize = 1; s_Clust = string(itoa(m_Clusterize)); m_Flag = 1; s_Flag = string(itoa(m_Flag)); m_FlagCut = 10; m_Predisc = 50; m_Prepix = 2; m_Frame = -1; m_NoClus = 0; filename = new char[128]; bgfilename = NULL; m_doNoiseShift = 1; //do we want noise back shift?Yes (1), No (0) //log stream open TDatime * datime = new TDatime(); string day = string(itoa(datime->GetDay())); string month = string(itoa(datime->GetMonth())); string year = string(itoa(datime->GetYear())); string sdmy = "log_" + day + "_" + month + "_" + year + ".txt"; ofstream log; log.open(sdmy.c_str(), ios_base::app); log << "#---------------------------------------#" << endl; log << datime->AsSQLString() << endl; log << "#---------------------------------------#" << endl; log.close(); logdmyname = sdmy; gClient->GetColorByName("#ffffff",wcolor); gClient->GetColorByName("#2B547E",bcolor); gClient->GetColorByName("#151B54",tcolor); gClient->GetColorByName("#AFDCEC",tbgcolor); c_distcut = NULL; } void TGAppMainFrame::InitPlot(){ //plot alldata plot_alldata = new TGMdiFrame(fMainFrame, 500, 300); fMenuBar_plot = new TGMdiMenuBar(plot_alldata, 10, 5); plot_alldata->AddFrame(fMenuBar_plot, new TGLayoutHints(kLHintsTop | kLHintsExpandX)); plot_alldata->DontCallClose(); plot_alldata->SetWindowName("All data"); fRootEmbeddedCanvas_alldata = new TRootEmbeddedCanvas(0,plot_alldata,500,300,kSunkenFrame, ucolor); wfRootEmbeddedCanvas = fRootEmbeddedCanvas_alldata->GetCanvasWindowId(); c_alldata = new TCanvas("c_alldata", 10, 10, wfRootEmbeddedCanvas); c_alldata->Divide(1,2); fRootEmbeddedCanvas_alldata->AdoptCanvas(c_alldata); plot_alldata->AddFrame(fRootEmbeddedCanvas_alldata, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,2,2,2,2)); plot_alldata->SetMdiHints(kMdiDefaultHints | kMdiHelp); plot_alldata->MapSubwindows(); plot_alldata->Layout(); plot_alldata->Move(300, 100); } void TGAppMainFrame::InitTGMDI(){ tgmdiFrame = new TGMdiFrame(fMainFrame, 270, 500); //tgmdiFrame->Connect("CloseWindow()", "TGAppMainFrame", this, "CloseWindow()"); tgmdiFrame->DontCallClose(); // to avoid double deletions. fShutter = new TGShutter(tgmdiFrame, kSunkenFrame); AddShutterItem2("Generate Event list"); AddShutterItem1("Plot events"); fLayout = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY); tgmdiFrame->AddFrame(fShutter, fLayout); tgmdiFrame->MapSubwindows(); tgmdiFrame->SetWindowName("Shutter"); // tgmdiFrame->MapWindow(); tgmdiFrame->Layout(); tgmdiFrame->Move(0, 0);//500-30 } char * TGAppMainFrame::itoa(int x){ char * ret = new char[128]; sprintf(ret, "%d", x); return ret; } char * TGAppMainFrame::ftoa(float x){ char * ret = new char[128]; sprintf(ret, "%f", x); return ret; } void TGAppMainFrame::BuffData(char * buff){ SetValues(); ifstream indata; indata.open(buff); Float_t xt, yt, intent, clustt, sigtag, sigtag_count; while(1){ if(!(indata.good()))break; indata >> xt >> yt >> intent >> clustt >> sigtag >> sigtag_count; if(sigtag == -999) m_NoClus = 1; alldata_nt->Fill(xt, yt, intent, clustt, sigtag, sigtag_count); } // cout << "m_NoClus = " << m_NoClus << endl; // cout << "Entries in alldata = " << alldata_nt->GetEntries() << endl; indata.close(); Zero = 1; } //We got everything up until now, let's draw out the stuff... void TGAppMainFrame::DrawData(char * FileName){ if(Zero == 1){ draw_i++; SetValues(); /// // cout << "All Entries: " << alldata_nt->GetEntries() << endl; // TH2F * data_h2 = (TH2F*)gROOT->FindObject("data_image"); //TH1F * data_h1 = (TH1F*)gROOT->FindObject("data_colsum"); //if(data_h2)delete data_h2; string onumb = string(itoa(draw_i)); string onameh2 = "data_image" + onumb; TH2F * data_h2 = new TH2F(onameh2.c_str(), "", 1252, 0.0, 1252.0, 1151, 0.0, 1151.0); //if(data_h1)delete data_h1; string onameh1 = "data_colsum" + onumb; TH1F * data_h1 = new TH1F(onameh1.c_str(), "", 1252, 0.0, 1252.0); data_h2->GetXaxis()->SetTitle("pixel x"); data_h2->GetXaxis()->CenterTitle(); data_h2->GetYaxis()->SetTitle("pixel y"); data_h2->GetYaxis()->CenterTitle(); data_h1->GetXaxis()->SetTitle("pixel x"); data_h1->GetXaxis()->CenterTitle(); data_h1->GetYaxis()->SetTitle("Column sum"); data_h1->GetYaxis()->CenterTitle(); Float_t angle = 0.0; Float_t xtransf = 0.0;// Float_t ytransf = 0.0;// TVector3 v(2.0, 1.0,0.0); angle = ROTATE_FRAME*PI/180.0; Float_t xt, yt, intent, clustt; ifstream indata; indata.open(FileName); cout << endl; cout << color(green, white) << "|------" << flush; cout << color(black, white) << flush; cout << " Opening event list file: " << flush; cout << color(blue, white) << FileName << endl; cout << color(black, white) << flush; Float_t xt, yt, intent, clustt, sigtag, sigtag_count; TNtuple * temp_nt = (TNtuple*)gROOT->FindObject("temp_nt"); if(temp_nt)delete temp_nt; temp_nt = new TNtuple("temp_nt", "temp_nt", "xt:yt:intent:clustt:sigtag:sigtag_count"); while(1){ if(!(indata.good()))break; indata >> xt >> yt >> intent >> clustt >> sigtag >> sigtag_count; temp_nt->Fill(xt, yt, intent, clustt, sigtag, sigtag_count); } temp_nt->SetBranchAddress("xt", &xt); temp_nt->SetBranchAddress("yt", &yt); temp_nt->SetBranchAddress("intent", &intent); temp_nt->SetBranchAddress("clustt", &clustt); temp_nt->SetBranchAddress("sigtag", &sigtag); temp_nt->SetBranchAddress("sigtag_count", &sigtag_count); int cur, next, step; Float_t fcur, fnext, fnexti, inten_norm; int ci = -1; while(ci < temp_nt->GetEntries()){ ci++; //cout << "ci: " << ci << endl; temp_nt->GetEntry(ci); fcur = sigtag_count; temp_nt->GetEntry(ci+1); fnext = sigtag_count; inten_norm = 0; temp_nt->GetEntry(ci); if(sigtag == -999){//non-clusterized data if(intent >= CLUST_INT_MIN && intent <= CLUST_INT_MAX && clustt <= CLUST_PIX){ if(r_Flag == 0){ if(m_Binarize == 1)data_h2->Fill(xt, yt, 1.0); if(m_Binarize == 0)data_h2->Fill(xt,yt, intent); //cout << x << ", " << y << endl; } if(r_Flag == 1){ xtransf = xt - X0; ytransf = yt - Y0; v.SetXYZ(xtransf, ytransf, 0.0); v.RotateZ(angle); xtransf = v.X() + X0; ytransf = v.Y() + Y0; if(m_Binarize == 1)data_h2->Fill(xtransf, ytransf, 1.0); if(m_Binarize == 0)data_h2->Fill(xtransf, ytransf, intent); } } } if(sigtag == 1){//clust.data, candidate // || sigtag == -1)//clust. data, else //cout << "starting normalizing" << endl; for(int i = 0 ; i < clustt; i++){ temp_nt->GetEntry(ci+i); inten_norm += intent; } if(inten_norm >= CLUST_INT_MIN && inten_norm <= CLUST_INT_MAX && clustt <= CLUST_PIX){ for(int i = 0 ; i < clustt; i++){ temp_nt->GetEntry(ci+i); if(r_Flag == 1){ xtransf = xt - X0; ytransf = yt - Y0; v.SetXYZ(xtransf, ytransf, 0.0); v.RotateZ(angle); xtransf = v.X() + X0; ytransf = v.Y() + Y0; if(m_Binarize == 1)data_h2->Fill(xtransf, ytransf, (float)(intent/inten_norm)); if(m_Binarize == 0)data_h2->Fill(xtransf, ytransf, intent); } if(r_Flag == 0){ if(m_Binarize == 1)data_h2->Fill(xt, yt, (float)(intent/inten_norm)); if(m_Binarize == 0)data_h2->Fill(xt, yt, intent); } } } ci = ci + clustt - 1; } } temp_nt->ResetBranchAddresses(); Zero = 1; int colsum = 0; for(int fx = 1; fx <= data_h2->GetXaxis()->GetNbins(); fx++){ colsum = 0; for(int fy = 1; fy <= data_h2->GetYaxis()->GetNbins(); fy++){ colsum += data_h2->GetBinContent(fx, fy); } data_h1->SetBinContent(fx, colsum); } TGMdiFrame * plot_dist = new TGMdiFrame(fMainFrame, 600, 400); TRootEmbeddedCanvas * fRECanvas_dist = new TRootEmbeddedCanvas(0,plot_dist,600,400,kSunkenFrame, ucolor); Int_t wfRECanvas_dist = fRECanvas_dist->GetCanvasWindowId(); TCanvas * c_dist = new TCanvas("Distributions", 1, 1, wfRECanvas_dist); c_dist->Divide(1,2); fRECanvas_dist->AdoptCanvas(c_dist); c_dist->SetBorderMode(0); c_dist->cd()->SetBorderMode(0); c_dist->cd()->GetFrame()->SetBorderMode(0); plot_dist->AddFrame(fRECanvas_dist, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,0,0,0,0)); plot_dist->SetMdiHints(kMdiDefaultHints | kMdiHelp); string Filename = string(FileName); int found = Filename.find_last_of("/\\"); string name = Filename.substr(found+1, Filename.size()); plot_dist->SetWindowName(Filename.c_str()); plot_dist->MapSubwindows(); plot_dist->Layout(); plot_dist->Move(150, 140); c_dist->cd(1); data_h2->SetStats(kFALSE); data_h2->Draw("cols"); TPaveText * pt1 = new TPaveText(0.85, 0.65, 1.0, 1.0, "NDC");//NDC sets coords relative to pad dim Int_t ci; // for color index setting ci = TColor::GetColor("#fff2ab");//lightyellow //gClient->GetColorByName("#fff2ab",ci); pt1->SetFillColor(ci); pt1->SetTextSize(0.0528765); pt1->SetTextAlign(12); ci = TColor::GetColor("#32a629");//greenish, 4 = blue //gClient->GetColorByName("#32a629",ci); pt1->SetTextColor(ci); pt1->SetTextFont(20); string s2 = "Normalized clusts: "; string s2_n; if(m_Binarize == 0)s2_n = "No"; if(m_Binarize == 1)s2_n = "Yes"; s2 = s2 + s2_n; string s3 = "Pix adu: "; string s3_n = string(itoa(fNumericEntries[0]->GetNumber()));//clust_int_min s3 = s3 + s3_n + " - "; string s4_n = string(itoa(fNumericEntries[1]->GetNumber()));//clust_int_max s3 = s3 + s4_n; string s5 = "# of pixs/clust: "; string s5_n = string(itoa(fNumericEntries[2]->GetNumber()));//clust_pix s5 = s5 + s5_n; string s6 = "Rot. by: "; string s6_n = string(ftoa(ROTATE_FRAME)); s6 = s6 + s6_n; pt1->AddText(s2.c_str()); pt1->AddText(s3.c_str()); pt1->AddText(s5.c_str()); pt1->AddText(s6.c_str()); pt1->Draw("c"); //to draw your text object c_dist->cd(2); data_h1->SetStats(kFALSE); data_h1->Draw(); c_dist->Update(); cout << color(green,white) << "|------" << flush; cout << color(black, white) << flush; cout << " Ready!" << endl; }else{ cout << endl; cout << color(white, green) << "|------" << flush; cout << " No data, please open an event list file!" << endl; cout << color(black, white) << flush; } break; } void TGAppMainFrame::DrawAlldata(){ // cout << plot_alldata->IsMapSupwindows() << endl; Float_t sigtag, sigtag_count; if(Zero == 1){ SetValues(); // gClient->GetColorByName("#7d99d1",ucolor); //if(plot_alldata->IsMapSubwindows() == kFALSE){ alldata_h2 = (TH2F*)gROOT->FindObject("alldata_h2"); if(alldata_h2)delete alldata_h2; alldata_h2 = new TH2F("alldata_h2", "", 1242, 0.0, 1242.0, 1152, 0.0, 1152.0); alldata_h1 = (TH1F*)gROOT->FindObject("alldata_h1"); if(alldata_h1)delete alldata_h1; alldata_h1 = new TH1F("alldata_h1", "", 1242, 0.0, 1242.0); alldata_h2->GetXaxis()->SetTitle("pixel x"); alldata_h2->GetXaxis()->CenterTitle(); alldata_h2->GetYaxis()->SetTitle("pixel y"); alldata_h2->GetYaxis()->CenterTitle(); alldata_h1->GetXaxis()->SetTitle("pixel x"); alldata_h1->GetXaxis()->CenterTitle(); alldata_h1->GetYaxis()->SetTitle("column sum"); alldata_h1->GetYaxis()->CenterTitle(); alldata_nt->SetBranchAddress("x", &x); alldata_nt->SetBranchAddress("y", &y); alldata_nt->SetBranchAddress("inten", &inten); alldata_nt->SetBranchAddress("clust", &clust); alldata_nt->SetBranchAddress("sigtag", &sigtag); alldata_nt->SetBranchAddress("sigtag_count", &sigtag_count); Float_t angle = 0.0; Float_t xtransf = 0.0;// Float_t ytransf = 0.0;// TVector3 v(2.0, 1.0,0.0); angle = ROTATE_FRAME*PI/180.0; // cout << "Pi: " << PI << endl; //cout << "Angle: " << angle << endl; if(r_Flag == 1){ cout << color(green, white) << "|------" << flush; cout << color(black, white) << flush; cout << " Rotation around center by degree: " << flush; char * rot = ftoa(ROTATE_FRAME); cout << color(blue, white) << rot << endl; cout << color(black, white) << flush; } int cur, next, step; Float_t fcur, fnext, fnexti, inten_norm; int ci = -1; while(ci < alldata_nt->GetEntries()){ ci++; //cout << "ci: " << ci << endl; alldata_nt->GetEntry(ci); fcur = sigtag_count; alldata_nt->GetEntry(ci+1); fnext = sigtag_count; inten_norm = 0; alldata_nt->GetEntry(ci); if(sigtag == -999){//non-clusterized data if(inten >= CLUST_INT_MIN && inten <= CLUST_INT_MAX && clust <= CLUST_PIX){ if(r_Flag == 0){ if(m_Binarize == 1)alldata_h2->Fill(x, y); if(m_Binarize == 0)alldata_h2->Fill(x, y, inten); //cout << x << ", " << y << endl; } if(r_Flag == 1){ xtransf = x - X0; ytransf = y - Y0; v.SetXYZ(xtransf, ytransf, 0.0); v.RotateZ(angle); xtransf = v.X() + X0; ytransf = v.Y() + Y0; if(m_Binarize == 1)alldata_h2->Fill(xtransf, ytransf); if(m_Binarize == 0)alldata_h2->Fill(xtransf, ytransf, inten); } } } if(sigtag == 1){//clust.data, candidate // || sigtag == -1)//clust. data, else //cout << "starting normalizing" << endl; for(int i = 0 ; i < clust; i++){ alldata_nt->GetEntry(ci+i); inten_norm += inten; } // cout << "inten_norm: " << inten_norm << endl; if(inten_norm >= CLUST_INT_MIN && inten_norm <= CLUST_INT_MAX && clust <= CLUST_PIX){ for(int i = 0 ; i < clust; i++){ alldata_nt->GetEntry(ci+i); if(r_Flag == 1){ xtransf = x - X0; ytransf = y - Y0; v.SetXYZ(xtransf, ytransf, 0.0); v.RotateZ(angle); xtransf = v.X() + X0; ytransf = v.Y() + Y0; if(m_Binarize == 1)alldata_h2->Fill(xtransf, ytransf, (float)(inten/inten_norm)); if(m_Binarize == 0)alldata_h2->Fill(xtransf, ytransf, inten); } if(r_Flag == 0){ if(m_Binarize == 1)alldata_h2->Fill(x, y, (float)(inten/inten_norm)); if(m_Binarize == 0)alldata_h2->Fill(x, y, inten); } } } ci = ci + clust - 1; } } int colsum = 0; for(int fx = 1; fx <= alldata_h2->GetXaxis()->GetNbins(); fx++){ colsum = 0; for(int fy = 1; fy <= alldata_h2->GetYaxis()->GetNbins(); fy++){ colsum += alldata_h2->GetBinContent(fx, fy); } alldata_h1->SetBinContent(fx, colsum); } // c_alldata->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)", "TGAppMainFrame", this, "EventInfo(Int_t, Int_t, Int_t, TObject*)"); c_alldata->cd(1); alldata_h2->SetStats(kFALSE); alldata_h2->Draw("cols"); TPaveText * pt1 = new TPaveText(0.85, 0.65, 1.0, 1.0, "NDC");//NDC sets coords relative to pad dim Int_t ci; // for color index setting ci = TColor::GetColor("#fff2ab");//lightyellow //gClient->GetColorByName("#fff2ab",ci); pt1->SetFillColor(ci); pt1->SetTextSize(0.0528765); pt1->SetTextAlign(12); ci = TColor::GetColor("#32a629");//greenish, 4 = blue //gClient->GetColorByName("#32a629",ci); pt1->SetTextColor(ci); pt1->SetTextFont(20); string s2 = "Normalize clusts: "; string s2_n; if(m_Binarize == 0)s2_n = "No"; if(m_Binarize == 1)s2_n = "Yes"; s2 = s2 + s2_n; string s3 = "Pix adc: "; string s3_n = string(itoa(fNumericEntries[0]->GetNumber()));//clust_int_min s3 = s3 + s3_n + " - "; string s4_n = string(itoa(fNumericEntries[1]->GetNumber()));//clust_int_max s3 = s3 + s4_n; string s5 = "# of pixs/clust: "; string s5_n = string(itoa(fNumericEntries[2]->GetNumber()));//clust_pix s5 = s5 + s5_n; string s6 = "Rot. by: "; string s6_n = string(ftoa(ROTATE_FRAME)); s6 = s6 + s6_n; pt1->AddText(s2.c_str()); pt1->AddText(s3.c_str()); pt1->AddText(s5.c_str()); pt1->AddText(s6.c_str()); pt1->Draw("c"); //to draw your text object c_alldata->cd(2); alldata_h1->SetStats(kFALSE); alldata_h1->Draw(); c_alldata->Update(); alldata_nt->ResetBranchAddresses(); }else{ cout << endl; cout << "No data, please open an event list file!" << endl; } } void TGAppMainFrame::SetValues(){ CLUST_INT_MIN = fNumericEntries[0]->GetNumber(); CLUST_INT_MAX = fNumericEntries[1]->GetNumber(); CLUST_PIX = fNumericEntries[2]->GetNumber(); // cout << endl; // cout << "Cluster Int. Min: " << CLUST_INT_MIN << endl; // cout << "Cluster Int. Max: " << CLUST_INT_MAX << endl; // cout << "# of pixels in cluster Int. Min: " << CLUST_PIX << endl; ROTATE_FRAME = 0.0; if(r_Flag == 1){ ROTATE_FRAME = fNumericEntries[3]->GetNumber(); } } void TGAppMainFrame::Empty(){ cout << "|------" << flush; cout << " Setting everything to zero... " << flush; alldata_h1->Reset(); alldata_h2->Reset(); alldata_nt = (TNtuple*)gROOT->FindObject("alldata"); if(alldata_nt)delete alldata_nt; alldata_nt = new TNtuple("alldata_nt", "alldata", "x:y:inten:clust:sigtag:sigtag_count"); Zero = 0; // cout << color(red, white) << "|------" << flush; // cout << color(, white) << flush; // cout << color(black, white) << flush; cout << " okay, event list empty! " << endl; } void TGAppMainFrame::SetStatusText(const char *txt, Int_t pi){ //Set text in status bar fSStatusBar->SetText(txt, pi); } void TGAppMainFrame::EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected){ //writes the event status in the status bar parts const char *text0 = NULL; const char *text1 = NULL; const char *text3 = NULL; char text2[50]; // text0 = selected->GetTitle(); text0 = selected->GetTitle(); SetStatusText(text0, 0); // text1 = selected->GetName(); text1 = selected->GetName(); SetStatusText(text1, 1); if(event == kKeyPress){ sprintf(text2, "%c", (char) px); }else{ sprintf(text2, "%d,%d", px, py); } SetStatusText(text2, 2); // text3 = selected->GetObjectInfo(px, py); text3 = selected->GetObjectInfo(px, py); SetStatusText(text3, 3); } //---------------------------------------------------------------------- //Tiff convert functions //if multi - disable bg open void TGAppMainFrame::HandleCheckButton1(){ // Handle check button1 item. if(fCheckButton3912->IsDown() == kTRUE){ fCheckButton3913->SetState(kButtonUp); fTextButton3925_0->SetEnabled(kFALSE); fNumberEntry_frame->SetState(kTRUE); }elseif(fCheckButton3912->IsDown() == kFALSE){ fCheckButton3913->SetState(kButtonDown); fTextButton3925_0->SetEnabled(kTRUE); fNumberEntry_frame->SetState(kFALSE); } } //if single - enable bg open void TGAppMainFrame::HandleCheckButton2(){ // Handle check button2 item. if(fCheckButton3913->IsDown() == kTRUE){ fCheckButton3912->SetState(kButtonUp); fTextButton3925_0->SetEnabled(kTRUE); fNumberEntry_frame->SetState(kFALSE); }elseif(fCheckButton3913->IsDown() == kFALSE){ fCheckButton3912->SetState(kButtonDown); fTextButton3925_0->SetEnabled(kFALSE); fNumberEntry_frame->SetState(kTRUE); } } void TGAppMainFrame::HandleCheckButton3(){ if(fCheckButton_flag->IsDown() == kTRUE){ m_Flag = 1; m_doNoiseShift = 1; //do we want noise back shift?Yes (1), No (0) // fNumberEntry_frame->SetState(kTRUE); }elseif(fCheckButton_flag->IsDown() == kFALSE){ m_Flag = 1; m_doNoiseShift = 0; //do we want noise back shift?Yes (1), No (0) } SetValuesConvert(); } void TGAppMainFrame::HandleCheckButton4(){ if(fCheckButtonClusterize->IsDown() == kTRUE){ m_Clusterize = 1; fNumberEntry_prepix->SetState(kTRUE); }elseif(fCheckButtonClusterize->IsDown() == kFALSE){ m_Clusterize = 0; fNumberEntry_prepix->SetState(kFALSE); } SetValuesConvert(); } void TGAppMainFrame::HandleCheckButtonRotate(){ if(fCheckButton_rotate->IsDown() == kTRUE){ r_Flag = 1; fNumericEntries[3]->SetState(kTRUE); }elseif(fCheckButton_rotate->IsDown() == kFALSE){ r_Flag = 0; fNumericEntries[3]->SetState(kFALSE); } } void TGAppMainFrame::HandleCheckButtonCut(){ if(fCheckButton_cut->IsDown() == kTRUE){ fNumericEntries[4]->SetState(kTRUE); fNumericEntries[5]->SetState(kTRUE); fNumericEntries[6]->SetState(kTRUE); fNumericEntries[7]->SetState(kTRUE); m_graph_cut = 1; }elseif(fCheckButton_cut->IsDown() == kFALSE){ fNumericEntries[4]->SetState(kFALSE); fNumericEntries[5]->SetState(kFALSE); fNumericEntries[6]->SetState(kFALSE); fNumericEntries[7]->SetState(kFALSE); m_graph_cut = 0; } } void TGAppMainFrame::HandleCheckButtonBin(){ if(fCheckButton_bin->IsDown() == kTRUE){ m_Binarize = 1; }elseif(fCheckButton_bin->IsDown() == kFALSE){ m_Binarize = 0; } } void TGAppMainFrame::OpenFile(){ SetValuesConvert(); if(fCheckButton3913->IsDown() == kTRUE && fCheckButton3912->IsDown() == kFALSE){//single tiff(s) static TString dir("/Users/larry/data/"); TGFileInfo fi1; fi1.fIniDir = StrDup(dir); fi1.SetMultipleSelection(kTRUE); fi1.fFilename = NULL; new TGFileDialog(gClient->GetRoot(), fMain, kFDOpen,&fi1); int namei = 0; char * buff = NULL; ofstream log; log.open(logdmyname.c_str(), ios_base::app); if(fi1.fFileNamesList){ if(bgfilename){ TDatime * datime = new TDatime(); string hour = string(itoa(datime->GetHour())); string min = string(itoa(datime->GetMinute())); string sec = string(itoa(datime->GetSecond())); string time = hour + ":" + min + ":" + sec; log << "[_____] At " << time << " [______________] " << endl; cout << endl; cout << color(red, white) << "[_____] At " << time << " [______________] " << endl; cout << "TIFF->Event list generation" << endl; log << "TIFF->Event list generation" << endl; cout << color(black, white) << flush; log << "Event list parameters" << endl; log << "Event list parameters: " << endl; log << "\t" << "Background TIFF file: " << BGFilename << endl; if(m_Clusterize == 0)log << "\t" << "Clusterization: No" << endl; if(m_Clusterize == 1)log << "\t" << "Clusterization: Yes" << endl; log << "\t" << " Pulse height level pre-discrimination: " << s_Predisc << endl; if(m_Clusterize == 1){ log << "\t" << " Cluster size pre-discrimination: " << flush; log << s_Prepix << endl; } //check if alldata.txt already exist and if yes, delete it TObjString *el0; TIter next0(fi1.fFileNamesList); el0 = (TObjString *) next0(); TString t0 = el0->GetString(); buff = t0.Data(); string slogfile = string(buff); int found = slogfile.find_last_of("/"); string folder = slogfile.substr(0, found+1); if(m_Clusterize == 0)slogfile = folder + "alldata_PCUT" + string(itoa(m_Predisc)) + "_noclus.txt"; if(m_Clusterize == 1){ slogfile = folder + "alldata_PCUT" + string(itoa(m_Predisc)) + "_PPIX" + s_Prepix + "_clus.txt"; } Long_t id; Long_t size; Long_t flags; Long_t modtime; int resstat = gSystem->GetPathInfo(slogfile.c_str(), &id, &size, &flags, &modtime); if(resstat == 0){ ofstream dummy_of; dummy_of.open(slogfile.c_str()); dummy_of.close(); } TObjString *el1 = NULL; TIter next(fi1.fFileNamesList); while((el1 = (TObjString *) next())){ namei++; //new TFile(el->GetString(), "update"); TString t1 = el1->GetString(); buff = t1.Data(); if(buff){ log << "\t" << "Input single frame tiff file(s): " << buff << endl; //cout << color(red, white) << "|------" << flush; //cout << color(black, white) << flush; //cout << " Converting single frame tiff file(s): " << flush; //cout << color(blue, white) << buff << endl; //cout << color(black, white) << "" << flush; BuffSingleTiff(buff); filename = buff; mac_flag = 1; pc_flag = 0; } } cout << "Event list parameters: " << endl; cout << color(red, white) << "|------" << flush; cout << color(black, white) << flush; cout << " Background TIFF file: " << flush; cout << color(blue, white) << BGFilename << endl; cout << color(black, white) << flush; cout << color(red, white) << "|------" << flush; cout << color(black, white) << flush; cout << " Clusterization: "<< flush; if(m_Clusterize == 0)cout << color(blue, white) << "No" << endl; if(m_Clusterize == 1)cout << color(blue, white) << "Yes" << endl; cout << color(black, white) << flush; cout << color(red, white) << "|------" << flush; cout << color(black, white) << flush; cout << " Pulse height level pre-discrimination: " << flush; cout << color(blue, white) << s_Predisc << endl; cout << color(black, white) << flush; if(m_Clusterize ==1){ cout << color(red, white) << "|------" << flush; cout << color(black, white) << flush; cout << " Cluster size pre-discrimination: " << flush; cout << color(blue, white) << s_Prepix << endl; cout << color(black, white) << flush; } log << "\t" << "Output event list file: " << flush; log << slogfile << endl; log.close(); cout << color(red, white) << "|------" << flush; cout << color(black, white) << flush; cout << " Output event list file: " << flush; cout << color(blue, white) << slogfile << endl; cout << color(black, white) << flush; cout << color(red, white) << flush; cout << "Event list generator ended" << endl; cout << color(black, white) << flush; }else{ cout << color(red, white) << flush; cout << "No bg TIFF file set" << endl; cout << color(black, white) << flush; } }else{ } }else if(fCheckButton3912->IsDown() == kTRUE && fCheckButton3913->IsDown() == kFALSE){ bgfilename = NULL; static TString dir("/Users/larry/data/"); TGFileInfo fi; fi.fFileTypes = filetypesin; fi.fIniDir = StrDup(dir); fi.fFilename = NULL; //printf("fIniDir = %s\n", fi.fIniDir); new TGFileDialog(gClient->GetRoot(), fMain, kFDOpen,&fi); //printf("Open file: %s (dir: %s)\n", fi.fFilename, fi.fIniDir); if(fi.fFilename){ char * buff = NULL; TString * t = new TGString(fi.fFilename); buff = t->Data(); if(buff){ ReadMultiTiff(buff); filename = buff; mac_flag = 0; pc_flag = 1; } }else{ } }else{ cerr << "No button selected: multiple frame tiff / single frame tiff" << endl; } } void TGAppMainFrame::OpenBgFile(){ static TString dir("/Users/larry/data/"); TGFileInfo fi; fi.fFilename = NULL; fi.fFileTypes = filetypesin; fi.fIniDir = StrDup(dir); //printf("fIniDir = %s\n", fi.fIniDir); new TGFileDialog(gClient->GetRoot(), fMain, kFDOpen, &fi); if(fi.fFilename){ //printf("Open file: %s (dir: %s)\n", fi.fFilename, fi.fIniDir); BGFilename = string(fi.fFilename); bgfilename = BGFilename.c_str(); cout << endl; cout << color(red, white) << "|------" << flush; cout << color(black, white) << flush; cout << " Single frame TIFF bckg file is set to: " << flush; cout << color(blue, white) << BGFilename << endl; cout << color(black, white) << flush; }else{ } } void TGAppMainFrame::DrawNoise(){ //Draw noise TH1F * noise_h = (TH1F*)gROOT->FindObject("noise_h"); if(noise_h)delete noise_h; noise_h = new TH1F("noise_h", "Noise", 600, -100.0, 500.0); //noise_h->GetXaxis()->SetTitle("pixel intensity"); //noise_h->GetXaxis()->CenterTitle(); //noise_h->GetYaxis()->SetTitle("Entries"); //noise_h->GetYaxis()->CenterTitle(); int x = 0; int found = 0; if(tiff_filename.c_str()){ found = tiff_filename.find_last_of("/\\"); string dir = tiff_filename.substr(0, found+1); string ofilename = dir + string("noise.txt"); cout << "Noise file: " << ofilename << endl; ifstream indata; indata.open(ofilename.c_str()); int bin = 1; while(1){ if(!(indata.good()))break; indata >> x; // noise_h->Fill((Float_t)x); noise_h->SetBinContent(bin, x); bin++; } indata.close(); TGMdiFrame * plot_noise = new TGMdiFrame(fMainFrame, 400, 400); TRootEmbeddedCanvas * fRECanvas_noise = new TRootEmbeddedCanvas(0,plot_noise,380,380,kSunkenFrame, ucolor); Int_t wfRECanvas_noise = fRECanvas_noise->GetCanvasWindowId(); TCanvas * c_noise = new TCanvas("Noise", 1, 1, wfRECanvas_noise); fRECanvas_noise->AdoptCanvas(c_noise); c_noise->SetBorderMode(0); c_noise->cd()->SetBorderMode(0); c_noise->cd()->GetFrame()->SetBorderMode(0); plot_noise->AddFrame(fRECanvas_noise, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,0,0,0,0)); plot_noise->SetMdiHints(kMdiDefaultHints | kMdiHelp); plot_noise->SetWindowName("Frame noise"); plot_noise->MapSubwindows(); plot_noise->Layout(); c_noise->cd(); noise_h->Draw(); } } void TGAppMainFrame::SetValuesConvert(){ m_Predisc = fNumberEntry3916->GetNumber(); string s_Predisc_s = string(itoa(m_Predisc)); s_Predisc = s_Predisc_s; m_Prepix = fNumberEntry_prepix->GetNumber(); s_Prepix = string(itoa(m_Prepix)); s_Flag = string(this->itoa(m_Flag)); m_FlagCut = 10; s_FlagCut = string(itoa(m_FlagCut)); m_Frame = fNumberEntry_frame->GetNumber(); s_Frame = string(itoa(m_Frame)); if(fCheckButtonClusterize->IsDown() == kTRUE)m_Clusterize = 1; if(fCheckButtonClusterize->IsDown() != kTRUE)m_Clusterize = 0; s_Clust = string(itoa(m_Clusterize)); s_doNoiseShift = string(itoa(m_doNoiseShift)); } int TGAppMainFrame::BuffSingleTiff(char * tiffile){ SetValuesConvert(); // string opentiff = "proctiffsingle.exe '"; string opentiff = "proctiffsingle '"; string bg = BGFilename; tiff_filename = string(tiffile); opentiff = opentiff + string(tiffile) + "' '" + bg + "' " + s_Predisc + " " + s_Prepix + " " + s_Flag + " " + s_FlagCut + " " + s_Clust + " " + s_doNoiseShift; cout << opentiff.c_str() << endl; gSystem->Exec(opentiff.c_str()); //Output file info is written to log in the TGAppMainFrame::OpenFile method return 0; } int TGAppMainFrame::ReadMultiTiff(char * tiffile){ SetValuesConvert(); // string opentiff = "proctiffmulti.exe '"; string opentiff = "proctiffmulti '"; string slogfile = string(tiffile); opentiff = opentiff + string(tiffile) + "' " + s_Predisc + " " + s_Prepix + " " + s_Flag + " " + s_Frame + " " + s_FlagCut + " " + s_Clust + " " + s_doNoiseShift; tiff_filename = string(tiffile); //cout << opentiff.c_str() << endl; ofstream log; log.open(logdmyname.c_str(), ios_base::app); TDatime * datime = new TDatime(); string hour = string(itoa(datime->GetHour())); string min = string(itoa(datime->GetMinute())); string sec = string(itoa(datime->GetSecond())); string time = hour + ":" + min + ":" + sec; log << "[_____] At " << time << " [______________] " << endl; cout << endl; cout << color(red, white) << "[_____] At " << time << " [______________] " << endl; cout << "TIFF->Event list generation" << endl; cout << color(black, white) << flush; log << "TIFF->Event list generation" << endl; log << "Event list parameters: " << endl; if(m_Clusterize == 0)log << "\t" << "Clusterization: No" << endl; if(m_Clusterize == 1)log << "\t" << "Clusterization: Yes" << endl; log << "\t" << "Frame(s) (-1 meaning all): " << s_Frame << endl; log << "\t" << "Pulse height level pre-discrimination: " << s_Predisc << endl; if(m_Clusterize ==1){ log << "\t" << " Cluster size pre-discrimination: " << flush; log << s_Prepix << endl; } log << "\t" << "Generating event list from multi frame tiff file: " << slogfile << endl; cout << opentiff.c_str() << endl; gSystem->Exec(opentiff.c_str()); cout << color(black, white) << flush; cout << "Event list parameters: " << endl; cout << color(red, white) << "|------" << flush; cout << color(black, white) << flush; cout << " Clusterization: " << flush; if(m_Clusterize == 0)cout << color(blue, white) << "No" << endl; if(m_Clusterize == 1)cout << color(blue, white) << "Yes" << endl; cout << color(red, white) << "|------" << flush; cout << color(black, white) << flush; cout << " Frame(s) [-1: all]: " << flush; cout << color(blue, white) << s_Frame << endl; cout << color(red, white) << "|------" << flush; cout << color(black, white) << flush; cout << " Pulse height pre-discrimination level: " << flush; cout << color(blue, white) << s_Predisc << endl; if(m_Clusterize ==1){ cout << color(red, white) << "|------" << flush; cout << color(black, white) << flush; cout << " Cluster size pre-discrimination: " << flush; cout << color(blue, white) << s_Prepix << endl; cout << color(black, white) << flush; } cout << color(red, white) << "|------" << flush; cout << color(black, white) << flush; cout << " Generating event list from multi frame tiff file: " << flush; cout << color(blue, white) << slogfile << endl; log << "\t" << "Output event list file: "; if(m_Clusterize == 1){ slogfile = slogfile + "_PCUT" + string(itoa(m_Predisc)) + "_PPIX" + s_Prepix + "_clus.txt"; } if(m_Clusterize == 0)slogfile = slogfile + "_PCUT" + string(itoa(m_Predisc)) + "_noclus.txt"; log << slogfile << endl; log.close(); cout << color(red, white) << "|------" << flush; cout << color(black, white) << flush; cout << " Output event list file: " << flush; cout << color(blue, white) << slogfile << endl; cout << color(black, white) << flush; cout << color(red, white) << "Event list generator ended" << endl; cout << color(black, white) << flush; return 0; } void TGAppMainFrame::AddShutterItem1(const char *name){ static int id = 5001; TGLayoutHints *l = new TGLayoutHints(kLHintsTop | kLHintsCenterX, 5, 5, 5, 0); TGShutterItem *item1 = new TGShutterItem(fShutter, new TGHotString(name), id++); TGCompositeFrame *container1 = (TGCompositeFrame *) item1->GetContainer(); TGVerticalFrame * fF1 = new TGVerticalFrame(container1, 250, 350); container1->AddFrame(fF1, new TGLayoutHints(kLHintsExpandX|kLHintsExpandY,2,2,2,2)); //_____________________________________________________ //Adding binarization checkbutton TGGroupFrame * fG3 = new TGGroupFrame(fF1, new TGString("Settings"),kVerticalFrame); fF1->AddFrame(fG3, new TGLayoutHints(kLHintsExpandX|kLHintsTop, 2, 2, 2, 2)); // fLabel[5] = new TGLabel(fG3, "Binarization"); // fLabel[5]->SetTextFont("-adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1", kTRUE); //fG3->AddFrame(fLabel[5], new TGLayoutHints(kLHintsLeft, 0, 0, 0,0)); fCheckButton_bin = new TGCheckButton(fG3,"Normalize cluster ph", 4997); fG3->AddFrame(fCheckButton_bin, new TGLayoutHints(kLHintsCenterX|kLHintsTop,0,0,0,0)); fCheckButton_bin->SetState(kButtonDown); fCheckButton_bin->Connect("Clicked()", "TGAppMainFrame", this, "HandleCheckButtonBin()"); //_____________________________________________________ //Adding discrimination features for (int i = 0; i <= 2; i++) { fLabel[i] = new TGLabel(fG3, numlabel[i]); // fLabel[i]->SetTextFont("-adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1", kTRUE); fG3->AddFrame(fLabel[i], new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2, 2, 2,2)); fNumericEntries[i] = new TGNumberEntry(fG3, numinit[i], 10, 3, (TGNumberFormat::EStyle) 0); fG3->AddFrame(fNumericEntries[i], new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2, 2, 2, 2)); } //___________________________________________ //adding rotation feature in a horizontal frame fLabel[3] = new TGLabel(fF1, numlabel[3]); //fLabel[3]->SetTextFont("-adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1", kTRUE); fF1->AddFrame(fLabel[3], new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2, 2, 2,2)); TGHorizontalFrame * fhori1 = new TGHorizontalFrame(fF1, 100, 20); fF1->AddFrame(fhori1, new TGLayoutHints(kLHintsTop|kLHintsCenterX,2,2,2,2)); fNumericEntries[3] = new TGNumberEntry(fhori1, numinit[3], 6, 3,(TGNumberFormat::kNESRealTwo),(TGNumberFormat::kNEAAnyNumber), (TGNumberFormat::kNELNoLimits)); fNumericEntries[3]->SetState(kFALSE); fhori1->AddFrame(fNumericEntries[3], new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2, 2, 2, 2)); fCheckButton_rotate = new TGCheckButton(fhori1,"", 4999); fhori1->AddFrame(fCheckButton_rotate, new TGLayoutHints(kLHintsCenterX | kLHintsTop,2,2,2,2)); // fCheckButton_rotate->MoveResize(32,56,112,20); fCheckButton_rotate->SetState(kButtonUp); fCheckButton_rotate->Connect("Clicked()", "TGAppMainFrame", this, "HandleCheckButtonRotate()"); //___________________________________________ //adding current cut window points feature TGGroupFrame * fG2 = new TGGroupFrame(fF1, new TGString("Rectangular ROI"),kVerticalFrame); fF1->AddFrame(fG2, new TGLayoutHints(kLHintsCenterX|kLHintsTop, 2, 2, 2, 2)); fLabel[4] = new TGLabel(fG2, numlabel[4]); fG2->AddFrame(fLabel[4], new TGLayoutHints(kLHintsCenterX|kLHintsTop, 0, 0, 0,0)); TGHorizontalFrame * fhori2 = new TGHorizontalFrame(fG2, 40, 20); fG2->AddFrame(fhori2, new TGLayoutHints(kLHintsCenterX|kLHintsTop,0,0,0,0)); fNumericEntries[4] = new TGNumberEntry(fhori2, numinit[4], 5, 3,(TGNumberFormat::EStyle) 0); fNumericEntries[4]->SetState(kFALSE); fhori2->AddFrame(fNumericEntries[4], new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2, 2, 2, 2)); fNumericEntries[5] = new TGNumberEntry(fhori2, numinit[5], 5, 3,(TGNumberFormat::EStyle) 0); fNumericEntries[5]->SetState(kFALSE); fhori2->AddFrame(fNumericEntries[5], new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2, 2, 2, 2)); fCheckButton_cut = new TGCheckButton(fhori2,"", 4998); fhori2->AddFrame(fCheckButton_cut, new TGLayoutHints(kLHintsLeft,0,0,0,0)); // fCheckButton_rotate->MoveResize(32,56,112,20); fCheckButton_cut->SetState(kButtonUp); fCheckButton_cut->Connect("Clicked()", "TGAppMainFrame", this,"HandleCheckButtonCut()"); fLabel[5] = new TGLabel(fG2, numlabel[5]); // fLabel[5]->SetTextFont("-adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1", kTRUE); fG2->AddFrame(fLabel[5], new TGLayoutHints(kLHintsLeft, 0, 0, 0,0)); TGHorizontalFrame * fhori3 = new TGHorizontalFrame(fG2, 40, 20); fG2->AddFrame(fhori3, new TGLayoutHints(kLHintsTop|kLHintsCenterX,0,0,0,0)); fNumericEntries[6] = new TGNumberEntry(fhori3, numinit[6], 5, 3,(TGNumberFormat::EStyle) 0); fNumericEntries[6]->SetState(kFALSE); fhori3->AddFrame(fNumericEntries[6], new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2, 2, 2, 2)); fNumericEntries[7] = new TGNumberEntry(fhori3, numinit[7], 5, 3,(TGNumberFormat::EStyle) 0); fNumericEntries[7]->SetState(kFALSE); fhori3->AddFrame(fNumericEntries[7], new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2, 2, 2, 2)); //___________________________________________ TGGroupFrame * fG1 = new TGGroupFrame(fF1, new TGString("All data buttons"),kVerticalFrame); fF1->AddFrame(fG1, new TGLayoutHints(kLHintsCenterX|kLHintsTop, 2, 2, 2, 2)); // TGTextButton *setvalues = new TGTextButton(fG1,"&Set"); // setvalues->Connect("Clicked()","TGAppMainFrame",this,"SetValues()"); // fG1->AddFrame(setvalues, new TGLayoutHints(kLHintsLeft,2,2,5,5)); TGTextButton *draw = new TGTextButton(fG1,"&Update/ReDraw"); draw->Connect("Clicked()","TGAppMainFrame",this,"DrawAlldata()"); fG1->AddFrame(draw, new TGLayoutHints(kLHintsTop|kLHintsCenterX,2,2,2,2)); TGTextButton *empty = new TGTextButton(fG1,"&Empty list"); empty->Connect("Clicked()","TGAppMainFrame",this,"Empty()"); fG1->AddFrame(empty, new TGLayoutHints(kLHintsTop|kLHintsCenterX,2,2,2,2)); fShutter->AddItem(item1); } void TGAppMainFrame::AddShutterItem2(const char *name){ static int id = 5002; TGShutterItem *item1 = new TGShutterItem(fShutter, new TGHotString(name), id++); TGCompositeFrame *container1 = (TGCompositeFrame *) item1->GetContainer(); //_____________________________________________________ ///big first horizontal frame containing 3 vertical frames fMainFrame3910_0 = new TGVerticalFrame(container1,250,300); container1->AddFrame(fMainFrame3910_0, new TGLayoutHints(kLHintsExpandX|kLHintsExpandY,2,2,2,2)); //first vertical frame in group frame 1 fMainFrame3910_1 = new TGVerticalFrame(fMainFrame3910_0); fMainFrame3910_0->AddFrame(fMainFrame3910_1, new TGLayoutHints(kLHintsTop|kLHintsLeft,2,2,2,2)); TGGroupFrame * fGroupframe1 = new TGGroupFrame(fMainFrame3910_1, new TGString("TIFF/Clusterization options"),kVerticalFrame); fMainFrame3910_1->AddFrame(fGroupframe1, new TGLayoutHints(kLHintsCenterY, 2, 2, 2, 2)); fCheckButtonClusterize = new TGCheckButton(fGroupframe1,"Clusterize", 39999); fGroupframe1->AddFrame(fCheckButtonClusterize, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); // fCheckButtonClusterize->MoveResize(32,32,112,20); fCheckButtonClusterize->SetState(kButtonDown); fCheckButtonClusterize->Connect("Clicked()", "TGAppMainFrame", this, "HandleCheckButton4()"); fCheckButton3912 = new TGCheckButton(fGroupframe1,"Multi frame tiff", 3912); fGroupframe1->AddFrame(fCheckButton3912, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); //fCheckButton3912->MoveResize(32,56,112,20); fCheckButton3912->SetState(kButtonDown); fCheckButton3912->Connect("Clicked()", "TGAppMainFrame", this, "HandleCheckButton1()"); fCheckButton3913 = new TGCheckButton(fGroupframe1,"Single frame tiff(s)", 3913); fGroupframe1->AddFrame(fCheckButton3913, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); //fCheckButton3913->MoveResize(32,80,112,20); fCheckButton3913->Connect("Clicked()", "TGAppMainFrame", this, "HandleCheckButton2()"); //buttons in group frame 1 TGGroupFrame * fGroupframe1 = new TGGroupFrame(fMainFrame3910_1, new TGString("Process TIFF files"),kVerticalFrame); fMainFrame3910_1->AddFrame(fGroupframe1, new TGLayoutHints(kLHintsLeft|kLHintsTop, 2, 2, 2, 2)); fTextButton3925_0 = new TGTextButton(fGroupframe1,"Set bckg tiff file"); fGroupframe1->AddFrame(fTextButton3925_0, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY,2,2,2,2)); // fTextButton3925_0->SetTextJustify(36); fTextButton3925_0->Connect("Clicked()", "TGAppMainFrame", this, "OpenBgFile()"); fTextButton3925_0->SetEnabled(kFALSE); TGTextButton *fTextButton3925 = new TGTextButton(fGroupframe1,"Open tiff file(s)"); fGroupframe1->AddFrame(fTextButton3925, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY,2,2,2,2)); // fTextButton3925->SetTextJustify(36); //fTextButton3925->Resize(98,24); fTextButton3925->Connect("Clicked()", "TGAppMainFrame", this, "OpenFile()"); ///Second vertical frame in group frame 1 fMainFrame3910_2 = new TGVerticalFrame(fMainFrame3910_0); fMainFrame3910_0->AddFrame(fMainFrame3910_2, new TGLayoutHints(kLHintsTop|kLHintsLeft,2,2,2,2)); TGGroupFrame * fGroupframe2 = new TGGroupFrame(fMainFrame3910_2, new TGString("Prediscr./Frame options"),kVerticalFrame); fMainFrame3910_2->AddFrame(fGroupframe2, new TGLayoutHints(kLHintsCenterY, 2, 2, 2, 2)); //Prediscrimination level TGLabel *fLabel3915 = new TGLabel(fGroupframe2,"Pulse height pre-discr. level"); fLabel3915->SetTextJustify(30); fGroupframe2->AddFrame(fLabel3915, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); fNumberEntry3916 = new TGNumberEntry(fGroupframe2, (Double_t) 1,6,-1,(TGNumberFormat::kNESInteger),(TGNumberFormat::kNEAAnyNumber) ,(TGNumberFormat::kNELNoLimits)); fNumberEntry3916->SetNumber(m_Predisc); fGroupframe2->AddFrame(fNumberEntry3916, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); //number entry for pre_max number of signal pixels in tiff file, so //the algorithm will put back these into their original pixels, not taking center of mass TGLabel *fLabel_pix = new TGLabel(fGroupframe2,"Cluster size pre-discr. level"); fLabel_pix->SetTextJustify(30); fGroupframe2->AddFrame(fLabel_pix, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); fNumberEntry_prepix = new TGNumberEntry(fGroupframe2, (Double_t) 1,6,-1,(TGNumberFormat::kNESInteger), (TGNumberFormat::kNEAAnyNumber),(TGNumberFormat::kNELLimitMin), 1); fNumberEntry_prepix->SetNumber(m_Prepix); fGroupframe2->AddFrame(fNumberEntry_prepix, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); //number entry for frame number of multiframe tiff file, from which frame //one wants the noise to be extracted TGLabel *fLabel_frame = new TGLabel(fGroupframe2,"Frame # (All: -1)"); fLabel_frame->SetTextJustify(30); fGroupframe2->AddFrame(fLabel_frame, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); fNumberEntry_frame = new TGNumberEntry(fGroupframe2, (Double_t) 1,6,-1,(TGNumberFormat::kNESInteger), (TGNumberFormat::kNEAAnyNumber),(TGNumberFormat::kNELLimitMin), -1); fNumberEntry_frame ->SetNumber(m_Frame); fGroupframe2->AddFrame(fNumberEntry_frame, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); ///Third vertical frame in groupframe 2 fMainFrame3910_3 = new TGVerticalFrame(fMainFrame3910_0); fMainFrame3910_0->AddFrame(fMainFrame3910_3, new TGLayoutHints(kLHintsTop|kLHintsLeft,2,2,2,2)); TGGroupFrame * fGroupframe3 = new TGGroupFrame(fMainFrame3910_3, new TGString("View img. pulse height distr."),kVerticalFrame); fMainFrame3910_3->AddFrame(fGroupframe3, new TGLayoutHints(kLHintsCenterY, 2, 2, 2, 2)); //checkbutton for lower cut on the nois fCheckButton_flag = new TGCheckButton(fGroupframe3,"Apply noise correction", 3914); fGroupframe3->AddFrame(fCheckButton_flag, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); //fCheckButton_flag->MoveResize(32,104,112,20); fCheckButton_flag->Connect("Clicked()", "TGAppMainFrame", this, "HandleCheckButton3()"); fCheckButton_flag->SetState(kTRUE); //number entry for lower cut on the noise TGHorizontalFrame * fNoiseframe = new TGHorizontalFrame(fGroupframe3); fGroupframe3->AddFrame(fNoiseframe, new TGLayoutHints(kLHintsTop|kLHintsLeft,2,2,2,2)); //fNumberEntry_flagcut = new TGNumberEntry(fNoiseframe, (Double_t) 1,6,-1,(TGNumberFormat::kNESInteger),(TGNumberFormat::kNEAAnyNumber) ,(TGNumberFormat::kNELNoLimits)); //fNumberEntry_flagcut->SetNumber(m_FlagCut); //fNoiseframe->AddFrame(fNumberEntry_flagcut, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); fTextButton3926 = new TGTextButton(fNoiseframe,"Draw noise"); fNoiseframe->AddFrame(fTextButton3926, new TGLayoutHints(kLHintsLeft | kLHintsTop,8,2,2,2)); fTextButton3926->SetTextJustify(30); //fTextButton3926->Resize(98,24); fTextButton3926->Connect("Clicked()", "TGAppMainFrame", this, "DrawNoise()"); fTextButton3926->SetEnabled(kTRUE); /////////////////////////////////// TGFont *ufont; // will reflect user font changes // ufont = gClient->GetFont("-*-Times New Roman-normal-r-*-*-20-*-*-*-*-*-*-*"); ufont = gClient->GetFont("fixed"); TGGC *uGC; // will reflect user GC changes // graphics context changes GCValues_t vall3922; vall3922.fMask = kGCForeground | kGCBackground | kGCFillStyle | kGCFont | kGCGraphicsExposures; gClient->GetColorByName("#ffffff",vall3922.fForeground); gClient->GetColorByName("#c0c0c0",vall3922.fBackground); vall3922.fFillStyle = kFillSolid; vall3922.fFont = ufont->GetFontHandle(); vall3922.fGraphicsExposures = kFALSE; uGC = gClient->GetGC(&vall3922, kTRUE); // fNumberEntry_flagcut->SetState(kFALSE); fTextButton3926->SetEnabled(kTRUE); filename = NULL; fShutter->AddItem(item1); } //---------------------------------------------------------------------- void LogTxt(){ } ostream& operator<<(ostream& o, const color& c) { if(c.fore > lightgray)//bold color o << "\033[1;3" << c.fore - lightgray - 1 << "m"; else o << "\033[0;3" << c.fore << "m"; return o << "\033[4" << c.back << "m"; } ostream& operator<<(ostream& o, const gotoxy& g) { return o << "\033[" << g.y << ";" << g.x << "f"; } void wait(int seconds){ clock_t endwait; int cl = clock(); endwait = cl + seconds * std::CLK_TCK; while(clock() < endwait){} } //---------------------------------------------------------------------- void TestGui() { new TGAppMainFrame(gClient->GetRoot(), 800, 600); // TDatime * progtime = new TDatime(); //while(1){ // cout << progtime->AsSQLString() << endl; //} } //---------------------------------------------------------------------- // //#ifdef STANDALONE //int main(int argc, char **argv) //{ // TApplication theApp("MdiTest", &argc, argv); // // mditest(); // // theApp.Run(); // // return 0; //} #endif