19#include <TGeoManager.h>
20#include <TGeoUniformMagField.h>
21#include <TInterpreter.h>
22#include <TLorentzVector.h>
24#include <TVirtualGeoTrack.h>
25#include <TVirtualMC.h>
27#include "Ex03MCStack.h"
151 if (TString(setup) !=
"") {
152 gROOT->LoadMacro(setup);
153 gInterpreter->ProcessLine(
"Config()");
156 "InitMC",
"Processing Config() has failed. (No MC is instantiated.)");
174 gMC->ProcessRun(nofEvents);
219 cerr <<
"Selected MC does not support TGeo geometry" << endl;
220 cerr <<
"Exiting program" << endl;
225 cout <<
"Geometry will be defined via TGeo" << endl;
230 cout <<
"Geometry will be defined via VMC" << endl;
291 if (gMC->TrackPid() == 50000050) {
295 if (gMC->TrackPid() == 50000051) {
311 static Int_t trackId = 0;
312 if (TString(gMC->GetName()) ==
"TFluka" &&
313 gMC->GetStack()->GetCurrentTrackNumber() != trackId) {
316 trackId = gMC->GetStack()->GetCurrentTrackNumber();
330 TString volName = gMC->CurrentVolName();
331 if (volName !=
"TANK")
return;
333 if ((gMC->TrackCharge() != 0.) && (gMC->IsTrackEntering())) {
335 Double_t energy = 1e-06;
338 TLorentzVector momentum(
339 energy, 0.1 * energy, 0.1 * energy, 0.98994949 * energy);
343 if ((gMC->TrackPid() == 50000050) && (gMC->Edep() > 0.)) {
344 TLorentzVector momentum;
345 gMC->TrackMomentum(momentum);
346 momentum = -1. * momentum;
353 Int_t nofPhotons, TLorentzVector momentum)
357 for (Int_t i = 0; i < nofPhotons; ++i) {
359 TLorentzVector position;
360 gMC->TrackPosition(position);
362 Int_t pdgEncoding = 50000051;
364 Double_t polarization[3];
365 polarization[0] = 0.3;
366 polarization[1] = 0.4;
367 polarization[2] = 0.866025403784438597;
370 gMC->GetStack()->PushTrack(1, gMC->GetStack()->GetCurrentTrackNumber(),
371 pdgEncoding, momentum.X(), momentum.Y(), momentum.Z(), momentum.T(),
372 position.X(), position.Y(), position.Z(), position.T(), polarization[0],
373 polarization[1], polarization[2], kPFeedBackPhoton, ntrack, 1.0, 0);
402 if (TString(gMC->GetName()) ==
"TGeant3TGeo") {
405 gGeoManager->SetVisOption(0);
406 gGeoManager->SetTopVisible();
407 gGeoManager->GetTopVolume()->Draw();
412 if (gGeoManager->GetListOfTracks() && gGeoManager->GetTrack(0) &&
413 ((TVirtualGeoTrack*)gGeoManager->GetTrack(0))->HasPoints()) {
415 gGeoManager->DrawTracks(
"/*");
419 cout <<
"Number of optical photons produced in this event : " <<
fGammaCounter
423 cout <<
"Number of feedback photons produced in this event : "
436 cout <<
"Number of optical photons produced in this run : "
440 cout <<
"Number of feedback photons produced in this run : "
Definition of the Ex06DetectorConstructionOld class.
Definition of the Ex06DetectorConstruction class.
Definition of the Ex06MCApplication class.
Definition of the Ex06PrimaryGenerator class.
Implementation of the TVirtualMCStack interface.
The detector construction (via TGeo ).
void ConstructMaterials()
The detector construction (via TGeo ).
Implementation of the TVirtualMCApplication.
Bool_t fTestStackPopper
Option for stack popper test.
void RunMC(Int_t nofEvents)
virtual void GeneratePrimaries()
Ex06MCApplication(const char *name, const char *title)
Int_t fFeedbackCounter
Feedback photons counter.
TVirtualMagField * fMagField
The magnetic field.
void GenerateFeedback(Int_t nofPhotons, TLorentzVector momentum)
Int_t fRunGammaCounter
Optical photons counter2.
Int_t fRunFeedbackCounter
Feedback photons counter2.
virtual void BeginPrimary()
Bool_t fIsMaster
If is on master thread.
virtual ~Ex06MCApplication()
void InitMC(const char *setup)
Int_t fGammaCounter
Optical photons counter.
Ex06DetectorConstruction * fDetConstruction
Dector construction.
virtual void InitGeometry()
Bool_t fOldGeometry
Option for geometry definition.
virtual void BeginEvent()
virtual void ConstructGeometry()
virtual TVirtualMCApplication * CloneForWorker() const
Ex03MCStack * fStack
VMC stack.
virtual void InitOnWorker()
Ex06PrimaryGenerator * fPrimaryGenerator
Primary generator.
TMCVerbose fVerbose
VMC verbose helper.
virtual void FinishEvent()
virtual void FinishPrimary()
virtual void Merge(TVirtualMCApplication *localMCApplication)
virtual void ConstructOpGeometry()