#include #include #include #include #include "TObjArray.h" #include "DCrossSectionData.h" #include "particleType.h" using namespace std; TObjArray* Import_CrossSections(string locFileName, vector& locBeamEnergyVector); TObjArray* Import_ddCrossSections(string locFileName, vector& locFirstDimVector, int locNumExtraNums = 0, bool locHasFSIColumn = false); void Handle_EndOfBin(TObjArray *locCrossArray, vector& locSecondDimVector, vector& locCrossValueVector, vector& locCrossErrorVector); DCrossSectionData* Import_CrossSections(string locDataName) { //general name format: Organization_Channel_Name (Author / Variation) vector locFirstDimVector; /* DCrossSectionData* locCrossSectionData = new DCrossSectionData(string locReactionName, Particle_t locBeamPID, Particle_t locAngleParticlePID); locCrossSectionData->Set_Data(locDataName, locCrossSectionArray, locFirstDimVector, bool locIsSqrtSFlag, bool locIsCosThetaFlag, bool locGraphPerEnergyBinFlag, bool locIsDSigmaDCosThetaFlag); */ //PPM if(locDataName == "BnGa_PPM_BnGa12-1") { string locFileName = "rootfiles/crossfiles/Prediction_PPM_Cross_BnGa12-1.txt"; TObjArray* locCrossSectionArray = Import_ddCrossSections(locFileName, locFirstDimVector, 0); DCrossSectionData* locCrossSectionData = new DCrossSectionData("#gammad#rightarrowp#pi^{#minus}(p)", ParticleName_ROOT(Gamma), ParticleName_ROOT(PiMinus), ParticleMass(Gamma), ParticleMass(Deuteron)); locCrossSectionData->Set_Data(locDataName, locCrossSectionArray, locFirstDimVector, false, true, true, false); return locCrossSectionData; } else if(locDataName == "BnGa_PPM_201402") { string locFileName = "rootfiles/crossfiles/Prediction_PPM_Cross_BnGa_201402.txt"; TObjArray* locCrossSectionArray = Import_ddCrossSections(locFileName, locFirstDimVector, 0); DCrossSectionData* locCrossSectionData = new DCrossSectionData("#gamman#rightarrowp#pi^{#minus}", ParticleName_ROOT(Gamma), ParticleName_ROOT(PiMinus), ParticleMass(Gamma), ParticleMass(Deuteron)); locCrossSectionData->Set_Data(locDataName, locCrossSectionArray, locFirstDimVector, false, true, true, false); return locCrossSectionData; } else if(locDataName == "SAID_PPM_GB12") { string locFileName = "rootfiles/crossfiles/Prediction_PPM_Cross_SAID_GB12.txt"; TObjArray* locCrossSectionArray = Import_ddCrossSections(locFileName, locFirstDimVector, 0); DCrossSectionData* locCrossSectionData = new DCrossSectionData("#gamman#rightarrowp#pi^{#minus}", ParticleName_ROOT(Gamma), ParticleName_ROOT(PiMinus), ParticleMass(Gamma), ParticleMass(Deuteron)); locCrossSectionData->Set_Data(locDataName, locCrossSectionArray, locFirstDimVector, false, true, true, false); return locCrossSectionData; } else if(locDataName == "CLAS_PPM_Mattione_FSICorr") { string locFileName = "rootfiles/crossfiles/CLAS_PPM_Cross_Mattione_FSICorr.txt"; TObjArray* locCrossSectionArray = Import_ddCrossSections(locFileName, locFirstDimVector, 0); DCrossSectionData* locCrossSectionData = new DCrossSectionData("#gamman#rightarrowp#pi^{#minus}", ParticleName_ROOT(Gamma), ParticleName_ROOT(PiMinus), ParticleMass(Gamma), ParticleMass(Deuteron)); locCrossSectionData->Set_Data(locDataName, locCrossSectionArray, locFirstDimVector, false, false, true, false); return locCrossSectionData; } else if(locDataName == "CLAS_PPM_Mattione_FSICorrV2") { string locFileName = "rootfiles/crossfiles/CLAS_PPM_Cross_Mattione_FSICorrV2.txt"; TObjArray* locCrossSectionArray = Import_ddCrossSections(locFileName, locFirstDimVector, 0); DCrossSectionData* locCrossSectionData = new DCrossSectionData("#gamman#rightarrowp#pi^{#minus}", ParticleName_ROOT(Gamma), ParticleName_ROOT(PiMinus), ParticleMass(Gamma), ParticleMass(Deuteron)); locCrossSectionData->Set_Data(locDataName, locCrossSectionArray, locFirstDimVector, false, false, true, false); return locCrossSectionData; } //PPM SUBSETS else if(locDataName == "BNL_PPM_Shafi_700") { string locFileName = "rootfiles/crossfiles/BNL_PPM_Shafi_700.txt"; TObjArray* locCrossSectionArray = Import_ddCrossSections(locFileName, locFirstDimVector, 0); DCrossSectionData* locCrossSectionData = new DCrossSectionData("#gamman#rightarrowp#pi^{#minus}", ParticleName_ROOT(Gamma), ParticleName_ROOT(PiMinus), ParticleMass(Gamma), ParticleMass(Deuteron)); locCrossSectionData->Set_Data(locDataName, locCrossSectionArray, locFirstDimVector, false, false, true, false); return locCrossSectionData; } else if(locDataName == "CALT_PPM_Scheffler_700") { string locFileName = "rootfiles/crossfiles/CALT_PPM_Scheffler_700.txt"; TObjArray* locCrossSectionArray = Import_ddCrossSections(locFileName, locFirstDimVector, 0); DCrossSectionData* locCrossSectionData = new DCrossSectionData("#gamman#rightarrowp#pi^{#minus}", ParticleName_ROOT(Gamma), ParticleName_ROOT(PiMinus), ParticleMass(Gamma), ParticleMass(Deuteron)); locCrossSectionData->Set_Data(locDataName, locCrossSectionArray, locFirstDimVector, false, false, true, false); return locCrossSectionData; } else if(locDataName == "CALT_PPM_Scheffler_Subset") { string locFileName = "rootfiles/crossfiles/CALT_PPM_Scheffler_Subset.txt"; TObjArray* locCrossSectionArray = Import_ddCrossSections(locFileName, locFirstDimVector, 0); DCrossSectionData* locCrossSectionData = new DCrossSectionData("#gamman#rightarrowp#pi^{#minus}", ParticleName_ROOT(Gamma), ParticleName_ROOT(PiMinus), ParticleMass(Gamma), ParticleMass(Deuteron)); locCrossSectionData->Set_Data(locDataName, locCrossSectionArray, locFirstDimVector, false, false, true, false); return locCrossSectionData; } else if(locDataName == "DESY_PPM_Benz_Subset") { string locFileName = "rootfiles/crossfiles/DESY_PPM_Benz_Subset.txt"; TObjArray* locCrossSectionArray = Import_ddCrossSections(locFileName, locFirstDimVector, 0); DCrossSectionData* locCrossSectionData = new DCrossSectionData("#gamman#rightarrowp#pi^{#minus}", ParticleName_ROOT(Gamma), ParticleName_ROOT(PiMinus), ParticleMass(Gamma), ParticleMass(Deuteron)); locCrossSectionData->Set_Data(locDataName, locCrossSectionArray, locFirstDimVector, false, false, true, false); return locCrossSectionData; } //PPM WEI CHEN (g10) else if(locDataName == "CLAS_PPM_WeiChen") { string locFileName = "rootfiles/crossfiles/CLAS_PPM_Cross_WeiChen.txt"; TObjArray* locCrossSectionArray = Import_ddCrossSections(locFileName, locFirstDimVector, 1); for(size_t loc_i = 0; loc_i < locFirstDimVector.size(); ++loc_i) locFirstDimVector[loc_i] /= 1000.0; //input is in MeV: convert to GeV //FIX UNCERTAINTIES for(size_t loc_i = 0; loc_i < locFirstDimVector.size(); ++loc_i) { TGraphErrors* locGraph = (TGraphErrors*)locCrossSectionArray->At(loc_i); double locCrossUncertPercentage = 0.0; if(locFirstDimVector[loc_i] <= 1.2) locCrossUncertPercentage = 11.54; else if(locFirstDimVector[loc_i] <= 1.4) locCrossUncertPercentage = 11.59; else if(locFirstDimVector[loc_i] <= 1.6) locCrossUncertPercentage = 11.65; else if(locFirstDimVector[loc_i] <= 1.8) locCrossUncertPercentage = 11.73; else if(locFirstDimVector[loc_i] <= 2.0) locCrossUncertPercentage = 11.82; else if(locFirstDimVector[loc_i] <= 2.2) locCrossUncertPercentage = 12.03; else if(locFirstDimVector[loc_i] <= 2.4) locCrossUncertPercentage = 12.23; else if(locFirstDimVector[loc_i] <= 2.6) locCrossUncertPercentage = 12.49; else if(locFirstDimVector[loc_i] <= 2.8) locCrossUncertPercentage = 12.67; else if(locFirstDimVector[loc_i] <= 3.0) locCrossUncertPercentage = 12.84; else if(locFirstDimVector[loc_i] <= 3.2) locCrossUncertPercentage = 13.09; else if(locFirstDimVector[loc_i] <= 3.4) locCrossUncertPercentage = 13.28; else locCrossUncertPercentage = 13.70; int locN = locGraph->GetN(); double* locY = locGraph->GetY(); double* locEY = locGraph->GetEY(); for(int loc_j = 0; loc_j < locN; ++loc_j) locEY[loc_j] = locY[loc_j]*locCrossUncertPercentage/100.0; } DCrossSectionData* locCrossSectionData = new DCrossSectionData("#gammad#rightarrowp#pi^{#minus}(p)", ParticleName_ROOT(Gamma), ParticleName_ROOT(PiMinus), ParticleMass(Gamma), ParticleMass(Deuteron)); locCrossSectionData->Set_Data(locDataName, locCrossSectionArray, locFirstDimVector, false, false, true, false); return locCrossSectionData; } else if(locDataName == "CLAS_PPM_WeiChen_FSICorr") { string locFileName = "rootfiles/crossfiles/CLAS_PPM_Cross_WeiChen.txt"; TObjArray* locCrossSectionArray = Import_ddCrossSections(locFileName, locFirstDimVector, 0, true); for(size_t loc_i = 0; loc_i < locFirstDimVector.size(); ++loc_i) locFirstDimVector[loc_i] /= 1000.0; //input is in MeV: convert to GeV for(size_t loc_i = 0; loc_i < locFirstDimVector.size(); ++loc_i) { TGraphErrors* locGraph = (TGraphErrors*)locCrossSectionArray->At(loc_i); double locCrossUncertPercentage = 0.0; if(locFirstDimVector[loc_i] <= 1.2) locCrossUncertPercentage = 11.54; else if(locFirstDimVector[loc_i] <= 1.4) locCrossUncertPercentage = 11.59; else if(locFirstDimVector[loc_i] <= 1.6) locCrossUncertPercentage = 11.65; else if(locFirstDimVector[loc_i] <= 1.8) locCrossUncertPercentage = 11.73; else if(locFirstDimVector[loc_i] <= 2.0) locCrossUncertPercentage = 11.82; else if(locFirstDimVector[loc_i] <= 2.2) locCrossUncertPercentage = 12.03; else if(locFirstDimVector[loc_i] <= 2.4) locCrossUncertPercentage = 12.23; else if(locFirstDimVector[loc_i] <= 2.6) locCrossUncertPercentage = 12.49; else if(locFirstDimVector[loc_i] <= 2.8) locCrossUncertPercentage = 12.67; else if(locFirstDimVector[loc_i] <= 3.0) locCrossUncertPercentage = 12.84; else if(locFirstDimVector[loc_i] <= 3.2) locCrossUncertPercentage = 13.09; else if(locFirstDimVector[loc_i] <= 3.4) locCrossUncertPercentage = 13.28; else locCrossUncertPercentage = 13.70; double locFSIUncertPercentage = 0.0; if(locFirstDimVector[loc_i] <= 1.8) locFSIUncertPercentage = 2.0; else if(locFirstDimVector[loc_i] <= 2.7) locFSIUncertPercentage = 3.0; else locFSIUncertPercentage = 5.0; //for FSI locCrossUncertPercentage = sqrt(locCrossUncertPercentage*locCrossUncertPercentage + locFSIUncertPercentage*locFSIUncertPercentage); int locN = locGraph->GetN(); double* locY = locGraph->GetY(); double* locEY = locGraph->GetEY(); for(int loc_j = 0; loc_j < locN; ++loc_j) locEY[loc_j] = locY[loc_j]*locCrossUncertPercentage/100.0; } DCrossSectionData* locCrossSectionData = new DCrossSectionData("#gamman#rightarrowp#pi^{#minus}", ParticleName_ROOT(Gamma), ParticleName_ROOT(PiMinus), ParticleMass(Gamma), ParticleMass(Deuteron)); locCrossSectionData->Set_Data(locDataName, locCrossSectionArray, locFirstDimVector, false, false, true, false); return locCrossSectionData; } //STRANGE else if(locDataName == "CLAS_KPL_MikeMcCracken") { string locFileName = "rootfiles/crossfiles/CLAS_KPL_Cross_McCrackenNew.txt"; TObjArray* locCrossSectionArray = Import_ddCrossSections(locFileName, locFirstDimVector, 0); DCrossSectionData* locCrossSectionData = new DCrossSectionData("#gammap#rightarrowK^{+}#Lambda", ParticleName_ROOT(Gamma), ParticleName_ROOT(KPlus), ParticleMass(Gamma), ParticleMass(Proton)); locCrossSectionData->Set_Data(locDataName, locCrossSectionArray, locFirstDimVector, true, true, true, true); return locCrossSectionData; } else if(locDataName == "CLAS_KPSM_SergioPereira") { string locFileName = "rootfiles/crossfiles/CLAS_KPSM_Cross_Pereira.txt"; TObjArray* locCrossSectionArray = Import_ddCrossSections(locFileName, locFirstDimVector, 0); DCrossSectionData* locCrossSectionData = new DCrossSectionData("#gammad#rightarrowK^{+}#Sigma^{-}(p)", ParticleName_ROOT(Gamma), ParticleName_ROOT(KPlus), ParticleMass(Gamma), ParticleMass(Neutron)); locCrossSectionData->Set_Data(locDataName, locCrossSectionArray, locFirstDimVector, false, true, true, true); return locCrossSectionData; } //STRANGE* else if(locDataName == "CLAS_KPSSM_HaiyunLu") { string locFileName = "rootfiles/crossfiles/CLAS_KPSSM_Cross_Lu.txt"; TObjArray* locCrossSectionArray = Import_ddCrossSections(locFileName, locFirstDimVector, 0); DCrossSectionData* locCrossSectionData = new DCrossSectionData("#gammad#rightarrowK^{+}#Sigma*(1385)^{-}(p)", ParticleName_ROOT(Gamma), ParticleName_ROOT(KPlus), ParticleMass(Gamma), ParticleMass(Deuteron)); locCrossSectionData->Set_Data(locDataName, locCrossSectionArray, locFirstDimVector, false, true, true, true); return locCrossSectionData; } else if(locDataName == "LEPS_KPSSM_KenHicks") { string locFileName = "rootfiles/crossfiles/LEPS_KPSSM_Cross_Hicks.txt"; TObjArray* locCrossSectionArray = Import_ddCrossSections(locFileName, locFirstDimVector, 0); DCrossSectionData* locCrossSectionData = new DCrossSectionData("#gammad#rightarrowK^{+}#Sigma*(1385)^{-}(p)", ParticleName_ROOT(Gamma), ParticleName_ROOT(KPlus), ParticleMass(Gamma), ParticleMass(Deuteron)); locCrossSectionData->Set_Data(locDataName, locCrossSectionArray, locFirstDimVector, false, true, true, true); return locCrossSectionData; } else if(locDataName == "KPSSM_YongseokOh") { string locFileName = "rootfiles/crossfiles/Model_KPSSM_Cross_Oh.txt"; TObjArray* locCrossSectionArray = Import_ddCrossSections(locFileName, locFirstDimVector, 1); DCrossSectionData* locCrossSectionData = new DCrossSectionData("#gamma}n}#rightarrowK^{+}#Sigma*(1385)^{-}", ParticleName_ROOT(Gamma), ParticleName_ROOT(KPlus), ParticleMass(Gamma), ParticleMass(Neutron)); locCrossSectionData->Set_Data(locDataName, locCrossSectionArray, locFirstDimVector, false, true, true, true); return locCrossSectionData; } else if(locDataName == "KSZL_SanghoKim_NStars") { string locFileName = "rootfiles/crossfiles/Model_KSZL_Cross_OhNew_WithNStars.txt"; TObjArray* locCrossSectionArray = Import_ddCrossSections(locFileName, locFirstDimVector, 1); DCrossSectionData* locCrossSectionData = new DCrossSectionData("#gamma}n}#rightarrowK*(892)^{0}#Lambda", ParticleName_ROOT(Gamma), ParticleName_ROOT(KStar_892_0), ParticleMass(Gamma), ParticleMass(Neutron)); locCrossSectionData->Set_Data(locDataName, locCrossSectionArray, locFirstDimVector, false, true, true, true); //WARNING: POINTS IN REVERSE ORDER return locCrossSectionData; } else if(locDataName == "KSZL_SanghoKim_NoNStars") { string locFileName = "rootfiles/crossfiles/Model_KSZL_Cross_OhNew_WithoutNStars.txt"; TObjArray* locCrossSectionArray = Import_ddCrossSections(locFileName, locFirstDimVector, 1); DCrossSectionData* locCrossSectionData = new DCrossSectionData("#gamma}n}#rightarrowK*(892)^{0}#Lambda", ParticleName_ROOT(Gamma), ParticleName_ROOT(KStar_892_0), ParticleMass(Gamma), ParticleMass(Neutron)); locCrossSectionData->Set_Data(locDataName, locCrossSectionArray, locFirstDimVector, false, true, true, true); //WARNING: POINTS IN REVERSE ORDER return locCrossSectionData; } return NULL; } TObjArray* Import_ddCrossSections(string locFileName, vector& locFirstDimVector, int locNumExtraNums, bool locHasFSIColumn) { cout << "IMPORT FUNC" << endl; //assumes input is in order of: First-Dimension Term, Second-Dimension Term, Cross Value, Cross Error, #Extras ifstream locInputStream(locFileName.c_str()); TObjArray *locCrossArray = new TObjArray(); double locFirstDimValue, locSecondDimValue, locCrossValue, locCrossError, locDummy; vector locSecondDimVector, locCrossValueVector, locCrossErrorVector; locInputStream >> locFirstDimValue; locFirstDimVector.clear(); locFirstDimVector.push_back(locFirstDimValue); while(!locInputStream.eof()) { locInputStream >> locSecondDimValue >> locCrossValue >> locCrossError; for(int loc_j = 0; loc_j < locNumExtraNums; ++loc_j) locInputStream >> locDummy; double locFSICorr = 0.0; if(locHasFSIColumn) { locInputStream >> locFSICorr; locCrossValue /= locFSICorr; locCrossError /= locFSICorr; } locInputStream >> locFirstDimValue; //for the NEXT iteration if(locCrossValue > 0.0) { locSecondDimVector.push_back(locSecondDimValue); locCrossValueVector.push_back(locCrossValue); locCrossErrorVector.push_back(locCrossError); } if(fabs(locFirstDimValue - locFirstDimVector.back()) > 0.0) //next iteration is a different bin { cout << "IMPORTING: END OF BIN " << locFirstDimVector.size() << endl; Handle_EndOfBin(locCrossArray, locSecondDimVector, locCrossValueVector, locCrossErrorVector); locFirstDimVector.push_back(locFirstDimValue); //for the NEXT iteration } } Handle_EndOfBin(locCrossArray, locSecondDimVector, locCrossValueVector, locCrossErrorVector); cout << "IMPORTING: END OF LAST BIN" << endl; return locCrossArray; } //vector Reverse_Order(vector& locInputVector); void Handle_EndOfBin(TObjArray *locCrossArray, vector& locSecondDimVector, vector& locCrossValueVector, vector& locCrossErrorVector) { //finished previous energy bin size_t locNumPoints = locSecondDimVector.size(); /* if(locSecondDimVector[0] > locSecondDimVector[1]) { locSecondDimVector = Reverse_Order(locSecondDimVector); locCrossValueVector = Reverse_Order(locCrossValueVector); locCrossErrorVector = Reverse_Order(locCrossErrorVector); } */ double* locCosThetaValueArray = new double[locNumPoints]; for(size_t loc_i = 0; loc_i < locNumPoints; ++loc_i) locCosThetaValueArray[loc_i] = locSecondDimVector[loc_i]; double* locCrossValueArray = new double[locNumPoints]; for(size_t loc_i = 0; loc_i < locNumPoints; ++loc_i) locCrossValueArray[loc_i] = locCrossValueVector[loc_i]; double* locCrossErrorArray = new double[locNumPoints]; for(size_t loc_i = 0; loc_i < locNumPoints; ++loc_i) locCrossErrorArray[loc_i] = locCrossErrorVector[loc_i]; locSecondDimVector.clear(); locCrossValueVector.clear(); locCrossErrorVector.clear(); TGraphErrors* locGraphErrors = new TGraphErrors(locNumPoints, locCosThetaValueArray, locCrossValueArray, NULL, locCrossErrorArray); locCrossArray->AddLast(locGraphErrors); } /* vector Reverse_Order(vector& locInputVector) { vector locOutputVector; locOutputVector.resize(locInputVector.size()); for(size_t loc_i = 0; loc_i < locInputVector.size(); ++loc_i) locOutputVector[locInputVector.size() - loc_i - 1] = locInputVector[loc_i]; return locOutputVector; } */ TObjArray* Import_CrossSections(string locFileName, vector& locBeamEnergyVector) { cout << "IMPORT FUNC" << endl; //assumes input is in order of: First-Dimension Term, Second-Dimension Term, Cross Value, Cross Error, #Extras ifstream locInputStream(locFileName.c_str()); TObjArray *locCrossArray = new TObjArray(); double locBeamEnergy, locCosTheta, locCrossValue, locCrossError, locDummy; vector locCosThetaVector, locCrossValueVector, locCrossErrorVector; locInputStream >> locBeamEnergy; locBeamEnergyVector.clear(); locBeamEnergyVector.push_back(locBeamEnergy); while(!locInputStream.eof()) { locInputStream >> locCosTheta >> locCrossValue >> locDummy >> locDummy >> locDummy >> locDummy >> locCrossError; locInputStream >> locBeamEnergy; //for the NEXT iteration if(locCrossValue > 0.0) { locCosThetaVector.push_back(locCosTheta); locCrossValueVector.push_back(locCrossValue); locCrossErrorVector.push_back(locCrossError); } if(fabs(locBeamEnergy - locBeamEnergyVector.back()) > 0.0) //next iteration is a different bin { cout << "IMPORTING: END OF BIN " << locBeamEnergyVector.size() << endl; Handle_EndOfBin(locCrossArray, locCosThetaVector, locCrossValueVector, locCrossErrorVector); locBeamEnergyVector.push_back(locBeamEnergy); //for the NEXT iteration } } Handle_EndOfBin(locCrossArray, locCosThetaVector, locCrossValueVector, locCrossErrorVector); cout << "IMPORTING: END OF LAST BIN" << endl; return locCrossArray; }