Geant4  10.01.p01
DMXRunAction.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // --------------------------------------------------------------
28 // GEANT 4 - Underground Dark Matter Detector Advanced Example
29 //
30 // For information related to this code contact: Alex Howard
31 // e-mail: alexander.howard@cern.ch
32 // --------------------------------------------------------------
33 // Comments
34 //
35 // Underground Advanced
36 // by A. Howard and H. Araujo
37 // (27th November 2001)
38 //
39 // History:
40 // 17 Jan 2002 Alex Howard Added Analysis
41 // 23 Oct 2009 Luciano Pandola Removed un-necessary calls from EndOfRun()
42 //
43 // RunAction program
44 // --------------------------------------------------------------
45 
46 #include "DMXRunActionMessenger.hh"
47 #include "DMXRunAction.hh"
48 
49 #include "G4Run.hh"
50 #include "G4ios.hh"
51 
52 #include <fstream>
53 
54 #include "DMXAnalysisManager.hh"
55 
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
57 
59 {
61  savehitsFile = "hits.out";
62  savepmtFile = "pmt.out";
63  savehistFile = "dmx";
64 }
65 
66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
67 
69 {
70  delete runMessenger;
71  runMessenger = 0;
72 
73 }
74 
75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
76 
78 {
79  //Master mode or sequential
80  if (IsMaster())
81  G4cout << "### Run " << aRun->GetRunID() << " starts (master)." << G4endl;
82  else
83  G4cout << "### Run " << aRun->GetRunID() << " starts (worker)." << G4endl;
84 
85  // Book histograms and ntuples
86  Book();
87 
88 }
89 
90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
91 
93 {;}
94 
95 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
96 
98 {
99  // Get/create analysis manager
100  G4AnalysisManager* man = G4AnalysisManager::Instance();
101 
102  // Open an output file
103  man->OpenFile(savehistFile);
104  man->SetFirstHistoId(1);
105  man->SetFirstNtupleId(1);
106 
107 
108  // ---- primary ntuple ------
109  // id==1
110  man->CreateNtuple("tree1", "Particle Source Energy");
111  man->CreateNtupleDColumn("energy");
112  man->FinishNtuple();
113 
114  // ---- secondary ntuple ------
115  //id==2
116  man->CreateNtuple("tree2", "Scintillation Hits Info");
117  man->CreateNtupleDColumn("Event");
118  man->CreateNtupleDColumn("e_prim");
119  man->CreateNtupleDColumn("tot_e");
120  man->CreateNtupleDColumn("s_hits");
121  man->CreateNtupleDColumn("xe_time");
122  man->CreateNtupleDColumn("num_ph");
123  man->CreateNtupleDColumn("avphtime");
124  man->CreateNtupleDColumn("firstpart");
125  man->CreateNtupleDColumn("firstparte");
126  man->CreateNtupleDColumn("gamma");
127  man->CreateNtupleDColumn("neutron");
128  man->CreateNtupleDColumn("posi");
129  man->CreateNtupleDColumn("elec");
130  man->CreateNtupleDColumn("other");
131  man->CreateNtupleDColumn("seed1");
132  man->CreateNtupleDColumn("seed2");
133  man->FinishNtuple();
134 
135  // ---- tertiary ntuple ------
136  //id==3
137  man->CreateNtuple("tree3", "PMT Hits Info");
138  man->CreateNtupleDColumn("event");
139  man->CreateNtupleDColumn("hits");
140  man->CreateNtupleDColumn("xpos");
141  man->CreateNtupleDColumn("ypos");
142  man->CreateNtupleDColumn("zpos");
143  man->FinishNtuple();
144 
145  // Creating 1-dimensional histograms
146  man->CreateH1("h1","Source Energy /keV", 1000,0.,10000.);
147  man->CreateH1("h2","Energy Deposit /keV", 1000,0.,1000.);
148  man->CreateH1("h3","Nuclear Recoil Edep /keV", 100,0.,100.);
149  man->CreateH1("h4","Number of Photons - LowE", 200,0.,200.);
150  man->CreateH1("h5","Number of Photons - HighE", 100,0.,10000.);
151  man->CreateH1("h6","Average Photon Arrival/ns", 200,0.,200.);
152  man->CreateH1("h7","1st event Photon Arrival", 200,0.,200.);
153  man->CreateH1("h8","Gamma Energy Deposit/keV", 1000,0.,1000.);
154  man->CreateH1("h9","Neutron Ener Deposit/keV", 1000,0.,1000.);
155  man->CreateH1("h10","Electron Ener Deposit/keV",1000,0.,1000.);
156  man->CreateH1("h11","Positron Ener Deposit/keV",1000,0.,1000.);
157  man->CreateH1("h12","Other Ener Deposit/keV", 1000,0.,1000.);
158 
159  //Creating 2-dimensional histograms
160  man->CreateH2("hh1","PMT Hit Pattern",
161  300 ,-30.,30.,300,-30.,30.);
162  man->CreateH2("hh2","1st event PMT Hit Pattern",
163  300 ,-30.,30.,300,-30.,30.);
164 
165  return;
166 
167 }
168 
169 
G4bool SetFirstHistoId(G4int firstId)
G4int CreateH1(const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none", const G4String &binSchemeName="linear")
void BeginOfRunAction(const G4Run *)
Definition: DMXRunAction.cc:77
G4int CreateNtuple(const G4String &name, const G4String &title)
G4bool OpenFile(const G4String &fileName="")
G4GLOB_DLL std::ostream G4cout
void EndOfRunAction(const G4Run *)
Definition: DMXRunAction.cc:92
G4String savehistFile
Definition: DMXRunAction.hh:78
G4bool IsMaster() const
G4int GetRunID() const
Definition: G4Run.hh:76
Definition: G4Run.hh:46
G4bool SetFirstNtupleId(G4int firstId)
G4String savehitsFile
Definition: DMXRunAction.hh:76
G4String savepmtFile
Definition: DMXRunAction.hh:77
#define G4endl
Definition: G4ios.hh:61
G4int CreateNtupleDColumn(const G4String &name)
G4int CreateH2(const G4String &name, const G4String &title, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinSchemeName="linear", const G4String &ybinSchemeName="linear")
DMXRunActionMessenger * runMessenger
Definition: DMXRunAction.hh:80