AIDA GELINA BRIKEN nToF CRIB ISOLDE CIRCE nTOFCapture DESPEC DTAS EDI_PSA 179Ta CARME StellarModelling DCF K40
  DTAS  ELOG logo
Message ID: 7     Entry time: Wed May 15 08:11:46 2019
Author: Tolosa, Nacher, Algora, Kiss 
Subject: Energy resolutions 
Using getSigmaCal.cxx macro to check energy resolutions...
root [3] getSigmaCal("201905151555_137Cs.root")


EAn01	660.978	20.4516	7.27122%	

EAn02	662.018	21.8206	7.74577%	

EAn03	654.685	21.2331	7.62164%	

EAn04	664.496	21.7799	7.70251%	

EAn05	661.188	21.3019	7.57112%	

EAn06	663.225	22.609	8.01103%	

EAn07	658.977	21.7486	7.75584%	

EAn08	661.333	21.1595	7.51887%	

EAn11	660.622	20.6158	7.33354%	

EAn12	662.106	22.8196	8.09931%	

EAn13	660.16	19.4654	6.92918%	

EAn14	660.348	22.9705	8.17459%	

EAn15	660.277	19.6762	7.00298%	

EAn16	661.323	22.0482	7.83478%	

EAn17	659.072	21.5303	7.6769%	

EAn18	662.739	22.9924	8.15284%	

EDy01	660.951	20.8514	7.41366%	

EDy02	661.465	22.2272	7.89669%	

EDy03	654.887	21.7742	7.81345%	

EDy04	663.585	22.2593	7.88284%	

EDy05	660.353	21.7962	7.75661%	

EDy06	661.692	23.2316	8.25072%	***

EDy07	658.636	22.3986	7.99178%	

EDy08	662.167	21.8422	7.75169%	

EDy11	661.634	21.2086	7.53289%	

EDy12	662.504	23.1784	8.22173%	***

EDy13	660.297	20.7076	7.36985%	

EDy14	662.493	23.5084	8.33893%	***

EDy15	661.844	20.3493	7.22539%	

EDy16	662.861	23.092	8.18665%	

EDy17	661.152	22.215	7.89612%	

EDy18	659.903	23.6411	8.41889%	***
Attachment 1: getSigmaCal.cxx  2 kB  Uploaded Wed May 15 09:43:38 2019  | Hide | Hide all
#include "TH1.h"
#include "TSpectrum.h"
#include "TFile.h"
#include "TGraph.h"
#include "TF1.h"
#include "TMath.h"

#include <string>
#include <cmath>
#include <vector>
#include <iostream>
#include <map>
#include <sstream>


constexpr int eblow = 10; //bins
constexpr int rebinFac = 1; //
constexpr int maxnpeaks = 10; //max peaks to look for
constexpr double sigmaPeak = 4.0;
constexpr double thrPeak = 0.05;

constexpr double ene60Co1 = 1173.2;// keV
constexpr double ene60Co2 = 1332.5;// keV
constexpr double ene137Cs = 661.66;// keV

const std::vector<std::string> histoNames_v = { "EAn01",
						"EAn02",
						"EAn03",
						"EAn04",
						"EAn05",
						"EAn06",
						"EAn07",
						"EAn08",
						"EAn11",
						"EAn12",
						"EAn13",
						"EAn14",
						"EAn15",
						"EAn16",
						"EAn17",
						"EAn18",
						"EDy01",
						"EDy02",
						"EDy03",
						"EDy04",
						"EDy05",
						"EDy06",
						"EDy07",
						"EDy08",
						"EDy11",
						"EDy12",
						"EDy13",
						"EDy14",
						"EDy15",
						"EDy16",
						"EDy17",
						"EDy18"
						};

//const std::vector<std::string> histoNames_v = { "EDy18"	};


double ff (double *x,double*p){return p[0]*std::exp(-(*x - p[1])*(*x - p[1])/(2*p[2]*p[2]))+p[3];};
double ff2 (double *x,double*p){return p[0]*std::exp(-(*x - p[1])*(*x - p[1])/(2*p[2]*p[2]))+p[3]   + p[4]*ROOT::Math::erfc( (*x- p[1])/( sqrt(2)*p[2])) ;};



auto myTF1 = new TF1("myGaus", ff2 , 0 ,1 , 5 );

std::vector<TH1*> h_v;
std::vector<TH1*> hFit_v;

void getSigmaCal(std::string ifilename )
{
  TFile ifile( ifilename.c_str(), "read" );
  
  TH1 * h = nullptr;
  for( auto & histoName_it : histoNames_v )
  {
    ifile.GetObject( histoName_it.c_str(), h );
    if( h )
    {
      h->GetXaxis()->SetRangeUser(550,750);
      myTF1->SetParameters(1000,662,30,200,100);
      h->Fit("myGaus","");
      double mean(h->GetFunction("myGaus")->GetParameters()[1]);
      double sigma(h->GetFunction("myGaus")->GetParameters()[2]);
      
      std::cout << h->GetName() << "\t" << mean << "\t" << sigma << "\t" << 235*sigma/mean << "%\t" <<  std::endl;
      
      h_v.push_back( (TH1*) h->Clone( std::string( std::string(h->GetName()) + "_c" ).c_str() ) );
      h_v.back()->SetDirectory(0);
      hFit_v.push_back( (TH1*)h->GetFunction("myGaus")->CreateHistogram()->Clone( std::string( std::string(h->GetName()) + "_cFit" ).c_str() ) );
      hFit_v.back()->SetDirectory(0);
    }
    
  }
  ifile.Close();
  
  TFile ofile("calFit5.root","recreate");
  for(auto & vit : h_v )
    vit->Write();
//   for(auto & vit : hFit_v )
//     vit->Write();
  
  
  ofile.Close();
  
  return;
}
Attachment 2: calFit5.root  383 kB  Uploaded Wed May 15 09:43:53 2019
ELOG V3.1.4-unknown