Day 3 - Geant4 User Actions

Geant4 and Calorimetry in HEP

OBJECTIVE

HOW

PRACTICE

Here we are using the G4UserStackingAction and G4UserEventAction. In this exercise we access electrons, positrons and gammas in an electromagnetic shower at the time they are created and print out properties like energy and creation time. A few root histograms are created and are stored in: Analysis_0.root (analysis is covered later this afternoon)

The other task is to modify the EventAction to add a print out when an Event has finished.

Exercise 3.4.1 : StackingAction

  calorimeter electrons.mac

Hint look for the lines in the main program calorimeter.cc

 G4UserStackingAction* stacking_action = new StackingAction;
 runManager->SetUserAction(stacking_action);

Exercise 3.4.2 : EventAction

SOLUTION

Solution 1

 G4ClassificationOfNewTrack classification = fWaiting;
  G4String particleType = aTrack->GetDefinition()->GetParticleName();
  G4double time   = aTrack->GetGlobalTime ()/ns;
  G4double energy = aTrack->GetTotalEnergy ()/MeV;

  //
  // here we  print out when a new e+, e- or gamma is created
  //
  if (particleType == "e+")
    {
      G4cout << "New e+ created Energy: " <<energy  << "MeV,  Time:  "<< time <<"  ns"<<G4endl;
#ifdef G4ANALYSIS_USE_ROOT  
      analysis->pcounter++;
#endif
    }
  else if (particleType == "gamma") 
    {
#ifdef G4ANALYSIS_USE_ROOT
      analysis->gammacounter++;
#endif
      G4cout << "New gamma created, Energy: " <<energy  << "Mev,  Time:  "<<time<<"  ns"<<G4endl; 
    }
  else if  (particleType == "e-")
    {
#ifdef G4ANALYSIS_USE_ROOT  
      analysis->ecounter++;
#endif
      G4cout << "New e- created, Energy: " <<energy  << "  Time:  "<< time<<"  ns"<<G4endl; 
    }

Solution 2

Add the following lines to the EndOfEventAction

 G4int evtNb = evt->GetEventID();
  G4cout << " Finished Event :  "<< evtNb<<G4endl;


Generated on Thu May 12 14:04:21 2011