Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // Gorad (Geant4 Open-source Radiation Analys 26 // Gorad (Geant4 Open-source Radiation Analysis and Design) 27 // 27 // 28 // Author : Makoto Asai (SLAC National Accele 28 // Author : Makoto Asai (SLAC National Accelerator Laboratory) 29 // 29 // 30 // Development of Gorad is funded by NASA Joh 30 // Development of Gorad is funded by NASA Johnson Space Center (JSC) 31 // under the contract NNJ15HK11B. 31 // under the contract NNJ15HK11B. 32 // 32 // 33 // ******************************************* 33 // ******************************************************************** 34 // 34 // 35 // GRRunActionMessenger.cc 35 // GRRunActionMessenger.cc 36 // A messenger class that defines histograms 36 // A messenger class that defines histograms and n-tuple in GRRunAction. 37 // 37 // 38 // History 38 // History 39 // September 8th, 2020 : first implementatio 39 // September 8th, 2020 : first implementation 40 // 40 // 41 // ******************************************* 41 // ******************************************************************** 42 42 43 #include "GRRunActionMessenger.hh" 43 #include "GRRunActionMessenger.hh" 44 44 45 #include "GRRunAction.hh" 45 #include "GRRunAction.hh" 46 #include "G4UIcommand.hh" 46 #include "G4UIcommand.hh" 47 #include "G4UIparameter.hh" 47 #include "G4UIparameter.hh" 48 #include "G4UIdirectory.hh" 48 #include "G4UIdirectory.hh" 49 #include "G4UIcmdWithAString.hh" 49 #include "G4UIcmdWithAString.hh" 50 #include "G4UIcmdWithABool.hh" 50 #include "G4UIcmdWithABool.hh" 51 #include "G4UIcmdWithAnInteger.hh" 51 #include "G4UIcmdWithAnInteger.hh" 52 #include "G4UIcmdWithoutParameter.hh" 52 #include "G4UIcmdWithoutParameter.hh" 53 #include "G4UnitsTable.hh" 53 #include "G4UnitsTable.hh" 54 54 55 GRRunActionMessenger::GRRunActionMessenger(GRR 55 GRRunActionMessenger::GRRunActionMessenger(GRRunAction* dc) 56 : pRA(dc), currentID(-1) 56 : pRA(dc), currentID(-1) 57 { 57 { 58 G4UIparameter* para = nullptr; 58 G4UIparameter* para = nullptr; 59 59 60 anaDir = new G4UIdirectory("/gorad/analysis/ 60 anaDir = new G4UIdirectory("/gorad/analysis/"); 61 anaDir->SetGuidance("GORAD analysis commands 61 anaDir->SetGuidance("GORAD analysis commands"); 62 62 63 verboseCmd = new G4UIcmdWithAnInteger("/gora 63 verboseCmd = new G4UIcmdWithAnInteger("/gorad/analysis/verbose",this); 64 verboseCmd->SetGuidance("Set verbose level") 64 verboseCmd->SetGuidance("Set verbose level"); 65 verboseCmd->SetParameterName("level",true); 65 verboseCmd->SetParameterName("level",true); 66 verboseCmd->SetDefaultValue(0); 66 verboseCmd->SetDefaultValue(0); 67 verboseCmd->SetRange("level>=0"); 67 verboseCmd->SetRange("level>=0"); 68 verboseCmd->AvailableForStates(G4State_Idle) 68 verboseCmd->AvailableForStates(G4State_Idle); 69 69 70 fileCmd = new G4UIcmdWithAString("/gorad/ana 70 fileCmd = new G4UIcmdWithAString("/gorad/analysis/file",this); 71 fileCmd->SetGuidance("Define the output file 71 fileCmd->SetGuidance("Define the output file name."); 72 fileCmd->SetParameterName("file",false); 72 fileCmd->SetParameterName("file",false); 73 fileCmd->AvailableForStates(G4State_Idle); 73 fileCmd->AvailableForStates(G4State_Idle); 74 74 75 listCmd = new G4UIcmdWithoutParameter("/gora 75 listCmd = new G4UIcmdWithoutParameter("/gorad/analysis/list",this); 76 listCmd->SetGuidance("List defined histogram 76 listCmd->SetGuidance("List defined histograms."); 77 listCmd->AvailableForStates(G4State_Idle); 77 listCmd->AvailableForStates(G4State_Idle); 78 78 79 openCmd = new G4UIcmdWithAnInteger("/gorad/a 79 openCmd = new G4UIcmdWithAnInteger("/gorad/analysis/open",this); 80 openCmd->SetGuidance("Open a histogram that 80 openCmd->SetGuidance("Open a histogram that has already been created and closed."); 81 openCmd->SetGuidance("\"create\" command ope 81 openCmd->SetGuidance("\"create\" command open the new histogram so you don't need to open it."); 82 openCmd->SetGuidance("A histogram is closed 82 openCmd->SetGuidance("A histogram is closed when another histogram is created. This \"open\" command is required only for reopening the closed histogram."); 83 openCmd->SetParameterName("id",false); 83 openCmd->SetParameterName("id",false); 84 openCmd->AvailableForStates(G4State_Idle); 84 openCmd->AvailableForStates(G4State_Idle); 85 85 86 plotCmd = new G4UIcmdWithAnInteger("/gorad/a 86 plotCmd = new G4UIcmdWithAnInteger("/gorad/analysis/plot",this); 87 plotCmd->SetGuidance("Create an additional p 87 plotCmd->SetGuidance("Create an additional postscript plot for specified histogram/profile."); 88 plotCmd->SetGuidance("Regardless of this com 88 plotCmd->SetGuidance("Regardless of this command, histogram is dumped to the output file."); 89 plotCmd->SetGuidance("If id is not specified 89 plotCmd->SetGuidance("If id is not specified, currently open histogram/profile is plotted."); 90 plotCmd->SetGuidance("If id = -1, all curren 90 plotCmd->SetGuidance("If id = -1, all currently defined histograms/profiles are plotted."); 91 plotCmd->SetParameterName("id",true,true); 91 plotCmd->SetParameterName("id",true,true); 92 plotCmd->AvailableForStates(G4State_Idle); 92 plotCmd->AvailableForStates(G4State_Idle); 93 93 94 carryCmd = new G4UIcmdWithABool("/gorad/anal 94 carryCmd = new G4UIcmdWithABool("/gorad/analysis/carry",this); 95 carryCmd->SetGuidance("Carry histograms over 95 carryCmd->SetGuidance("Carry histograms over more than one runs."); 96 carryCmd->SetGuidance("Once this is set, his 96 carryCmd->SetGuidance("Once this is set, histograms won't be output until /gorad/analysis/flush is explicitly issued."); 97 carryCmd->SetGuidance("This command has to b 97 carryCmd->SetGuidance("This command has to be issued before starting the run to be carried over."); 98 carryCmd->SetParameterName("carry",true); 98 carryCmd->SetParameterName("carry",true); 99 carryCmd->SetDefaultValue(true); 99 carryCmd->SetDefaultValue(true); 100 carryCmd->AvailableForStates(G4State_Idle); 100 carryCmd->AvailableForStates(G4State_Idle); 101 101 102 flushCmd = new G4UIcmdWithoutParameter("/gor 102 flushCmd = new G4UIcmdWithoutParameter("/gorad/analysis/flush",this); 103 flushCmd->SetGuidance("Make output. This com 103 flushCmd->SetGuidance("Make output. This command is necessary if /gorad/analysis/carry is set."); 104 flushCmd->AvailableForStates(G4State_Idle); 104 flushCmd->AvailableForStates(G4State_Idle); 105 105 106 resetCmd = new G4UIcmdWithoutParameter("/gor 106 resetCmd = new G4UIcmdWithoutParameter("/gorad/analysis/reset",this); 107 resetCmd->SetGuidance("Reset histograms with 107 resetCmd->SetGuidance("Reset histograms without making output."); 108 resetCmd->AvailableForStates(G4State_Idle); 108 resetCmd->AvailableForStates(G4State_Idle); 109 109 110 idOffsetCmd = new G4UIcommand("/gorad/analys 110 idOffsetCmd = new G4UIcommand("/gorad/analysis/idOffset",this); 111 idOffsetCmd->SetGuidance("Define offset numb 111 idOffsetCmd->SetGuidance("Define offset numbers of the histogram ID."); 112 idOffsetCmd->SetGuidance(" The hostogram ID 112 idOffsetCmd->SetGuidance(" The hostogram ID is set as (scorer_id + <offset>) * <factor> + copy_number - 1"); 113 para = new G4UIparameter("offset",'i',true); 113 para = new G4UIparameter("offset",'i',true); 114 para->SetParameterRange("offset>=0"); 114 para->SetParameterRange("offset>=0"); 115 para->SetDefaultValue(0); 115 para->SetDefaultValue(0); 116 idOffsetCmd->SetParameter(para); 116 idOffsetCmd->SetParameter(para); 117 para = new G4UIparameter("factor",'i',true); 117 para = new G4UIparameter("factor",'i',true); 118 para->SetParameterRange("factor>0"); 118 para->SetParameterRange("factor>0"); 119 para->SetDefaultValue(1000); 119 para->SetDefaultValue(1000); 120 idOffsetCmd->SetParameter(para); 120 idOffsetCmd->SetParameter(para); 121 idOffsetCmd->AvailableForStates(G4State_Idle 121 idOffsetCmd->AvailableForStates(G4State_Idle); 122 122 123 oneDDir = new G4UIdirectory("/gorad/analysis 123 oneDDir = new G4UIdirectory("/gorad/analysis/1D/"); 124 oneDDir->SetGuidance("1-dimentional histogra 124 oneDDir->SetGuidance("1-dimentional histogram"); 125 125 126 create1DCmd = new G4UIcommand("/gorad/analys 126 create1DCmd = new G4UIcommand("/gorad/analysis/1D/create",this); 127 create1DCmd->SetGuidance("Create a 1D histog 127 create1DCmd->SetGuidance("Create a 1D histogram and fill it with event-by-event score."); 128 create1DCmd->SetGuidance("Scoring mesh (logi 128 create1DCmd->SetGuidance("Scoring mesh (logical volume for real-world volume scoring) and"); 129 create1DCmd->SetGuidance("primitive scorers 129 create1DCmd->SetGuidance("primitive scorers must be defined prior to this command."); 130 para = new G4UIparameter("meshName",'s',fals 130 para = new G4UIparameter("meshName",'s',false); 131 para->SetGuidance("Scoring mesh name. Logica 131 para->SetGuidance("Scoring mesh name. Logical volume name for real-world volume scoring."); 132 create1DCmd->SetParameter(para); 132 create1DCmd->SetParameter(para); 133 para = new G4UIparameter("primName",'s',fals 133 para = new G4UIparameter("primName",'s',false); 134 create1DCmd->SetParameter(para); 134 create1DCmd->SetParameter(para); 135 para = new G4UIparameter("idx",'i',true); 135 para = new G4UIparameter("idx",'i',true); 136 para->SetGuidance("Index (i.e. copy number) 136 para->SetGuidance("Index (i.e. copy number) of the cell to be scored. \"-1\" (defult) to score all cells."); 137 para->SetDefaultValue(-1); 137 para->SetDefaultValue(-1); 138 para->SetParameterRange("idx>=-1"); 138 para->SetParameterRange("idx>=-1"); 139 create1DCmd->SetParameter(para); 139 create1DCmd->SetParameter(para); 140 create1DCmd->AvailableForStates(G4State_Idle 140 create1DCmd->AvailableForStates(G4State_Idle); 141 141 142 create1DPrimPCmd = new G4UIcommand("/gorad/a 142 create1DPrimPCmd = new G4UIcommand("/gorad/analysis/1D/primary",this); 143 create1DPrimPCmd->SetGuidance("Create a 1D e 143 create1DPrimPCmd->SetGuidance("Create a 1D energy spectrum histogram and fill it with kinetic energy of each primary particle."); 144 create1DPrimPCmd->SetGuidance("Weight of eac 144 create1DPrimPCmd->SetGuidance("Weight of each primary track is taken into account if the flag is set."); 145 para = new G4UIparameter("histName",'s',fals 145 para = new G4UIparameter("histName",'s',false); 146 para->SetGuidance("Histogram name"); 146 para->SetGuidance("Histogram name"); 147 create1DPrimPCmd->SetParameter(para); 147 create1DPrimPCmd->SetParameter(para); 148 para = new G4UIparameter("weightFlag",'b',tr 148 para = new G4UIparameter("weightFlag",'b',true); 149 para->SetGuidance("Weight of each primary tr 149 para->SetGuidance("Weight of each primary track is taken into account"); 150 para->SetDefaultValue(true); 150 para->SetDefaultValue(true); 151 create1DPrimPCmd->SetParameter(para); 151 create1DPrimPCmd->SetParameter(para); 152 create1DPrimPCmd->AvailableForStates(G4State 152 create1DPrimPCmd->AvailableForStates(G4State_Idle); 153 153 154 create1DPlotPCmd = new G4UIcommand("/gorad/a 154 create1DPlotPCmd = new G4UIcommand("/gorad/analysis/1D/spectrum",this); 155 create1DPlotPCmd->SetGuidance("Create a 1D e 155 create1DPlotPCmd->SetGuidance("Create a 1D energy spectrum histogram and fill it with each individual track that gets into the volume."); 156 create1DPlotPCmd->SetGuidance("Histogram is 156 create1DPlotPCmd->SetGuidance("Histogram is created for each physical volume separately."); 157 create1DPlotPCmd->SetGuidance("So, this comm 157 create1DPlotPCmd->SetGuidance("So, this command should not be used for Box or Cylinder mesh type due to memory consumption concern."); 158 create1DPlotPCmd->SetGuidance("Currently, th 158 create1DPlotPCmd->SetGuidance("Currently, this is supported only for volume flux scorer."); 159 para = new G4UIparameter("meshName",'s',fals 159 para = new G4UIparameter("meshName",'s',false); 160 para->SetGuidance("Scoring mesh name. Logica 160 para->SetGuidance("Scoring mesh name. Logical volume name for real-world volume scoring."); 161 create1DPlotPCmd->SetParameter(para); 161 create1DPlotPCmd->SetParameter(para); 162 para = new G4UIparameter("primName",'s',fals 162 para = new G4UIparameter("primName",'s',false); 163 para->SetGuidance("Scoring primitive name.") 163 para->SetGuidance("Scoring primitive name."); 164 create1DPlotPCmd->SetParameter(para); 164 create1DPlotPCmd->SetParameter(para); 165 create1DPlotPCmd->AvailableForStates(G4State 165 create1DPlotPCmd->AvailableForStates(G4State_Idle); 166 166 167 set1DCmd = new G4UIcmdWithoutParameter("/gor 167 set1DCmd = new G4UIcmdWithoutParameter("/gorad/analysis/1D/set",this); 168 set1DCmd->SetGuidance("This command is obsol 168 set1DCmd->SetGuidance("This command is obsolete. Use /gorad/analysis/1D/config instead."); 169 169 170 config1DCmd = new G4UIcommand("/gorad/analys 170 config1DCmd = new G4UIcommand("/gorad/analysis/1D/config",this); 171 config1DCmd->SetGuidance("Set binning parame 171 config1DCmd->SetGuidance("Set binning parameters of the current 1D histogram."); 172 config1DCmd->SetGuidance("<unit> is applied 172 config1DCmd->SetGuidance("<unit> is applied to <minVal> and <maxVal> as well as filled value."); 173 para = new G4UIparameter("nBin",'i',false); 173 para = new G4UIparameter("nBin",'i',false); 174 para->SetParameterRange("nBin>0"); 174 para->SetParameterRange("nBin>0"); 175 config1DCmd->SetParameter(para); 175 config1DCmd->SetParameter(para); 176 para = new G4UIparameter("minVal",'d',false) 176 para = new G4UIparameter("minVal",'d',false); 177 config1DCmd->SetParameter(para); 177 config1DCmd->SetParameter(para); 178 para = new G4UIparameter("maxVal",'d',false) 178 para = new G4UIparameter("maxVal",'d',false); 179 config1DCmd->SetParameter(para); 179 config1DCmd->SetParameter(para); 180 para = new G4UIparameter("unit",'s',true); 180 para = new G4UIparameter("unit",'s',true); 181 para->SetDefaultValue("none"); 181 para->SetDefaultValue("none"); 182 config1DCmd->SetParameter(para); 182 config1DCmd->SetParameter(para); 183 para = new G4UIparameter("scale",'s',true); 183 para = new G4UIparameter("scale",'s',true); 184 para->SetGuidance("Define the binning scale. 184 para->SetGuidance("Define the binning scale. (default: linear)"); 185 para->SetParameterCandidates("linear log"); 185 para->SetParameterCandidates("linear log"); 186 para->SetDefaultValue("linear"); 186 para->SetDefaultValue("linear"); 187 config1DCmd->SetParameter(para); 187 config1DCmd->SetParameter(para); 188 para = new G4UIparameter("logVal",'b',true); 188 para = new G4UIparameter("logVal",'b',true); 189 para->SetDefaultValue(false); 189 para->SetDefaultValue(false); 190 config1DCmd->SetParameter(para); 190 config1DCmd->SetParameter(para); 191 config1DCmd->AvailableForStates(G4State_Idle 191 config1DCmd->AvailableForStates(G4State_Idle); 192 192 193 title1DCmd = new G4UIcommand("/gorad/analysi 193 title1DCmd = new G4UIcommand("/gorad/analysis/1D/title",this); 194 title1DCmd->SetGuidance("Define histogram ti 194 title1DCmd->SetGuidance("Define histogram title"); 195 para = new G4UIparameter("title",'s',false); 195 para = new G4UIparameter("title",'s',false); 196 title1DCmd->SetParameter(para); 196 title1DCmd->SetParameter(para); 197 para = new G4UIparameter("x_axis",'s',false) 197 para = new G4UIparameter("x_axis",'s',false); 198 title1DCmd->SetParameter(para); 198 title1DCmd->SetParameter(para); 199 para = new G4UIparameter("y_axis",'s',false) 199 para = new G4UIparameter("y_axis",'s',false); 200 title1DCmd->SetParameter(para); 200 title1DCmd->SetParameter(para); 201 title1DCmd->AvailableForStates(G4State_Idle) 201 title1DCmd->AvailableForStates(G4State_Idle); 202 202 203 set1DYaxisLogCmd = new G4UIcmdWithABool("/go 203 set1DYaxisLogCmd = new G4UIcmdWithABool("/gorad/analysis/1D/yaxisLog",this); 204 set1DYaxisLogCmd->SetGuidance("Set y-axis in 204 set1DYaxisLogCmd->SetGuidance("Set y-axis in log scale."); 205 set1DYaxisLogCmd->SetParameterName("flag",tr 205 set1DYaxisLogCmd->SetParameterName("flag",true); 206 set1DYaxisLogCmd->SetDefaultValue(true); 206 set1DYaxisLogCmd->SetDefaultValue(true); 207 set1DYaxisLogCmd->AvailableForStates(G4State 207 set1DYaxisLogCmd->AvailableForStates(G4State_Idle); 208 208 209 onePDir = new G4UIdirectory("/gorad/analysis 209 onePDir = new G4UIdirectory("/gorad/analysis/1P/"); 210 onePDir->SetGuidance("1-dimentional profile 210 onePDir->SetGuidance("1-dimentional profile plot"); 211 211 212 create1PCmd = new G4UIcommand("/gorad/analys 212 create1PCmd = new G4UIcommand("/gorad/analysis/1P/create",this); 213 create1PCmd->SetGuidance("Create a 1D profil 213 create1PCmd->SetGuidance("Create a 1D profile plot and fill it with event-by-event score."); 214 create1PCmd->SetGuidance("Scoring mesh (logi 214 create1PCmd->SetGuidance("Scoring mesh (logical volume for real-world volume scoring) and"); 215 create1PCmd->SetGuidance("primitive scorers 215 create1PCmd->SetGuidance("primitive scorers must be defined prior to this command."); 216 create1PCmd->SetGuidance("Copy number of the 216 create1PCmd->SetGuidance("Copy number of the scoring cell is used as the x-axis value."); 217 para = new G4UIparameter("meshName",'s',fals 217 para = new G4UIparameter("meshName",'s',false); 218 para->SetGuidance("Scoring mesh name. Logica 218 para->SetGuidance("Scoring mesh name. Logical volume name for real-world volume scoring."); 219 create1PCmd->SetParameter(para); 219 create1PCmd->SetParameter(para); 220 para = new G4UIparameter("primName",'s',fals 220 para = new G4UIparameter("primName",'s',false); 221 create1PCmd->SetParameter(para); 221 create1PCmd->SetParameter(para); 222 para = new G4UIparameter("idx",'i',false); 222 para = new G4UIparameter("idx",'i',false); 223 para->SetGuidance("Maximum index (i.e. copy 223 para->SetGuidance("Maximum index (i.e. copy number) of the cell to be scored."); 224 para->SetParameterRange("idx>0"); 224 para->SetParameterRange("idx>0"); 225 create1PCmd->SetParameter(para); 225 create1PCmd->SetParameter(para); 226 create1PCmd->AvailableForStates(G4State_Idle 226 create1PCmd->AvailableForStates(G4State_Idle); 227 227 228 set1PCmd = new G4UIcommand("/gorad/analysis/ 228 set1PCmd = new G4UIcommand("/gorad/analysis/1P/set",this); 229 set1PCmd->SetGuidance("Set binning parameter 229 set1PCmd->SetGuidance("Set binning parameters of the current 1D profile plot."); 230 set1PCmd->SetGuidance("<unit> is applied to 230 set1PCmd->SetGuidance("<unit> is applied to <minYVal> and <maxYVal> as well as filled value."); 231 para = new G4UIparameter("minYVal",'d',false 231 para = new G4UIparameter("minYVal",'d',false); 232 set1PCmd->SetParameter(para); 232 set1PCmd->SetParameter(para); 233 para = new G4UIparameter("maxYVal",'d',false 233 para = new G4UIparameter("maxYVal",'d',false); 234 set1PCmd->SetParameter(para); 234 set1PCmd->SetParameter(para); 235 para = new G4UIparameter("unit",'s',true); 235 para = new G4UIparameter("unit",'s',true); 236 para->SetDefaultValue("none"); 236 para->SetDefaultValue("none"); 237 set1PCmd->SetParameter(para); 237 set1PCmd->SetParameter(para); 238 para = new G4UIparameter("func-x",'s',true); 238 para = new G4UIparameter("func-x",'s',true); 239 para->SetGuidance("The function applied to t 239 para->SetGuidance("The function applied to the filled x-value (default: none)."); 240 para->SetParameterCandidates("log log10 exp 240 para->SetParameterCandidates("log log10 exp none"); 241 para->SetDefaultValue("none"); 241 para->SetDefaultValue("none"); 242 set1PCmd->SetParameter(para); 242 set1PCmd->SetParameter(para); 243 para = new G4UIparameter("func-y",'s',true); 243 para = new G4UIparameter("func-y",'s',true); 244 para->SetGuidance("The function applied to t 244 para->SetGuidance("The function applied to the filled y-value (default: none)."); 245 para->SetParameterCandidates("log log10 exp 245 para->SetParameterCandidates("log log10 exp none"); 246 para->SetDefaultValue("none"); 246 para->SetDefaultValue("none"); 247 set1PCmd->SetParameter(para); 247 set1PCmd->SetParameter(para); 248 para = new G4UIparameter("scale",'s',true); 248 para = new G4UIparameter("scale",'s',true); 249 para->SetGuidance("Define the binning scale. 249 para->SetGuidance("Define the binning scale. (default: linear)"); 250 para->SetParameterCandidates("linear log"); 250 para->SetParameterCandidates("linear log"); 251 para->SetDefaultValue("linear"); 251 para->SetDefaultValue("linear"); 252 set1PCmd->SetParameter(para); 252 set1PCmd->SetParameter(para); 253 set1PCmd->AvailableForStates(G4State_Idle); 253 set1PCmd->AvailableForStates(G4State_Idle); 254 254 255 title1PCmd = new G4UIcommand("/gorad/analysi 255 title1PCmd = new G4UIcommand("/gorad/analysis/1P/title",this); 256 title1PCmd->SetGuidance("Define histogram ti 256 title1PCmd->SetGuidance("Define histogram title"); 257 para = new G4UIparameter("title",'s',false); 257 para = new G4UIparameter("title",'s',false); 258 title1PCmd->SetParameter(para); 258 title1PCmd->SetParameter(para); 259 para = new G4UIparameter("x_axis",'s',false) 259 para = new G4UIparameter("x_axis",'s',false); 260 title1PCmd->SetParameter(para); 260 title1PCmd->SetParameter(para); 261 para = new G4UIparameter("y_axis",'s',false) 261 para = new G4UIparameter("y_axis",'s',false); 262 title1PCmd->SetParameter(para); 262 title1PCmd->SetParameter(para); 263 title1PCmd->AvailableForStates(G4State_Idle) 263 title1PCmd->AvailableForStates(G4State_Idle); 264 264 265 ntupleDir = new G4UIdirectory("/gorad/analys 265 ntupleDir = new G4UIdirectory("/gorad/analysis/ntuple/"); 266 onePDir->SetGuidance("Define an ntuple"); 266 onePDir->SetGuidance("Define an ntuple"); 267 267 268 addColumnCmd = new G4UIcommand("/gorad/analy 268 addColumnCmd = new G4UIcommand("/gorad/analysis/ntuple/addColumn",this); 269 addColumnCmd->SetGuidance("Define a column a 269 addColumnCmd->SetGuidance("Define a column and fill it with event-by-event score."); 270 addColumnCmd->SetGuidance("Scoring mesh (log 270 addColumnCmd->SetGuidance("Scoring mesh (logical volume for real-world volume scoring) and"); 271 addColumnCmd->SetGuidance("primitive scorers 271 addColumnCmd->SetGuidance("primitive scorers must be defined prior to this command."); 272 para = new G4UIparameter("meshName",'s',fals 272 para = new G4UIparameter("meshName",'s',false); 273 para->SetGuidance("Scoring mesh name. Logica 273 para->SetGuidance("Scoring mesh name. Logical volume name for real-world volume scoring."); 274 addColumnCmd->SetParameter(para); 274 addColumnCmd->SetParameter(para); 275 para = new G4UIparameter("primName",'s',fals 275 para = new G4UIparameter("primName",'s',false); 276 addColumnCmd->SetParameter(para); 276 addColumnCmd->SetParameter(para); 277 para = new G4UIparameter("unit",'s',true); 277 para = new G4UIparameter("unit",'s',true); 278 para->SetDefaultValue("none"); 278 para->SetDefaultValue("none"); 279 addColumnCmd->SetParameter(para); 279 addColumnCmd->SetParameter(para); 280 para = new G4UIparameter("idx",'i',true); 280 para = new G4UIparameter("idx",'i',true); 281 para->SetGuidance("Index (i.e. copy number) 281 para->SetGuidance("Index (i.e. copy number) of the cell to be scored. \"-1\" (defult) to score all cells."); 282 para->SetDefaultValue(-1); 282 para->SetDefaultValue(-1); 283 para->SetParameterRange("idx>=-1"); 283 para->SetParameterRange("idx>=-1"); 284 addColumnCmd->SetParameter(para); 284 addColumnCmd->SetParameter(para); 285 addColumnCmd->AvailableForStates(G4State_Idl 285 addColumnCmd->AvailableForStates(G4State_Idle); 286 } 286 } 287 287 288 GRRunActionMessenger::~GRRunActionMessenger() 288 GRRunActionMessenger::~GRRunActionMessenger() 289 { 289 { 290 delete addColumnCmd; 290 delete addColumnCmd; 291 delete ntupleDir; 291 delete ntupleDir; 292 292 293 delete create1PCmd; 293 delete create1PCmd; 294 delete set1PCmd; 294 delete set1PCmd; 295 delete title1PCmd; 295 delete title1PCmd; 296 delete onePDir; 296 delete onePDir; 297 297 298 delete create1DCmd; 298 delete create1DCmd; 299 delete create1DPrimPCmd; 299 delete create1DPrimPCmd; 300 delete create1DPlotPCmd; 300 delete create1DPlotPCmd; 301 delete set1DCmd; 301 delete set1DCmd; 302 delete config1DCmd; 302 delete config1DCmd; 303 delete title1DCmd; 303 delete title1DCmd; 304 delete set1DYaxisLogCmd; 304 delete set1DYaxisLogCmd; 305 delete oneDDir; 305 delete oneDDir; 306 306 307 delete fileCmd; 307 delete fileCmd; 308 delete verboseCmd; 308 delete verboseCmd; 309 delete listCmd; 309 delete listCmd; 310 delete openCmd; 310 delete openCmd; 311 delete plotCmd; 311 delete plotCmd; 312 delete carryCmd; 312 delete carryCmd; 313 delete flushCmd; 313 delete flushCmd; 314 delete resetCmd; 314 delete resetCmd; 315 delete idOffsetCmd; 315 delete idOffsetCmd; 316 delete anaDir; 316 delete anaDir; 317 } 317 } 318 318 319 #include "G4Tokenizer.hh" 319 #include "G4Tokenizer.hh" 320 320 321 void GRRunActionMessenger::SetNewValue(G4UIcom 321 void GRRunActionMessenger::SetNewValue(G4UIcommand* cmd, G4String val) 322 { 322 { 323 if(cmd==fileCmd) 323 if(cmd==fileCmd) 324 { pRA->SetFileName(val); } 324 { pRA->SetFileName(val); } 325 else if(cmd==verboseCmd) 325 else if(cmd==verboseCmd) 326 { pRA->SetVerbose(verboseCmd->GetNewIntValue 326 { pRA->SetVerbose(verboseCmd->GetNewIntValue(val)); } 327 else if(cmd==listCmd) 327 else if(cmd==listCmd) 328 { pRA->ListHistograms(); } 328 { pRA->ListHistograms(); } 329 else if(cmd==openCmd) 329 else if(cmd==openCmd) 330 { 330 { 331 auto id = openCmd->GetNewIntValue(val); 331 auto id = openCmd->GetNewIntValue(val); 332 if(currentID!=id) 332 if(currentID!=id) 333 { 333 { 334 if(!CheckOpenID(cmd)) return; 334 if(!CheckOpenID(cmd)) return; 335 auto valid = pRA->Open(id); 335 auto valid = pRA->Open(id); 336 if(!valid) 336 if(!valid) 337 { 337 { 338 G4ExceptionDescription ed; 338 G4ExceptionDescription ed; 339 ed << "<" << id << "> is not a valid h 339 ed << "<" << id << "> is not a valid histogram ID."; 340 cmd->CommandFailed(ed); 340 cmd->CommandFailed(ed); 341 } 341 } 342 else 342 else 343 { currentID = id; } 343 { currentID = id; } 344 } 344 } 345 } 345 } 346 else if(cmd==plotCmd) 346 else if(cmd==plotCmd) 347 { 347 { 348 auto id = plotCmd->GetNewIntValue(val); 348 auto id = plotCmd->GetNewIntValue(val); 349 G4bool valid = true; 349 G4bool valid = true; 350 if(id==-1) 350 if(id==-1) 351 { valid = pRA->SetAllPlotting(true); } 351 { valid = pRA->SetAllPlotting(true); } 352 else 352 else 353 { valid = pRA->SetPlotting(id,true); } 353 { valid = pRA->SetPlotting(id,true); } 354 if(!valid) 354 if(!valid) 355 { 355 { 356 G4ExceptionDescription ed; 356 G4ExceptionDescription ed; 357 ed << "Histogram/profile id <" << id << 357 ed << "Histogram/profile id <" << id << "> is not valid."; 358 cmd->CommandFailed(ed); 358 cmd->CommandFailed(ed); 359 } 359 } 360 } 360 } 361 else if(cmd==carryCmd) 361 else if(cmd==carryCmd) 362 { pRA->SetCarry(carryCmd->GetNewBoolValue(va 362 { pRA->SetCarry(carryCmd->GetNewBoolValue(val)); } 363 else if(cmd==flushCmd) 363 else if(cmd==flushCmd) 364 { pRA->Flush(); } 364 { pRA->Flush(); } 365 else if(cmd==resetCmd) 365 else if(cmd==resetCmd) 366 { /*pRA->ResetHistograms();*/ } 366 { /*pRA->ResetHistograms();*/ } 367 else if(cmd==idOffsetCmd) 367 else if(cmd==idOffsetCmd) 368 { 368 { 369 G4Tokenizer next(val); 369 G4Tokenizer next(val); 370 G4int offset = StoI(next()); 370 G4int offset = StoI(next()); 371 G4int factor = StoI(next()); 371 G4int factor = StoI(next()); 372 pRA->SetOffset(offset,factor); 372 pRA->SetOffset(offset,factor); 373 } 373 } 374 374 375 // 1D histogram commands 375 // 1D histogram commands 376 376 377 else if(cmd==create1DCmd) 377 else if(cmd==create1DCmd) 378 { 378 { 379 if(!CheckOpenID(cmd)) return; 379 if(!CheckOpenID(cmd)) return; 380 G4Tokenizer next(val); 380 G4Tokenizer next(val); 381 G4String meshName = next(); 381 G4String meshName = next(); 382 G4String primName = next(); 382 G4String primName = next(); 383 G4int idx = StoI(next()); 383 G4int idx = StoI(next()); 384 auto id = pRA->Create1D(meshName,primName, 384 auto id = pRA->Create1D(meshName,primName,idx); 385 if(id<0) 385 if(id<0) 386 { 386 { 387 G4ExceptionDescription ed; 387 G4ExceptionDescription ed; 388 ed << "1D histogram <" << val << "> cann 388 ed << "1D histogram <" << val << "> cannot be created."; 389 cmd->CommandFailed(ed); 389 cmd->CommandFailed(ed); 390 } 390 } 391 else 391 else 392 { currentID = id; } 392 { currentID = id; } 393 } 393 } 394 else if(cmd==create1DPrimPCmd) 394 else if(cmd==create1DPrimPCmd) 395 { 395 { 396 if(!CheckOpenID(cmd)) return; 396 if(!CheckOpenID(cmd)) return; 397 G4Tokenizer next(val); 397 G4Tokenizer next(val); 398 G4String meshName = next(); 398 G4String meshName = next(); 399 G4bool wgt = StoB(next()); 399 G4bool wgt = StoB(next()); 400 auto id = pRA->Create1DForPrimary(meshName 400 auto id = pRA->Create1DForPrimary(meshName,wgt); 401 if(id<0) 401 if(id<0) 402 { 402 { 403 G4ExceptionDescription ed; 403 G4ExceptionDescription ed; 404 ed << "1D histogram <" << val << "> cann 404 ed << "1D histogram <" << val << "> cannot be created."; 405 cmd->CommandFailed(ed); 405 cmd->CommandFailed(ed); 406 } 406 } 407 else 407 else 408 { currentID = id; } 408 { currentID = id; } 409 } 409 } 410 else if(cmd==create1DPlotPCmd) 410 else if(cmd==create1DPlotPCmd) 411 { 411 { 412 if(!CheckOpenID(cmd)) return; 412 if(!CheckOpenID(cmd)) return; 413 G4Tokenizer next(val); 413 G4Tokenizer next(val); 414 G4String meshName = next(); 414 G4String meshName = next(); 415 G4String primName = next(); 415 G4String primName = next(); 416 G4bool wgt = true; 416 G4bool wgt = true; 417 auto id = pRA->Create1DForPlotter(meshName 417 auto id = pRA->Create1DForPlotter(meshName,primName,wgt); 418 if(id<0) 418 if(id<0) 419 { 419 { 420 G4ExceptionDescription ed; 420 G4ExceptionDescription ed; 421 ed << "1D histogram <" << val << "> cann 421 ed << "1D histogram <" << val << "> cannot be created."; 422 cmd->CommandFailed(ed); 422 cmd->CommandFailed(ed); 423 } 423 } 424 else 424 else 425 { currentID = id; } 425 { currentID = id; } 426 } 426 } 427 else if(cmd==set1DCmd) 427 else if(cmd==set1DCmd) 428 { 428 { 429 G4ExceptionDescription ed; 429 G4ExceptionDescription ed; 430 ed << "This command is OBSOLETE. Use /gora 430 ed << "This command is OBSOLETE. Use /gorad/analysis/1D/config command!!"; 431 cmd->CommandFailed(ed); 431 cmd->CommandFailed(ed); 432 } 432 } 433 else if(cmd==config1DCmd) 433 else if(cmd==config1DCmd) 434 { 434 { 435 if(!CheckID(cmd)) return; 435 if(!CheckID(cmd)) return; 436 G4Tokenizer next(val); 436 G4Tokenizer next(val); 437 G4int nBin = StoI(next()); 437 G4int nBin = StoI(next()); 438 G4double minVal = StoD(next()); 438 G4double minVal = StoD(next()); 439 G4double maxVal = StoD(next()); 439 G4double maxVal = StoD(next()); 440 G4String unit = next(); 440 G4String unit = next(); 441 G4String schem = next(); 441 G4String schem = next(); 442 G4bool logVal = StoB(next()); 442 G4bool logVal = StoB(next()); 443 if(unit!="none" && !(G4UnitDefinition::IsU 443 if(unit!="none" && !(G4UnitDefinition::IsUnitDefined(unit))) 444 { 444 { 445 G4ExceptionDescription ed; 445 G4ExceptionDescription ed; 446 ed << "Unknown unit <" << unit << ">. Co 446 ed << "Unknown unit <" << unit << ">. Command failed."; 447 cmd->CommandFailed(ed); 447 cmd->CommandFailed(ed); 448 } 448 } 449 else 449 else 450 { pRA->Set1D(currentID,nBin,minVal,maxVal, 450 { pRA->Set1D(currentID,nBin,minVal,maxVal,unit,schem,logVal); } 451 } 451 } 452 else if(cmd==title1DCmd) 452 else if(cmd==title1DCmd) 453 { 453 { 454 if(!CheckID(cmd)) return; 454 if(!CheckID(cmd)) return; 455 G4Tokenizer next(val); 455 G4Tokenizer next(val); 456 G4String title = next(); 456 G4String title = next(); 457 G4String x_axis = next(); 457 G4String x_axis = next(); 458 G4String y_axis = next(); 458 G4String y_axis = next(); 459 pRA->Set1DTitle(currentID,title,x_axis,y_a 459 pRA->Set1DTitle(currentID,title,x_axis,y_axis); 460 } 460 } 461 else if(cmd==set1DYaxisLogCmd) 461 else if(cmd==set1DYaxisLogCmd) 462 { 462 { 463 if(!CheckID(cmd)) return; 463 if(!CheckID(cmd)) return; 464 auto succ = pRA->Set1DYAxisLog(currentID,s 464 auto succ = pRA->Set1DYAxisLog(currentID,set1DYaxisLogCmd->GetNewBoolValue(val)); 465 if(!succ) 465 if(!succ) 466 { 466 { 467 G4ExceptionDescription ed; 467 G4ExceptionDescription ed; 468 ed << "This command is not available for 468 ed << "This command is not available for this histogram."; 469 cmd->CommandFailed(ed); 469 cmd->CommandFailed(ed); 470 } 470 } 471 } 471 } 472 472 473 // 1D profile commands 473 // 1D profile commands 474 474 475 else if(cmd==create1PCmd) 475 else if(cmd==create1PCmd) 476 { 476 { 477 if(!CheckOpenID(cmd)) return; 477 if(!CheckOpenID(cmd)) return; 478 G4Tokenizer next(val); 478 G4Tokenizer next(val); 479 G4String meshName = next(); 479 G4String meshName = next(); 480 G4String primName = next(); 480 G4String primName = next(); 481 G4int cn = StoI(next()); 481 G4int cn = StoI(next()); 482 auto id = pRA->Create1P(meshName,primName, 482 auto id = pRA->Create1P(meshName,primName,cn); 483 if(id<0) 483 if(id<0) 484 { 484 { 485 G4ExceptionDescription ed; 485 G4ExceptionDescription ed; 486 ed << "1D histogram <" << val << "> cann 486 ed << "1D histogram <" << val << "> cannot be created."; 487 cmd->CommandFailed(ed); 487 cmd->CommandFailed(ed); 488 } 488 } 489 else 489 else 490 { currentID = id; } 490 { currentID = id; } 491 } 491 } 492 else if(cmd==set1PCmd) 492 else if(cmd==set1PCmd) 493 { 493 { 494 if(!CheckID(cmd)) return; 494 if(!CheckID(cmd)) return; 495 G4Tokenizer next(val); 495 G4Tokenizer next(val); 496 G4double minYVal = StoD(next()); 496 G4double minYVal = StoD(next()); 497 G4double maxYVal = StoD(next()); 497 G4double maxYVal = StoD(next()); 498 G4String unit = next(); 498 G4String unit = next(); 499 G4String funcX = next(); 499 G4String funcX = next(); 500 G4String funcY = next(); 500 G4String funcY = next(); 501 G4String schem = next(); 501 G4String schem = next(); 502 if(unit!="none" && !(G4UnitDefinition::IsU 502 if(unit!="none" && !(G4UnitDefinition::IsUnitDefined(unit))) 503 { 503 { 504 G4ExceptionDescription ed; 504 G4ExceptionDescription ed; 505 ed << "Unknown unit <" << unit << ">. Co 505 ed << "Unknown unit <" << unit << ">. Command failed."; 506 cmd->CommandFailed(ed); 506 cmd->CommandFailed(ed); 507 } 507 } 508 else 508 else 509 { pRA->Set1P(currentID,minYVal,maxYVal,uni 509 { pRA->Set1P(currentID,minYVal,maxYVal,unit,funcX,funcY,schem); } 510 } 510 } 511 else if(cmd==title1PCmd) 511 else if(cmd==title1PCmd) 512 { 512 { 513 if(!CheckID(cmd)) return; 513 if(!CheckID(cmd)) return; 514 G4Tokenizer next(val); 514 G4Tokenizer next(val); 515 G4String title = next(); 515 G4String title = next(); 516 G4String x_axis = next(); 516 G4String x_axis = next(); 517 G4String y_axis = next(); 517 G4String y_axis = next(); 518 pRA->Set1PTitle(currentID,title,x_axis,y_a 518 pRA->Set1PTitle(currentID,title,x_axis,y_axis); 519 } 519 } 520 520 521 // ntuple commands 521 // ntuple commands 522 522 523 else if(cmd==addColumnCmd) 523 else if(cmd==addColumnCmd) 524 { 524 { 525 G4Tokenizer next(val); 525 G4Tokenizer next(val); 526 G4String meshName = next(); 526 G4String meshName = next(); 527 G4String primName = next(); 527 G4String primName = next(); 528 G4String unit = next(); 528 G4String unit = next(); 529 G4int idx = StoI(next()); 529 G4int idx = StoI(next()); 530 if(unit!="none" && !(G4UnitDefinition::IsU 530 if(unit!="none" && !(G4UnitDefinition::IsUnitDefined(unit))) 531 { 531 { 532 G4ExceptionDescription ed; 532 G4ExceptionDescription ed; 533 ed << "Unknown unit <" << unit << ">. Co 533 ed << "Unknown unit <" << unit << ">. Command failed."; 534 cmd->CommandFailed(ed); 534 cmd->CommandFailed(ed); 535 } 535 } 536 else 536 else 537 { 537 { 538 auto id = pRA->NtupleColumn(meshName,pri 538 auto id = pRA->NtupleColumn(meshName,primName,unit,idx); 539 if(id<0) 539 if(id<0) 540 { 540 { 541 G4ExceptionDescription ed; 541 G4ExceptionDescription ed; 542 ed << "Ntuple column <" << val << "> c 542 ed << "Ntuple column <" << val << "> cannot be created."; 543 cmd->CommandFailed(ed); 543 cmd->CommandFailed(ed); 544 } 544 } 545 } 545 } 546 } 546 } 547 } 547 } 548 548 549 G4String GRRunActionMessenger::GetCurrentValue 549 G4String GRRunActionMessenger::GetCurrentValue(G4UIcommand* cmd) 550 { 550 { 551 G4String val(""); 551 G4String val(""); 552 if(cmd==openCmd) 552 if(cmd==openCmd) 553 { val = openCmd->ConvertToString(currentID); 553 { val = openCmd->ConvertToString(currentID); } 554 if(cmd==fileCmd) 554 if(cmd==fileCmd) 555 { val = pRA->GetFileName(); } 555 { val = pRA->GetFileName(); } 556 else if(cmd==verboseCmd) 556 else if(cmd==verboseCmd) 557 { val = verboseCmd->ConvertToString(pRA->Get 557 { val = verboseCmd->ConvertToString(pRA->GetVerbose()); } 558 else if(cmd==plotCmd) 558 else if(cmd==plotCmd) 559 { val = plotCmd->ConvertToString(currentID); 559 { val = plotCmd->ConvertToString(currentID); } 560 else if(cmd==carryCmd) 560 else if(cmd==carryCmd) 561 { val = carryCmd->ConvertToString(pRA->GetCa 561 { val = carryCmd->ConvertToString(pRA->GetCarry()); } 562 else if(cmd==idOffsetCmd) 562 else if(cmd==idOffsetCmd) 563 { 563 { 564 G4int offset = 0; 564 G4int offset = 0; 565 G4int factor = 0; 565 G4int factor = 0; 566 pRA->GetOffset(offset,factor); 566 pRA->GetOffset(offset,factor); 567 val = idOffsetCmd->ConvertToString(offset) 567 val = idOffsetCmd->ConvertToString(offset); 568 val += " "; 568 val += " "; 569 val += idOffsetCmd->ConvertToString(factor 569 val += idOffsetCmd->ConvertToString(factor); 570 } 570 } 571 571 572 return val; 572 return val; 573 } 573 } 574 574 575 575 576 576