diff --git a/Manual.pdf b/Manual.pdf old mode 100755 new mode 100644 index 336fa8e..40523fd Binary files a/Manual.pdf and b/Manual.pdf differ diff --git a/docs/manual.tex b/docs/manual.tex index e324805..d991381 100755 --- a/docs/manual.tex +++ b/docs/manual.tex @@ -68,9 +68,11 @@ \section{jEnv Toolbar} \begin{enumerate} \item Grabbed Histogram Icon \item Open a new peak fitting environment (copy grabbed histogram if $TH1$) -\item Open a new 2/3D gating tool if grabbed histogram is $TH2/TH3$. +\item Open a TSpectrum Tool (if grabbed histogram is $TH1$) +\item Open a new 2/3D gating tool (if grabbed histogram is $TH2/TH3$.) \item Open a new TBrowser and draw grabbed. \item Create a new canvas and draw a copy of grabbed +\item Overlay a copy of grabbed in the NEXT clicked canvas \item Open a dialogue box to save grabbed to disk \item Close the toolbar. \item Exit root @@ -346,6 +348,52 @@ \subsection{Fit Inputs} \end{tabular} \end{center} +\section{TSpectrum Tool} +The $TSpectrum Tool$ provides a gui interface for manipulating $TH1$ spectra, correcting over-subtraction and subtracting continuum background with the ROOT $TSpectrum$ class. + +\begin{center} +\begin{tabular}{ c c } +\begin{minipage}{0.35\textwidth} +\begin{enumerate} +\item Correct over-subtraction. +\item Hide/Show bin errors. +\item Subtract TSpectrum background. +\item View/Result Window. +\item Rebin resultant histogram. +\item TSpectrum options. +\item TSpectrum smoothing iterations N. +\item Selected option. +\item Selected N. +\item Enable over-subtracted background. +\item Set minimum bin content to zero. +\end{enumerate} \end{minipage} +& +\raisebox{-.5\height}{\includegraphics[width=0.65\textwidth]{TSpectrum1.png}} +\\ +\end{tabular} +\end{center} + +\subsection{TSpectrum Background} +This tool allows experimenting with the different settings of TSpectrum graphically. +One of the following options may be selected : $BackOrder2$, $BackOrder4$, $BackOrder6$, $BackOrder8$, $BackSmoothing3$, $BackSmoothing5$, $BackSmoothing7$, $BackSmoothing9$, $BackSmoothing11$, $BackSmoothing13$, $BackIncreasingWindow$, $Compton$. For details see the ROOT TSpectrum documentation. In general use the default $BackOrder2$ is sufficient and good agreement can be achieved with varying the number of iterations $N$. Occasional, in the case of over-subtraction, increasing to $BackSmoothing5$ or above may be needed. The $Compton$ option does not provide good background for a dense HPGe spectrum. +\\ +When a good background is achieved you may elect to subtract it from the data with the $Remove Background$ tick button. Subtracting continuum background from TSpectrum is a matter of personal preference and is not scientifically rigorous. This can help fitting and automation. +\begin{center} +\includegraphics[width=0.5\textwidth]{TSpectrum4.png} +\end{center} + +\subsection{Over-Subtracted Spectra} +The tool's provisional feature to correct over-subtraction is intended for situations in which spectra were produced such that over-subtraction was unavoidable. The default TSpectrum behaviour will fail in the presence of over-subtraction. Click the $OverSubMode$ option and the tool will perform attempt to compensate. Note that this option will produce backgrounds that are too high when over-subtraction is not present. +\begin{center} +\includegraphics[width=0.5\textwidth]{TSpectrum2.png} +\end{center} +Additionally you may request to correct the over-subtracted histogram bins with the $Remove Oversub$ check box. Bins below the $TSpectrum$ line will be increased until they are within $1\sigma$. This is useful when one needs to use such a spectra in a subsequent subtraction and you wish to mistakenly avoid adding counts. Ideally one would find an alternate original subtraction to avoid the problem in the first place, but this tool is intended to provide one solution, to be used with discretion, when there is not alternative. +\begin{center} +\includegraphics[width=0.5\textwidth]{TSpectrum3.png} +\end{center} +The $ZeroMin$ option simply sets that when performing a correction, no bin will be below zero. This accelerates the correction and is the default setting (irrespective of selection) when $Remove Oversub$ is selected but $OverSubMode$ is not. + + \section{Command Line and Script Peak Fitting} The following static function may be used to fit with Ultrapeak in scripts or on the command line: diff --git a/include/james_gating_tool.h b/include/james_gating_tool.h index f7af997..bf76ed4 100755 --- a/include/james_gating_tool.h +++ b/include/james_gating_tool.h @@ -62,6 +62,8 @@ class jgating_tool : public TGMainFrame { vector< TH1* > savehists; vector< TGCheckButton* > savechecks; vector< TGTextButton* > savebutton; + + TH1* fInputStore; public: jgating_tool(const char *); diff --git a/include/jlibmaster.h b/include/jlibmaster.h index 7151d60..21a5a0b 100755 --- a/include/jlibmaster.h +++ b/include/jlibmaster.h @@ -1,4 +1,4 @@ -// James library master 19 Dec 2017 +// James library master 20 Dec 2017 #include #include #include diff --git a/src/james_gating_frame.cpp b/src/james_gating_frame.cpp index 5c2b954..d4944c4 100755 --- a/src/james_gating_frame.cpp +++ b/src/james_gating_frame.cpp @@ -543,9 +543,10 @@ TVirtualPad* hold=gPad; proj->SetStats(0); proj->SetTitle(""); + proj->SetLineColor(1); + proj_flow->SetStats(0); proj_flow->SetTitle(""); - proj_flow->SetLineColor(1); delete selected; selected=(TH1*)proj->Clone(("selected"+suffix).c_str()); @@ -563,14 +564,16 @@ TVirtualPad* hold=gPad; full->SetTitle(""); delete output_hist_point; output_hist_point=(TH1*)full->Clone(("outputhist"+suffix).c_str()); + output_hist_point->SetLineColor(1); + output_hist_point->GetXaxis()->SetTitleOffset(1.0);//Fixed a problem from other lib with Yaxis title + delete gate_hist; gate_hist=(TH1*)full->Clone(("gate_hist"+suffix).c_str()); delete free_hist; free_hist=(TH1*)full->Clone(("free_hist"+suffix).c_str()); free_hist->SetLineColor(1); - - + UpdateSpecBack(); DoAutoFit(); UpdateDraw(); @@ -852,6 +855,8 @@ void j_gating_frame::DoHistogram(){ } gate_hist=hist_gater_bin(gate_down,gate_up,raw_input,xyz,"gate_hist"+suffix); + gate_hist->SetLineColor(1); + gate_hist->GetXaxis()->SetTitleOffset(1.0);//Fixed a problem from other lib with Yaxis title switch (background_mode) { case 1://full diff --git a/src/james_gating_tool.cpp b/src/james_gating_tool.cpp index ce1fb66..e03ef3b 100755 --- a/src/james_gating_tool.cpp +++ b/src/james_gating_tool.cpp @@ -17,15 +17,19 @@ int jgating_tool::jgating_tool_iterator = 0; jgating_tool::jgating_tool(const char * input) : jgating_tool(gROOT->FindObject(input)){} -jgating_tool::jgating_tool(TObject* input) : TGMainFrame(gClient->GetRoot(), 100, 100,kHorizontalFrame) ,gJframe1(0),fCheck0(0),fCheck1(0),fFitFcn(0),peaknumremove(0),fTip(0),fFitPanel(0){ +jgating_tool::jgating_tool(TObject* input) : TGMainFrame(gClient->GetRoot(), 100, 100,kHorizontalFrame) ,gJframe1(0),fCheck0(0),fCheck1(0),fFitFcn(0),peaknumremove(0),fTip(0),fFitPanel(0),fInputStore(0){ TVirtualPad* hold=gPad; if(!input)return; bool Bthree=input->IsA()->InheritsFrom("TH3"); + if(Bthree){ + cout<IsA()->InheritsFrom("TH2"); if(Bthree||Btwo){//Main IF histogram loop - + SetCleanup(kDeepCleanup); // //--- layout for the frame: @@ -41,6 +45,15 @@ TVirtualPad* hold=gPad; SetWindowName(input->GetName()); TH1* pass=(TH1*)input; + if(Btwo&&!Bthree){ + // Until recently didn't store and in local class copy, rarely and issue, but it COULD be + // Still too intensive to do it for TH3 though. + stringstream ss; + ss<<"GateStoreCopy"<Clone(ss.str().c_str()); + pass=fInputStore; + } + //If TH3 extra gate panel if(Bthree){ @@ -193,6 +206,9 @@ jgating_tool::~jgating_tool() { if(fFitPanel){delete fFitPanel;} if(fTip){fTip->Hide();delete fTip;} + if(fInputStore){delete fInputStore;} + + // Clean up Cleanup(); diff --git a/src/james_gpad_tools.cpp b/src/james_gpad_tools.cpp index f74b781..04610d4 100755 --- a/src/james_gpad_tools.cpp +++ b/src/james_gpad_tools.cpp @@ -52,7 +52,8 @@ TH1* hist_capture(TVirtualPad* fPad){ // Just a basic little no frills, minimal input peak fitter for standard size y/e peaks // Added it in to help with quick peak identification void ClickPeakDrawConnect(Int_t event, Int_t px, Int_t py, TObject *selected_ob) -{TVirtualPad* hold=gPad; +{ +// TVirtualPad* hold=gPad; if(!gTQSender)return; if(((TObject*)gTQSender)->IsA() != TCanvas::Class())return; @@ -103,7 +104,7 @@ void ClickPeakDrawConnect(Int_t event, Int_t px, Int_t py, TObject *selected_ob) Can->GetCanvas()->Update(); } -gPad=hold; +// gPad=hold; } // Hide the tooltip associated with a Canvas, use on close or as an override diff --git a/src/james_hist_formatting.cpp b/src/james_hist_formatting.cpp index 63230f7..70b45c8 100755 --- a/src/james_hist_formatting.cpp +++ b/src/james_hist_formatting.cpp @@ -4,7 +4,7 @@ void axislab(TH1* HH,string x,string y,string z){ HH->GetXaxis()->SetTitle(x.c_str()); if(y==""){ - double w=HH->GetBinWidth(1); + double w=HH->GetXaxis()->GetBinWidth(1); stringstream ss; ss<<"Counts"; bool N=true; diff --git a/src/james_spectool.cpp b/src/james_spectool.cpp index 871b7c4..03db538 100755 --- a/src/james_spectool.cpp +++ b/src/james_spectool.cpp @@ -18,6 +18,8 @@ vector jSpecTool::BackOpt={"BackOrder2","BackOrder4","BackOrder6","BackO jSpecTool::jSpecTool(TH1* input) : TGMainFrame(gClient->GetRoot(), 100, 100,kVerticalFrame),histin(0),histsub(0),histzero(0),specback(0){ TVirtualPad* hold=gPad; + input->GetXaxis()->SetRange(1,-1); + TGLayoutHints* ffExpandXpad = new TGLayoutHints(kLHintsExpandX, 1, 1, 1, 1); SetCleanup(kDeepCleanup); @@ -93,7 +95,7 @@ TVirtualPad* hold=gPad; smoothframe->AddFrame(fTeh2); fCheck3 = new TGCheckButton(smoothframe," OverSubMode "); - fCheck3->SetState(kButtonDown); + fCheck3->SetState(kButtonUp); fCheck3->Connect(" Clicked()", "jSpecTool", this,"UpdateSpecBack()"); fCheck3->SetToolTipText("Background will do anti-oversubtraction iterations background"); smoothframe->AddFrame(fCheck3); @@ -257,8 +259,9 @@ void jSpecTool::RemovalPrep(TH1* hist){ int jSpecTool::RemovalStart(TH1* hist){ //because often zeros at the start make trouble double max=hist->GetBinContent(hist->GetMaximumBin()); + double min=hist->GetBinContent(hist->GetMinimumBin()); for(int i=1;i<=hist->GetNbinsX();i++){ - if(hist->GetBinContent(i)>max*0.05){ + if(hist->GetBinContent(i)>min+((max-min)*0.05)){ return i; } }