modified all related code for the updated DetectorGeo format

This commit is contained in:
Ryan Tang 2023-04-09 16:22:57 -04:00
parent ef8e20d915
commit 72ce53279d
12 changed files with 67 additions and 56 deletions

10
.gitignore vendored
View File

@ -8,3 +8,13 @@ EventBuilder
data_raw data_raw
root_data root_data
Cleopatra/ExtractXSec
Cleopatra/ExtractXSecFromText
Cleopatra/FindThetaCM
Cleopatra/InFileCreator
Cleopatra/Isotope
Cleopatra/IsotopeShort
Cleopatra/PlotSimulation
Cleopatra/PlotTGraphTObjArray
Cleopatra/Transfer

View File

@ -109,7 +109,7 @@ void Check_Simulation(TString filename = "transfer.root",
TMacro * reactionConfigTxt = (TMacro *) file->FindObjectAny("reactionConfig"); TMacro * reactionConfigTxt = (TMacro *) file->FindObjectAny("reactionConfig");
TString Reaction=reactionConfigTxt->GetName(); TString Reaction=reactionConfigTxt->GetName();
ReactionConfig reactionConfig = LoadReactionConfig(reactionConfigTxt); AnalysisLib::ReactionConfig reactionConfig = AnalysisLib::LoadReactionConfig(reactionConfigTxt);
int nEvent = reactionConfig.numEvents; int nEvent = reactionConfig.numEvents;
printf("number of events generated : %d \n", nEvent); printf("number of events generated : %d \n", nEvent);
@ -137,15 +137,15 @@ void Check_Simulation(TString filename = "transfer.root",
printf(" loading detector Geometry.\n"); printf(" loading detector Geometry.\n");
TMacro * detGeoTxt = (TMacro *) file->FindObjectAny("detGeo"); TMacro * detGeoTxt = (TMacro *) file->FindObjectAny("detGeo");
DetGeo detGeo = LoadDetectorGeo(detGeoTxt); AnalysisLib::DetGeo detGeo = AnalysisLib::LoadDetectorGeo(detGeoTxt);
double field = detGeo.Bfield; double field = detGeo.Bfield;
TString fdmsg = field > 0 ? "out of plan" : "into plan"; TString fdmsg = field > 0 ? "out of plan" : "into plan";
TString msg2; TString msg2;
msg2.Form("field = %.2f T, %s", field, fdmsg.Data()); msg2.Form("field = %.2f T, %s", field, fdmsg.Data());
double prepDist = detGeo.detPerpDist; double prepDist = detGeo.array1.detPerpDist;
double length = detGeo.detLength; double length = detGeo.array1.detLength;
double posRecoil = detGeo.recoilPos; double posRecoil = detGeo.recoilPos;
double rhoRecoilIn = detGeo.recoilInnerRadius; double rhoRecoilIn = detGeo.recoilInnerRadius;
double rhoRecoilOut = detGeo.recoilOuterRadius; double rhoRecoilOut = detGeo.recoilOuterRadius;
@ -153,11 +153,11 @@ void Check_Simulation(TString filename = "transfer.root",
double posRecoil1 = detGeo.recoilPos1; double posRecoil1 = detGeo.recoilPos1;
double posRecoil2 = detGeo.recoilPos2; double posRecoil2 = detGeo.recoilPos2;
vector<double> pos = detGeo.detPos; vector<double> pos = detGeo.array1.detPos;
float firstPos = detGeo.firstPos; float firstPos = detGeo.array1.firstPos;
int rDet = detGeo.nDet; int rDet = detGeo.array1.nDet;
int cDet = detGeo.mDet; int cDet = detGeo.array1.mDet;
double elum1 = detGeo.elumPos1; double elum1 = detGeo.elumPos1;
@ -191,7 +191,7 @@ void Check_Simulation(TString filename = "transfer.root",
string temp = exListMacro->GetListOfLines()->At(i)->GetName(); string temp = exListMacro->GetListOfLines()->At(i)->GetName();
if( temp[0] == '#' ) break; if( temp[0] == '#' ) break;
if( temp[0] == '/' ) continue; if( temp[0] == '/' ) continue;
vector<string> tempStr = SplitStr(temp, " "); vector<string> tempStr = AnalysisLib::SplitStr(temp, " ");
printf("%d | %s \n", i, tempStr[0].c_str()); printf("%d | %s \n", i, tempStr[0].c_str());
exList.push_back(atof(tempStr[0].c_str())); exList.push_back(atof(tempStr[0].c_str()));
} }
@ -413,7 +413,7 @@ void Check_Simulation(TString filename = "transfer.root",
//check gate text length, if > 30, break by "&&" //check gate text length, if > 30, break by "&&"
int ll = gate.Length(); int ll = gate.Length();
if( ll > 30 ) { if( ll > 30 ) {
vector<string> strList = SplitStr( (string) gate.Data(), "&&"); vector<string> strList = AnalysisLib::SplitStr( (string) gate.Data(), "&&");
for( int i = 0; i < strList.size(); i++){ for( int i = 0; i < strList.size(); i++){
text.DrawLatex(0., 0.6 - 0.05*i, (TString) strList[i]); text.DrawLatex(0., 0.6 - 0.05*i, (TString) strList[i]);
} }

View File

@ -419,7 +419,7 @@ int ExtractXSecFromText(string readFile){
//printf("%d | %s\n", lineNum, line.c_str()); //printf("%d | %s\n", lineNum, line.c_str());
//after the comment line, the next line must be column name //after the comment line, the next line must be column name
vector<string> header= SplitStr(line, " "); vector<string> header= AnalysisLib::SplitStr(line, " ");
//printf("---%lu #", header.size()); //printf("---%lu #", header.size());
//for( int i = 0; i < header.size(); i++){ //for( int i = 0; i < header.size(); i++){
// printf("%s|", header[i].c_str()); // printf("%s|", header[i].c_str());

View File

@ -12,6 +12,7 @@
#include "TFile.h" #include "TFile.h"
#include "TTree.h" #include "TTree.h"
#include "TF1.h"
#include "TMacro.h" #include "TMacro.h"
#include "TObjArray.h" #include "TObjArray.h"
#include "TGraph.h" #include "TGraph.h"
@ -33,13 +34,13 @@ void FindThetaCM(double Ex, int nDivision=1, double XRATION = 0.95,
double xBeam, yBeam; // mm double xBeam, yBeam; // mm
/**///========================================================= load files /**///========================================================= load files
ReactionConfig reactionConfig; AnalysisLib::ReactionConfig reactionConfig;
DetGeo detGeo; AnalysisLib::DetGeo detGeo;
TMacro * haha = new TMacro(); TMacro * haha = new TMacro();
if( haha->ReadFile(basicConfig.c_str()) > 0 ){ if( haha->ReadFile(basicConfig.c_str()) > 0 ){
reactionConfig = LoadReactionConfig(haha); reactionConfig = AnalysisLib::LoadReactionConfig(haha);
PrintReactionConfig(reactionConfig); AnalysisLib::PrintReactionConfig(reactionConfig);
KEAmean = reactionConfig.beamEnergy; KEAmean = reactionConfig.beamEnergy;
KEAsigma = reactionConfig.beamEnergySigma; KEAsigma = reactionConfig.beamEnergySigma;
@ -100,19 +101,19 @@ void FindThetaCM(double Ex, int nDivision=1, double XRATION = 0.95,
printf("----- loading detector geometery : %s.", detGeoFileName.c_str()); printf("----- loading detector geometery : %s.", detGeoFileName.c_str());
TMacro * kaka = new TMacro(); TMacro * kaka = new TMacro();
if( kaka->ReadFile(detGeoFileName.c_str()) > 0 ){ if( kaka->ReadFile(detGeoFileName.c_str()) > 0 ){
detGeo = LoadDetectorGeo(kaka); detGeo = AnalysisLib::LoadDetectorGeo(kaka);
pos = detGeo.detPos; pos = detGeo.array1.detPos;
a = detGeo.detPerpDist; a = detGeo.array1.detPerpDist;
length = detGeo.detLength; length = detGeo.array1.detLength;
firstPos = detGeo.firstPos; firstPos = detGeo.array1.firstPos;
iDet = detGeo.nDet; iDet = detGeo.array1.nDet;
jDet = detGeo.mDet; jDet = detGeo.array1.mDet;
BField = detGeo.Bfield; BField = detGeo.Bfield;
printf("... done.\n"); printf("... done.\n");
PrintDetGeo(detGeo); AnalysisLib::PrintDetGeo(detGeo);
}else{ }else{
printf("... fail\n"); printf("... fail\n");

View File

@ -79,11 +79,11 @@ public:
double GetReactionGamma() {return gamma;} double GetReactionGamma() {return gamma;}
double GetCMTotalEnergy() {return Etot;} double GetCMTotalEnergy() {return Etot;}
ReactionConfig GetRectionConfig() { return reaction;} AnalysisLib::ReactionConfig GetRectionConfig() { return reaction;}
private: private:
ReactionConfig reaction; AnalysisLib::ReactionConfig reaction;
string nameA, namea, nameb, nameB; string nameA, namea, nameb, nameB;
double thetaIN, phiIN; double thetaIN, phiIN;
@ -201,7 +201,7 @@ void TransferReaction::SetReactionFromFile(string settingFile){
TMacro * haha = new TMacro(); TMacro * haha = new TMacro();
if( haha->ReadFile(settingFile.c_str()) > 0 ) { if( haha->ReadFile(settingFile.c_str()) > 0 ) {
reaction = LoadReactionConfig(haha); reaction = AnalysisLib::LoadReactionConfig(haha);
SetA(reaction.beamA, reaction.beamZ); SetA(reaction.beamA, reaction.beamZ);
Seta(reaction.targetA, reaction.targetZ); Seta(reaction.targetA, reaction.targetZ);
@ -501,7 +501,7 @@ public:
trajectory GetTrajectory_b() {return orbitb;} trajectory GetTrajectory_b() {return orbitb;}
trajectory GetTrajectory_B() {return orbitB;} trajectory GetTrajectory_B() {return orbitB;}
DetGeo GetDetectorGeometry() {return detGeo;} AnalysisLib::DetGeo GetDetectorGeometry() {return detGeo;}
private: private:
@ -522,7 +522,7 @@ private:
t.loop = -1; t.loop = -1;
} }
DetGeo detGeo; AnalysisLib::DetGeo detGeo;
trajectory orbitb, orbitB; trajectory orbitb, orbitB;
@ -607,7 +607,7 @@ bool HELIOS::SetDetectorGeometry(string filename){
TMacro * haha = new TMacro(); TMacro * haha = new TMacro();
if( haha->ReadFile(filename.c_str()) > 0 ) { if( haha->ReadFile(filename.c_str()) > 0 ) {
detGeo = LoadDetectorGeo(haha); detGeo = AnalysisLib::LoadDetectorGeo(haha);
PrintDetGeo(detGeo); PrintDetGeo(detGeo);
@ -615,22 +615,22 @@ bool HELIOS::SetDetectorGeometry(string filename){
BfieldTheta = detGeo.BfieldTheta; BfieldTheta = detGeo.BfieldTheta;
sign = detGeo.BfieldSign; sign = detGeo.BfieldSign;
bore = detGeo.bore; bore = detGeo.bore;
perpDist = detGeo.detPerpDist;
width = detGeo.detWidth;
posRecoil = detGeo.recoilPos; posRecoil = detGeo.recoilPos;
rhoRecoilin = detGeo.recoilInnerRadius; rhoRecoilin = detGeo.recoilInnerRadius;
rhoRecoilout = detGeo.recoilOuterRadius; rhoRecoilout = detGeo.recoilOuterRadius;
length = detGeo.detLength;
blocker = detGeo.blocker; length = detGeo.array1.detLength;
firstPos = detGeo.firstPos; width = detGeo.array1.detWidth;
pos = detGeo.detPos; perpDist = detGeo.array1.detPerpDist;
nDet = detGeo.nDet; blocker = detGeo.array1.blocker;
mDet = detGeo.mDet; firstPos = detGeo.array1.firstPos;
pos = detGeo.array1.detPos;
nDet = detGeo.array1.nDet;
mDet = detGeo.array1.mDet;
isFromOutSide = detGeo.array1.detFaceOut;
isCoincidentWithRecoil = detGeo.isCoincidentWithRecoil; isCoincidentWithRecoil = detGeo.isCoincidentWithRecoil;
isFromOutSide = detGeo.detFaceOut;
isDetReady = true; isDetReady = true;
}else{ }else{
printf("cannot read file %s.\n", filename.c_str()); printf("cannot read file %s.\n", filename.c_str());

View File

@ -74,7 +74,7 @@ int InFileCreator(string readFile, string infile, double angMin, double angMax,
if( tempLine.size() < 5 ) continue; if( tempLine.size() < 5 ) continue;
//split line using space //split line using space
vector<string> str0 = SplitStr(tempLine, " "); vector<string> str0 = AnalysisLib::SplitStr(tempLine, " ");
if ( str0.size() == 0 ) continue; if ( str0.size() == 0 ) continue;
printf(" %s\n", tempLine.c_str()); printf(" %s\n", tempLine.c_str());
@ -83,8 +83,8 @@ int InFileCreator(string readFile, string infile, double angMin, double angMax,
/// printf(" str0[%d] %s \n", i, str0[i].c_str()); /// printf(" str0[%d] %s \n", i, str0[i].c_str());
///} ///}
vector<string> str1 = SplitStr(str0[0], "(", 0); vector<string> str1 = AnalysisLib::SplitStr(str0[0], "(", 0);
vector<string> str2 = SplitStr(str1[1], ")", 1); vector<string> str2 = AnalysisLib::SplitStr(str1[1], ")", 1);
str2[0] = "(" + str2[0]; str2[0] = "(" + str2[0];

View File

@ -1,7 +1,7 @@
#include <fstream> #include <fstream>
#include <stdlib.h> #include <stdlib.h>
#include "../Armory/Check_Simulation.C" #include "Check_Simulation.C"
using namespace std; using namespace std;

View File

@ -85,7 +85,7 @@ MyMainFrame::MyMainFrame(const TGWindow *p,UInt_t w,UInt_t h) {
TGVerticalFrame *hframe2 = new TGVerticalFrame(fMain,600,800 ); TGVerticalFrame *hframe2 = new TGVerticalFrame(fMain,600,800 );
hframe->AddFrame(hframe2,new TGLayoutHints( kLHintsExpandX | kLHintsExpandY, 2,2,2,2)); hframe->AddFrame(hframe2,new TGLayoutHints( kLHintsExpandX | kLHintsExpandY, 2,2,2,2));
fileName = "reactionConfig.txt"; fileName = "../working/reactionConfig.txt";
TGHorizontalFrame *hframe00 = new TGHorizontalFrame(hframe2,600,600 ); TGHorizontalFrame *hframe00 = new TGHorizontalFrame(hframe2,600,600 );
hframe2->AddFrame(hframe00, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX , 2,2,2,2)); hframe2->AddFrame(hframe00, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX , 2,2,2,2));
@ -566,7 +566,7 @@ void MyMainFrame::Command(int ID) {
TH1F * temp = (TH1F*) gROOT->FindObjectAny("hExCal"); TH1F * temp = (TH1F*) gROOT->FindObjectAny("hExCal");
if( temp != NULL ){ if( temp != NULL ){
fitAuto(temp, -1); AutoFit::fitAuto(temp, -1);
statusLabel->SetText("Auto Fit hExCal"); statusLabel->SetText("Auto Fit hExCal");
}else{ }else{
statusLabel->SetText("Cannot find historgram hExCal. Please Run Plot Simulation first."); statusLabel->SetText("Cannot find historgram hExCal. Please Run Plot Simulation first.");

View File

@ -37,9 +37,9 @@ void Transfer(
printf("----- loading reaction setting from %s. \n", basicConfig.c_str()); printf("----- loading reaction setting from %s. \n", basicConfig.c_str());
printf("\e[32m#################################### Beam \e[0m\n"); printf("\e[32m#################################### Beam \e[0m\n");
const ReactionConfig reactionConfig = reaction.GetRectionConfig(); const AnalysisLib::ReactionConfig reactionConfig = reaction.GetRectionConfig();
PrintReactionConfig(reactionConfig); AnalysisLib::PrintReactionConfig(reactionConfig);
vector<float> ExAList = reactionConfig.beamEx; vector<float> ExAList = reactionConfig.beamEx;
int nExA = (int) ExAList.size(); int nExA = (int) ExAList.size();
@ -49,7 +49,7 @@ void Transfer(
HELIOS helios; HELIOS helios;
helios.SetDetectorGeometry(heliosDetGeoFile); helios.SetDetectorGeometry(heliosDetGeoFile);
const DetGeo detGeo = helios.GetDetectorGeometry(); const AnalysisLib::DetGeo detGeo = helios.GetDetectorGeometry();
printf("==================================== E-Z plot slope\n"); printf("==================================== E-Z plot slope\n");
double betaRect = reaction.GetReactionBeta() ; double betaRect = reaction.GetReactionBeta() ;
@ -128,7 +128,7 @@ void Transfer(
if( line.substr(0,2) == "//" ) continue; if( line.substr(0,2) == "//" ) continue;
if( line.substr(0,2) == "#=" ) break; if( line.substr(0,2) == "#=" ) break;
vector<string> str = SplitStr(line, " "); vector<string> str = AnalysisLib::SplitStr(line, " ");
ExKnown.push_back(atof(str[0].c_str())); ExKnown.push_back(atof(str[0].c_str()));
ExStrength.push_back(atof(str[1].c_str())); ExStrength.push_back(atof(str[1].c_str()));
@ -597,9 +597,9 @@ void Transfer(
trajectory orb_b = helios.GetTrajectory_b(); trajectory orb_b = helios.GetTrajectory_b();
trajectory orb_B = helios.GetTrajectory_B(); trajectory orb_B = helios.GetTrajectory_B();
e = helios.GetEnergy() + gRandom->Gaus(0, detGeo.eSigma); e = helios.GetEnergy() + gRandom->Gaus(0, detGeo.array1.eSigma);
double ranX = gRandom->Gaus(0, detGeo.zSigma); double ranX = gRandom->Gaus(0, detGeo.array1.zSigma);
z = orb_b.z + ranX; z = orb_b.z + ranX;
detX = helios.GetDetX() + ranX; detX = helios.GetDetX() + ranX;

View File

@ -23,7 +23,7 @@ FindThetaCM: FindThetaCM.C FindThetaCM.h ../Cleopatra/HELIOS_LIB.h ../Cleopatra/
Transfer: Transfer.C Transfer.h ../Cleopatra/HELIOS_LIB.h ../Cleopatra/Isotope.h ../Cleopatra/constant.h Transfer: Transfer.C Transfer.h ../Cleopatra/HELIOS_LIB.h ../Cleopatra/Isotope.h ../Cleopatra/constant.h
$(CC) Transfer.C -o Transfer `root-config --cflags --glibs` $(CC) Transfer.C -o Transfer `root-config --cflags --glibs`
PlotSimulation: PlotSimulation.C ../Armory/Check_Simulation.C PlotSimulation: PlotSimulation.C Check_Simulation.C
$(CC) PlotSimulation.C -o PlotSimulation `root-config --cflags --glibs` $(CC) PlotSimulation.C -o PlotSimulation `root-config --cflags --glibs`
Isotope: ../Cleopatra/Isotope.h ../Cleopatra/Isotope.C Isotope: ../Cleopatra/Isotope.h ../Cleopatra/Isotope.C

View File

@ -8,6 +8,7 @@
#include <TMacro.h> #include <TMacro.h>
#include <TList.h> #include <TList.h>
#include <TFile.h>
#include <TMath.h> #include <TMath.h>
#include <TObjArray.h> #include <TObjArray.h>
#include <TCutG.h> #include <TCutG.h>
@ -153,7 +154,6 @@ struct ReactionConfig{
bool isRedo; ///isReDo bool isRedo; ///isReDo
std::vector<float> beamEx; ///excitation_energy_of_A[MeV] std::vector<float> beamEx; ///excitation_energy_of_A[MeV]
}; };
///Using TMacro to load the detectorGeo frist, ///Using TMacro to load the detectorGeo frist,

View File

@ -9,7 +9,7 @@ false //is_coincident_with_recoil
0 //Recoil_2_position_[mm] 0 //Recoil_2_position_[mm]
0.00 //Elum_1_position_[mm]_(just_another_recoil_detector_but_for_light_recoil) 0.00 //Elum_1_position_[mm]_(just_another_recoil_detector_but_for_light_recoil)
0.00 //Elum_2_position_[mm]_when_Elum=0_disable_tree_branch 0.00 //Elum_2_position_[mm]_when_Elum=0_disable_tree_branch
#===============1st_detector #===============1st_Array
11.5 //distance_from_axis_[mm] 11.5 //distance_from_axis_[mm]
10.0 //width_of_detector_[mm] 10.0 //width_of_detector_[mm]
50 //length_of_detector_[mm] 50 //length_of_detector_[mm]
@ -25,7 +25,7 @@ Out //detector_facing_Out_or_In
176.8 176.8
235.8 //5th_det 235.8 //5th_det
290.0 290.0
#===============2nd_detector #===============2nd_Array
true //is_2nd_detctor_exist_false=false_other=true true //is_2nd_detctor_exist_false=false_other=true
11.5 //distance_from_axis_[mm] 11.5 //distance_from_axis_[mm]
10.0 //width_of_detector_[mm] 10.0 //width_of_detector_[mm]