Skip to content

Commit

Permalink
Updated docs and tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
jsmallcombe committed Dec 20, 2017
1 parent 92cac25 commit 6e97053
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 12 deletions.
Binary file modified Manual.pdf
100755 → 100644
Binary file not shown.
50 changes: 49 additions & 1 deletion docs/manual.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:

Expand Down
2 changes: 2 additions & 0 deletions include/james_gating_tool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down
2 changes: 1 addition & 1 deletion include/jlibmaster.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// James library master 19 Dec 2017
// James library master 20 Dec 2017
#include <james_effpeaks.h>
#include <james_env.h>
#include <james_fitholder.h>
Expand Down
11 changes: 8 additions & 3 deletions src/james_gating_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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();
Expand Down Expand Up @@ -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
Expand Down
20 changes: 18 additions & 2 deletions src/james_gating_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<<endl<<endl<<" ============== Beginning Loading of TH3 ============ "<<endl<<" ====== Please be patient until window appears ====== "<<endl<<endl;
}

bool Btwo=input->IsA()->InheritsFrom("TH2");
if(Bthree||Btwo){//Main IF histogram loop

SetCleanup(kDeepCleanup);

// //--- layout for the frame:
Expand All @@ -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"<<make_iterator();
fInputStore=(TH1*)pass->Clone(ss.str().c_str());
pass=fInputStore;
}

//If TH3 extra gate panel

if(Bthree){
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 3 additions & 2 deletions src/james_gpad_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/james_hist_formatting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions src/james_spectool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ vector<string> 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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 6e97053

Please sign in to comment.