Warning, /geant4/examples/extended/analysis/AnaEx03/README is written in an unsupported language. File is not indexed.
0001 --------------------------------------------------
0002
0003 =========================================================
0004 Geant4 - an Object-Oriented Toolkit for Simulation in HEP
0005 =========================================================
0006
0007 AnaEx03
0008 -------
0009
0010 Example AnaEx03 demonstrates usage of analysis commands for file management
0011 (new since Geant4 11.1), in particular writing histograms and ntuples in a file
0012 multiple times, and commands for histogram deleting (new since Geant4 11.2).
0013
0014 It uses the same scenario (detector description, primary generator
0015 and physics) as AnaEx02 and AnaEx02. In difference from these examples
0016 the analysis manipulations (histograms and ntuples booking and filling)
0017 are performed directly with G4AnalysisManager. The classes that are same
0018 in all three examples are located in shared directory.
0019
0020 For detector description, primary generator, physics and the example output
0021 see README in AnaEx01 example.
0022
0023 Histograms, Ntuple:
0024 --------------------
0025
0026 The example produces the same 4 histograms and 2 ntuples as in AnaEx01.
0027
0028 These histos and ntuples are booked in the RunAction constructor and filled from
0029 EventAction.
0030
0031 The file managent in this example, usually performed via calls to G4AnalysisManager
0032 OpenFile(), Write() and CloseFile() in the code, is in this example performed
0033 via UI commands in a macro:
0034 /analysis/openFile
0035 /analysis/write
0036 /analysis/closeFile
0037
0038 Note that the file need not to be closed at each end of run, but the histograms and ntuples
0039 can be saved in the same file multiple time. In that case we need to reset the histograms
0040 and ntuples data before a new run:
0041 /analysis/reset
0042
0043 We can define the default file type and set it to the analysis manager via
0044 /analysis/setDefaultFileType root # or csv hdf5 xml
0045
0046 The file names then need not to be provided with the file extension and the same macro
0047 can be used with different output types.
0048
0049 To demonstrate UI commands for deleting of selected histograms:
0050 /analysis/h1/delete id [keepSetting]
0051 two H1 histograms, id: 1 and 3, are deleted in AnaEx03.in macro before starting Run 2,
0052 and new histograms are then created before starting Run3. New histograms are created at
0053 id's liberated with previous deleting, 1 and 3.
0054
0055 It should be notes that using UI commands for writing histograms and ntuples in a file
0056 multiple times is not necessary, the same can be achieved by calls to G4AnalysisManager
0057 functions from the code using conditional statements.
0058
0059 Macros:
0060 --------
0061
0062 The AnaEx03.in macro performs 5 runs and produces 2 files: e-.root, containg data from first
0063 3 runs, and proton.root, containing data from the next 2 runs.
0064 The macro uses the defaultFileType parameter (alias), which default value, "root" is
0065 defined in main.
0066
0067 AnaEx03-csv.in, AnaEx03-hdf5.in, AnaEx03-root.in, AnaEx03-xml.in:
0068
0069 In these macros, the default value of the defaultFileType is overritten with
0070
0071 /control/alias defaultFileType cvs # or hdf5 root xml
0072
0073 and then the AnaEx03.in macro is called.
0074
0075 The plotter.mac macro can be used in the interactive mode to plot histograms. It should be executed after the first /run/beamOn call and before the first /analysis/reset call.
0076 (See also a commented line with this macro call in AnaEx03.in.)
0077
0078 How to run
0079 --------------
0080
0081 - It is preferable to execute the exampole in the 'batch' mode from macro files:
0082 % ./AnaEx03 AnaEx03.in
0083 % ./AnaEx03 AnaEx03.in >& output
0084
0085 - When executing AnaEx03 in the 'interactive mode' with visualization, be careful not
0086 to forget to issue the /analysis/openFile command befor starting a run:
0087
0088 % ./AnaEx03
0089 and type in the commands from AnaEx03[-xyz].mac line by line:
0090 Idle> /analysis/openFile myFile
0091 Idle> /tracking/verbose 1
0092 Idle> /run/beamOn 10
0093 Idle> ...
0094 Idle> /analysis/write
0095 Idle> /analysis/closeFile
0096 ....
0097 Idle> exit
0098
0099 All AnaEx03-*.in macros are used in Geant4 testing.