/* Example of MiniSim class * * The MiniSim class allows you to run a RAT simulation inside another RAT * simulation. This may be used, e.g., to build Monte Carlo-based response * tables for fitters at runtime rather than relying on user-defined * parameters. * * This MiniSim throws some isotropic betas with a user-specified position and * energy, and computes the mean NHIT for the events. */ #ifndef __RAT__ExampleMiniSim__ #define __RAT__ExampleMiniSim__ #include #include #include #include namespace RAT { class ExampleMiniSim : public MiniSim { public: ExampleMiniSim(const G4ThreeVector ¢er=G4ThreeVector(0,0,0), double betaEnergy=3.5*MeV); virtual ~ExampleMiniSim(); // some function from which we'll call MiniSim::BeamOn(int nevents) // it's not necessary to do things this way void Run(const int nevents); // getter to extract data after running simulation double GetMeanNhits() { return fMeanNhits; } // must override GeneratePrimaries virtual void GeneratePrimaries(G4Event* event); // overriding other methods is optional // here, just use BeginOfEventAction to clear pmt hits and EndOfEventAction // to grab nhits virtual void BeginOfEventAction(const G4Event* event); virtual void EndOfEventAction(const G4Event* event); protected: G4ThreeVector fCenter; double fBetaEnergy; // store the simulation output in class members // here just histogram nhits, could be more interesting TH1F* fNhits; double fMeanNhits; }; } // namespace RAT #endif