19#include <TGeoManager.h>
20#include <TGeoUniformMagField.h>
21#include <TInterpreter.h>
24#include <TParticlePDG.h>
28#include <TVirtualGeoTrack.h>
29#include <TVirtualMC.h>
31#include <TMCRootManager.h>
41#include "Ex03MCStack.h"
55 fUseLocalMagField(false),
84 fHodoscopeSD1 =
new A01HodoscopeSD(
"Hodoscope1",
"hodoscope1Logical");
85 fHodoscopeSD2 =
new A01HodoscopeSD(
"Hodoscope2",
"hodoscope2Logical");
92 if (!fUseLocalMagField) {
101 fWriteStack(origin.fWriteStack),
102 fWriteHits(origin.fWriteHits),
103 fUseLocalMagField(origin.fUseLocalMagField),
104 fVerbose(origin.fVerbose),
106 fDetConstruction(origin.fDetConstruction),
110 fHadCalorimeterSD(0),
113 fPrimaryGenerator(0),
148 fUseLocalMagField(false),
154 fHadCalorimeterSD(0),
157 fPrimaryGenerator(0),
215 if (TString(setup) !=
"") {
216 gROOT->LoadMacro(setup);
217 gInterpreter->ProcessLine(
"Config()");
220 "InitMC",
"Processing Config() has failed. (No MC is instantiated.)");
225#if ROOT_VERSION_CODE >= 336402
228 fRootManager =
new TMCRootManager(GetName(), TMCRootManager::kWrite);
233 fRootManager =
new TMCRootManager(GetName(), TMCRootManager::kWrite);
256 gMC->ProcessRun(nofEvents);
286 fRootManager =
new TMCRootManager(GetName(), TMCRootManager::kWrite);
339 if (TString(gMC->GetName()) ==
"TGeant3TGeo")
SetCuts();
382 if (TString(gMC->GetName()) ==
"TGeant3TGeo" &&
383 gGeoManager->GetListOfTracks() && gGeoManager->GetTrack(0) &&
384 ((TVirtualGeoTrack*)gGeoManager->GetTrack(0))->HasPoints()) {
386 gGeoManager->ClearTracks();
446 if (TString(gMC->GetName()) ==
"TGeant3TGeo") {
449 gGeoManager->SetVisOption(0);
450 gGeoManager->SetTopVisible();
451 gGeoManager->GetTopVolume()->Draw();
456 if (gGeoManager->GetListOfTracks() && gGeoManager->GetTrack(0) &&
457 ((TVirtualGeoTrack*)gGeoManager->GetTrack(0))->HasPoints()) {
459 gGeoManager->DrawTracks(
"/*");
470 <<
">>> Event " << gMC->CurrentEvent()
471 <<
" >>> Simulation truth : " << primary->GetPDG()->GetName() <<
" ("
472 << primary->Px() * 1e03 <<
", " << primary->Py() * 1e03 <<
", "
473 << primary->Pz() * 1e03 <<
") MeV" << endl;
521 Int_t mediumId = gMC->MediumId(
"Air");
523 gMC->Gstpar(mediumId,
"CUTGAM", 990.e-09);
524 gMC->Gstpar(mediumId,
"BCUTE", 990.e-09);
525 gMC->Gstpar(mediumId,
"CUTELE", 990.e-09);
526 gMC->Gstpar(mediumId,
"DCUTE", 990.e-09);
529 mediumId = gMC->MediumId(
"G4_Galactic");
531 gMC->Gstpar(mediumId,
"CUTGAM", 990.e-09);
532 gMC->Gstpar(mediumId,
"BCUTE", 990.e-09);
533 gMC->Gstpar(mediumId,
"CUTELE", 990.e-09);
534 gMC->Gstpar(mediumId,
"DCUTE", 990.e-09);
537 mediumId = gMC->MediumId(
"Scintillator");
539 gMC->Gstpar(mediumId,
"CUTGAM", 2.40367 - 06);
540 gMC->Gstpar(mediumId,
"BCUTE", 356.639e-06);
541 gMC->Gstpar(mediumId,
"CUTELE", 356.639e-06);
542 gMC->Gstpar(mediumId,
"DCUTE", 356.639e-06);
545 mediumId = gMC->MediumId(
"ArgonGas");
547 gMC->Gstpar(mediumId,
"CUTGAM", 990.e-09);
548 gMC->Gstpar(mediumId,
"BCUTE", 990.e-09);
549 gMC->Gstpar(mediumId,
"CUTELE", 990.e-09);
550 gMC->Gstpar(mediumId,
"DCUTE", 990.e-09);
553 mediumId = gMC->MediumId(
"CsI");
555 gMC->Gstpar(mediumId,
"CUTGAM", 38.5665e-06);
556 gMC->Gstpar(mediumId,
"BCUTE", 689.033e-06);
557 gMC->Gstpar(mediumId,
"CUTELE", 689.033e-06);
558 gMC->Gstpar(mediumId,
"DCUTE", 689.033e-06);
561 mediumId = gMC->MediumId(
"Lead");
563 gMC->Gstpar(mediumId,
"CUTGAM", 101.843e-06);
564 gMC->Gstpar(mediumId,
"BCUTE", 1.36749e-03);
565 gMC->Gstpar(mediumId,
"CUTELE", 1.36749e-03);
566 gMC->Gstpar(mediumId,
"DCUTE", 1.36749e-03);
Definition of the A01DriftChamberSD class.
Definition of the A01EmCalorimeterSD class.
Definition of the A01HadCalorimeterSD class.
Definition of the A01HodoscopeSD class.
Definition of the A01MCApplication class.
Definition of the A01MagField class.
Definition of the A01PrimaryGenerator class.
Definition of the A01RootDetectorConstruction class.
The calorimeter sensitive detector.
void SetWriteHits(Bool_t writeHits)
The EM calorimeter sensitive detector.
void SetWriteHits(Bool_t writeHits)
The hadron calorimeter sensitive detector.
void SetWriteHits(Bool_t writeHits)
The calorimeter sensitive detector.
void SetWriteHits(Bool_t writeHits)
Implementation of the TVirtualMCApplication.
void SetWriteHits(Bool_t writeHits)
void RunMC(Int_t nofEvents)
A01HodoscopeSD * fHodoscopeSD2
Hodoscope 2 SD.
A01MagField * fMagField
Magnetic field.
virtual void GeneratePrimaries()
A01DriftChamberSD * fDriftChamberSD1
Drift Chamber 1 SD.
virtual void BeginPrimary()
Bool_t fIsMaster
If is on master thread.
A01RootDetectorConstruction * fDetConstruction
Detector construction.
virtual void AddParticles()
virtual ~A01MCApplication()
virtual void FinishRunOnWorker()
virtual void ConstructGeometry()
virtual void FinishEvent()
virtual void FinishPrimary()
A01DriftChamberSD * fDriftChamberSD2
Drift Chamber 2 SD.
void InitMC(const char *setup)
virtual void InitGeometry()
TMCVerbose fVerbose
VMC verbose helper.
A01HadCalorimeterSD * fHadCalorimeterSD
Had Calorimeter SD.
Bool_t fWriteStack
Option to write stack.
Bool_t fUseLocalMagField
Option to use local magnetic field (working only with Geant4 !)
Ex03MCStack * fStack
VMC stack.
virtual void BeginEvent()
A01PrimaryGenerator * fPrimaryGenerator
Primary generator.
void SetUseLocalMagField(Bool_t localMagField)
virtual void InitOnWorker()
virtual TVirtualMCApplication * CloneForWorker() const
TMCRootManager * fRootManager
Root manager.
void RegisterStack() const
A01EmCalorimeterSD * fEmCalorimeterSD
Em Calorimeter SD.
A01HodoscopeSD * fHodoscopeSD1
Hodoscope 1 SD.
Definition of a uniform magnetic field within a given region.
virtual void GeneratePrimaries()
The detector construction (via TGeo )
void SetUseLocalMagField(Bool_t localMagField)
Implementation of the TVirtualMCStack interface.
TParticle * GetParticle(Int_t id) const