Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /geant4/examples/advanced/underground_physics/src/DMXRunAction.cc was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 // --------------------------------------------------------------
0028 //   GEANT 4 - Underground Dark Matter Detector Advanced Example
0029 //
0030 //      For information related to this code contact: Alex Howard
0031 //      e-mail: alexander.howard@cern.ch
0032 // --------------------------------------------------------------
0033 // Comments
0034 //
0035 //                  Underground Advanced
0036 //               by A. Howard and H. Araujo 
0037 //                    (27th November 2001)
0038 //
0039 // History:
0040 // 17 Jan 2002 Alex Howard Added Analysis
0041 // 23 Oct 2009 Luciano Pandola Removed un-necessary calls from EndOfRun()
0042 //
0043 // RunAction program
0044 // --------------------------------------------------------------
0045 
0046 #include "DMXRunActionMessenger.hh"
0047 #include "DMXRunAction.hh"
0048 
0049 #include "G4Run.hh"
0050 #include "G4ios.hh"
0051 #include "G4AnalysisManager.hh"
0052 
0053 #include <fstream>
0054 
0055 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0056 
0057 DMXRunAction::DMXRunAction()
0058 {
0059   runMessenger = new DMXRunActionMessenger(this);
0060   savehitsFile = "hits.out";
0061   savepmtFile  = "pmt.out";
0062   savehistFile = "dmx";
0063 }
0064 
0065 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0066 
0067 DMXRunAction::~DMXRunAction()
0068 {
0069   delete runMessenger;
0070   runMessenger = 0;
0071 
0072 }
0073 
0074 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0075 
0076 void DMXRunAction::BeginOfRunAction(const G4Run* aRun)
0077 {
0078   //Master mode or sequential
0079   if (IsMaster())    
0080     G4cout << "### Run " << aRun->GetRunID() << " starts (master)." << G4endl;
0081   else
0082     G4cout << "### Run " << aRun->GetRunID() << " starts (worker)." << G4endl;
0083   
0084   // Book histograms and ntuples
0085   Book();
0086 
0087 }
0088 
0089 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0090 
0091 void DMXRunAction::EndOfRunAction(const G4Run*)
0092 {;}
0093 
0094 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0095 
0096 void DMXRunAction::Book()
0097 {  
0098   // Get/create analysis manager
0099   G4AnalysisManager* man = G4AnalysisManager::Instance();
0100   man->SetDefaultFileType("root");
0101   
0102   man->SetNtupleMerging(true);
0103   
0104   // Open an output file
0105   man->OpenFile(savehistFile);
0106   man->SetFirstHistoId(1);
0107   man->SetFirstNtupleId(1);
0108 
0109 
0110   // ---- primary ntuple ------
0111   // id==1
0112   man->CreateNtuple("tree1", "Particle Source Energy");
0113   man->CreateNtupleDColumn("energy");
0114   man->FinishNtuple();
0115 
0116   // ---- secondary ntuple ------   
0117   //id==2
0118   man->CreateNtuple("tree2", "Scintillation Hits Info");
0119   man->CreateNtupleDColumn("Event");
0120   man->CreateNtupleDColumn("e_prim");
0121   man->CreateNtupleDColumn("tot_e");
0122   man->CreateNtupleDColumn("s_hits");
0123   man->CreateNtupleDColumn("xe_time");
0124   man->CreateNtupleDColumn("num_ph");
0125   man->CreateNtupleDColumn("avphtime");
0126   man->CreateNtupleDColumn("firstpart");
0127   man->CreateNtupleDColumn("firstparte");
0128   man->CreateNtupleDColumn("gamma");
0129   man->CreateNtupleDColumn("neutron");
0130   man->CreateNtupleDColumn("posi");
0131   man->CreateNtupleDColumn("elec");
0132   man->CreateNtupleDColumn("other");
0133   man->CreateNtupleDColumn("seed1");
0134   man->CreateNtupleDColumn("seed2");
0135   man->FinishNtuple();
0136 
0137   // ---- tertiary ntuple ------   
0138   //id==3
0139   man->CreateNtuple("tree3", "PMT Hits Info");
0140   man->CreateNtupleDColumn("event");
0141   man->CreateNtupleDColumn("hits");
0142   man->CreateNtupleDColumn("xpos");
0143   man->CreateNtupleDColumn("ypos");
0144   man->CreateNtupleDColumn("zpos");
0145   man->FinishNtuple();
0146  
0147   // Creating 1-dimensional histograms
0148   man->CreateH1("h1","Source Energy /keV",  1000,0.,10000.);
0149   man->CreateH1("h2","Energy Deposit /keV", 1000,0.,1000.);
0150   man->CreateH1("h3","Nuclear Recoil Edep /keV", 100,0.,100.);
0151   man->CreateH1("h4","Number of Photons - LowE", 200,0.,200.);
0152   man->CreateH1("h5","Number of Photons - HighE", 100,0.,10000.);
0153   man->CreateH1("h6","Average Photon Arrival/ns", 200,0.,200.);
0154   man->CreateH1("h7","1st event Photon Arrival", 200,0.,200.);
0155   man->CreateH1("h8","Gamma Energy Deposit/keV", 1000,0.,1000.);
0156   man->CreateH1("h9","Neutron Ener Deposit/keV", 1000,0.,1000.);
0157   man->CreateH1("h10","Electron Ener Deposit/keV",1000,0.,1000.);
0158   man->CreateH1("h11","Positron Ener Deposit/keV",1000,0.,1000.);
0159   man->CreateH1("h12","Other Ener Deposit/keV", 1000,0.,1000.);
0160 
0161   //Creating 2-dimensional histograms
0162   man->CreateH2("hh1","PMT Hit Pattern", 
0163         300 ,-30.,30.,300,-30.,30.);
0164   man->CreateH2("hh2","1st event PMT Hit Pattern", 
0165         300 ,-30.,30.,300,-30.,30.);
0166 
0167   return;
0168 
0169 }
0170 
0171