X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=AliGeant4%2FAliTrackingAction.cxx;h=b625592c8fa34ab53c10269f1e0b23b90a7dab45;hb=ee84ac37832e9dec12f6454f4c31c309c21b1c28;hp=ac2b16be99da1708841eacc0c803567c854dd6d7;hpb=ff84942379cdd4a368a23077bd9b328af59503b0;p=u%2Fmrichter%2FAliRoot.git diff --git a/AliGeant4/AliTrackingAction.cxx b/AliGeant4/AliTrackingAction.cxx index ac2b16be99d..b625592c8fa 100644 --- a/AliGeant4/AliTrackingAction.cxx +++ b/AliGeant4/AliTrackingAction.cxx @@ -1,58 +1,64 @@ // $Id$ // Category: event // +// Author: I. Hrivnacova +// +// Class AliTrackingAction +// ----------------------- // See the class description in the header file. #include "AliTrackingAction.h" -#include "AliTrackingActionMessenger.h" #include "AliTrackInformation.h" #include "AliRun.h" #include "AliGlobals.h" #include "TG4StepManager.h" #include "TG4PhysicsManager.h" +#include "TG4ParticlesManager.h" #include #include #include #include #include - -/* -#include -#include -#include -*/ +#include // static data members AliTrackingAction* AliTrackingAction::fgInstance = 0; +//_____________________________________________________________________________ AliTrackingAction::AliTrackingAction() - : fPrimaryTrackID(0), - fVerboseLevel(2), + : AliVerbose("trackingAction",2), + fPrimaryTrackID(0), + fNewVerboseLevel(0), + fNewVerboseTrackID(-1), fSavePrimaries(true), - fTrackCounter(0) + fTrackCounter(0), + fMessenger(this) { // if (fgInstance) { AliGlobals::Exception("AliTrackingAction constructed twice."); } - fMessenger = new AliTrackingActionMessenger(this); fgInstance = this; } -AliTrackingAction::AliTrackingAction(const AliTrackingAction& right) { +//_____________________________________________________________________________ +AliTrackingAction::AliTrackingAction(const AliTrackingAction& right) + : AliVerbose("trackingAction"), + fMessenger(this) { // AliGlobals::Exception("AliTrackingAction is protected from copying."); } +//_____________________________________________________________________________ AliTrackingAction::~AliTrackingAction() { // - delete fMessenger; } // operators +//_____________________________________________________________________________ AliTrackingAction& AliTrackingAction::operator=(const AliTrackingAction &right) { @@ -66,6 +72,7 @@ AliTrackingAction::operator=(const AliTrackingAction &right) // private methods +//_____________________________________________________________________________ AliTrackInformation* AliTrackingAction::GetTrackInformation( const G4Track* track, const G4String& method) const @@ -73,6 +80,7 @@ AliTrackInformation* AliTrackingAction::GetTrackInformation( // Returns user track information. // --- +#ifdef TGEANT4_DEBUG G4VUserTrackInformation* trackInfo = track->GetUserInformation(); if (!trackInfo) return 0; @@ -85,10 +93,14 @@ AliTrackInformation* AliTrackingAction::GetTrackInformation( } return aliTrackInfo; +#else + return (AliTrackInformation*)track->GetUserInformation(); +#endif } // public methods +//_____________________________________________________________________________ void AliTrackingAction::PrepareNewEvent() { // Called by G4 kernel at the beginning of event. @@ -101,6 +113,7 @@ void AliTrackingAction::PrepareNewEvent() stepManager->SetSteppingManager(fpTrackingManager->GetSteppingManager()); } +//_____________________________________________________________________________ void AliTrackingAction::PreTrackingAction(const G4Track* aTrack) { // Called by G4 kernel before starting tracking. @@ -139,16 +152,27 @@ void AliTrackingAction::PreTrackingAction(const G4Track* aTrack) // finish previous primary track FinishPrimaryTrack(); fPrimaryTrackID = aTrack->GetTrackID(); + + // begin this primary track + gAlice->BeginPrimary(); } else { // save secondary particles info SaveTrack(aTrack); } + // verbose + if (trackID == fNewVerboseTrackID) { + G4String command = "/tracking/verbose "; + AliGlobals::AppendNumberToString(command, fNewVerboseLevel); + G4UImanager::GetUIpointer()->ApplyCommand(command); + } + // aliroot pre track actions gAlice->PreTrack(); } +//_____________________________________________________________________________ void AliTrackingAction::PostTrackingAction(const G4Track* aTrack) { // Called by G4 kernel after finishing tracking. @@ -190,6 +214,7 @@ void AliTrackingAction::PostTrackingAction(const G4Track* aTrack) gAlice->PostTrack(); } +//_____________________________________________________________________________ void AliTrackingAction::FinishPrimaryTrack() { // Calls AliRun::PurifyKine and fills trees of hits @@ -201,13 +226,13 @@ void AliTrackingAction::FinishPrimaryTrack() if (fPrimaryTrackID>0) { // verbose - if (fVerboseLevel == 3) { + if (VerboseLevel() == 3) { G4cout << "$$$ Primary track " << fPrimaryTrackID << G4endl; } - else if ( fVerboseLevel == 2 && fPrimaryTrackID % 10 == 0 ) { + else if (VerboseLevel() == 2 && fPrimaryTrackID % 10 == 0 ) { G4cout << "$$$ Primary track " << fPrimaryTrackID << G4endl; } - else if ( fVerboseLevel == 1 && fPrimaryTrackID % 100 == 0 ) { + else if (VerboseLevel() == 1 && fPrimaryTrackID % 100 == 0 ) { G4cout << "$$$ Primary track " << fPrimaryTrackID << G4endl; } @@ -217,6 +242,7 @@ void AliTrackingAction::FinishPrimaryTrack() fPrimaryTrackID = 0; } +//_____________________________________________________________________________ void AliTrackingAction::SaveTrack(const G4Track* track) { // Get all needed parameters from G4track and pass them @@ -242,7 +268,9 @@ void AliTrackingAction::SaveTrack(const G4Track* track) // << G4endl; // PDG code - G4int pdg = track->GetDefinition()->GetPDGEncoding(); + G4int pdg + = TG4ParticlesManager::Instance() + ->GetPDGEncodingFast(track->GetDefinition()); // track kinematics G4ThreeVector momentum = track->GetMomentum(); @@ -271,8 +299,7 @@ void AliTrackingAction::SaveTrack(const G4Track* track) mcProcess = kPPrimary; } else { - TG4PhysicsManager* pPhysicsManager = TG4PhysicsManager::Instance(); - mcProcess = pPhysicsManager->GetMCProcess(kpProcess); + mcProcess = TG4PhysicsManager::Instance()->GetMCProcess(kpProcess); // distinguish kPDeltaRay from kPEnergyLoss if (mcProcess == kPEnergyLoss) mcProcess = kPDeltaRay; } @@ -284,3 +311,22 @@ void AliTrackingAction::SaveTrack(const G4Track* track) } +//_____________________________________________________________________________ +void AliTrackingAction::SetNewVerboseLevel(G4int level) +{ +// Set the new verbose level that will be set when the track with +// specified track ID (fNewVerboseTrackID) starts tracking. +// --- + + fNewVerboseLevel = level; +} + +//_____________________________________________________________________________ +void AliTrackingAction::SetNewVerboseTrackID(G4int trackID) +{ +// Set the trackID for which the new verbose level (fNewVerboseLevel) +// will be applied. +// --- + + fNewVerboseTrackID = trackID; +}