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 * statusLabel;
TGLabel * fileLabel;
TGLabel * statusLabel; TGNumberEntry * angMin;
TGNumberEntry * angMax;
TGNumberEntry * angMin; TGNumberEntry * angStep;
TGNumberEntry * angMax;
TGNumberEntry * angStep; TGCheckButton * withDWBA;
TGCheckButton * withDWBA; TGCheckButton * isInFile;
TGCheckButton * isRun;
TGCheckButton * isInFile; TGCheckButton * isExtract;
TGCheckButton * isRun; TGCheckButton * isPlot;
TGCheckButton * isExtract;
TGCheckButton * isPlot; TGComboBox * extractFlag;
TGComboBox * extractFlag; TGTextEntry * txtName ;
TGTextEntry * txtEx ;
TGTextEntry * txtName ;
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();
}; };
@ -144,13 +142,6 @@ MyMainFrame::MyMainFrame(const TGWindow *p,UInt_t w,UInt_t h) {
openRec->ChangeOptions( openRec->GetOptions() | kFixedSize ); openRec->ChangeOptions( openRec->GetOptions() | kFixedSize );
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);
@ -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"; if( withDWBA->GetState() ) {
filename = "reaction2.dat"; //when no file, no output ptolemyRoot = "DWBA.root";
if( withDWBA->GetState() ) {
ptolemyRoot = "DWBA2.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 ){