18#include "MCApplication.h"
19#include "DetectorConstruction.h"
20#include "Ex03MCStack.h"
21#include "PrimaryGenerator.h"
22#include "SensitiveDetector.h"
24#include <TMCRootManager.h>
27#include <TGeoManager.h>
28#include <TGeoUniformMagField.h>
30#include <TInterpreter.h>
34#include <TVirtualGeoTrack.h>
35#include <TVirtualMC.h>
59 fSensitiveDetector(0),
90 fPrintModulo(origin.fPrintModulo),
92 fVerbose(origin.fVerbose),
94 fDetConstruction(origin.fDetConstruction),
95 fSensitiveDetector(0),
98 fOldGeometry(origin.fOldGeometry),
128 fSensitiveDetector(0),
129 fPrimaryGenerator(0),
131 fOldGeometry(kFALSE),
176 fHistograms.push_back(
new TH1D(
"1",
"Edep", 100, 0., 0.1));
177 fHistograms.push_back(
new TH1D(
"2",
"XTR Gamma spectrum", 100, 0., 0.1));
179 new TH1D(
"3",
"Secondary Gamma spectrum", 100, 0., 0.1));
180 fHistograms.push_back(
new TH1D(
"4",
"Secondary e- spectrum", 100, 0., 0.1));
196 if (TString(setup) !=
"") {
197 gROOT->LoadMacro(setup);
198 gInterpreter->ProcessLine(
"Config()");
201 "InitMC",
"Processing Config() has failed. (No MC is instantiated.)");
206#if ROOT_VERSION_CODE >= 336402
209 fRootManager =
new TMCRootManager(GetName(), TMCRootManager::kWrite);
214 fRootManager =
new TMCRootManager(GetName(), TMCRootManager::kWrite);
236 gMC->ProcessRun(nofEvents);
249 cout <<
" ================== run summary =====================" << endl;
250 cout <<
" End of Run TotNbofEvents = " <<
fEventNo << endl;
252 cout <<
" Mean energy deposit in absorber = " <<
fHistograms[0]->GetMean()
253 <<
" +-" <<
fHistograms[0]->GetRMS() <<
" MeV " << endl;
255 cout <<
" Total number of XTR gammas = " <<
fHistograms[1]->GetEntries()
258 cout <<
" Total number of all gammas = " <<
fHistograms[2]->GetEntries()
279 fRootManager =
new TMCRootManager(GetName(), TMCRootManager::kWrite);
340 if (TString(gMC->GetName()) ==
"TGeant3TGeo" &&
341 gGeoManager->GetListOfTracks() && gGeoManager->GetTrack(0) &&
342 ((TVirtualGeoTrack*)gGeoManager->GetTrack(0))->HasPoints()) {
344 gGeoManager->ClearTracks();
350 cout <<
"\n---> Begin of event: " <<
fEventNo << endl;
371 if (gMC->TrackPid() == kGamma) {
377#if ((ROOT_VERSION_CODE >= ROOT_VERSION(6, 7, 3)) || \
378 ((ROOT_VERSION_CODE <= ROOT_VERSION(6, 0, 0)) && \
379 (ROOT_VERSION_CODE >= ROOT_VERSION(5, 34, 35))))
380 if (creatorProcess == kPTransitionRadiation) {
382 if (creatorProcess == kPNull) {
390 if (gMC->TrackPid() == kElectron &&
393 fHistograms[3]->Fill((gMC->Etot() - gMC->TrackMass()) * 1e+03);
406 static Int_t trackId = 0;
407 if (TString(gMC->GetName()) ==
"TFluka" &&
408 gMC->GetStack()->GetCurrentTrackNumber() != trackId) {
410 trackId = gMC->GetStack()->GetCurrentTrackNumber();
Implementation of the TVirtualMCStack interface.
virtual TParticle * GetCurrentTrack() const
virtual Int_t GetCurrentParentTrackNumber() const
The detector construction (via TGeo )
Implementation of the TVirtualMCApplication.
virtual void InitGeometry()
virtual void FinishPrimary()
virtual void GeneratePrimaries()
Ex03MCStack * fStack
VMC stack.
virtual void ConstructGeometry()
Int_t fPrintModulo
The event modulus number to be printed.
virtual void FinishEvent()
Bool_t fIsMaster
If is on master thread.
SensitiveDetector * fSensitiveDetector
Absorber SD.
PrimaryGenerator * fPrimaryGenerator
Primary generator.
TMCVerbose fVerbose
VMC verbose helper.
virtual TVirtualMCApplication * CloneForWorker() const
virtual void FinishRunOnWorker()
virtual void BeginPrimary()
void RunMC(Int_t nofEvents)
virtual void BeginEvent()
TGeoUniformMagField * fMagField
Magnetic field.
void RegisterStack() const
TMCRootManager * fRootManager
Root manager.
Int_t fEventNo
Event counter.
virtual void InitOnWorker()
void InitMC(const char *setup)
DetectorConstruction * fDetConstruction
Dector construction.
virtual void GeneratePrimaries()
The absorber sensitive detector.
Double_t GetEdep() const
Return energy deposit.
virtual void Print(Option_t *option="") const
std::vector< TH1D * > fHistograms