update Simulation_Helper.C

This commit is contained in:
Ryan Tang 2024-02-20 19:46:29 -05:00
parent 7a5107998a
commit 11248d361d
2 changed files with 56 additions and 99 deletions

View File

@ -105,8 +105,8 @@ void Check_Simulation(TString filename = "transfer.root",
TFile * file = new TFile(filename, "read"); TFile * file = new TFile(filename, "read");
TTree * tree = (TTree*) file->Get("tree"); TTree * tree = (TTree*) file->Get("tree");
TObjArray * fxList = (TObjArray *) file->FindObjectAny("EZCure"); TObjArray * fxList = (TObjArray *) file->FindObjectAny("EZCurve");
TObjArray * txList = (TObjArray *) file->FindObjectAny("EZ_thetaCM"); TObjArray * txList = (TObjArray *) file->FindObjectAny("thetaCM_Z");
gStyle->SetOptStat(""); gStyle->SetOptStat("");
gStyle->SetStatY(0.9); gStyle->SetStatY(0.9);

View File

@ -34,44 +34,42 @@
TString isoFileName; TString isoFileName;
class MyMainFrame { class MyMainFrame {
RQ_OBJECT("MyMainFrame") RQ_OBJECT("MyMainFrame")
private: private:
TGMainFrame *fMain; TGMainFrame *fMain;
TGTextEdit * editor; TGTextEdit * editor;
TString fileName; TString fileName;
TGLabel * fileLabel; TGLabel * fileLabel;
TGLabel * statusLabel; TGLabel * statusLabel;
TGNumberEntry * angMin; TGNumberEntry * angMin;
TGNumberEntry * angMax; TGNumberEntry * angMax;
TGNumberEntry * angStep; TGNumberEntry * angStep;
TGCheckButton * withDWBA; TGCheckButton * withDWBA;
TGCheckButton * isInFile; TGCheckButton * isInFile;
TGCheckButton * isRun; TGCheckButton * isRun;
TGCheckButton * isExtract; TGCheckButton * isExtract;
TGCheckButton * isPlot; TGCheckButton * isPlot;
TGComboBox * extractFlag; TGComboBox * extractFlag;
TGTextEntry * txtName ; TGTextEntry * txtName ;
TGTextEntry * txtEx ; TGTextEntry * txtEx ;
bool isUse2ndArray;
public: public:
MyMainFrame(const TGWindow *p,UInt_t w,UInt_t h); MyMainFrame(const TGWindow *p,UInt_t w,UInt_t h);
virtual ~MyMainFrame(); virtual ~MyMainFrame();
void Command(int); void Command(int);
void OpenFile(int); void OpenFile(int);
void GetData(); void GetData();
bool IsFileExist(TString filename); bool IsFileExist(TString filename);
void CheckIsUse2ndArray();
}; };
@ -145,13 +143,6 @@ MyMainFrame::MyMainFrame(const TGWindow *p,UInt_t w,UInt_t h) {
openRec->Connect("Clicked()","MyMainFrame",this, "OpenFile(=1)"); openRec->Connect("Clicked()","MyMainFrame",this, "OpenFile(=1)");
simFrame->AddFrame(openRec,new TGLayoutHints(kLHintsRight, 5,5,3,4)); simFrame->AddFrame(openRec,new TGLayoutHints(kLHintsRight, 5,5,3,4));
TGTextButton *openEx = new TGTextButton(simFrame, "Ex List");
openEx->SetWidth(150);
openEx->SetHeight(20);
openEx->ChangeOptions( openEx->GetOptions() | kFixedSize );
openEx->Connect("Clicked()","MyMainFrame",this, "OpenFile(=2)");
simFrame->AddFrame(openEx,new TGLayoutHints(kLHintsRight, 5,5,3,4));
withDWBA = new TGCheckButton(simFrame, "Sim with DWBA\n+DWBA.root\n+DWBA.Ex.txt"); withDWBA = new TGCheckButton(simFrame, "Sim with DWBA\n+DWBA.root\n+DWBA.Ex.txt");
withDWBA->SetWidth(140); withDWBA->SetWidth(140);
withDWBA->ChangeOptions(kFixedSize ); withDWBA->ChangeOptions(kFixedSize );
@ -355,13 +346,6 @@ bool MyMainFrame::IsFileExist(TString filename){
return file.is_open(); return file.is_open();
} }
void MyMainFrame::CheckIsUse2ndArray(){
DetGeo detGeo;
detGeo.LoadDetectorGeo("../working/detectorGeo.txt", false);
isUse2ndArray = detGeo.use2ndArray;
}
void MyMainFrame::OpenFile(int ID){ void MyMainFrame::OpenFile(int ID){
@ -371,22 +355,12 @@ void MyMainFrame::OpenFile(int ID){
if ( ID == 0 ) fileName = "../working/detectorGeo.txt"; if ( ID == 0 ) fileName = "../working/detectorGeo.txt";
CheckIsUse2ndArray(); if ( ID == 1 ) fileName = "../working/reactionConfig.txt";
if( isUse2ndArray){ if ( ID == 3 ) fileName = "../working/DWBA";
if ( ID == 1 ) fileName = "../working/reactionConfig2.txt"; if ( ID == 5 ) fileName = "../working/DWBA.in";
if ( ID == 2 ) fileName = "../working/Ex2.txt"; if ( ID == 6 ) fileName = "../working/DWBA.out";
if ( ID == 3 ) fileName = "../working/DWBA2"; if ( ID == 7 ) fileName = "../working/DWBA.Xsec.txt";
if ( ID == 5 ) fileName = "../working/DWBA2.in";
if ( ID == 6 ) fileName = "../working/DWBA2.out";
if ( ID == 7 ) fileName = "../working/DWBA2.Xsec.txt";
}else{
if ( ID == 1 ) fileName = "../working/reactionConfig.txt";
if ( ID == 2 ) fileName = "../working/Ex.txt";
if ( ID == 3 ) fileName = "../working/DWBA";
if ( ID == 5 ) fileName = "../working/DWBA.in";
if ( ID == 6 ) fileName = "../working/DWBA.out";
if ( ID == 7 ) fileName = "../working/DWBA.Xsec.txt";
}
if ( ID == 4 ) fileName = "../working/Check_Simulation_Config.txt"; if ( ID == 4 ) fileName = "../working/Check_Simulation_Config.txt";
if ( ID == 8 ) fileName = isoFileName; if ( ID == 8 ) fileName = isoFileName;
@ -440,8 +414,6 @@ void MyMainFrame::Command(int ID) {
editor->SaveFile(fileName); editor->SaveFile(fileName);
CheckIsUse2ndArray();
if( ID == 0 ){ if( ID == 0 ){
if( isInFile->GetState()) { if( isInFile->GetState()) {
@ -495,59 +467,44 @@ void MyMainFrame::Command(int ID) {
string basicConfig = "reactionConfig.txt"; string basicConfig = "reactionConfig.txt";
string heliosDetGeoFile = "detectorGeo.txt"; string heliosDetGeoFile = "detectorGeo.txt";
string excitationFile = "Ex.txt"; //when no file, only ground state
TString ptolemyRoot = ""; // when no file, use isotropic distribution of thetaCM TString ptolemyRoot = ""; // when no file, use isotropic distribution of thetaCM
TString saveFileName = "transfer.root"; TString saveFileName = "transfer.root";
TString filename = "reaction.dat"; //when no file, no output
if( withDWBA->GetState() ) { if( withDWBA->GetState() ) {
ptolemyRoot = "DWBA1.root"; ptolemyRoot = "DWBA.root";
excitationFile = "DWBA1.Ex.txt";
} }
if( isUse2ndArray ){ basicConfig = "reactionConfig.txt";
basicConfig = "reactionConfig2.txt"; heliosDetGeoFile = "detectorGeo.txt";
heliosDetGeoFile = "detectorGeo.txt"; ptolemyRoot = ""; // when no file, use isotropic distribution of thetaCM
excitationFile = "Ex2.txt"; //when no file, only ground state saveFileName = "transfer.root";
ptolemyRoot = ""; // when no file, use isotropic distribution of thetaCM
saveFileName = "transfer2.root";
filename = "reaction2.dat"; //when no file, no output
if( withDWBA->GetState() ) { if( withDWBA->GetState() ) {
ptolemyRoot = "DWBA2.root"; ptolemyRoot = "DWBA.root";
excitationFile = "DWBA2.Ex.txt";
}
} }
statusLabel->SetText("Running simulation......."); statusLabel->SetText("Running simulation.......");
Transfer( basicConfig, heliosDetGeoFile, excitationFile, ptolemyRoot, saveFileName, filename); Transfer( basicConfig, heliosDetGeoFile, 0, ptolemyRoot, saveFileName);
statusLabel->SetText("Plotting simulation......."); statusLabel->SetText("Plotting simulation.......");
if( isUse2ndArray ){ Check_Simulation("transfer.root");
Check_Simulation("transfer2.root");
}else{
Check_Simulation("transfer1.root");
}
statusLabel->SetText("Plotted Simulation result"); statusLabel->SetText("Plotted Simulation result");
} }
if( ID == 2 ){ if( ID == 2 ){
if( isUse2ndArray ){ Check_Simulation("transfer.root");
Check_Simulation("transfer2.root");
}else{
Check_Simulation("transfer.root");
}
statusLabel->SetText(" Run Simulation first."); statusLabel->SetText(" Run Simulation first.");
} }
if( ID == 3 ){ if( ID == 3 ){
if( fileName != "" ){ if( fileName != "" ){
statusLabel->SetText(fileName + " saved."); statusLabel->SetText(fileName + " saved.");
}else{ }else{
statusLabel->SetText("cannot save HELP page."); statusLabel->SetText("cannot save HELP page.");
} }
} }
if( ID == 4 ){ if( ID == 4 ){