diff --git a/Projects/AlPhaPha/2024/ReadMe.md b/Projects/AlPhaPha/2024/ReadMe.md index da164f4affeeae8e5b08ad898af0d751b7b670c5..5e43e53745167d503f54d02b6778879160eb628a 100644 --- a/Projects/AlPhaPha/2024/ReadMe.md +++ b/Projects/AlPhaPha/2024/ReadMe.md @@ -1,8 +1,8 @@ # Code cheat sheet ## Root Prompt -''' +``` - Tree-\>Draw("Branch\>\>HistName(nBin,xmin,xmax)","Condition","Option") -''' +``` ## YCM f to find source @@ -10,9 +10,9 @@ ctrl-O to go back ctrl-I to go forward ## Cmake Set-up for clangd -''' +``` cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -''' +``` ## Do not forget In project config modifiy analysis output before doing a test analysis diff --git a/Projects/AlPhaPha/2024/macro/chio/CalibrationChio/SplineChioXY.C b/Projects/AlPhaPha/2024/macro/chio/CalibrationChio/SplineChioXY.C new file mode 100644 index 0000000000000000000000000000000000000000..f42a6a5be77bf8a37eeada11a808afb74a415d6d --- /dev/null +++ b/Projects/AlPhaPha/2024/macro/chio/CalibrationChio/SplineChioXY.C @@ -0,0 +1,139 @@ +#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