From 0c68d1955758f26a2c41383e7a9d0393be0a338d Mon Sep 17 00:00:00 2001
From: gypaos <gypaos@gmail.com>
Date: Mon, 1 Feb 2021 13:39:26 +0100
Subject: [PATCH] Fix bug with pdf name; fix LM ordering in fit

---
 .../online/Calibration_DSSSD/Analyse207Bi.C   | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/Projects/ComptonTelescope/online/Calibration_DSSSD/Analyse207Bi.C b/Projects/ComptonTelescope/online/Calibration_DSSSD/Analyse207Bi.C
index 0f73f36c1..6064f760a 100644
--- a/Projects/ComptonTelescope/online/Calibration_DSSSD/Analyse207Bi.C
+++ b/Projects/ComptonTelescope/online/Calibration_DSSSD/Analyse207Bi.C
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// This macro calibrates DSSSD with a 207Bi source.                          //
+// This macro calibrates DSSSDs with a 207Bi source.                         //
 //                                                                           //
 // It treats either all ASIC channels (channel = -1) or a single one         //
 // (specify channel number). A boolean (isPside) should indicate whether the //
@@ -58,7 +58,7 @@ Double_t gaussianPeak(Double_t*, Double_t*);
 
 
 void Analyse207Bi(const char* name = "bb7_3309-7_bi207_20210126_13h09_run5_conv_RawDSSSDHistos.root",
-                  Bool_t isPside = 1, Int_t channel = 15)
+                  Bool_t isPside = 1, Int_t channel = 20)
 {
    // no statistical box, no histogram name, no fit info
    if (gStyle->GetOptStat())  gStyle->SetOptStat(0);
@@ -93,6 +93,7 @@ void Analyse207Bi(const char* name = "bb7_3309-7_bi207_20210126_13h09_run5_conv_
    cout << "sname = " << sname << endl;
    label += sname.substr(16, 20);
    cout << "label = " << label << endl;
+   label += (isPside) ? "_pside" : "_nside";
    TString pdfname = Form("Analyse207Bi_%s.pdf", label.c_str());
    can->Print(Form("%s[", pdfname.Data()));
 
@@ -239,6 +240,7 @@ void Analyse207Bi(const char* name = "bb7_3309-7_bi207_20210126_13h09_run5_conv_
          // loop on "480"- and "975"-keV features
          // p = 0 -> 480 keV
          // p = 1 -> 975 keV
+         Double_t sigma480 = 0;
          for (UInt_t p = 0; p < mainLineEnergy.size(); ++p) {
             can->cd(3+p);
             pad = (TPad*) can->FindObject(Form("can_%d", 3+p));                                  
@@ -290,11 +292,17 @@ void Analyse207Bi(const char* name = "bb7_3309-7_bi207_20210126_13h09_run5_conv_
 
             // positive amplitudes and position in range
             for (UInt_t i = 0; i < peakListForFit.size(); ++i) {
-               fit->SetParLimits(1 + 2*i, fit->GetParameter(1+2*i)-20,
-                                          fit->GetParameter(1+2*i)+20);
+               // +/- 10 channels prevents L and M inversion
+               fit->SetParLimits(1 + 2*i, fit->GetParameter(1+2*i)-10,
+                                          fit->GetParameter(1+2*i)+10);
                fit->SetParLimits(2 + 2*i, 0, 1e5);
             }
 
+            // width of 975 keV line within 20% of 480 keV line
+            if (p == 1) {
+               fit->SetParLimits(0, sigma480/1.1, sigma480*1.1);
+            }
+
             // fit spectrum
             h->Fit("fit", "RBQ0");
 //            h->Fit("fit", "RB0");
@@ -317,6 +325,9 @@ void Analyse207Bi(const char* name = "bb7_3309-7_bi207_20210126_13h09_run5_conv_
                signalFcn->DrawCopy("same");
             }
 
+            // get resolution for the 480 keV line
+            sigma480 = param[2];
+
             ///////////////////////////////////////////////////////////////////////////
             // fill calibration arrays
             // K-transition
-- 
GitLab