From 72ce53279d7dcf23f44c11cf6ada3539f010656f Mon Sep 17 00:00:00 2001 From: Ryan Tang Date: Sun, 9 Apr 2023 16:22:57 -0400 Subject: [PATCH] modified all related code for the updated DetectorGeo format --- .gitignore | 12 +++++++++++- Cleopatra/Check_Simulation.C | 20 ++++++++++---------- Cleopatra/ExtractXSec.h | 2 +- Cleopatra/FindThetaCM.h | 25 +++++++++++++------------ Cleopatra/HELIOS_LIB.h | 32 ++++++++++++++++---------------- Cleopatra/InFileCreator.h | 6 +++--- Cleopatra/PlotSimulation.C | 2 +- Cleopatra/Simulation_Helper.C | 4 ++-- Cleopatra/Transfer.h | 12 ++++++------ Cleopatra/makefile | 2 +- armory/AnalysisLib.h | 2 +- working/detectorGeo.txt | 4 ++-- 12 files changed, 67 insertions(+), 56 deletions(-) diff --git a/.gitignore b/.gitignore index 01e9e07..98b4f2b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,14 @@ EventBuilder *.so data_raw -root_data \ No newline at end of file +root_data + +Cleopatra/ExtractXSec +Cleopatra/ExtractXSecFromText +Cleopatra/FindThetaCM +Cleopatra/InFileCreator +Cleopatra/Isotope +Cleopatra/IsotopeShort +Cleopatra/PlotSimulation +Cleopatra/PlotTGraphTObjArray +Cleopatra/Transfer \ No newline at end of file diff --git a/Cleopatra/Check_Simulation.C b/Cleopatra/Check_Simulation.C index 1a80a57..c6bdaee 100644 --- a/Cleopatra/Check_Simulation.C +++ b/Cleopatra/Check_Simulation.C @@ -109,7 +109,7 @@ void Check_Simulation(TString filename = "transfer.root", TMacro * reactionConfigTxt = (TMacro *) file->FindObjectAny("reactionConfig"); TString Reaction=reactionConfigTxt->GetName(); - ReactionConfig reactionConfig = LoadReactionConfig(reactionConfigTxt); + AnalysisLib::ReactionConfig reactionConfig = AnalysisLib::LoadReactionConfig(reactionConfigTxt); int nEvent = reactionConfig.numEvents; printf("number of events generated : %d \n", nEvent); @@ -137,15 +137,15 @@ void Check_Simulation(TString filename = "transfer.root", printf(" loading detector Geometry.\n"); TMacro * detGeoTxt = (TMacro *) file->FindObjectAny("detGeo"); - DetGeo detGeo = LoadDetectorGeo(detGeoTxt); + AnalysisLib::DetGeo detGeo = AnalysisLib::LoadDetectorGeo(detGeoTxt); double field = detGeo.Bfield; TString fdmsg = field > 0 ? "out of plan" : "into plan"; TString msg2; msg2.Form("field = %.2f T, %s", field, fdmsg.Data()); - double prepDist = detGeo.detPerpDist; - double length = detGeo.detLength; + double prepDist = detGeo.array1.detPerpDist; + double length = detGeo.array1.detLength; double posRecoil = detGeo.recoilPos; double rhoRecoilIn = detGeo.recoilInnerRadius; double rhoRecoilOut = detGeo.recoilOuterRadius; @@ -153,11 +153,11 @@ void Check_Simulation(TString filename = "transfer.root", double posRecoil1 = detGeo.recoilPos1; double posRecoil2 = detGeo.recoilPos2; - vector pos = detGeo.detPos; + vector pos = detGeo.array1.detPos; - float firstPos = detGeo.firstPos; - int rDet = detGeo.nDet; - int cDet = detGeo.mDet; + float firstPos = detGeo.array1.firstPos; + int rDet = detGeo.array1.nDet; + int cDet = detGeo.array1.mDet; double elum1 = detGeo.elumPos1; @@ -191,7 +191,7 @@ void Check_Simulation(TString filename = "transfer.root", string temp = exListMacro->GetListOfLines()->At(i)->GetName(); if( temp[0] == '#' ) break; if( temp[0] == '/' ) continue; - vector tempStr = SplitStr(temp, " "); + vector tempStr = AnalysisLib::SplitStr(temp, " "); printf("%d | %s \n", i, 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 "&&" int ll = gate.Length(); if( ll > 30 ) { - vector strList = SplitStr( (string) gate.Data(), "&&"); + vector strList = AnalysisLib::SplitStr( (string) gate.Data(), "&&"); for( int i = 0; i < strList.size(); i++){ text.DrawLatex(0., 0.6 - 0.05*i, (TString) strList[i]); } diff --git a/Cleopatra/ExtractXSec.h b/Cleopatra/ExtractXSec.h index ff42554..45b03c8 100644 --- a/Cleopatra/ExtractXSec.h +++ b/Cleopatra/ExtractXSec.h @@ -419,7 +419,7 @@ int ExtractXSecFromText(string readFile){ //printf("%d | %s\n", lineNum, line.c_str()); //after the comment line, the next line must be column name - vector header= SplitStr(line, " "); + vector header= AnalysisLib::SplitStr(line, " "); //printf("---%lu #", header.size()); //for( int i = 0; i < header.size(); i++){ // printf("%s|", header[i].c_str()); diff --git a/Cleopatra/FindThetaCM.h b/Cleopatra/FindThetaCM.h index 9d2678f..ad41d8c 100644 --- a/Cleopatra/FindThetaCM.h +++ b/Cleopatra/FindThetaCM.h @@ -12,6 +12,7 @@ #include "TFile.h" #include "TTree.h" +#include "TF1.h" #include "TMacro.h" #include "TObjArray.h" #include "TGraph.h" @@ -33,13 +34,13 @@ void FindThetaCM(double Ex, int nDivision=1, double XRATION = 0.95, double xBeam, yBeam; // mm /**///========================================================= load files - ReactionConfig reactionConfig; - DetGeo detGeo; + AnalysisLib::ReactionConfig reactionConfig; + AnalysisLib::DetGeo detGeo; TMacro * haha = new TMacro(); if( haha->ReadFile(basicConfig.c_str()) > 0 ){ - reactionConfig = LoadReactionConfig(haha); + reactionConfig = AnalysisLib::LoadReactionConfig(haha); - PrintReactionConfig(reactionConfig); + AnalysisLib::PrintReactionConfig(reactionConfig); KEAmean = reactionConfig.beamEnergy; 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()); TMacro * kaka = new TMacro(); if( kaka->ReadFile(detGeoFileName.c_str()) > 0 ){ - detGeo = LoadDetectorGeo(kaka); + detGeo = AnalysisLib::LoadDetectorGeo(kaka); - pos = detGeo.detPos; - a = detGeo.detPerpDist; - length = detGeo.detLength; - firstPos = detGeo.firstPos; - iDet = detGeo.nDet; - jDet = detGeo.mDet; + pos = detGeo.array1.detPos; + a = detGeo.array1.detPerpDist; + length = detGeo.array1.detLength; + firstPos = detGeo.array1.firstPos; + iDet = detGeo.array1.nDet; + jDet = detGeo.array1.mDet; BField = detGeo.Bfield; printf("... done.\n"); - PrintDetGeo(detGeo); + AnalysisLib::PrintDetGeo(detGeo); }else{ printf("... fail\n"); diff --git a/Cleopatra/HELIOS_LIB.h b/Cleopatra/HELIOS_LIB.h index 1e08e79..c93aa3f 100644 --- a/Cleopatra/HELIOS_LIB.h +++ b/Cleopatra/HELIOS_LIB.h @@ -79,11 +79,11 @@ public: double GetReactionGamma() {return gamma;} double GetCMTotalEnergy() {return Etot;} - ReactionConfig GetRectionConfig() { return reaction;} + AnalysisLib::ReactionConfig GetRectionConfig() { return reaction;} private: - ReactionConfig reaction; + AnalysisLib::ReactionConfig reaction; string nameA, namea, nameb, nameB; double thetaIN, phiIN; @@ -201,7 +201,7 @@ void TransferReaction::SetReactionFromFile(string settingFile){ TMacro * haha = new TMacro(); if( haha->ReadFile(settingFile.c_str()) > 0 ) { - reaction = LoadReactionConfig(haha); + reaction = AnalysisLib::LoadReactionConfig(haha); SetA(reaction.beamA, reaction.beamZ); Seta(reaction.targetA, reaction.targetZ); @@ -501,7 +501,7 @@ public: trajectory GetTrajectory_b() {return orbitb;} trajectory GetTrajectory_B() {return orbitB;} - DetGeo GetDetectorGeometry() {return detGeo;} + AnalysisLib::DetGeo GetDetectorGeometry() {return detGeo;} private: @@ -522,7 +522,7 @@ private: t.loop = -1; } - DetGeo detGeo; + AnalysisLib::DetGeo detGeo; trajectory orbitb, orbitB; @@ -607,7 +607,7 @@ bool HELIOS::SetDetectorGeometry(string filename){ TMacro * haha = new TMacro(); if( haha->ReadFile(filename.c_str()) > 0 ) { - detGeo = LoadDetectorGeo(haha); + detGeo = AnalysisLib::LoadDetectorGeo(haha); PrintDetGeo(detGeo); @@ -615,22 +615,22 @@ bool HELIOS::SetDetectorGeometry(string filename){ BfieldTheta = detGeo.BfieldTheta; sign = detGeo.BfieldSign; bore = detGeo.bore; - perpDist = detGeo.detPerpDist; - width = detGeo.detWidth; posRecoil = detGeo.recoilPos; rhoRecoilin = detGeo.recoilInnerRadius; rhoRecoilout = detGeo.recoilOuterRadius; - length = detGeo.detLength; - blocker = detGeo.blocker; - firstPos = detGeo.firstPos; - pos = detGeo.detPos; - nDet = detGeo.nDet; - mDet = detGeo.mDet; + + length = detGeo.array1.detLength; + width = detGeo.array1.detWidth; + perpDist = detGeo.array1.detPerpDist; + blocker = detGeo.array1.blocker; + firstPos = detGeo.array1.firstPos; + pos = detGeo.array1.detPos; + nDet = detGeo.array1.nDet; + mDet = detGeo.array1.mDet; + isFromOutSide = detGeo.array1.detFaceOut; isCoincidentWithRecoil = detGeo.isCoincidentWithRecoil; - isFromOutSide = detGeo.detFaceOut; - isDetReady = true; }else{ printf("cannot read file %s.\n", filename.c_str()); diff --git a/Cleopatra/InFileCreator.h b/Cleopatra/InFileCreator.h index cc1c10f..3c7473f 100644 --- a/Cleopatra/InFileCreator.h +++ b/Cleopatra/InFileCreator.h @@ -74,7 +74,7 @@ int InFileCreator(string readFile, string infile, double angMin, double angMax, if( tempLine.size() < 5 ) continue; //split line using space - vector str0 = SplitStr(tempLine, " "); + vector str0 = AnalysisLib::SplitStr(tempLine, " "); if ( str0.size() == 0 ) continue; 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()); ///} - vector str1 = SplitStr(str0[0], "(", 0); - vector str2 = SplitStr(str1[1], ")", 1); + vector str1 = AnalysisLib::SplitStr(str0[0], "(", 0); + vector str2 = AnalysisLib::SplitStr(str1[1], ")", 1); str2[0] = "(" + str2[0]; diff --git a/Cleopatra/PlotSimulation.C b/Cleopatra/PlotSimulation.C index 2318017..e3080c1 100644 --- a/Cleopatra/PlotSimulation.C +++ b/Cleopatra/PlotSimulation.C @@ -1,7 +1,7 @@ #include #include -#include "../Armory/Check_Simulation.C" +#include "Check_Simulation.C" using namespace std; diff --git a/Cleopatra/Simulation_Helper.C b/Cleopatra/Simulation_Helper.C index 5a18f79..78775f4 100644 --- a/Cleopatra/Simulation_Helper.C +++ b/Cleopatra/Simulation_Helper.C @@ -85,7 +85,7 @@ MyMainFrame::MyMainFrame(const TGWindow *p,UInt_t w,UInt_t h) { TGVerticalFrame *hframe2 = new TGVerticalFrame(fMain,600,800 ); 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 ); 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"); if( temp != NULL ){ - fitAuto(temp, -1); + AutoFit::fitAuto(temp, -1); statusLabel->SetText("Auto Fit hExCal"); }else{ statusLabel->SetText("Cannot find historgram hExCal. Please Run Plot Simulation first."); diff --git a/Cleopatra/Transfer.h b/Cleopatra/Transfer.h index 9c093d5..41fef91 100644 --- a/Cleopatra/Transfer.h +++ b/Cleopatra/Transfer.h @@ -37,9 +37,9 @@ void Transfer( printf("----- loading reaction setting from %s. \n", basicConfig.c_str()); printf("\e[32m#################################### Beam \e[0m\n"); - const ReactionConfig reactionConfig = reaction.GetRectionConfig(); + const AnalysisLib::ReactionConfig reactionConfig = reaction.GetRectionConfig(); - PrintReactionConfig(reactionConfig); + AnalysisLib::PrintReactionConfig(reactionConfig); vector ExAList = reactionConfig.beamEx; int nExA = (int) ExAList.size(); @@ -49,7 +49,7 @@ void Transfer( HELIOS helios; helios.SetDetectorGeometry(heliosDetGeoFile); - const DetGeo detGeo = helios.GetDetectorGeometry(); + const AnalysisLib::DetGeo detGeo = helios.GetDetectorGeometry(); printf("==================================== E-Z plot slope\n"); double betaRect = reaction.GetReactionBeta() ; @@ -128,7 +128,7 @@ void Transfer( if( line.substr(0,2) == "//" ) continue; if( line.substr(0,2) == "#=" ) break; - vector str = SplitStr(line, " "); + vector str = AnalysisLib::SplitStr(line, " "); ExKnown.push_back(atof(str[0].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(); - 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; detX = helios.GetDetX() + ranX; diff --git a/Cleopatra/makefile b/Cleopatra/makefile index a9fdcd0..b53277a 100644 --- a/Cleopatra/makefile +++ b/Cleopatra/makefile @@ -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 $(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` Isotope: ../Cleopatra/Isotope.h ../Cleopatra/Isotope.C diff --git a/armory/AnalysisLib.h b/armory/AnalysisLib.h index 8d26dd4..aaf10f5 100644 --- a/armory/AnalysisLib.h +++ b/armory/AnalysisLib.h @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -153,7 +154,6 @@ struct ReactionConfig{ bool isRedo; ///isReDo std::vector beamEx; ///excitation_energy_of_A[MeV] - }; ///Using TMacro to load the detectorGeo frist, diff --git a/working/detectorGeo.txt b/working/detectorGeo.txt index 9abec51..d302ecc 100644 --- a/working/detectorGeo.txt +++ b/working/detectorGeo.txt @@ -9,7 +9,7 @@ false //is_coincident_with_recoil 0 //Recoil_2_position_[mm] 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 -#===============1st_detector +#===============1st_Array 11.5 //distance_from_axis_[mm] 10.0 //width_of_detector_[mm] 50 //length_of_detector_[mm] @@ -25,7 +25,7 @@ Out //detector_facing_Out_or_In 176.8 235.8 //5th_det 290.0 -#===============2nd_detector +#===============2nd_Array true //is_2nd_detctor_exist_false=false_other=true 11.5 //distance_from_axis_[mm] 10.0 //width_of_detector_[mm]