TMCVerbose.cxx

Go to the documentation of this file.
00001 // @(#)root/vmc:$Id: TMCVerbose.cxx 20882 2007-11-19 11:31:26Z rdm $
00002 // Author: Ivana Hrivnacova, 27/03/2002
00003 
00004 /*************************************************************************
00005  * Copyright (C) 2006, Rene Brun and Fons Rademakers.                    *
00006  * Copyright (C) 2002, ALICE Experiment at CERN.                         *
00007  * All rights reserved.                                                  *
00008  *                                                                       *
00009  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00010  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00011  *************************************************************************/
00012 
00013 #include "Riostream.h"
00014 #include "TVirtualMC.h"
00015 #include "TVirtualMCStack.h"
00016 #include "TDatabasePDG.h"
00017 #include "TParticlePDG.h"
00018 #include "TArrayI.h"
00019 
00020 #include "TMCVerbose.h"
00021 
00022 //______________________________________________________________________________
00023 //
00024 // Class for printing detailed info from MC application.
00025 // Defined levels:
00026 //  0  no output
00027 //  1  info up to event level
00028 //  2  info up to tracking level
00029 //  3  detailed info for each step
00030 //______________________________________________________________________________
00031 
00032 
00033 ClassImp(TMCVerbose)
00034 
00035 //_____________________________________________________________________________
00036 TMCVerbose::TMCVerbose(Int_t level)
00037   : TObject(),
00038     fLevel(level),
00039     fStepNumber(0)
00040 {
00041 // Standard constructor
00042 // ---
00043 
00044 }
00045 
00046 //_____________________________________________________________________________
00047 TMCVerbose::TMCVerbose()
00048   : TObject(),
00049     fLevel(0),
00050     fStepNumber(0)
00051 {
00052 // Default constructor
00053 // ---
00054 }
00055 
00056 //_____________________________________________________________________________
00057 TMCVerbose::~TMCVerbose()
00058 {
00059 // Destructor
00060 // ---
00061 }
00062 
00063 //
00064 // private methods
00065 //
00066 
00067 //_____________________________________________________________________________
00068 void TMCVerbose::PrintBanner() const
00069 {
00070 // Prints banner for track information
00071 // ---
00072 
00073    cout << endl;
00074    for (Int_t i=0; i<10; i++) cout << "**********";
00075    cout << endl;
00076 }
00077 
00078 //_____________________________________________________________________________
00079 void TMCVerbose::PrintTrackInfo() const
00080 {
00081 // Prints track information
00082 // ---
00083 
00084    // Particle
00085    //
00086    cout << "  Particle = ";
00087    TParticlePDG* particle = TDatabasePDG::Instance()->GetParticle(gMC->TrackPid());
00088    if (particle)
00089       cout << particle->GetName() << "  ";
00090    else
00091       cout << "unknown" << "  ";
00092 
00093    // Track ID
00094    //
00095    cout << "   Track ID = " << gMC->GetStack()->GetCurrentTrackNumber() << "  ";
00096 
00097    // Parent ID
00098    //
00099    cout << "   Parent ID = " << gMC->GetStack()->GetCurrentParentTrackNumber();
00100 }
00101 
00102 //_____________________________________________________________________________
00103 void TMCVerbose::PrintStepHeader() const
00104 {
00105 // Prints the header for stepping information
00106 // ---
00107 
00108    cout << "Step#     "
00109         << "X(cm)    "
00110         << "Y(cm)    "
00111         << "Z(cm)  "
00112         << "KinE(MeV)   "
00113         << "dE(MeV) "
00114         << "Step(cm) "
00115         << "TrackL(cm) "
00116         << "Volume  "
00117         << "Process "
00118         << endl;
00119 }
00120 
00121 //
00122 // public methods
00123 //
00124 
00125 //_____________________________________________________________________________
00126 void TMCVerbose::InitMC()
00127 {
00128 // Initialize MC info.
00129 // ---
00130 
00131    if (fLevel>0)
00132       cout << "--- Init MC " << endl;
00133 }
00134 
00135 //_____________________________________________________________________________
00136 void TMCVerbose::RunMC(Int_t nofEvents)
00137 {
00138 // MC run info.
00139 // ---
00140 
00141    if (fLevel>0)
00142       cout << "--- Run MC for " << nofEvents << " events" << endl;
00143 }
00144 
00145 //_____________________________________________________________________________
00146 void TMCVerbose::FinishRun()
00147 {
00148 // Finish MC run info.
00149 // ---
00150 
00151    if (fLevel>0)
00152       cout << "--- Finish Run MC " << endl;
00153 }
00154 
00155 //_____________________________________________________________________________
00156 void TMCVerbose::ConstructGeometry()
00157 {
00158 // Construct geometry info
00159 // ---
00160 
00161    if (fLevel>0)
00162       cout << "--- Construct geometry " << endl;
00163 }
00164 
00165 //_____________________________________________________________________________
00166 void TMCVerbose::ConstructOpGeometry()
00167 {
00168 // Construct geometry for optical physics info
00169 // ---
00170 
00171    if (fLevel>0)
00172       cout << "--- Construct geometry for optical processes" << endl;
00173 }
00174 
00175 //_____________________________________________________________________________
00176 void TMCVerbose::InitGeometry()
00177 {
00178 // Initialize geometry info
00179 // ---
00180 
00181    if (fLevel>0)
00182       cout << "--- Init geometry " << endl;
00183 }
00184 
00185 //_____________________________________________________________________________
00186 void TMCVerbose::AddParticles()
00187 {
00188 // Add particles info
00189 // ---
00190 
00191    if (fLevel>0)
00192       cout << "--- Add particles " << endl;
00193 }
00194 
00195 //_____________________________________________________________________________
00196 void TMCVerbose::AddIons()
00197 {
00198 // Add ions info
00199 // ---
00200 
00201    if (fLevel>0)
00202       cout << "--- Add ions " << endl;
00203 }
00204 
00205 //_____________________________________________________________________________
00206 void TMCVerbose::GeneratePrimaries()
00207 {
00208 // Generate primaries info
00209 // ---
00210 
00211    if (fLevel>0)
00212       cout << "--- Generate primaries " << endl;
00213 }
00214 
00215 //_____________________________________________________________________________
00216 void TMCVerbose::BeginEvent()
00217 {
00218 // Begin event info
00219 // ---
00220 
00221    if (fLevel>0)
00222       cout << "--- Begin event " << endl;
00223 }
00224 
00225 //_____________________________________________________________________________
00226 void TMCVerbose::BeginPrimary()
00227 {
00228 // Begin of a primary track info
00229 // ---
00230 
00231    if (fLevel>1)
00232       cout << "--- Begin primary " << endl;
00233 }
00234 
00235 //_____________________________________________________________________________
00236 void TMCVerbose::PreTrack()
00237 {
00238 // Begin of each track info
00239 // ---
00240 
00241    if (fLevel>2) {
00242       PrintBanner();
00243       PrintTrackInfo();
00244       PrintBanner();
00245       PrintStepHeader();
00246 
00247       fStepNumber = 0;
00248 
00249       return;
00250    }
00251 
00252    if (fLevel>1)
00253       cout << "--- Pre track " << endl;
00254 }
00255 
00256 //_____________________________________________________________________________
00257 void TMCVerbose::Stepping()
00258 {
00259 // Stepping info
00260 // ---
00261 
00262    if (fLevel>2) {
00263 
00264 #if __GNUC__ >= 3
00265       cout << std::fixed;
00266 #endif
00267 
00268       // Step number
00269       //
00270       cout << "#" << setw(4) << fStepNumber++ << "  ";
00271 
00272       // Position
00273       //
00274       Double_t x, y, z;
00275       gMC->TrackPosition(x, y, z);
00276       cout << setw(8) << setprecision(3) << x << " "
00277            << setw(8) << setprecision(3) << y << " "
00278            << setw(8) << setprecision(3) << z << "  ";
00279 
00280       // Kinetic energy
00281       //
00282       Double_t px, py, pz, etot;
00283       gMC->TrackMomentum(px, py, pz, etot);
00284       Double_t ekin = etot - gMC->TrackMass();
00285       cout << setw(9) << setprecision(4) << ekin*1e03 << " ";
00286 
00287       // Energy deposit
00288       //
00289       cout << setw(9) << setprecision(4) << gMC->Edep()*1e03 << " ";
00290 
00291       // Step length
00292       //
00293       cout << setw(8) << setprecision(3) << gMC->TrackStep() << " ";
00294 
00295       // Track length
00296       //
00297       cout << setw(8) << setprecision(3) << gMC->TrackLength() << "     ";
00298 
00299       // Volume
00300       //
00301       if (gMC->CurrentVolName() != 0)
00302          cout << setw(4) << gMC->CurrentVolName() << "  ";
00303       else
00304          cout << setw(4) << "None"  << "  ";
00305 
00306       // Process
00307       //
00308       TArrayI processes;
00309       Int_t nofProcesses = gMC->StepProcesses(processes);
00310       if (nofProcesses > 0)
00311          cout << TMCProcessName[processes[nofProcesses-1]];
00312 
00313       cout << endl;
00314    }
00315 }
00316 
00317 //_____________________________________________________________________________
00318 void TMCVerbose::PostTrack()
00319 {
00320 // Finish of each track info
00321 // ---
00322 
00323    if (fLevel==2)
00324       cout << "--- Post track " << endl;
00325 }
00326 
00327 //_____________________________________________________________________________
00328 void TMCVerbose::FinishPrimary()
00329 {
00330 // Finish of a primary track info
00331 // ---
00332 
00333    if (fLevel==2)
00334       cout << "--- Finish primary " << endl;
00335 }
00336 
00337 //_____________________________________________________________________________
00338 void TMCVerbose::FinishEvent()
00339 {
00340 // Finish of an event info
00341 // ---
00342 
00343    if (fLevel>0)
00344       cout << "--- Finish event " << endl;
00345 }
00346 

Generated on Tue Jul 5 14:45:27 2011 for ROOT_528-00b_version by  doxygen 1.5.1