AIDA GELINA BRIKEN nToF CRIB ISOLDE CIRCE nTOFCapture DESPEC DTAS EDI_PSA 179Ta CARME StellarModelling DCF K40
  nTOFCapture  ELOG logo
Message ID: 64     Entry time: Thu Apr 4 09:50:36 2024
Author: CLW 
Subject: First Si analysis 2024 run 

Au and Si29 runs normalised by proton number show consistency (dedicated pulses, example detector 4). Plots for tof spectra zooming on one resonance and histogram of counts in this resonance divided by protons with statistical errors.

Plots were produced with the macros attached.

Attachment 1: au_counts.pdf  13 kB  Uploaded Thu Apr 4 10:51:51 2024  | Hide | Hide all
au_counts.pdf
Attachment 2: au.pdf  21 kB  Uploaded Thu Apr 4 10:51:51 2024  | Hide | Hide all
au.pdf
Attachment 3: si29_counts.pdf  14 kB  Uploaded Thu Apr 4 10:51:57 2024  | Hide | Hide all
si29_counts.pdf
Attachment 4: si29.pdf  23 kB  Uploaded Thu Apr 4 10:51:57 2024  | Hide | Hide all
si29.pdf
Attachment 5: consistency.C  8 kB  Uploaded Thu Apr 4 10:52:06 2024  | Hide | Hide all
#include "TCanvas.h"
#include "TBrowser.h"
#include "TH2F.h"
#include "TH1F.h"
#include "TGraph.h"
#include "TGraphErrors.h"
#include "TMath.h"
#include <fstream>
#include "TFrame.h"
#include "TSystem.h"
#include "TLegend.h"
#include "TLegendEntry.h"
#include "TFile.h"
#include "TROOT.h"
#include "TStyle.h"
#include "TBox.h"
#include "TRandom.h"
#include "TObject.h"
#include "TObjString.h"
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include "TLine.h"
#include "TTree.h"
#include "TBrowser.h"
#include "TF1.h"
#include <TStyle.h>
#include <THStack.h>
#include <TPad.h>
#include "TRandom.h"




