CMS 3D CMS Logo

Public Member Functions | Public Attributes | Private Member Functions | Private Attributes

TrackingAction Class Reference

#include <TrackingAction.h>

List of all members.

Public Member Functions

TrackWithHistorycurrentTrackWithHistory ()
G4TrackingManager * getTrackManager ()
virtual void PostUserTrackingAction (const G4Track *aTrack)
virtual void PreUserTrackingAction (const G4Track *aTrack)
 TrackingAction (EventAction *ea, const edm::ParameterSet &ps)
virtual ~TrackingAction ()

Public Attributes

SimActivityRegistry::BeginOfTrackSignal m_beginOfTrackSignal
SimActivityRegistry::EndOfTrackSignal m_endOfTrackSignal

Private Member Functions

bool isNewPrimary (const G4Track *aTrack)

Private Attributes

TrackWithHistorycurrentTrack_
bool detailedTiming
EventActioneventAction_
int trackMgrVerbose
G4VSolid * worldSolid

Detailed Description

Definition at line 15 of file TrackingAction.h.


Constructor & Destructor Documentation

TrackingAction::TrackingAction ( EventAction ea,
const edm::ParameterSet ps 
)

Definition at line 21 of file TrackingAction.cc.

References worldSolid.

  : eventAction_(e),currentTrack_(0),
  detailedTiming(p.getUntrackedParameter<bool>("DetailedTiming",false)),
  trackMgrVerbose(p.getUntrackedParameter<int>("G4TrackManagerVerbosity",0)) {

  worldSolid = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume()->GetLogicalVolume()->GetSolid();
}
TrackingAction::~TrackingAction ( ) [virtual]

Definition at line 29 of file TrackingAction.cc.

{}

Member Function Documentation

TrackWithHistory* TrackingAction::currentTrackWithHistory ( ) [inline]

Definition at line 22 of file TrackingAction.h.

References currentTrack_.

{ return currentTrack_; }
G4TrackingManager * TrackingAction::getTrackManager ( )

Definition at line 118 of file TrackingAction.cc.

References trackMgrVerbose.

Referenced by TrackingVerboseAction::update().

{
    G4TrackingManager * theTrackingManager = 0;
    theTrackingManager = fpTrackingManager;
    theTrackingManager->SetVerboseLevel(trackMgrVerbose);
    return theTrackingManager;
}
bool TrackingAction::isNewPrimary ( const G4Track *  aTrack) [private]

Definition at line 126 of file TrackingAction.cc.

References TrackInformation::isPrimary().

Referenced by PreUserTrackingAction().

                                                       {

  TrackInformation * trkInfo = (TrackInformation *)aTrack->GetUserInformation();
  return trkInfo->isPrimary();

} 
void TrackingAction::PostUserTrackingAction ( const G4Track *  aTrack) [virtual]

Definition at line 67 of file TrackingAction.cc.

References EventAction::addTkCaloStateInfo(), EventAction::addTrack(), TrackWithHistory::checkAtEnd(), currentTrack_, eventAction_, LogDebug, m_endOfTrackSignal, AlCaHLTBitMon_ParallelJobs::p, pos, CurrentG4Track::postTracking(), TrackWithHistory::save(), EventAction::trackContainer(), TrackWithHistory::trackID(), x, detailsBasic3DVector::y, and z.

Referenced by RunManager::abortEvent().

