00001
00002
00003
00004
00005
00006
00007 #include "TROOT.h"
00008 #include "TFile.h"
00009 #include "TTree.h"
00010 #include "TBranch.h"
00011 #include "TStopwatch.h"
00012
00013 #include <time.h>
00014 #define ELAPSEDT 300
00015
00016 class MyEventAction : public GLG4VEventAction {
00017 private:
00018 TFile* fROOTOutputFile;
00019 TTree* fROOTOutputTree;
00020 TTree* fROOTRunTree;
00021 TStopwatch* timer;
00022 time_t Ptime;
00023
00024 public:
00025 MyEventAction(): GLG4VEventAction(),
00026 fROOTOutputFile(0), fROOTOutputTree(0)
00027 {
00028 fFileCmd->SetGuidance("This will be a ROOT Format File;");
00029 timer= new TStopwatch();
00030 }
00031
00032 ~MyEventAction(){ CloseFile(); }
00033
00034 virtual void BeginOfEventAction(const G4Event* evt)
00035 {
00036 GLG4VEventAction::BeginOfEventAction(evt);
00037 timer->Start();
00038 }
00039 virtual void EndOfEventAction(const G4Event* evt)
00040 {
00041 timer->Stop();
00042 GLG4VEventAction::EndOfEventAction(evt);
00043 }
00044 virtual void OpenFile(const G4String filename,G4bool outputMode);
00045 virtual void CloseFile();
00046 virtual void FillData(const G4Event*);
00047 virtual void Clear(){;}
00048
00049 void CreateTree();
00050
00051
00052
00053
00054
00055
00056
00057
00058 enum { max_primary_particles= 16, max_hits_for_ROOT=4000 };
00059 Int_t eventID;
00060 Int_t runID;
00061 Float_t UT;
00062 Float_t delta_UT;
00063 Int_t eventType;
00064
00065 struct vertex_info_s {
00066 Int_t n_particles;
00067 Float_t t0[max_primary_particles],x0[max_primary_particles],
00068 y0[max_primary_particles],z0[max_primary_particles];
00069 Int_t pdg_code[max_primary_particles];
00070 Float_t px[max_primary_particles];
00071 Float_t py[max_primary_particles];
00072 Float_t pz[max_primary_particles];
00073 Float_t polx[max_primary_particles];
00074 Float_t poly[max_primary_particles];
00075 Float_t polz[max_primary_particles];
00076 Float_t ke[max_primary_particles];
00077 } vertex_info;
00078 Double_t vketot;
00079 Float_t vcentroid_x, vcentroid_y, vcentroid_z;
00080
00081 Int_t n_photon_hits;
00082 Double_t hit_time[max_hits_for_ROOT];
00083 Short_t hit_pmt[max_hits_for_ROOT];
00084 Short_t hit_wl[max_hits_for_ROOT];
00085 Float_t hit_x[max_hits_for_ROOT], hit_y[max_hits_for_ROOT],
00086 hit_z[max_hits_for_ROOT], hit_px[max_hits_for_ROOT],
00087 hit_py[max_hits_for_ROOT], hit_pz[max_hits_for_ROOT],
00088 hit_polx[max_hits_for_ROOT], hit_poly[max_hits_for_ROOT],
00089 hit_polz[max_hits_for_ROOT];
00090 Int_t hit_count[max_hits_for_ROOT];
00091
00092
00093 Float_t totScintEdep;
00094 Float_t totScintEdepQuenched;
00095 Float_t scint_centroid_x, scint_centroid_y, scint_centroid_z;
00096 };