ExN02SteppingVerbose.cc

From New IAC Wiki
Revision as of 03:08, 23 January 2018 by Vanwdani (talk | contribs) (Created page with "<pre> // // ******************************************************************** // * License and Disclaimer * // *...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
//
// ********************************************************************
// * License and Disclaimer                                           *
// *                                                                  *
// * The  Geant4 software  is  copyright of the Copyright Holders  of *
// * the Geant4 Collaboration.  It is provided  under  the terms  and *
// * conditions of the Geant4 Software License,  included in the file *
// * LICENSE and available at  http://cern.ch/geant4/license .  These *
// * include a list of copyright holders.                             *
// *                                                                  *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work  make  any representation or  warranty, express or implied, *
// * regarding  this  software system or assume any liability for its *
// * use.  Please see the license in the file  LICENSE  and URL above *
// * for the full disclaimer and the limitation of liability.         *
// *                                                                  *
// * This  code  implementation is the result of  the  scientific and *
// * technical work of the GEANT4 collaboration.                      *
// * By using,  copying,  modifying or  distributing the software (or *
// * any work based  on the software)  you  agree  to acknowledge its *
// * use  in  resulting  scientific  publications,  and indicate your *
// * acceptance of all terms of the Geant4 Software license.          *
// ********************************************************************
//
//
// $Id: ExN02SteppingVerbose.cc 69899 2013-05-17 10:05:33Z gcosmo $
// 
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 

#include "ExN02SteppingVerbose.hh"

#include "G4SteppingManager.hh"
#include "G4UnitsTable.hh"
int event_count=0;
int trigger=0;
int flag=0;
double Theta,theta;
double Phi;

double x_0,x_1;
double y_0,y_1;
double z_0,z_1;

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExN02SteppingVerbose::ExN02SteppingVerbose()
{
  outfile.open("MollerShield.dat");
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

ExN02SteppingVerbose::~ExN02SteppingVerbose()
{
  outfile.close();
} 

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void ExN02SteppingVerbose::StepInfo()
{
  CopyState();
  
const G4VProcess* process  = fStep->GetPostStepPoint()->GetProcessDefinedStep();
        G4String procName = " UserLimit";
        if (process) procName = process->GetProcessName();
        if (fStepStatus == fWorldBoundary) procName = "OutOfWorld";
if(fTrack->GetDefinition()->GetPDGEncoding()==11 && fTrack->GetParentID()==0 && flag==0)
    {
        x_1=fTrack->GetPosition().x();
        y_1=fTrack->GetPosition().y();
        z_1=fTrack->GetPosition().z();

        Theta=sqrt((x_1-x_0)*(x_1-x_0)+(y_1-y_0)*(y_1-y_0)+(z_1-z_0)*(z_1-z_0));
        Theta=acos((z_1-z_0)/Theta)*180/3.14159265359;  

        theta=sqrt((fTrack->GetMomentum().x())*(fTrack->GetMomentum().x())+(fTrack->GetMomentum().y())*(fTrack->GetMomentum().y())+(fTrack->GetMomentum().z())*(fTrack->GetMomentum().z()));
        theta=acos((fTrack->GetMomentum().z())/theta)*180/3.14159265359;  

        Phi=sqrt((fTrack->GetMomentum().x())*(fTrack->GetMomentum().x())+(fTrack->GetMomentum().y())*(fTrack->GetMomentum().y()));
        Phi=acos((fTrack->GetMomentum().x())/Phi)*180/3.14159265359;  
        if(fTrack->GetMomentum().y()<0)
                Phi=-Phi;

        outfile << std::setw(5) << fTrack->GetCurrentStepNumber() << " "
           << std::setprecision(7)<< std::setw(9) << G4BestUnit(fTrack->GetPosition().x(),"Length")
           << std::setprecision(7)<< std::setw(9) << G4BestUnit(fTrack->GetPosition().y(),"Length")
           << std::setprecision(7)<< std::setw(9) << G4BestUnit(fTrack->GetPosition().z(),"Length")
           << std::setprecision(7)<< std::setw(9) << G4BestUnit(fTrack->GetMomentum().x(),"Energy")
           << std::setprecision(7)<< std::setw(9) << G4BestUnit(fTrack->GetMomentum().y(),"Energy") 
          << std::setprecision(7)<< std::setw(9) << G4BestUnit(fTrack->GetMomentum().z(),"Energy")  
           << std::setprecision(7)<< std::setw(9) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
           << std::setprecision(7)<< std::setw(15) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
           << std::setprecision(7)<< std::setw(9) << G4BestUnit(fStep->GetStepLength(),"Length")
           << std::setprecision(7)<< std::setw(9) << G4BestUnit(fTrack->GetTrackLength(),"Length")
           << std::setw(9) << fTrack->GetVolume()->GetName()
           << std::setw(15) << procName
           << std::setprecision(4)<< std::setw(10) << Theta
           << std::setprecision(4)<< std::setw(10) << theta
           << std::setprecision(4)<< std::setw(10) << Phi
           << G4endl;        

        if(fTrack->GetVolume()->GetName()=="Tracker")
                flag=1;

    }

}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void ExN02SteppingVerbose::TrackingStarted()
{

CopyState();
G4int prec = G4cout.precision(17);

if( verboseLevel > 0 )
        {
        
        flag=0;

    outfile << "Event # " << event_count << G4endl;
    outfile << std::setw( 5) << "Step#"      << " "
           << std::setw(9) << "X"          << "    "
           << std::setw(9) << "Y"          << "    "  
           << std::setw(9) << "Z"          << "    "
           << std::setw(9) << "Px"          << "    "
           << std::setw(9) << "Py"          << "    "
           << std::setw(9) << "Pz"          << "    "
           << std::setw(9) << "KineE"      << " "
           << std::setw(15) << "dEStep"     << " "  
           << std::setw(15) << "StepLeng"  
           << std::setw(15) << "TrakLeng"
           << std::setw(9) << "Volume"     << "  "
           << std::setw(15) << "Process"   << "  "
           << std::setw(12) << "Theta(pos)"  << "  "
           << std::setw(8) << "theta(mom)" << "  "
           << std::setw(8) << "Phi(pos)" << G4endl;             

        x_0=fTrack->GetPosition().x();
        y_0=fTrack->GetPosition().y();
        z_0=fTrack->GetPosition().z();

           

   outfile << std::setw(5) << fTrack->GetCurrentStepNumber() << " "
           << std::setprecision(7)<< std::setw(9) << G4BestUnit(fTrack->GetPosition().x(),"Length")
           << std::setprecision(7)<< std::setw(9) << G4BestUnit(fTrack->GetPosition().y(),"Length")
           << std::setprecision(7)<< std::setw(9) << G4BestUnit(fTrack->GetPosition().z(),"Length")
           << std::setprecision(7)<< std::setw(9) << G4BestUnit(fTrack->GetMomentum().x(),"Energy")
           << std::setprecision(7)<< std::setw(9) << G4BestUnit(fTrack->GetMomentum().y(),"Energy") 
           << std::setprecision(7)<< std::setw(9) << G4BestUnit(fTrack->GetMomentum().z(),"Energy")  
           << std::setprecision(7)<< std::setw(9) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
           << std::setprecision(7)<< std::setw(15) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
           << std::setprecision(7)<< std::setw(9) << G4BestUnit(fStep->GetStepLength(),"Length")
           << std::setprecision(7)<< std::setw(9) << G4BestUnit(fTrack->GetTrackLength(),"Length")
           << std::setw(9) << fTrack->GetVolume()->GetName()
           << "   initStep" 
           << std::setw(12) << "NA"          
           << std::setw(12) << "NA" 
           << std::setw(10) << "NA" <<   G4endl;        
        event_count++;
         
        }
  G4cout.precision(prec);
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......