void plot(){
    // replace this with name of your singles file
    TFile *f=new TFile("Single_Si29_ded.root","read");
    TString histo, norm, protons;
    
    ///file with a list of the histogram names for one detector
    // format Zn_T_u3_C6D6_runxxxxxx Zn_A_u3_SILI_runxxxxxx Zn_h_info_C6D6_runxxxxxx
    ifstream inni("Si29_C6D64_HistList.dat");
    TCanvas *c=new TCanvas();

    /// replace this with the tof around a resonance, i.e. binlow is the start of the resonance, binhigh is the end of the resonance
    // you can choose any resonance, best is a large one which is usally at big tof values
    /// this will be different for Au and for Zn.

float binlow=2250000;
float binhigh=2400000;

    TLegend *legend = new TLegend(0.65, 0.38, 0.89, 0.89);
    legend->SetBorderSize(1);
    legend->SetFillColor(0);
    legend->SetTextSize(0.03);
    int count2=0;
    int count_protons=0;
    
    
    //// replace this with the number of lines in your file "list"
int lines=59;

            float value[lines];
            float value2[lines];
            float valuesili[lines];
            float valuepkup[lines];
    float staterror[lines];
    while(1){
        
        inni>>histo>>norm>>protons;
        if ( ! inni ) break;

        
        char *s;
        if(count2==0) s="hist";
        if(count2>0)s="hist same";
        count2++;
        cout<<histo<<" "<<norm<<endl;
        
        
        TH1F *h=(TH1F*)f->Get(histo);
        //TH1F *hnorm=(TH1F*)f->Get(norm);
        TH1F *hpro=(TH1F*)f->Get(protons);
        
        
        int bin1=h->FindBin(binlow); //Ge70Bins
        int bin2=h->FindBin(binhigh);
        
        // this gives the total number of count in the resonance
        
        int counter2=h->Integral(bin1,bin2);

      
    
    value[count2-1]=float(counter2)/hpro->GetBinContent(4)*7E12;
        staterror[count2-1]=sqrt(float(counter2))/hpro->GetBinContent(4)*7E12;
             value2[count2-1]=float(counter2);
             valuesili[count2-1]=float(hpro->GetBinContent(4)/hpro->GetBinContent(8));
            valuepkup[count2-1]=float(hpro->GetBinContent(4)/hpro->GetBinContent(7));
   
        h->Scale(1/hpro->GetBinContent(4)*7E12);
        h->Rebin(50);
        h->SetLineColor(count2);
        h->DrawCopy(s);
        legend->AddEntry(h,histo, "l");
    }
    float sum=0;
    float weight=0;
     float weightsum=0;   
    for(int i=0;i<count2;i++){

        weight=value2[i]/(value[i]*value[i]);

       sum=sum+value[i]*weight;


        weightsum=weightsum+weight;

        cout<<value[i]<<" "<<weight<<" "<<i<<endl;
    }


cout<< sum/weightsum <<endl;
   
    float deviation=0;
double stddev=0;

    for(int i=0;i<count2;i++){
        deviation=(sum/weightsum-value[i])/sum*weightsum*100;

stddev=(sum/weightsum-value[i])*(sum/weightsum-value[i])+stddev;

        cout<<" "<<deviation<<" % "<<sqrt(value2[i])/value2[i]*100<<" % counting "<<deviation/(sqrt(value2[i])/value2[i]*100)<< "   "<<i<<endl;
    }
    deviation=sqrt(1/count2*deviation);
    cout<<count2<<" "<<sum/count2<<endl;

double stddev2=sqrt(1/(float(count2-1))*stddev);

//STOP PROTON SCALING

cout<<"std dev is "<<stddev2/(sum/weightsum)*100<<" %"<<endl;
    legend->Draw();
cout<<"                                "<<endl;
    for(int i=0;i<count2;i++){

        cout<<" "<<valuesili[i]<<"  Prot/SILI    "<<valuepkup[i]<<"  Prot/PKUP   "<<valuesili[i]/valuepkup[i]<<" SILI/PKUP"<<endl;
    }


TH1F *hprosi=new TH1F("","",50,0,50);
TH1F *hprook=new TH1F("","",50,0,50);
TH1F *hsipk=new TH1F("","",50,0,50);
    TH1F *hcounts=new TH1F("","",50,0,50);

for(int i=0;i<count2;i++){
hprosi->SetBinContent(i+1,valuesili[i]);
hprook->SetBinContent(i+1,valuepkup[i]);
hsipk->SetBinContent(i+1,valuesili[i]/valuepkup[i]);
    hcounts->SetBinContent(i+1,value[i]);
    hcounts->SetBinError(i+1,staterror[i]);
    }

TCanvas *c3=new TCanvas;
c3->Divide(2,2);
c3->cd(1);
hprosi->Draw();
c3->cd(2);
hprook->Draw();
c3->cd(3);
hsipk->Draw();
    c3->cd(4);
    hcounts->Draw();
    
    
    TCanvas *c5=new TCanvas;
    hcounts->Draw();
}










