Newer
Older
/*************************************************************************
* Copyright (C) 2006, Rene Brun and Fons Rademakers. *
* Copyright (C) 2002, ALICE Experiment at CERN. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#include "Riostream.h"
#include "TVirtualMC.h"
#include "TVirtualMCStack.h"
#include "TDatabasePDG.h"
#include "TParticlePDG.h"
#include "TArrayI.h"
#include "TMCVerbose.h"
/** \class TMCVerbose
Class for printing a detailed infomation from MC application.
Defined levels:
- 0 no output
- 1 info up to event level
- 2 info up to tracking level
- 3 detailed info for each step
*/
////////////////////////////////////////////////////////////////////////////////
/// Standard constructor
TMCVerbose::TMCVerbose(Int_t level)
: TObject(),
fLevel(level),
fStepNumber(0)
{
}
////////////////////////////////////////////////////////////////////////////////
/// Default constructor
TMCVerbose::TMCVerbose()
: TObject(),
fLevel(0),
fStepNumber(0)
////////////////////////////////////////////////////////////////////////////////
/// Destructor
TMCVerbose::~TMCVerbose()
{
}
//
// private methods
//
////////////////////////////////////////////////////////////////////////////////
/// Prints banner for track information
std::cout << std::endl;
for (Int_t i=0; i<10; i++) std::cout << "**********";
std::cout << std::endl;
////////////////////////////////////////////////////////////////////////////////
/// Prints track information
void TMCVerbose::PrintTrackInfo() const
{
// Particle
//
TParticlePDG* particle = TDatabasePDG::Instance()->GetParticle(gMC->TrackPid());
if (particle)
else
// Track ID
//
std::cout << " Track ID = " << gMC->GetStack()->GetCurrentTrackNumber() << " ";
// Parent ID
//
std::cout << " Parent ID = " << gMC->GetStack()->GetCurrentParentTrackNumber();
////////////////////////////////////////////////////////////////////////////////
/// Prints the header for stepping information
void TMCVerbose::PrintStepHeader() const
{
<< "X(cm) "
<< "Y(cm) "
<< "Z(cm) "
<< "KinE(MeV) "
<< "dE(MeV) "
<< "Step(cm) "
<< "TrackL(cm) "
<< "Volume "
<< "Process "
}
//
// public methods
//
////////////////////////////////////////////////////////////////////////////////
/// Initialize MC info.
{
if (fLevel>0)
////////////////////////////////////////////////////////////////////////////////
/// MC run info.
{
if (fLevel>0)
std::cout << "--- Run MC for " << nofEvents << " events" << std::endl;
////////////////////////////////////////////////////////////////////////////////
/// Finish MC run info.
{
if (fLevel>0)
////////////////////////////////////////////////////////////////////////////////
/// Construct geometry info
{
if (fLevel>0)
////////////////////////////////////////////////////////////////////////////////
/// Construct geometry for optical physics info
{
if (fLevel>0)
std::cout << "--- Construct geometry for optical processes" << std::endl;
////////////////////////////////////////////////////////////////////////////////
/// Initialize geometry info
{
if (fLevel>0)
////////////////////////////////////////////////////////////////////////////////
/// Add particles info
{
if (fLevel>0)
////////////////////////////////////////////////////////////////////////////////
/// Add ions info
void TMCVerbose::AddIons()
{
if (fLevel>0)
}
////////////////////////////////////////////////////////////////////////////////
/// Generate primaries info
{
if (fLevel>0)
////////////////////////////////////////////////////////////////////////////////
/// Begin event info
{
if (fLevel>0)
////////////////////////////////////////////////////////////////////////////////
/// Begin of a primary track info
{
if (fLevel>1)
////////////////////////////////////////////////////////////////////////////////
/// Begin of each track info
{
if (fLevel>2) {
PrintBanner();
PrintTrackInfo();
PrintBanner();
PrintStepHeader();
if (fLevel>1)
////////////////////////////////////////////////////////////////////////////////
/// Stepping info
// Position
//
Double_t x, y, z;
gMC->TrackPosition(x, y, z);
std::cout << std::setw(8) << std::setprecision(3) << x << " "
<< std::setw(8) << std::setprecision(3) << y << " "
<< std::setw(8) << std::setprecision(3) << z << " ";
Double_t px, py, pz, etot;
gMC->TrackMomentum(px, py, pz, etot);
Double_t ekin = etot - gMC->TrackMass();
std::cout << std::setw(9) << std::setprecision(4) << ekin*1e03 << " ";
std::cout << std::setw(9) << std::setprecision(4) << gMC->Edep()*1e03 << " ";
std::cout << std::setw(8) << std::setprecision(3) << gMC->TrackStep() << " ";
std::cout << std::setw(8) << std::setprecision(3) << gMC->TrackLength() << " ";
else
// Process
//
TArrayI processes;
Int_t nofProcesses = gMC->StepProcesses(processes);
if (nofProcesses > 0)
////////////////////////////////////////////////////////////////////////////////
/// Finish of each track info
{
if (fLevel==2)
////////////////////////////////////////////////////////////////////////////////
/// Finish of a primary track info
{
if (fLevel==2)
////////////////////////////////////////////////////////////////////////////////
/// Finish of an event info
{
if (fLevel>0)