// $Id$ // Category: event // // See the class description in the header file. #include "AliEventAction.h" #include "AliEventActionMessenger.h" #include "AliRun.h" #include "AliTrackingAction.h" #include "AliSensitiveDetector.h" #include "AliGlobals.h" #include "TG4GeometryManager.h" #include #include #include #include #include #include #include AliEventAction::AliEventAction() : fVerboseLevel(1), fDrawFlag("CHARGED") { // fMessenger = new AliEventActionMessenger(this); } AliEventAction::AliEventAction(const AliEventAction& right) { // AliGlobals::Exception("AliEventAction is protected from copying."); } AliEventAction::~AliEventAction() { // delete fMessenger; } // operators AliEventAction& AliEventAction::operator=(const AliEventAction &right) { // check assignement to self if (this == &right) return *this; AliGlobals::Exception("AliEventAction is protected from assigning."); return *this; } // private methods void AliEventAction::DisplayEvent(const G4Event* event) const { // Draws trajectories. // --- // trajectories processing G4TrajectoryContainer* trajectoryContainer = event->GetTrajectoryContainer(); G4int nofTrajectories = 0; if (trajectoryContainer) { nofTrajectories = trajectoryContainer->entries(); } if (fVerboseLevel>0) { G4cout << " " << nofTrajectories; G4cout << " trajectories stored." << endl; } G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance(); if(pVVisManager && nofTrajectories>0) { G4UImanager::GetUIpointer()->ApplyCommand("/vis~/draw/current"); for (G4int i=0; iGetTrajectoryContainer()))[i]; G4Trajectory* trajectory = dynamic_cast(vtrajectory); if (!trajectory) { AliGlobals::Exception( "AliEventAction::DisplayEvent: Unknown trajectory type."); } else if ( (fDrawFlag == "ALL") || ((fDrawFlag == "CHARGED") && (trajectory->GetCharge() != 0.))){ trajectory->DrawTrajectory(2000); } } G4UImanager::GetUIpointer()->ApplyCommand("/vis~/show/view"); } } // public methods void AliEventAction::BeginOfEventAction(const G4Event* event) { // Called by G4 kernel at the beginning of event. // --- G4int eventID = event->GetEventID(); // reset the counters (primary tracks, saved tracks) AliTrackingAction* trackingAction = AliTrackingAction::Instance(); trackingAction->PrepareNewEvent(); if (fVerboseLevel>0) G4cout << ">>> Event " << event->GetEventID() << endl; } void AliEventAction::EndOfEventAction(const G4Event* event) { // Called by G4 kernel at the end of event. // --- // save the last primary track store of // the current event AliTrackingAction* trackingAction = AliTrackingAction::Instance(); trackingAction->SaveAndDestroyTrack(); if (fVerboseLevel>0) { G4int nofPrimaryTracks = trackingAction->GetNofPrimaryTracks(); G4cout << " " << nofPrimaryTracks << " primary tracks processed." << endl; } // display event DisplayEvent(event); // aliroot // store event header data gAlice->GetHeader()->SetEvent(event->GetEventID()); gAlice->GetHeader()->SetNvertex(event->GetNumberOfPrimaryVertex()); gAlice->GetHeader()->SetNprimary(trackingAction->GetNofPrimaryTracks()); gAlice->GetHeader()->SetNtrack(trackingAction->GetNofSavedTracks()); gAlice->FinishEvent(); }