void plotau(){
    // replace this with name of your singles file
    TFile *f=new TFile("Single_Au_ded.root","read");
    TString histo, norm, protons;
    
    ///file with a list of the histogram names for one detector
    // format Zn_T_u3_C6D6_runxxxxxx Zn_A_u3_SILI_runxxxxxx Zn_h_info_C6D6_runxxxxxx
    ifstream inni("Au_C6D64_HistList.dat");
    TCanvas *c=new TCanvas();

    /// replace this with the tof around a resonance, i.e. binlow is the start of the resonance, binhigh is the end of the resonance
    // you can choose any resonance, best is a large one which is usally at big tof values
    /// this will be different for Au and for Zn.

float binlow=12000000;
float binhigh=14000000;

    TLegend *legend = new TLegend(0.65, 0.38, 0.89, 0.89);
    legend->SetBorderSize(1);
    legend->SetFillColor(0);
    legend->SetTextSize(0.03);
    int count2=0;
    int count_protons=0;
    
    
    //// replace this with the number of lines in your file "list"
int lines=59;

            float value[lines];
            float value2[lines];
            float valuesili[lines];
            float valuepkup[lines];
    float staterror[lines];
    while(1){
        
        inni>>histo>>norm>>protons;
        if ( ! inni ) break;

        
        char *s;
        if(count2==0) s="hist";
        if(count2>0)s="hist same";
        count2++;
        cout<<histo<<" "<<norm<<endl;
        
        
        TH1F *h=(TH1F*)f->Get(histo);
        //TH1F *hnorm=(TH1F*)f->Get(norm);
        TH1F *hpro=(TH1F*)f->Get(protons);
        
        
        int bin1=h->FindBin(binlow); //Ge70Bins
        int bin2=h->FindBin(binhigh);
        
        // this gives the total number of count in the resonance
        
        int counter2=h->Integral(bin1,bin2);

      
    
    value[count2-1]=float(counter2)/hpro->GetBinContent(4)*7E12;
        staterror[count2-1]=sqrt(float(counter2))/hpro->GetBinContent(4)*7E12;
             value2[count2-1]=float(counter2);
             valuesili[count2-1]=float(hpro->GetBinContent(4)/hpro->GetBinContent(8));
            valuepkup[count2-1]=float(hpro->GetBinContent(4)/hpro->GetBinContent(7));
   
        h->Scale(1/hpro->GetBinContent(4)*7E12);
        h->Rebin(50);
        h->SetLineColor(count2);
        h->DrawCopy(s);
        legend->AddEntry(h,histo, "l");
    }
    float sum=0;
    float weight=0;
     float weightsum=0;
    for(int i=0;i<count2;i++){

        weight=value2[i]/(value[i]*value[i]);

       sum=sum+value[i]*weight;


        weightsum=weightsum+weight;

        cout<<value[i]<<" "<<weight<<" "<<i<<endl;
    }


cout<< sum/weightsum <<endl;
   
    float deviation=0;
double stddev=0;

    for(int i=0;i<count2;i++){
        deviation=(sum/weightsum-value[i])/sum*weightsum*100;

stddev=(sum/weightsum-value[i])*(sum/weightsum-value[i])+stddev;

        cout<<" "<<deviation<<" % "<<sqrt(value2[i])/value2[i]*100<<" % counting "<<deviation/(sqrt(value2[i])/value2[i]*100)<< "   "<<i<<endl;
    }
    deviation=sqrt(1/count2*deviation);
    cout<<count2<<" "<<sum/count2<<endl;

double stddev2=sqrt(1/(float(count2-1))*stddev);

//STOP PROTON SCALING

cout<<"std dev is "<<stddev2/(sum/weightsum)*100<<" %"<<endl;
    legend->Draw();
cout<<"                                "<<endl;
    for(int i=0;i<count2;i++){
... 36 more lines ...
Attachment 6: List_Formatter.cpp  1 kB  Uploaded Thu Apr 4 10:52:06 2024  | Hide | Hide all
// g++ -Wall -O3 -g List_Formatter.cpp -o List_Formatter && ./List_Formatter

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

int main(){
	
	string sample_name = "Au"; //A prefix for the TTOFSort output file histogram names, e.g. Zn1 is the first block of zinc runs
	
    int runlist[]={118026, 118027, 118028, -1};
		
	for(int detn = 1; detn <= 4; detn++){ //Loop over 4 C6D6 detectors
		
		string outname = sample_name; //Create output file name in the format Sample_C6D6#_HistList.dat
		outname += "_C6D6";
		stringstream formatter;
		formatter << detn;
		outname += formatter.str(); //This string stream now contains detector name integer converted to string
		outname += "_HistList.dat";
		
		ofstream ofile;
		ofile.open(outname.c_str());
		if(!ofile.is_open()){cout << "ERROR: Cannot open output file " << outname << endl; return 0;}
		
		for(int run_index = 0; run_index < (int)(sizeof(runlist) / sizeof(int)); run_index++){ //Loop over each of the runs
			
			if(runlist[run_index] != -1){
				
				stringstream run_str;
				run_str << runlist[run_index]; //Save run number as string
				
				string histname1 = sample_name;
				histname1 += "_T_u";
				histname1 += formatter.str();
				histname1 += "_C6D6_run";
				histname1 += run_str.str();
				
				string histname2 = sample_name;
				histname2 += "_A_u";
				histname2 += formatter.str();
				histname2 += "_SILI_run";
				histname2 += run_str.str();
				
				string histname3 = sample_name;
				histname3 += "_h_info_C6D6_run";
				histname3 += run_str.str();
				
				run_str.str(""); //Clear the stringstream
				
				ofile << histname1 << " " << histname2 << " " << histname3 << endl;
			}
		}
		
		formatter.str(""); //Clear the stringstream
		
		ofile.close();
	}
	
	return 0;
}

ELOG V3.1.4-unknown