include/BDSOutput.hh

00001 // Provide interface to output
00002 
00003 
00004 #ifndef BDSOutput_h
00005 #define BDSOutput_h 
00006 
00007 #include "BDSGlobalConstants.hh"
00008 #include "BDSSampler.hh"
00009 #include "BDSSamplerHit.hh"
00010 #include "BDSSamplerSD.hh"
00011 #include "BDSSamplerCylinder.hh"
00012 #include "BDSEnergyCounterHit.hh"
00013 
00014 #include "BDSLWCalorimeter.hh"
00015 #include "BDSLWCalorimeterHit.hh"
00016 
00017 #include "G4TrajectoryContainer.hh"
00018 #include "G4Trajectory.hh"
00019 
00020 #include <fstream>
00021 #include <vector>
00022 // is the root output supported?
00023 #ifdef USE_ROOT
00024 #include "TROOT.h"
00025 #include "TH1F.h"
00026 #include "TNtuple.h"
00027 #include "TFile.h"
00028 #include "TTree.h"
00029 #include "TH3F.h"
00030 #endif
00031 
00032 enum BDSOutputFormat {
00033   _ASCII = 0,
00034   _ROOT = 1
00035   //, _ASCII_ROOT = 2
00036 };
00037 
00038 class BDSOutput {
00039 
00040 public: 
00041   BDSOutput(); // default constructor
00042   BDSOutput(BDSOutputFormat format);
00043 
00044   void SetFormat(BDSOutputFormat format);
00045   void Init(G4int FileNum);
00046   ~BDSOutput();
00047 
00048   void WriteHits(BDSSamplerHitsCollection*);
00049   void WriteEnergyLoss(BDSEnergyCounterHitsCollection*);
00050   G4int WriteTrajectory(TrajectoryVector* TrajVec);
00051   G4int WriteTrajectory(std::vector<G4VTrajectory*> TrajVec);
00052 
00053   void Echo(G4String str);
00054 
00055   G4int Commit(); //G4int FileNum);   // close the event
00056   void Write();           // close the event
00057   // for root output
00058 
00059 #ifdef USE_ROOT
00060   TFile* theRootOutputFile;
00061   //  TTree *theLWCalorimeterTree;
00062 
00063   TH1F *EnergyLossHisto;
00064   //  TH3F *EnergyLossHisto3d;
00065   TTree *PrecisionRegionEnergyLossTree;
00066   TTree *EnergyLossTree;
00067 #endif
00068 
00069   G4int nSamplers;
00070   G4double zMax, transMax; //Maximum values of longitudinal and transverse global position
00071   //BDSSamplerSD* BDSSamplerSensDet;
00072   std::vector <G4String> SampName;
00073   std::vector <G4String> CSampName;
00074 private:
00075   G4String _filename;
00076   G4int format;
00077   std::ofstream of;
00078   std::ofstream ofEloss;
00079   int outputFileNumber;
00080 
00081 //#ifdef USE_ROOT
00082   float x0,xp0,y0,yp0,z0,zp0,E0,t0;
00083   float x,xp,y,yp,z,zp,E,Edep,t;
00084   float X,Xp,Y,Yp,Z,Zp,s,weight,EWeightZ;
00085   int part,nev, pID, theID, track_id;
00086   float z_el,E_el;
00087   float x_el_p,y_el_p,z_el_p,E_el_p;
00088   int part_el_p,pID_el_p, weight_el_p;
00089   char volumeName_el_p[100];
00090 //#endif
00091 
00092 };
00093 
00094 extern BDSOutput* bdsOutput;
00095 #endif

Generated on 27 Aug 2013 for BDSIM by  doxygen 1.4.7