finsihed PID calibration

This commit is contained in:
Ryan Tang 2022-06-28 16:04:20 -04:00
parent 81cbf1c2cc
commit 44087a0df2
5 changed files with 79 additions and 82 deletions

View File

@ -76,7 +76,7 @@ TF1 * FitHist2(TH1F * hist1, TH1F * hist2, double a0, double a1, double scale, d
fit2->SetParameters(par);
fit2->SetParLimits(0, 0, 15);
fit2->SetParLimits(1, 0.6, 1.2);
fit2->SetParLimits(3, -0.00001, 0.00001);
fit2->SetParLimits(3, -0.00002, 0.00001);
//fit2->FixParameter(3, 0);
fit2->SetLineWidth(2);
fit2->SetLineColor(4);

View File

@ -42,9 +42,9 @@
318 8.209070 1.000661 1.207103 0.887063 -0.0000093263
319 8.011329 0.999823 1.600204 0.886653 -0.0000091960
320 0.326489 1.001083 0.552779 0.888471 -0.0000094284
321 0.257637 1.000806 0.321734 0.889154 -0.0000095403
322 0.241687 1.000738 0.340305 0.889576 -0.0000096254
323 0.167235 1.000447 0.501191 0.888241 -0.0000095490
323 -9.981457 0.980308 0.501191 0.888241 -0.0000095490
323 0.167234 1.000447 0.499583 0.888244 -0.0000095494
324 0.054908 0.999928 0.364381 0.889151 -0.0000095068
325 8.050909 0.999893 1.242025 0.888227 -0.0000091104
326 0.250943 1.000691 0.338226 0.889374 -0.0000093779

View File

@ -1,8 +1,6 @@
#define peachCake_cxx
#include "peachCake.h"
#include <TH2.h>
#include <TH1.h>
#include <TMath.h>
#include <TCanvas.h>
#include <TStyle.h>
@ -58,14 +56,6 @@ vector<vector<double>> eCorr;
double TOFCorrection(double x){
//for run 238
//return (-225.8 - 0.040017 * energy
// +0.0000710839 * energy*energy
// -6.28402e-8 * TMath::Power(energy,3)
// +2.90563e-11 * TMath::Power(energy,4)
// -6.70137e-15 * TMath::Power(energy,5)
// +6.08418e-19 * TMath::Power(energy,6) );
// for run 250
double par[6] = {10.9179,
0.00416034,
@ -77,23 +67,6 @@ double TOFCorrection(double x){
}
TH2F * createTH2F(const char* name, const char* title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup){
TH2F * hist2 = (TH2F *) gROOT->FindObjectAny( name );
if ( hist2 == NULL ) hist2 = new TH2F( name , title , nbinsx, xlow, xup, nbinsy, ylow, yup);
hist2->Reset();
return hist2;
}
TH1F * createTH1F(const char* name, const char* title, Int_t nbinsx, Double_t xlow, Double_t xup){
TH1F * hist1 = (TH1F *) gROOT->FindObjectAny( name );
if ( hist1 == NULL ) hist1 = new TH1F( name , title , nbinsx, xlow, xup);
hist1->Reset();
return hist1;
}
void peachCake::Begin(TTree * /*tree*/){
@ -102,7 +75,7 @@ void peachCake::Begin(TTree * /*tree*/){
hCloverID = createTH2F("hCloverID", "Clover; ID; energy [keV]", 52, 0, 52, 400, 0, 2000);
hPID0 = createTH2F("hPID0", "PID raw; ns; msx100", tofRange[0], tofRange[1], tofRange[2], dERange[0], dERange[1], dERange[2]);
hPID = createTH2F("hPID", "PID corrected; ns; msx100", tofRange[0], tofRange[1], tofRange[2], dERange[0], dERange[1], dERange[2]);
hPID = createTH2F("hPID", "PID slew corrected; ns; msx100", tofRange[0], tofRange[1], tofRange[2], dERange[0], dERange[1], dERange[2]);
hPID2 = createTH2F("hPID2", "PID; A/Q; Z", tofRange[0], 2.0, 4.2, dERange[0], 0, 16.5);
hTOF = createTH1F("hTOF", "TOF", tofRange[0], tofRange[1], tofRange[2]);
@ -137,21 +110,6 @@ void peachCake::Begin(TTree * /*tree*/){
pidCorr = LoadCorrectionParameters(pidCorrFileName, 1);
}
/**
cutFile = new TFile(cutFileName, "READ");
bool listExist = cutFile->GetListOfKeys()->Contains("cutList");
if( listExist ) {
cutList = (TObjArray*) cutFile->FindObjectAny("cutList");
numCut = cutList->GetLast()+1;
printf("----- found %d cuts \n", numCut);
for( int k = 0; k < numCut; k++){
if( cutList->At(k) != NULL ){
printf("found a cut at %2d \n", k);
}
}
}
* */
printf("============ start \n");
}
@ -168,6 +126,7 @@ Bool_t peachCake::Process(Long64_t entry){
b_cfd->GetEntry(entry);
b_runID->GetEntry(entry);
//========= initialization
energy = TMath::QuietNaN();
Long64_t startTimeL = 0;
Long64_t startTimeR = 0;
@ -192,10 +151,10 @@ Bool_t peachCake::Process(Long64_t entry){
crossTime = 0;
for( int i = 0; i < 4 ; i++) {
dyIonsTime[i] = 0;
dyBetaTime[i] = 0;
dyIonsEnergy[i] = 0;
dyBetaEnergy[i] = 0;
dyIonsTime[i] = 0;
dyBetaTime[i] = 0;
dyIonsEnergy[i] = 0;
dyBetaEnergy[i] = 0;
}
int multiDyBeta = 0;
@ -204,6 +163,24 @@ Bool_t peachCake::Process(Long64_t entry){
flag = 0;
vetoFlag = 0;
//============ format canvas title
if( entry == 0 ){
if( runID/100 == lastRunID + 1 ) {
int len = canvasTitle.Sizeof();
if( contFlag == false) {
canvasTitle.Remove(len-3);
canvasTitle += " - ";
}
if( contFlag == true) canvasTitle.Remove(len-6);
contFlag = true;
}
if( runID/100 > lastRunID + 1 ) contFlag = false;
if( runID/100 > lastRunID ){
canvasTitle += Form("%03d, ", runID/100 );
lastRunID = runID/100;
}
}
//======= Scanning the event
for( int i = 0; i < multi; i++){
//----- clover
@ -327,9 +304,6 @@ Bool_t peachCake::Process(Long64_t entry){
///======== Z vs A/Q
double c = 299.792458; /// mm/ns
/// exp value
///double FL = 37656 ; /// mm
///double Brho = 4.90370; /// T.mm
double FL = 56423 ; /// mm
double Brho = 9.04; /// T.mm
double ma = 931.5;
@ -342,16 +316,9 @@ Bool_t peachCake::Process(Long64_t entry){
double Z = sqrt((energy + 11.9473) / 23.097) * TMath::Power(beta / beta0, 1.3) ;
double AoQ = c * Brho / gamma/ beta / ma;
//printf("tof : %f, beta: %f (%f), Z : %f, A/Q : %f \n", TOF + tofOffset, beta, beta0, Z, AoQ);
//Z = -0.15938 + 1.01736 *Z + 0.000203316 * Z*Z;
//Z = -0.254632 + 1.06285 * Z - 0.00539634 * Z * Z + 0.000169443 * Z * Z * Z; ///2022-06-09
Z = 0.0153343 + 1.00339 * Z;
hPID2->Fill(AoQ, Z);
hZ->Fill(Z);
if( 3.5 > Z && Z > 2.5 ) hZ3->Fill( AoQ * 3);
@ -472,7 +439,7 @@ Bool_t peachCake::Process(Long64_t entry){
void peachCake::Terminate(){
printf("\n===============\n");
printf("\n=============================================\n");
if( saveNewTree ){
saveFile->cd();
@ -484,6 +451,9 @@ void peachCake::Terminate(){
gStyle->SetOptStat(111111);
int div[2] = {4, 2} ; ///x, y
int len = canvasTitle.Sizeof();
canvasTitle.Remove(len - 3);
printf("|%s|\n", canvasTitle.Data());
TCanvas * c1 = new TCanvas("c1", canvasTitle, 700 * div[0], 700 * div[1]);
c1->Divide(div[0], div[1]);

View File

@ -11,6 +11,8 @@
#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>
#include <TH2.h>
#include <TH1.h>
#include <TSelector.h>
#include <TBenchmark.h>
#include "cmath"
@ -52,7 +54,9 @@ public :
pidCorrFileName = "";
fHistRootName = "";
plotHists = true;
canvasTitle = "";
canvasTitle = "Run: ";
lastRunID = -1;
contFlag = false;
}
virtual ~peachCake() { }
virtual Int_t Version() const { return 2; }
@ -124,7 +128,8 @@ public :
bool plotHists;
TString canvasTitle;
int lastRunID;
bool contFlag;
};
#endif
@ -152,10 +157,6 @@ void peachCake::Init(TTree *tree){
fChain->SetBranchAddress("multiBeam", &multiBeam, &b_multiplicity_Beam);
fChain->SetBranchAddress("runID", &runID, &b_runID);
//============ Canvas Title
//============ new tree
printf(" is save tree? :%d \n", saveNewTree);
@ -230,4 +231,23 @@ void peachCake::SlaveTerminate(){
}
TH2F * createTH2F(const char* name, const char* title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup){
TH2F * hist2 = (TH2F *) gROOT->FindObjectAny( name );
if ( hist2 == NULL ) hist2 = new TH2F( name , title , nbinsx, xlow, xup, nbinsy, ylow, yup);
hist2->Reset();
return hist2;
}
TH1F * createTH1F(const char* name, const char* title, Int_t nbinsx, Double_t xlow, Double_t xup){
TH1F * hist1 = (TH1F *) gROOT->FindObjectAny( name );
if ( hist1 == NULL ) hist1 = new TH1F( name , title , nbinsx, xlow, xup);
hist1->Reset();
return hist1;
}
#endif // #ifdef peachCake_cxx

View File

@ -17,22 +17,29 @@ void script() {
//chain->Add("root_data/run-0241-*.root");
// new beam
chain->Add("root_data/run-024[6-8]*.root");
chain->Add("root_data/run-0250*.root");
chain->Add("root_data/run-025[1-4].root");
chain->Add("root_data/run-025[6-9].root");
chain->Add("root_data/run-026[1-4]*.root");
chain->Add("root_data/run-0269*.root");
chain->Add("root_data/run-027[0-1]*.root");
chain->Add("root_data/run-028[3-4]*.root");
chain->Add("root_data/run-028[6-8]*.root");
chain->Add("root_data/run-0292*.root");
chain->Add("root_data/run-029[4-6]*.root");
chain->Add("root_data/run-029[8-9]*.root");
chain->Add("root_data/run-03*.root");
//chain->Add("root_data/run-024[6-8]*.root");
//chain->Add("root_data/run-0250*.root");
//chain->Add("root_data/run-025[1-4].root");
//chain->Add("root_data/run-025[6-9].root");
//chain->Add("root_data/run-026[1-4]*.root");
//chain->Add("root_data/run-0269*.root");
//chain->Add("root_data/run-027[0-1]*.root");
//chain->Add("root_data/run-028[3-4]*.root");
//chain->Add("root_data/run-028[6-8]*.root");
//chain->Add("root_data/run-0292*.root");
//chain->Add("root_data/run-029[4-6]*.root");
//chain->Add("root_data/run-029[8-9]*.root");
//chain->Add("root_data/run-031*.root");
//chain->Add("root_data/run-032*.root");
chain->Add("root_data/run-0246-00.root");
chain->Add("root_data/run-0246-01.root");
chain->Add("root_data/run-0247-00.root");
chain->Add("root_data/run-0247-01.root");
chain->Add("root_data/run-0248-00.root");
chain->Add("root_data/run-0250-00.root");
chain->Add("root_data/run-0250-01.root");
bool isSaveNewTree = false;