{
    CurrentG4Track::postTracking(aTrack);
    if (eventAction_->trackContainer() != 0)
    {

      TrackInformationExtractor extractor;
      if (extractor(aTrack).storeTrack())
        {
          currentTrack_->save();
          
          math::XYZVectorD pos((aTrack->GetStep()->GetPostStepPoint()->GetPosition()).x(),
                               (aTrack->GetStep()->GetPostStepPoint()->GetPosition()).y(),
                               (aTrack->GetStep()->GetPostStepPoint()->GetPosition()).z());
          math::XYZTLorentzVectorD mom;
          
          uint32_t id = aTrack->GetTrackID();
          
          std::pair<math::XYZVectorD,math::XYZTLorentzVectorD> p(pos,mom);
          eventAction_->addTkCaloStateInfo(id,p);
#ifdef DebugLog
          LogDebug("SimTrackManager") << "TrackingAction addTkCaloStateInfo " << id << " of momentum " << mom << " at " << pos;
#endif
        }

      bool withAncestor = ((extractor(aTrack).getIDonCaloSurface() == aTrack->GetTrackID()) || (extractor(aTrack).isAncestor()));
      if (extractor(aTrack).isInHistory())
        {
          currentTrack_->checkAtEnd(aTrack);  // check with end-of-track information
          eventAction_->addTrack(currentTrack_, true, withAncestor);
#ifdef DebugLog
          math::XYZVectorD pos((aTrack->GetStep()->GetPostStepPoint()->GetPosition()).x(),
                               (aTrack->GetStep()->GetPostStepPoint()->GetPosition()).y(),
                               (aTrack->GetStep()->GetPostStepPoint()->GetPosition()).z());
          LogDebug("SimTrackManager") << "TrackingAction addTrack "  << currentTrack_->trackID() << " added with " << true << " and " << withAncestor << " at " << pos;
#endif
        }
      else
        {
          eventAction_->addTrack(currentTrack_, false, false);
#ifdef DebugLog
          LogDebug("SimTrackManager") << "TrackingAction addTrack " << currentTrack_->trackID() << " added with " << false << " and " << false;
#endif
          delete currentTrack_;
        }
    }
    EndOfTrack et(aTrack);
    m_endOfTrackSignal(&et);
    currentTrack_ = 0; // reset for next track
}
void TrackingAction::PreUserTrackingAction ( const G4Track *  aTrack) [virtual]

Definition at line 31 of file TrackingAction.cc.

References currentTrack_, eventAction_, isNewPrimary(), m_beginOfTrackSignal, EventAction::prepareForNewPrimary(), CurrentG4Track::setTrack(), and worldSolid.

{

    CurrentG4Track::setTrack(aTrack);

    if (currentTrack_ != 0) 
        throw SimG4Exception("TrackingAction: currentTrack is a mess...");
    currentTrack_ = new TrackWithHistory(aTrack);

    /*
      Trick suggested by Vladimir I. in order to debug with high 
      level verbosity only a single problematic tracks
    */      

    /*
    if ( aTrack->GetTrackID() == palce_here_the_trackid_of_problematic_tracks  ) {
      G4UImanager::GetUIpointer()->ApplyCommand("/tracking/verbose 6");
    } else if ( aTrack->GetTrackID() == place_here_the_trackid_of_following_track_to_donwgrade_the_severity ) {
      G4UImanager::GetUIpointer()->ApplyCommand("/tracking/verbose 0");
    }
    */
    BeginOfTrack bt(aTrack);
    m_beginOfTrackSignal(&bt);

    if (isNewPrimary(aTrack)) {
      eventAction_->prepareForNewPrimary();
    }
    //    G4cout << "Track " << aTrack->GetTrackID() << " R " << (aTrack->GetVertexPosition()).r() << " Z " << std::abs((aTrack->GetVertexPosition()).z()) << G4endl << "Top Solid " << worldSolid->GetName() << " is it inside " << worldSolid->Inside(aTrack->GetVertexPosition()) << " compared to " << kOutside << G4endl;
    if (worldSolid->Inside(aTrack->GetVertexPosition()) == kOutside) {
      //      G4cout << "Kill Track " << aTrack->GetTrackID() << G4endl;
      G4Track* theTrack = (G4Track *)(aTrack);
      theTrack->SetTrackStatus(fStopAndKill);
    }      

}

Member Data Documentation

Definition at line 33 of file TrackingAction.h.

Definition at line 30 of file TrackingAction.h.

Referenced by PostUserTrackingAction(), and PreUserTrackingAction().

Definition at line 25 of file TrackingAction.h.

Referenced by RunManager::initializeUserActions(), and PreUserTrackingAction().

Definition at line 26 of file TrackingAction.h.

Referenced by RunManager::initializeUserActions(), and PostUserTrackingAction().

Definition at line 34 of file TrackingAction.h.

Referenced by getTrackManager().

G4VSolid* TrackingAction::worldSolid [private]

Definition at line 32 of file TrackingAction.h.

Referenced by PreUserTrackingAction(), and TrackingAction().