use strict;
use warnings;
use SOOT ':all';

sub _geant3task {
  my $geant3 = TTask->new("geant3","Geant3 simulation main program");      
  $gROOT->GetListOfTasks()->Add($geant3); # FIXME check gROOT->GetListOfTasks (Can't locate object method "Add" via package "enum")
  my $uginit = TTask->new("uginit","Initialisation manager");      
  my $grun   = TTask->new("grun","#Run manager");      
  my $uglast = TTask->new("uglast","Termination manager");      
  $geant3->Add($uginit);
  $geant3->Add($grun);
  $geant3->Add($uglast);
  my $ginit  = TTask->new("ginit","Geant3 initialisation");      
  my $ugeom  = TTask->new("ugeom","Geometry initialisation manager");      
  my $gphysi = TTask->new("gphysi","Initialise cross-sections and energy loss tables");      
  my $ggclos = TTask->new("ggclos","Geometry analyzer and optimizer");      
  $uginit->Add($ginit);
  $uginit->Add($ugeom);
  $uginit->Add($gphysi);
  $uginit->Add($ggclos);
  my $gtrigi = TTask->new("gtrigi","Event initialisation");      
  my $gtrig  = TTask->new("gtrig","Event manager");      
  my $gtrigc = TTask->new("gtrigc","Event cleaner");      
  $grun->Add($gtrigi);
  $grun->Add($gtrig);
  $grun->Add($gtrigc);
  my $glast  = TTask->new("glast","Geant3 termination");      
  my $igend  = TTask->new("igend","Graphics package termination");      
  $uglast->Add($glast);
  $uglast->Add($igend);
  my $gukine = TTask->new("gukine","Event generator manager");      
  my $gutrev = TTask->new("gutrev","Event application manager");      
  my $gudigi = TTask->new("gudigi","Event digitisation manager");      
  my $guout  = TTask->new("guout","Event termination manager");      
  $gtrig->Add($gukine);
  $gtrig->Add($gutrev);
  $gtrig->Add($gudigi);
  $gtrig->Add($guout);
  my $gtreve = TTask->new("gtreve","Geant3 event manager");      
  $gutrev->Add($gtreve);
  my $gltrac = TTask->new("gltrac","Initialize tracking parameters");      
  my $gftrac = TTask->new("gftrac","select next track segment from stack JTRACK");      
  my $gutrak = TTask->new("gutrak","Application track manager");      
  $gtreve->Add($gltrac);
  $gtreve->Add($gftrac);
  $gtreve->Add($gutrak);
  my $gtrack = TTask->new("gtrack","Geant3 track manager");      
  $gutrak->Add($gtrack);
  my $gtgama = TTask->new("gtgama","photon propagator");      
  my $gtelec = TTask->new("gtelec","electron propagator");      
  my $gtneut = TTask->new("gtneut","neutron propagator");      
  my $gthadr = TTask->new("gthadr","hadron propagator");      
  my $gtmuon = TTask->new("gtmuon","muon propagator");      
  my $gtnino = TTask->new("gtnino","geantino propagator");      
  my $gtckov = TTask->new("gtckov","Cherenkov light propagator");      
  my $gthion = TTask->new("gthion","heavy ion propagator");      
  my $gustep = TTask->new("gustep","Application step manager");      
  my $gtmedi = TTask->new("gtmedi","Geometry volume finder");      
  $gtrack->Add($gtgama);
  $gtrack->Add($gtelec);
  $gtrack->Add($gtneut);
  $gtrack->Add($gthadr);
  $gtrack->Add($gtmuon);
  $gtrack->Add($gtnino);
  $gtrack->Add($gtckov);
  $gtrack->Add($gthion);
  $gtrack->Add($gustep);
  $gtrack->Add($gtmedi);
  my $gtnext = TTask->new("gtnext","Geometry bounary manager");      
  my $gpairg = TTask->new("gpairg","Generate pair production");      
  my $gcomp  = TTask->new("gcomp","Generate Compton scattering");      
  my $gphot  = TTask->new("gphot","Generate photo effect");      
  my $grayl  = TTask->new("grayl","Generate Rayleigh effect");      
  my $gpfis  = TTask->new("gpfis","Generate photo fission");      
  $gtgama->Add($gtnext);
  $gtgama->Add($gpairg);
  $gtgama->Add($gcomp);
  $gtgama->Add($gphot);
  $gtgama->Add($grayl);
  $gtgama->Add($gpfis);
  my $guswim = TTask->new("guswim","magnetic field propagator");      
  my $ggckov = TTask->new("ggckov","Generate Cherenkov photons");      
  my $gsync  = TTask->new("gsync","Generate synchrotron radiation");      
  my $gmults = TTask->new("gmults","Apply multiple scattering");      
  my $gbreme = TTask->new("gbreme","Generate Bremsstrahlung");      
  my $gdray  = TTask->new("gdray","Generate delta ray");      
  my $ganni  = TTask->new("ganni","Generate Positron annihilation");      
  my $gannir = TTask->new("gannir","Stopped tracks and annihilation at rest");      
  
  $gtelec->Add($gtnext);
  $gtelec->Add($guswim);
  $gtelec->Add($ggckov);
  $gtelec->Add($gsync);
  $gtelec->Add($gmults);
  $gtelec->Add($gbreme);
  $gtelec->Add($gdray);
  $gtelec->Add($ganni);
  $gtelec->Add($gannir);
  my $guphad = TTask->new("guphad","Hadronic cross-section manager");      
  my $guhadr = TTask->new("guhadr","Hadronic cascade manager");      
  my $gdecay = TTask->new("gdecay","Particle decay");      
  $gtneut->Add($gtnext);
  $gtneut->Add($guphad);
  $gtneut->Add($guhadr);
  $gtneut->Add($gdecay);
  
  $gthadr->Add($gtnext);
  $gthadr->Add($guphad);
  $gthadr->Add($guswim);
  $gthadr->Add($ggckov);
  $gthadr->Add($gmults);
  $gthadr->Add($guhadr);
  $gthadr->Add($gdecay);
  $gthadr->Add($gdray);
  my $gbremm = TTask->new("gbremm","Generate Bremsstrahlung");      
  my $gpairm = TTask->new("gpairm","Generate Pair production");      
  my $gmunu  = TTask->new("gmunu","Generate Nuclear interaction");      
  $gtmuon->Add($gtnext);
  $gtmuon->Add($guswim);
  $gtmuon->Add($ggckov);
  $gtmuon->Add($gmults);
  $gtmuon->Add($gbremm);
  $gtmuon->Add($gpairm);
  $gtmuon->Add($gdecay);
  $gtmuon->Add($gdray);
  $gtmuon->Add($gmunu);
  $gtmuon->Add($gdecay);
  
  $gtnino->Add($gtnext);
  my $glisur = TTask->new("glisur","Photon is reflected");      
  $gtckov->Add($gtnext);
  $gtckov->Add($glisur);
  
  $gthion->Add($gtnext);
  $gthion->Add($guswim);
  $gthion->Add($gmults);
  $gthion->Add($guhadr);
  $gthion->Add($gdray);
  
  TBrowser->new
}

_geant3task;
$gApplication->Run;

__END__
