// Mainframe macro generated from application: /home/dkramer/root/bin/root.exe // By ROOT version 5.17/06 on 2007-12-23 20:12:34 #include #include #include #ifndef ROOT_TGFileDialog #include "TGFileDialog.h" #endif #ifndef ROOT_TGNumberEntry #include "TGNumberEntry.h" #endif #ifndef ROOT_TGCanvas #include "TGCanvas.h" #endif #include "TGLabel.h" #include "Riostream.h" class MyMainFrame : public TGMainFrame { private: //TGCompositeFrame *fCframe; //TGMainFrame *fMyMainFrame; TGTextButton *fTextButtonRUN, *fPause, *fExit; TGTextButton *fGetFile, *fMakeRoot; TGNumberEntry *fNumEntryRSum, *fNumEntryCard, *fNumEntryChannel; TGCheckButton *fTextButtonGaps,*fCheckGray,*fCheckSEM; TGGroupFrame *fGframe; TGGroupFrame *pupu; TGLabel *fLabel; Bool_t start, pause; TString rootFile2o,rootFile2s; TFile *f; TTree *t2; ifstream in; Double_t DoseConv; Double_t BLMI_SemFactor; public: MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h); virtual ~MyMainFrame(); // slots void PrintMe(); void OpenFile(); void plotRunningSum(); TString OpenFileDialog(Int_t typeID=0); TString SaveFileDialog(); void ReadRSLogFile_andSaveRoot(); ClassDef(MyMainFrame, 0) }; MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h) : TGMainFrame(p, w, h),BLMI_SemFactor(74855) { //G__loadfile("FileDialog_2.C"); // if(G__loadfile("/home/dkramer/DATA/LSS5_W46/FileDialog_2.C")!=0) // { // cout<<"Please specify FileDialog_2.C location"<>FDialPath; // if(G__loadfile(FDialPath)!=0) gApplication->Terminate(0); // } // main frame // fMyMainFrame = new TGMainFrame(0,10,10,kMainFrame | kVerticalFrame); this->SetLayoutBroken(kTRUE); fTextButtonRUN = new TGTextButton(this,"&Process "); fTextButtonRUN->Connect("Clicked()", "MyMainFrame", this, "plotRunningSum()"); fTextButtonRUN->SetToolTipText("Plot the chosen RS from the opened .ROOT file"); fTextButtonRUN->SetTextJustify(36); fTextButtonRUN->Resize(112,48); this->AddFrame(fTextButtonRUN, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); fTextButtonRUN->MoveResize(288,304,112,48); fMakeRoot = new TGTextButton(this,"&Convert LogFile"); fMakeRoot->Connect("Clicked()", "MyMainFrame", this, "ReadRSLogFile_andSaveRoot()"); fMakeRoot->MoveResize(16,204,112,48); fMakeRoot->SetToolTipText("Dialog to open ASCII file with Expert Logging data\nconverts data to ROOT file (another dialog)"); fExit = new TGTextButton(this,"&Exit", "gApplication->Terminate(0)"); fExit->MoveResize(16,304,112,48); fExit->SetToolTipText("Close all the windows and exit"); pupu = new TGGroupFrame(this,"Acquisitions in TTree"); pupu->SetLayoutBroken(kTRUE); fLabel = new TGLabel(pupu,"No Input"); fLabel->SetTextJustify(36); pupu->AddFrame(fLabel, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); fLabel->MoveResize(32,32,112,30); pupu->SetLayoutManager(new TGVerticalLayout(pupu)); pupu->Resize(192,88); this->AddFrame(pupu, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); pupu->MoveResize(16,16,192,88); fGetFile = new TGTextButton(this,"&OpenFile"); fGetFile->MoveResize(152,304,112,48); fGetFile->Connect("Clicked()", "MyMainFrame", this, "OpenFile()"); fGetFile->SetToolTipText("Dialog to open .ROOT file with Expert logging data"); fTextButtonGaps = new TGCheckButton(this,"Plot gaps in data?"); fTextButtonGaps->MoveResize(16,120,112,40); fTextButtonGaps->SetToolTipText("Add second window to the plot\nGap between consecutive TimeStamps is plotted\nCorrect operation means 1second"); fCheckGray = new TGCheckButton(this,"Output dose in Grays?"); fCheckGray->MoveResize(16,154,140,40); fCheckGray->SetToolTipText("Counts are converted to dose in Grays\nUnchecked means counts"); fCheckSEM = new TGCheckButton(this,"SEM?"); fCheckSEM->MoveResize(170,154,100,40); fCheckSEM->SetToolTipText("Is this a SEM detector?\nDifferent calibration..."); //fExit->Connect("Clicked()", "MyMainFrame", this, "gApplication->Terminate(0)"); // fTextButtonRUN->Connect("Clicked()", "fMyMainFrame", this, "PrintMe()"); // // fExit = new TGTextButton(fHor1, "&Exit", "gApplication->Terminate(0)"); // TGFont *ufont; // will reflect user font changes ufont = gClient->GetFont("-*-helvetica-medium-r-*-*-12-*-*-*-*-*-iso8859-1"); TGGC *uGC; // will reflect user GC changes // graphics context changes GCValues_t valEntry576; valEntry576.fMask = kGCForeground | kGCBackground | kGCFillStyle | kGCFont | kGCGraphicsExposures; gClient->GetColorByName("#000000",valEntry576.fForeground); gClient->GetColorByName("#c0c0c0",valEntry576.fBackground); valEntry576.fFillStyle = kFillSolid; valEntry576.fFont = ufont->GetFontHandle(); valEntry576.fGraphicsExposures = kFALSE; uGC = gClient->GetGC(&valEntry576, kTRUE); // TGTextEntry *fTextEntry576 = new TGTextEntry(this, new TGTextBuffer(15),-1,uGC->GetGC(),ufont->GetFontStruct(),kSunkenFrame | kDoubleBord // er | kOwnBackground); // fTextEntry576->SetMaxLength(255); // fTextEntry576->SetAlignment(kTextLeft); // fTextEntry576->SetText("file name"); // fTextEntry576->Resize(160,fTextEntry576->GetDefaultHeight()); // this->AddFrame(fTextEntry576, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); // fTextEntry576->MoveResize(16,296,160,22); // fNumEntryRSum = new TGNumberEntry(this, (Double_t) 9,6,-1,(TGNumberFormat::EStyle) 5,(TGNumberFormat::EAttribute) 2,(TGNumberFormat::ELimit) 3,1,12); this->AddFrame(fNumEntryRSum, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); fNumEntryRSum->MoveResize(368,24,59,22); TGLabel *fLabelRSum = new TGLabel(this,"Running Sum"); fLabelRSum->SetTextJustify(36); fLabelRSum->MoveResize(280,24,80,22); fNumEntryCard = new TGNumberEntry(this, (Double_t) 1,6,-1,(TGNumberFormat::EStyle) 5,(TGNumberFormat::EAttribute) 2,(TGNumberFormat::ELimit) 3,1,16); this->AddFrame(fNumEntryCard, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); fNumEntryCard->MoveResize(368,56,59,22); TGLabel *fLabelCard = new TGLabel(this,"Card Number "); fLabelCard->SetTextJustify(36); fLabelCard->MoveResize(280,56,80,22); fNumEntryChannel = new TGNumberEntry(this, (Double_t) 1,6,-1,(TGNumberFormat::EStyle) 5,(TGNumberFormat::EAttribute) 2,(TGNumberFormat::ELimit) 3,1,16); this->AddFrame(fNumEntryChannel, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); fNumEntryChannel->MoveResize(368,88,59,22); TGLabel *fLabelChannel = new TGLabel(this,"Channel Num."); fLabelChannel->SetTextJustify(36); fLabelChannel->MoveResize(280,88,80,22); this->SetMWMHints(kMWMDecorAll, kMWMFuncAll, kMWMInputModeless); this->MapSubwindows(); this->Resize(this->GetDefaultSize()); this->MapWindow(); SetWindowName("Running Sums plot GUI"); //this->Resize(490,372); } MyMainFrame::~MyMainFrame() { // Destructor. Cleanup(); } void MyMainFrame::PrintMe() { if(t2){ fLabel->SetText(Form("%d",t2->GetEntries(Form("chnl==%i&&card==%i",fNumEntryChannel->GetNumberEntry()->GetIntNumber(),fNumEntryCard->GetNumberEntry()->GetIntNumber())))); }else{ cout<<"shit happens :o)"<SetText("Open File first!"); } // Parent frame Layout() method will redraw the label showing the new value. //fGframe->Layout(); //fLabel->Layout(); } void MyMainFrame::OpenFile() { rootFile2o = OpenFileDialog(); f = new TFile(rootFile2o); t2 = (TTree*)f->Get("t2"); PrintMe(); } // // void myguiTest() void guiMakeRoot_expertRS() { // Popup the GUI...// // new MyMainFrame(0, 350, 80); new MyMainFrame(0, 490, 372); } #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void MyMainFrame::plotRunningSum() { // // G__loadfile("/home/dkramer/DATA/LSS5_W46/FileDialog.C"); // // TString rootFile2o = OpenFileDialog(); if (!t2) { PrintMe(); return; } //cout<SetStyle("Plain"); //gROOT->ForceStyle(); // // TFile *f = new TFile("tr20071112_2.root"); // // TFile *f = new TFile(rootFile2o); // // TTree *t2 = (TTree*)f->Get("t2"); //vect[0] ... running sum 1 -> 40 us //vect[8] ... running sum 9 -> 1.3 s // // Int_t Chnl2plot = 2; // Int_t Card2plot = 1; // Int_t RS2plot = 8; Int_t Chnl2plot = fNumEntryChannel->GetNumberEntry()->GetIntNumber(); Int_t Card2plot = fNumEntryCard->GetNumberEntry()->GetIntNumber(); Int_t RS2plot = fNumEntryRSum->GetNumberEntry()->GetIntNumber() -1; //cout<>RS2plot; // // cout<<"Which CARD? [1..16]"<>Card2plot; // // cout<<"Which Channel? [1..16]"<>Chnl2plot; // // Int_t firstStamp; t2->SetBranchAddress("tstamp",&firstStamp); t2->GetEntry(0);//Read TimeStamp of the Data (Beginning) TTimeStamp timeStamp(firstStamp,0);//time structure int markernb[] = {2,3,4,5,7,8,23,24,25,26,27,29}; int colornb[] = {4,1,2,3,5,6,21,7,8,2,1,2,3,2,21,5,6,7,8,9,1,2,3,21,4,5,6,7,8,9}; double aver[] = {1., 2., 8., 16., 64., 256., 2048., 16384., 32768., 131072., 524288., 2097152.}; double tau = 40e-6; //shortest integration time // aver * tau == integration time; TCanvas *mycc = new TCanvas("mycc","Labtest",0,0,760,480); if (fTextButtonGaps->IsOn()) { mycc->Divide(1,2); mycc->cd(1); } //TGraph *h0 = new TGraph(t2->GetEntries("chnl==1&&card==1&&vect[0]>0")); if (fCheckGray->IsOn()) {// if (fCheckSEM->IsOn()) DoseConv = BLMI_SemFactor*3.38e-9;//2.33e-4;// Gy/bit else DoseConv = 3.38e-9;// Gy/bit {// const TString ddraw = Form("%e*vect[%d]/%e:tstamp",DoseConv,RS2plot,aver[RS2plot]*tau);// //cout<Draw(ddraw,dcut,"pl"); //t2->Draw("vect[8]:tstamp>>h8","chnl==1&&card==1&&vect[8]>0","plsame"); TGraph *h0 = (TGraph*)gPad->GetPrimitive("Graph"); TH2F *ht0 = (TH2F*)gPad->GetPrimitive("htemp"); //h0->SetDirectory(0); h0->SetLineColor(colornb[0]); h0->SetMarkerColor(colornb[0]); h0->SetMarkerStyle(8); h0->SetMarkerSize(0.5); ht0->GetXaxis()->SetTitle("Time Stamp"); ht0->GetXaxis()->SetTimeDisplay(1); if (fCheckGray->IsOn()) ht0->GetYaxis()->SetTitle("BLM signal [Gy/s]"); else ht0->GetYaxis()->SetTitle("BLM signal [counts]"); ht0->GetYaxis()->SetTitleOffset(1.25); ht0->SetTitle(Form("RSum %i Card %i Channel %i Date %i",RS2plot+1,Card2plot,Chnl2plot,timeStamp.GetDate()));//Card %i, Channel %i",Card2plot,Chnl2plot //h0->Draw("AP"); gPad->Update(); // // TGraph *h0 = (TGraph*)gPad->GetPrimitive("Graph"); // 2D // TH2F *htemp = (TH2F*)gPad->GetPrimitive("htemp"); // empty, but has axes // TAxis *xaxis = htemp->GetXaxis(); if (fTextButtonGaps->IsOn()) { mycc->cd(2); t2->Draw("timeStep:tstamp","chnl==1&&card==1",""); TGraph *h2 = (TGraph*)gPad->GetPrimitive("Graph"); // 2D TH2F *ht2 = (TH2F*)gPad->GetPrimitive("htemp"); h2->SetMarkerSize(0.5); h2->SetMarkerStyle(8); h2->SetMarkerColor(colornb[2]); ht2->GetXaxis()->SetTimeDisplay(1); ht2->GetXaxis()->SetTitle("Time Stamp"); ht2->GetYaxis()->SetTitle("Time Difference [s]"); ht2->SetTitle(Form("RSum %i, Card %i, Channel %i",RS2plot+1,Card2plot,Chnl2plot)); //h0->Draw("prof"); } } TString MyMainFrame::OpenFileDialog(Int_t typeID) { // Prompt for file to be opened. Depending on navigation in // dialog the current working directory can be changed. // The returned file name is always with respect to the // current directory. // // const char *gOpenAsTypes[] = { // // "SDDS files", "*.sdds", // "ROOT files", "*.root", // // "ASCI files", "*.dat", // 0, 0 // }; if(typeID==0){ const char *gOpenAsTypes[] = { "ROOT files", "*.root", 0, 0 }; }else{ const char *gOpenAsTypes[] = { "Logging files", "*.txt", "All files", "*.*", 0, 0 }; } // static TGFileInfo fi; fi.fFileTypes = gOpenAsTypes; new TGFileDialog(gClient->GetRoot(), gClient->GetRoot(), kFDOpen, &fi); return fi.fFilename; } TString MyMainFrame::SaveFileDialog() { // Prompt for file to be saved. Depending on navigation in // dialog the current working directory can be changed. // The returned file name is always with respect to the // current directory. const char *gSaveAsTypes[] = { "ROOT files", "*.root", "Encapsulated PostScript", "*.eps", "PostScript", "*.ps", "GIF", "*.gif", "SVG", "*.svg", "Macro files", "*.C", 0, 0 }; static TGFileInfo fi; fi.fFileTypes = gSaveAsTypes; new TGFileDialog(gClient->GetRoot(), gClient->GetRoot(), kFDSave, &fi); return fi.fFilename; } void MyMainFrame::ReadRSLogFile_andSaveRoot() { cout<<" 100MB file takes ~1.5mins..."<SetText("This will take time.."); // // TTree t2("t2","a Tree with data from LHC BLM logging - 1 crate");if(t2){ t2 = new TTree("t2","a Tree with data from LHC BLM logging - 1 crate"); MyBLM_t dataa; t2->Branch("vect",dataa.rsVect,"vect[12]/F"); t2->Branch("chnl",&dataa.chNumber,"chnl/I"); t2->Branch("card",&dataa.cardNumber,"card/I"); t2->Branch("tstamp",&dataa.tstamp,"tstamp/I");// // t2->Branch("tstamp","TTimeStamp",&dataa.tstamp,1000,0); t2->Branch("timeStep",&timeStep,"timeStep/F"); //cout<<"fgfgf"<>timee; sscanf(timee.Data(),"%4d%2d%2d%2d%2d%2d%*s",&year,&month,&day,&hours,&mins,&secs); sscanf(timee.Data(),"%*14c,%d,%d,%d",&dataa.cardNumber,&dataa.chNumber,&dataValue); //void Set(Int_t year, Int_t month, Int_t day, Int_t hour, Int_t min, Int_t sec, Int_t nsec, Bool_t isUTC, Int_t secOffset) timeStamp.Set(year,month,day,hours,mins,secs,0,0,0); // tstamp = hours + mins/60. + secs/3600.; //cout<Fill(); if(TMath::Abs(timeStamp.GetSec()-timePrevious.GetSec())>0.1){ stampCnt++; timePrevious=timeStamp; } if((dataa.cardNumber==CARDS)&&(dataa.chNumber==CHANNELS)){ cntr++; } //if(cntr==1000) break; } cout<<"number of acquisitions (zeros skipped!) "<Write(); //PrintMe(); //t2 = (TTree*)f2saveRoot.Get("t2"); //t2->Delete(); t2->Reset(); t2=0; f2saveRoot.Close(); f = new TFile(rootFile2s); t2 = (TTree*)f->Get("t2"); PrintMe(); }