diff --git a/Projects/AlPhaPha/2024/macro/chio/CalibrationChio/SplineChioXY.C b/Projects/AlPhaPha/2024/macro/chio/CalibrationChio/SplineChioXY.C index 4bbdc293bd5e685a74906d8d944cc274d5e9b180..0cb55f07691bc85f01ab3b8b7bace8e62728da15 100644 --- a/Projects/AlPhaPha/2024/macro/chio/CalibrationChio/SplineChioXY.C +++ b/Projects/AlPhaPha/2024/macro/chio/CalibrationChio/SplineChioXY.C @@ -10,9 +10,8 @@ using namespace std; -TSpline3* MakeSpline(TH2F* hInput, Int_t NCallee); -void ApplySplinePerCut(); -void ApplySpline(); +TSpline3* MakeSpline(TH2F* hInput, Int_t NCallee, double XMin , double + XMax, double YMin, double YMax); void HistoFiller(); ////////////////////////////////////////////////////////////////////////////////////////// @@ -39,13 +38,25 @@ void SplineChioXY( bool Create = false) { vector<TH2F*> hIC; hIC.push_back((TH2F*)inFile->Get("hChio_IC0_IC1_X_all")); hIC.push_back((TH2F*)inFile->Get("hChio_IC0_IC1_Y_all")); + hIC.push_back((TH2F*)inFile->Get("hChio_IC1_X")); + hIC.push_back((TH2F*)inFile->Get("hChio_IC1_Y")); TFile* fspline = new TFile("Output/spline_Chio_2024.root", "recreate"); + int NHist = static_cast<int>(hIC.size()); + double XMin[NHist] , XMax[NHist], YMin[NHist] , YMax[NHist]; + XMin[0] = -520 ; XMax[0] = 380 ; YMin[0] = 0 ; YMax[0] = 2 ; + XMin[1] = -70 ; XMax[1] = 79 ; YMin[1] = 0 ; YMax[1] = 2 ; + XMin[2] = -520 ; XMax[2] = 380 ; YMin[2] = 2000 ; YMax[2] = 9500 ; + XMin[3] = -70 ; XMax[3] = 79 ; YMin[3] = 2000 ; YMax[3] = 9500 ; + + + for (int i = 0; i < hIC.size(); i++) { - TSpline3* spline = MakeSpline(hIC[i] , i); - spline->SetName(Form("fspline_%d", i )); + TSpline3* spline = MakeSpline(hIC[i] , i, XMin[i] , XMax[i], YMin[i], YMax[i]); + if (i < 2) spline->SetName(Form("fsplineIC0_%d", i )); + else if (i>=2) spline->SetName(Form("fsplineIC1_%d",i)); spline->Write(); } //End loop on histogram @@ -84,6 +95,12 @@ void HistoFiller() { "hChio_IC0_IC1_X_all", 1000, -800, 800, 500, 1, 1.6); TH2F* hChio_IC0_IC1_Y_all = new TH2F("hChio_IC0_IC1_Y_all", "hChio_IC0_IC1_Y_all", 1000, -160, 160, 500, 1, 1.6); + TH2F* hChio_IC1_Y = new TH2F("hChio_IC1_Y", + "hChio_IC1_Y", 1000, -160, 160, 500, 2000, 9500); + TH2F* hChio_IC1_X = new TH2F("hChio_IC1_X", + "hChio_IC1_X", 1000, -800, 800, 500, 2000, 9500); + + //=========================================================================================================== // Beginning loop on entries @@ -106,9 +123,13 @@ void HistoFiller() { fIC_raw[i] = IC->fIC_raw[i]; } - hChio_IC0_IC1_X_all->Fill(FF_IC_X , fIC_raw[1] / fIC_raw[0] ); - hChio_IC0_IC1_Y_all->Fill(FF_IC_Y , fIC_raw[1] / fIC_raw[0] ); + //if (IC->Eres>11000 && IC->Eres < 12000){ + hChio_IC0_IC1_X_all->Fill(FF_IC_X , fIC_raw[1] / fIC_raw[0] ); + hChio_IC0_IC1_Y_all->Fill(FF_IC_Y , fIC_raw[1] / fIC_raw[0] ); + hChio_IC1_X->Fill(FF_IC_X, fIC_raw[1]); + hChio_IC1_Y->Fill(FF_IC_Y, fIC_raw[1]); + //} // 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 @@ -125,9 +146,20 @@ void HistoFiller() { canY->cd(); hChio_IC0_IC1_Y_all->Draw("colz"); + TCanvas* canX1 = new TCanvas("X1", "X1", 0, 0, 2000, 1000); + canX1->cd(); + hChio_IC1_X->Draw("colz"); + + TCanvas* canY1 = new TCanvas("Y1", "Y1", 0, 0, 2000, 1000); + canY1->cd(); + hChio_IC1_Y->Draw("colz"); + + TFile* outFile = new TFile("Output/Histo.root", "recreate"); hChio_IC0_IC1_X_all->Write(); hChio_IC0_IC1_Y_all->Write(); + hChio_IC1_Y->Write(); + hChio_IC1_X->Write(); outFile->Close(); } // End HistoFiller @@ -145,7 +177,8 @@ void HistoFiller() { * */ -TSpline3* MakeSpline(TH2F* hInput, Int_t NCallee) { +TSpline3* MakeSpline(TH2F* hInput, Int_t NCallee, double XMin = 0 , double + XMax = 1000 , double YMin=0 , double YMax = 100) { TSpline3* gspline; @@ -154,7 +187,7 @@ TSpline3* MakeSpline(TH2F* hInput, Int_t NCallee) { TCanvas* canfit = new TCanvas(Form("CanSpline_%02d",NCallee), Form("canfit_%02d",NCallee), 0, 0, 1000, 500); - + //=========================================================================================================== // Init profile @@ -166,7 +199,7 @@ TSpline3* MakeSpline(TH2F* hInput, Int_t NCallee) { hProfile->SetDirectory(0); canfit->cd(); - hProfile->GetYaxis()->SetRangeUser(0, 2); + hProfile->GetYaxis()->SetRangeUser(YMin, YMax); hProfile->Draw(); //=========================================================================================================== // First and last bin to get to 6k @@ -176,11 +209,11 @@ TSpline3* MakeSpline(TH2F* hInput, Int_t NCallee) { double Treshold = 1; for (int bin =1 ; bin<hProfile->GetNbinsX(); bin++) { FirstBin = bin; - if (hProfile->GetBinContent(bin)>Treshold) break; + if (hProfile->GetBinLowEdge(bin)> XMin) break; } for (int bin = hProfile->GetNbinsX(); bin>1 ; bin--) { LastBin = bin; - if (hProfile->GetBinContent(bin)>Treshold) break; + if (hProfile->GetBinLowEdge(bin)< XMax) break; } cout << FirstBin << " " << LastBin << endl; //=========================================================================================================== diff --git a/Projects/AlPhaPha/2024/macro/chio/CalibrationChio/TestSpline.C b/Projects/AlPhaPha/2024/macro/chio/CalibrationChio/TestSpline.C index 17574cc24f211908ed32fe0fd6f37e7fb6767a89..464d58aa05226d8d83873f977127e993ed147af4 100644 --- a/Projects/AlPhaPha/2024/macro/chio/CalibrationChio/TestSpline.C +++ b/Projects/AlPhaPha/2024/macro/chio/CalibrationChio/TestSpline.C @@ -36,7 +36,11 @@ void TestSpline() { TH2F* hICorr_X = new TH2F("hICorr_X","hICorr_X",1000,-600,400,500,1,1.6); TH2F* hICorr_Y = new TH2F("hICorr_Y","hICorr_Y",1000,-100,100,500,1,1.6); TH2F* hDE_Ecorr = new TH2F("DE_Ecorr","DE_Ecorr",1000,100,1,1000,100,1); + TH2F* hDEBis_Ecorr = new + TH2F("DEBis_Ecorr","DEBis_Ecorr",1000,0,20000,1000,0,25000); TH2F* hDE_E = new TH2F("DE_E","DE_E",1000,100,1,1000,100,1); + TH2F* hDE_E_IC1_Corr = new + TH2F("hDE_E_IC1_Corr","hDE_E_IC1_Corr",1000,0,20000,1000,0,25000); hICorr.push_back(hICorr_X); hICorr.push_back(hICorr_Y); @@ -44,8 +48,10 @@ void TestSpline() { hIC.push_back((TH2F*)fHisto->Get("hChio_IC0_IC1_Y_all")); vector<TSpline3*> spline; - for (int i = 0; i < hIC.size(); i++) { - spline.push_back((TSpline3*)fSpline->Get(Form("fspline_%d",i))); + for (int i = 0; i < 4; i++) { + + if (i<2) spline.push_back((TSpline3*)fSpline->Get(Form("fsplineIC0_%d",i))); + else if ( i>=2 && i<4) spline.push_back((TSpline3*)fSpline->Get(Form("fsplineIC1_%d",i))); } //End loop on histogram @@ -76,32 +82,58 @@ void TestSpline() { double IC0_Corr = IC->fIC_raw[1] /IC_CorrY; if (IC0_Corr != IC0_Corr ) IC0_Corr = 0; - double DE = 0 ,E =0 ,DEcorr=0 ; + double IC1_CorrY = IC->fIC_raw[1] * spline[3]->Eval(0) / + spline[3]->Eval(FF_IC_Y) ; + double IC1_CorrX = IC->fIC_raw[1] * spline[2]->Eval(0) / + spline[2]->Eval(FF_IC_X) ; + + + double DE = 0 ,E =0 ,DEcorr=0 ,DEIC1corr =0; + + //=========================================================================================================== + // Fill De from seg 1 to 3 + //=========================================================================================================== for (int seg = 0 ; seg < sizeof(IC->fIC_raw)/sizeof(IC->fIC_raw[0]) ; seg++ ){ if(seg > 1 && seg < 4) DE += IC->fIC_raw[seg] ; else if (seg >4) E+= IC->fIC_raw[seg] ; } - + + + + //=========================================================================================================== + // Filling DE with ICO + //=========================================================================================================== DEcorr += DE ; - if (IC0_Corr < 1e10 && IC0_Corr >0){ - DEcorr += IC0_Corr ;} + if ((IC0_Corr < 1e100 && IC0_Corr >-1000) || true){ + DEcorr += IC0_Corr ; + } else DEcorr += IC->fIC_raw[0]; - DE += IC->fIC_raw[0] ; DE = DE *0.5 + IC->fIC_raw[4]; DEcorr = DEcorr *0.5 + IC->fIC_raw[4]; - + /* - cout << IC0_Corr << " " << IC->fIC_raw[0] << endl; - cout << DEcorr << " " << DE << endl; - cout << "*************************" << endl; - */ - + cout << IC0_Corr << " " << IC->fIC_raw[0] << endl; + cout << DEcorr << " " << DE << endl; + cout << "*************************" << endl; + */ + + //=========================================================================================================== + // Chio online + //=========================================================================================================== + + double IC1corr = (IC->fIC_raw[1]*(1-0.000686068*FF_IC_Y))*(1-4.88238e-05*FF_IC_Y+7.40395e-06*FF_IC_Y*FF_IC_Y); + double DE_Bis = 0.5*(IC1corr+IC->fIC_raw[2]+IC->fIC_raw[3])+IC->fIC_raw[4]; + //double DE_Bis = 0.5*(IC->fIC_raw[1]+IC->fIC_raw[2]+IC->fIC_raw[3])+IC->fIC_raw[4]; + DEIC1corr = 0.5*(IC1_CorrY +IC->fIC_raw[2]+IC->fIC_raw[3])+IC->fIC_raw[4]; + + hDEBis_Ecorr->Fill(E,DE_Bis); hDE_E->Fill(E,DE); hDE_Ecorr->Fill(E,DEcorr); + hDE_E_IC1_Corr->Fill(E,DEIC1corr); } //End loop on event //=========================================================================================================== @@ -119,12 +151,15 @@ void TestSpline() { c1->cd(4); hIC[1]->Draw(); - TCanvas* c2 = new TCanvas("c2","c2",1000,1000); - c2->Divide(2); + TCanvas* c2 = new TCanvas("c2","c2",1500,1000); + c2->Divide(4); c2->cd(1); hDE_E->Draw(); c2->cd(2); hDE_Ecorr->Draw(); - + c2->cd(3); + hDEBis_Ecorr->Draw(); + c2->cd(4); + hDE_E_IC1_Corr->Draw(); } // End spline chio XY