Skip to content
Snippets Groups Projects
Commit 97481dbc authored by Theodore Efremov's avatar Theodore Efremov :hibiscus:
Browse files

Added spline for chio X and Y and updated readme

parent cc84575d
No related branches found
No related tags found
1 merge request!27Draft: [Epic] Preparation of the environement for the new GaseousDetectorScorers...
Pipeline #360138 failed
# Code cheat sheet # Code cheat sheet
## Root Prompt ## Root Prompt
''' ```
- Tree-\>Draw("Branch\>\>HistName(nBin,xmin,xmax)","Condition","Option") - Tree-\>Draw("Branch\>\>HistName(nBin,xmin,xmax)","Condition","Option")
''' ```
## YCM ## YCM
f to find source f to find source
...@@ -10,9 +10,9 @@ ctrl-O to go back ...@@ -10,9 +10,9 @@ ctrl-O to go back
ctrl-I to go forward ctrl-I to go forward
## Cmake Set-up for clangd ## Cmake Set-up for clangd
''' ```
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1
''' ```
## Do not forget ## Do not forget
In project config modifiy analysis output before doing a test analysis In project config modifiy analysis output before doing a test analysis
#include <TCanvas.h>
#include <TChain.h>
#include <TSpline.h>
#include <fstream>
#include <TH2.h>
#include <TFile.h>
#include <vector>
using namespace std;
void MakeSpline();
void ApplySplinePerCut();
void ApplySpline();
void HistoFiller();
//////////////////////////////////////////////////////////////////////////////////////////
void SplineChioXY(){
HistoFiller();
MakeSpline();
}
/**
* This function fill the histograms
*/
void HistoFiller(){
// Input and setters
TChain *chain = new TChain("PhysicsTree");
chain->Add("../../../root/analysis/VamosCalib241.root");
double FF_IC_X, FF_IC_Y, fIC_raw[11] ;
chain->SetBranchStatus("FF_IC_X",true);
chain->SetBranchAddress("FF_IC_X",&FF_IC_X);
chain->SetBranchStatus("FF_IC_Y",true);
chain->SetBranchAddress("FF_IC_Y",&FF_IC_Y);
chain->SetBranchStatus("fIC_raw",true);
chain->SetBranchAddress("fIC_raw",&fIC_raw);
// Output of the spline
double fIC0_CorrX;
double fIC0_CorrY;
// Histograms
TH2F *hChio_IC0_IC1_X_all = new TH2F("hChio_IC0_IC1_X_all","hChio_IC0_IC1_X_all",1000,-600,400,500,0,2);
TH2F *hChio_IC0_IC1_Y_all = new TH2F("hChio_IC0_IC1_Y_all","hChio_IC0_IC1_Y_all",1000,-70,70,500,0,2);
//===========================================================================================================
// Beginning loop on entries
//===========================================================================================================
int Nentries = chain->GetEntries();
for (int e=0 ; e<Nentries ; e++)
{
//Printing status
if(e%100000==0) cout << e*100./Nentries << "% \r" << flush;
chain->GetEntry(e);
hChio_IC0_IC1_X_all->Fill(fIC_raw[1]/fIC_raw[0],FF_IC_X);
hChio_IC0_IC1_Y_all->Fill(fIC_raw[1]/fIC_raw[0],FF_IC_Y);
//for(int i=0;i<Ncuts;i++) if(cutZ[i]->IsInside(FF_Eres,FF_DE)) {hChioDE_E[i]->Fill(FF_Eres,FF_DE); break;}
} //end loop on entries
//===========================================================================================================
// Output Canvas and files
//===========================================================================================================
TCanvas * canX = new TCanvas("X","X", 0,0,2000,1000);
canX->cd();
hChio_IC0_IC1_X_all->Draw("colz");
TCanvas * canY = new TCanvas("Y","Y", 0,0,2000,1000);
canY->cd();
hChio_IC0_IC1_Y_all->Draw("colz");
TFile *outFile=new TFile("Output/Spline.root","recreate");
hChio_IC0_IC1_X_all->Write();
hChio_IC0_IC1_Y_all->Write();
outFile->Close();
} // End HistoFiller
void MakeSpline(){
TFile *inFile=new TFile("Output/Spline.root");
TSpline3 *gspline;
vector<TH2F*> hIC;
vector<TH1F*> hProfile;
vector<TH1F*> pfx; // extended hProfile
vector<TFile*>fspline=new TFile("Output/spline_Chio_2024.root","recreate");
TCanvas * canfit = new TCanvas("canfit","canfit",0,0,2000,1500);
// Get the 2D plot in TCutG
hIC.push_back((TH2F*)inFile->Get("hChio_IC0_IC1_X_all"));
hIC.push_back((TH2F*)inFile->Get("hChio_IC0_IC1_Y_all"));
for
// Create the TProfile
hProfile[i]=(TH1F*)h2[i]->ProfileX();
hProfile[i]->SetLineWidth(2);
hProfile[i]->SetDirectory(0);
canfit->cd();
if (i==0) {
hProfile[i]->GetYaxis()->SetRangeUser(5000,26000);
hProfile[i]->Draw();
}
else hProfile[i]->Draw("same");
// Get the range of the TProfile
int FirstBin, LastBin;
double parpol3[4];
for(int bin=1; bin<hProfile[i]->GetNbinsX(); bin++){
FirstBin = bin;
if (hProfile[i]->GetBinContent(bin)>6000) break;
}
double parpol1[2];
for(int bin=hProfile[i]->GetNbinsX(); bin>1 ; bin--){
LastBin = bin;
if (hProfile[i]->GetBinContent(bin)>6000) break;
}//end makespline
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment