CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

TrackingVerboseAction Class Reference

#include <TrackingVerboseAction.h>

Inheritance diagram for TrackingVerboseAction:
SimWatcher Observer< const BeginOfRun * > Observer< const BeginOfEvent * > Observer< const BeginOfTrack * > Observer< const EndOfTrack * > Observer< const G4Step * >

List of all members.

Public Member Functions

 TrackingVerboseAction (edm::ParameterSet const &p)
void update (const G4Step *)
 This routine will be called when the appropriate signal arrives.
void update (const EndOfTrack *)
 This routine will be called when the appropriate signal arrives.
void update (const BeginOfTrack *)
 This routine will be called when the appropriate signal arrives.
void update (const BeginOfEvent *)
 This routine will be called when the appropriate signal arrives.
void update (const BeginOfRun *)
 This routine will be called when the appropriate signal arrives.
 ~TrackingVerboseAction ()

Private Member Functions

bool checkTrackingVerbose (const G4Track *)
void printTrackInfo (const G4Track *)
void setTrackingVerbose (int verblev)

Private Attributes

bool fDEBUG
bool fG4Verbose
bool fHighEtPhotons
int fLarge
std::vector< int > fPdgIds
bool fTkVerbThisEventON
bool fTrackingVerboseON
int fTVEventMax
int fTVEventMin
int fTVEventStep
int fTVTrackMax
int fTVTrackMin
int fTVTrackStep
G4VSteppingVerbose * fVerbose
int fVerboseLevel
G4TrackingManager * theTrackingManager

Detailed Description

Definition at line 37 of file TrackingVerboseAction.h.


Constructor & Destructor Documentation

TrackingVerboseAction::TrackingVerboseAction ( edm::ParameterSet const &  p)

Definition at line 27 of file TrackingVerboseAction.cc.

References fDEBUG, fG4Verbose, fHighEtPhotons, fLarge, fPdgIds, fTkVerbThisEventON, fTrackingVerboseON, fTVEventMax, fTVEventMin, fTVEventStep, fTVTrackMax, fTVTrackMin, fTVTrackStep, fVerboseLevel, and edm::ParameterSet::getUntrackedParameter().

                                                                      :
  theTrackingManager(0), fVerbose(0) {

  fLarge = int(1E10);
  fDEBUG = p.getUntrackedParameter<bool>("DEBUG",false);
  fHighEtPhotons = p.getUntrackedParameter<bool>("CheckForHighEtPhotons",false);
  fG4Verbose = p.getUntrackedParameter<bool>("G4Verbose",false);

  //----- Set which events are verbose
  fTVEventMin  = p.getUntrackedParameter<int>("EventMin",0);
  fTVEventMax  = p.getUntrackedParameter<int>("EventMax",fLarge);
  fTVEventStep = p.getUntrackedParameter<int>("EventStep",1);

  //----- Set which tracks of those events are verbose
  fTVTrackMin  = p.getUntrackedParameter<int>("TrackMin",0);
  fTVTrackMax  = p.getUntrackedParameter<int>("TrackMax",fLarge);
  fTVTrackStep = p.getUntrackedParameter<int>("TrackStep",1);

  //----- Set the verbosity level
  fVerboseLevel = p.getUntrackedParameter<int>("VerboseLevel",1);
  fPdgIds       = p.getUntrackedParameter<std::vector<int> >("PDGids");
  if (fDEBUG) {
    G4cout << "TV: fTVTrackMin " << fTVTrackMin 
           << " fTVTrackMax "    <<  fTVTrackMax 
           <<  " fTVTrackStep "  << fTVTrackStep  
           << " fTVEventMin "    << fTVEventMin 
           << " fTVEventMax "    << fTVEventMax   
           << " fTVEventStep "   << fTVEventStep 
           << " fVerboseLevel "  << fVerboseLevel 
           << " fG4Verbose "     << fG4Verbose 
           << " PDGIds     "     << fPdgIds.size() << G4endl;
    for (unsigned int ii=0; ii<fPdgIds.size(); ++ii) 
      G4cout << "TV: PDGId[" << ii << "] = " << fPdgIds[ii] << G4endl;
  }
  
  //----- Set verbosity off to start
  fTrackingVerboseON = false;
  fTkVerbThisEventON = false;
  
  G4cout << " TrackingVerbose constructed " << G4endl;
}
TrackingVerboseAction::~TrackingVerboseAction ( )

Definition at line 69 of file TrackingVerboseAction.cc.

{}

Member Function Documentation

bool TrackingVerboseAction::checkTrackingVerbose ( const G4Track *  aTrack) [private]

Definition at line 283 of file TrackingVerboseAction.cc.

References prof2calltree::count, fPdgIds, fTVTrackMax, fTVTrackMin, fTVTrackStep, and benchmark_cfg::pdgId.

Referenced by update().

                                                                      {
  int trackNo = aTrack->GetTrackID();    
  bool trackingVerboseThisTrack = false;
  //----- Check if track is in the selected range
  if (trackNo >= fTVTrackMin && trackNo <= fTVTrackMax) {
    if ((trackNo-fTVTrackMin) % fTVTrackStep == 0) trackingVerboseThisTrack = true;
  }
  if (trackingVerboseThisTrack && (fPdgIds.size()>0)) {
    int pdgId = aTrack->GetDefinition()->GetPDGEncoding();
    if (std::count(fPdgIds.begin(),fPdgIds.end(),pdgId) == 0) trackingVerboseThisTrack = false;
  }
  return trackingVerboseThisTrack;
}
void TrackingVerboseAction::printTrackInfo ( const G4Track *  aTrack) [private]

Definition at line 297 of file TrackingVerboseAction.cc.

References fVerbose.

Referenced by update().

                                                                {
  G4cout << G4endl
         << "*******************************************************"
         << "**************************************************" << G4endl
         << "* G4Track Information: "
         << "  Particle = " << aTrack->GetDefinition()->GetParticleName()
         << ","
         << "   Track ID = " << aTrack->GetTrackID()
         << ","
         << "   Parent ID = " << aTrack->GetParentID() << G4endl
         << "*******************************************************"
         << "**************************************************"
         << G4endl << G4endl;
  if (fVerbose) fVerbose->TrackingStarted();
}
void TrackingVerboseAction::setTrackingVerbose ( int  verblev) [private]

Definition at line 278 of file TrackingVerboseAction.cc.

References fDEBUG, and theTrackingManager.

Referenced by update().

                                                          {
  if (fDEBUG) G4cout << " setting verbose level " << verblev << G4endl;
  if (theTrackingManager!=0) theTrackingManager->SetVerboseLevel(verblev);
}
void TrackingVerboseAction::update ( const BeginOfTrack ) [virtual]

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfTrack * >.

Definition at line 115 of file TrackingVerboseAction.cc.

References checkTrackingVerbose(), fDEBUG, fHighEtPhotons, fTkVerbThisEventON, fTrackingVerboseON, fVerboseLevel, funct::log(), m, printTrackInfo(), proc, setTrackingVerbose(), mathSSE::sqrt(), and funct::tan().

                                                           {
  const G4Track * aTrack = (*trk)();

  //----- High ET photon printout
  //---------- Set /tracking/verbose
  //----- track is verbose only if event is verbose
  double tkP = aTrack->GetMomentum().mag();
  double tkPx = aTrack->GetMomentum().x();
  double tkPy = aTrack->GetMomentum().y();
  double tkPz = aTrack->GetMomentum().z();

  double tvtx = aTrack->GetVertexPosition().x();
  double tvty = aTrack->GetVertexPosition().y();
  double tvtz = aTrack->GetVertexPosition().z();

  double g4t_phi=atan2(tkPy,tkPx);

  double drpart=sqrt(tkPx*tkPx + tkPy*tkPy);

  double mythetapart=acos(tkPz/sqrt(drpart*drpart+tkPz*tkPz));

  double g4t_eta=-log(tan(mythetapart/2.));
  G4int MytrackNo = aTrack->GetTrackID();
    
  if (fHighEtPhotons) {
    if (aTrack->GetDefinition()->GetParticleName() == "gamma" && aTrack->GetParentID() !=0) {
      if((tkPx*tkPx + tkPy*tkPy + tkPz*tkPz)>1000.0*1000.0 &&
         aTrack->GetCreatorProcess()->GetProcessName() == "LCapture") {
        G4cout << "MY NEW GAMMA " << G4endl;
        G4cout << "**********************************************************************"  << G4endl;
        G4cout << "MY NEW TRACK ID = " << MytrackNo << "("
               << aTrack->GetDefinition()->GetParticleName()
               <<")"<< " PARENT ="<< aTrack->GetParentID() << G4endl;
        G4cout << "Primary particle: " 
               << aTrack->GetDynamicParticle()->GetPrimaryParticle() << G4endl;
        G4cout << "Process type: " << aTrack->GetCreatorProcess()->GetProcessType()
               << " Process name: " 
               << aTrack->GetCreatorProcess()->GetProcessName() << G4endl;
        G4cout << "ToT E = " << aTrack->GetTotalEnergy() 
               << " KineE = " << aTrack->GetKineticEnergy()
               << " Tot P = " << tkP << " Pt = " << sqrt(tkPx*tkPx + tkPy*tkPy) 
               << " VTX=(" << tvtx << "," << tvty << "," << tvtz << ")" << G4endl;
        if (aTrack->GetKineticEnergy() > 1.*GeV 
            && aTrack->GetCreatorProcess()->GetProcessName() != "LCapture")
          G4cout << " KineE > 1 GeV !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << G4endl;
        const G4VTouchable* touchable=aTrack->GetTouchable();
        if (touchable!=0 && touchable->GetVolume()!=0 &&
            touchable->GetVolume()->GetLogicalVolume()!=0) {
          G4Material* material=touchable->GetVolume()->GetLogicalVolume()->GetMaterial();
          G4cout << "G4LCapture Gamma E(GeV) " 
                 << aTrack->GetTotalEnergy()/GeV << "  "
                 << material->GetName()<< " " 
                 << touchable->GetVolume()->GetName() << G4endl;
          G4cout << "G4LCapture Gamma position(m): " 
                 << aTrack->GetPosition()/m << G4endl;
          G4cout << "G4LCapture created Gamma direction " 
                 << aTrack->GetMomentumDirection() << G4endl;
          G4cout << "G4LCapture gamma (eta,phi) = " 
                 << "(" << g4t_eta << "," << g4t_phi << ")" << G4endl;
        }
        aTrack->GetUserInformation()->Print();
        G4cout << "**********************************************************************"  << G4endl;
      }
    }

    if (aTrack->GetDefinition()->GetParticleName() == "gamma") {
      const G4VProcess * proc = aTrack->GetCreatorProcess();
      double Tgamma = aTrack->GetKineticEnergy();
      std::string ProcName;
      const  std::string nullstr ("Null_prc");
      if (proc) ProcName = proc->GetProcessName();
      else      ProcName = nullstr;
      if (Tgamma > 2.5*GeV ) { //&& ProcName!="Decay" && ProcName!="eBrem")
        std::string volumeName("_Unknown_Vol_");
        std::string materialName("_Unknown_Mat_");
        G4Material * material = 0;
        G4VPhysicalVolume * pvolume = 0;
        G4LogicalVolume * lvolume = 0;
        const G4VTouchable * touchable = aTrack->GetTouchable();
        if (touchable) pvolume = touchable->GetVolume();
        if (pvolume) {
          volumeName = pvolume->GetName();
          lvolume = pvolume->GetLogicalVolume();
        }
        if (lvolume) material = lvolume->GetMaterial();
        if (material) materialName = material->GetName();
        G4cout << "**** ALL photons > 2.5 GeV ****" << G4endl;
        G4cout << ProcName << "**** ALL photons: gamma E(GeV) "
               << aTrack->GetTotalEnergy()/GeV << "  "
               <<  materialName << " " << volumeName << G4endl;
        G4cout << ProcName << "**** ALL photons: gamma position(m): " 
               << aTrack->GetPosition()/m << G4endl;
        G4cout << ProcName << "**** ALL photons: gamma direction " 
               << aTrack->GetMomentumDirection() << G4endl;
        G4cout << "**********************************************************************"  << G4endl;
      }
    }                                               
  }
    
  //---------- Set /tracking/verbose
  //----- track is verbose only if event is verbose
  if (fTkVerbThisEventON) {
    bool trackingVerboseThisTrack = checkTrackingVerbose(aTrack);

    //----- Set the /tracking/verbose for this track 
    if ((trackingVerboseThisTrack) && (!fTrackingVerboseON) ) {
      setTrackingVerbose(fVerboseLevel);
      fTrackingVerboseON = true;
      if (fDEBUG) G4cout << "TV: VERBOSEtt1 " << aTrack->GetTrackID()
                         << G4endl;
      printTrackInfo(aTrack);
    } else if ((!trackingVerboseThisTrack) && ( fTrackingVerboseON )) {
      setTrackingVerbose(0);
      fTrackingVerboseON = false;
      if (fDEBUG) G4cout << "TV: VERBOSEtt0 " << aTrack->GetTrackID()
                         << G4endl;
    }
  }
}
void TrackingVerboseAction::update ( const G4Step *  ) [virtual]

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step * >.

Definition at line 249 of file TrackingVerboseAction.cc.

References fG4Verbose, fTrackingVerboseON, and NULL.

                                                      {

  if ((fG4Verbose) && (fTrackingVerboseON)) {
    G4Track* fTrack = fStep->GetTrack();
    G4cout << std::setw( 5) << fTrack->GetCurrentStepNumber() << " "
           << std::setw( 8) << G4BestUnit(fTrack->GetPosition().x() , "Length") << " "
           << std::setw( 8) << G4BestUnit(fTrack->GetPosition().y() , "Length") << " "
           << std::setw( 8) << G4BestUnit(fTrack->GetPosition().z() , "Length") << " "
           << std::setw( 9) << G4BestUnit(fTrack->GetKineticEnergy() , "Energy") << " "
           << std::setw( 8) << G4BestUnit(fStep->GetTotalEnergyDeposit(), "Energy") << " "
           << std::setw( 8) << G4BestUnit(fStep->GetStepLength() , "Length") << " "
           << std::setw( 9) << G4BestUnit(fTrack->GetTrackLength() , "Length") << " "
           << std::setw( 9) << G4BestUnit(fTrack->GetGlobalTime(), "Time") << " ";

    // Put cut comment here
    if( fTrack->GetNextVolume() != 0 ) {
      G4cout << std::setw(11) << fTrack->GetNextVolume()->GetName() << " ";
    } else {
      G4cout << std::setw(11) << "OutOfWorld" << " ";
    }
    if(fStep->GetPostStepPoint()->GetProcessDefinedStep() != NULL){
      G4cout << fStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName();
    } else {
      G4cout << "User Limit";
    }
    G4cout << G4endl;
  }
}
void TrackingVerboseAction::update ( const BeginOfEvent ) [virtual]

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 81 of file TrackingVerboseAction.cc.

References fDEBUG, fLarge, fTkVerbThisEventON, fTrackingVerboseON, fTVEventMax, fTVEventMin, fTVEventStep, fTVTrackMax, fTVTrackMin, fTVTrackStep, fVerboseLevel, and setTrackingVerbose().

                                                           {
  if (evt==0) return;
  const G4Event * anEvent = (*evt)();
  if (anEvent==0) return;

  //----------- Set /tracking/verbose for this event 
  int eventNo = anEvent->GetEventID();
  if (fDEBUG) G4cout << "TV: trackID: NEW EVENT " << eventNo << G4endl;

  fTkVerbThisEventON = false;
  //----- Check if event is in the selected range
  if (eventNo >= fTVEventMin && eventNo <= fTVEventMax) {
    if ((eventNo-fTVEventMin) % fTVEventStep == 0) fTkVerbThisEventON = true;
  }

  if (fDEBUG)
    G4cout << " TV: fTkVerbThisEventON " <<  fTkVerbThisEventON 
           << " fTrackingVerboseON " << fTrackingVerboseON 
           << " fTVEventMin " << fTVEventMin << " fTVEventMax " << fTVEventMax << G4endl;
  //----- check if verbosity has to be changed
  if ((fTkVerbThisEventON) && (!fTrackingVerboseON)) {
    if (fTVTrackMin == 0 && fTVTrackMax == fLarge && fTVTrackStep != 1) {
      setTrackingVerbose(fVerboseLevel);
      fTrackingVerboseON = true;
      if (fDEBUG) G4cout << "TV: VERBOSEet1 " << eventNo << G4endl;
    }
  } else if ((!fTkVerbThisEventON) && (fTrackingVerboseON) ) {
    setTrackingVerbose(0);
    fTrackingVerboseON = false;
    if (fDEBUG) G4cout << "TV: VERBOSEet0 " << eventNo << G4endl;
  }

}
void TrackingVerboseAction::update ( const BeginOfRun ) [virtual]

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun * >.

Definition at line 71 of file TrackingVerboseAction.cc.

References fDEBUG, fVerbose, TrackingAction::getTrackManager(), and theTrackingManager.

                                                         {
  TrackingAction * ta = 
    dynamic_cast<TrackingAction*>(G4EventManager::GetEventManager()->GetUserTrackingAction());
  theTrackingManager = ta->getTrackManager();
  fVerbose = G4VSteppingVerbose::GetInstance();
  if (fDEBUG)
    G4cout << " TV: Get the Tracking Manager: " << theTrackingManager
           << " and the SteppingVerbose: " << fVerbose << G4endl;
}
void TrackingVerboseAction::update ( const EndOfTrack ) [virtual]

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfTrack * >.

Definition at line 235 of file TrackingVerboseAction.cc.

References checkTrackingVerbose(), fDEBUG, fLarge, fTkVerbThisEventON, fTrackingVerboseON, fTVTrackMax, fTVTrackStep, and setTrackingVerbose().

                                                         {
  const G4Track * aTrack = (*trk)();
  if (fTkVerbThisEventON) {
    bool trackingVerboseThisTrack = checkTrackingVerbose(aTrack);
    if ((trackingVerboseThisTrack) && (fTrackingVerboseON ) &&
        (fTVTrackMax < fLarge || fTVTrackStep != 1)) {
      setTrackingVerbose(0);
      fTrackingVerboseON = false;
      if (fDEBUG) G4cout << "TV: VERBOSEtt0 " << aTrack->GetTrackID()
                         << G4endl;
    }
  }
}

Member Data Documentation

Definition at line 58 of file TrackingVerboseAction.h.

Referenced by setTrackingVerbose(), TrackingVerboseAction(), and update().

Definition at line 59 of file TrackingVerboseAction.h.

Referenced by TrackingVerboseAction(), and update().

Definition at line 60 of file TrackingVerboseAction.h.

Referenced by TrackingVerboseAction(), and update().

Definition at line 57 of file TrackingVerboseAction.h.

Referenced by TrackingVerboseAction(), and update().

std::vector<int> TrackingVerboseAction::fPdgIds [private]

Definition at line 70 of file TrackingVerboseAction.h.

Referenced by checkTrackingVerbose(), and TrackingVerboseAction().

Definition at line 69 of file TrackingVerboseAction.h.

Referenced by TrackingVerboseAction(), and update().

Definition at line 68 of file TrackingVerboseAction.h.

Referenced by TrackingVerboseAction(), and update().

Definition at line 65 of file TrackingVerboseAction.h.

Referenced by TrackingVerboseAction(), and update().

Definition at line 64 of file TrackingVerboseAction.h.

Referenced by TrackingVerboseAction(), and update().

Definition at line 66 of file TrackingVerboseAction.h.

Referenced by TrackingVerboseAction(), and update().

Definition at line 62 of file TrackingVerboseAction.h.

Referenced by checkTrackingVerbose(), TrackingVerboseAction(), and update().

Definition at line 61 of file TrackingVerboseAction.h.

Referenced by checkTrackingVerbose(), TrackingVerboseAction(), and update().

Definition at line 63 of file TrackingVerboseAction.h.

Referenced by checkTrackingVerbose(), TrackingVerboseAction(), and update().

G4VSteppingVerbose* TrackingVerboseAction::fVerbose [private]

Definition at line 72 of file TrackingVerboseAction.h.

Referenced by printTrackInfo(), and update().

Definition at line 67 of file TrackingVerboseAction.h.

Referenced by TrackingVerboseAction(), and update().

G4TrackingManager* TrackingVerboseAction::theTrackingManager [private]

Definition at line 71 of file TrackingVerboseAction.h.

Referenced by setTrackingVerbose(), and update().