00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
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
00025
00026
00027
00028
00029
00030
00031
00032
00033 ClassImp(TMCVerbose)
00034
00035
00036 TMCVerbose::TMCVerbose(Int_t level)
00037 : TObject(),
00038 fLevel(level),
00039 fStepNumber(0)
00040 {
00041
00042
00043
00044 }
00045
00046
00047 TMCVerbose::TMCVerbose()
00048 : TObject(),
00049 fLevel(0),
00050 fStepNumber(0)
00051 {
00052
00053
00054 }
00055
00056
00057 TMCVerbose::~TMCVerbose()
00058 {
00059
00060
00061 }
00062
00063
00064
00065
00066
00067
00068 void TMCVerbose::PrintBanner() const
00069 {
00070
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
00082
00083
00084
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
00094
00095 cout << " Track ID = " << gMC->GetStack()->GetCurrentTrackNumber() << " ";
00096
00097
00098
00099 cout << " Parent ID = " << gMC->GetStack()->GetCurrentParentTrackNumber();
00100 }
00101
00102
00103 void TMCVerbose::PrintStepHeader() const
00104 {
00105
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
00123
00124
00125
00126 void TMCVerbose::InitMC()
00127 {
00128
00129
00130
00131 if (fLevel>0)
00132 cout << "--- Init MC " << endl;
00133 }
00134
00135
00136 void TMCVerbose::RunMC(Int_t nofEvents)
00137 {
00138
00139
00140
00141 if (fLevel>0)
00142 cout << "--- Run MC for " << nofEvents << " events" << endl;
00143 }
00144
00145
00146 void TMCVerbose::FinishRun()
00147 {
00148
00149
00150
00151 if (fLevel>0)
00152 cout << "--- Finish Run MC " << endl;
00153 }
00154
00155
00156 void TMCVerbose::ConstructGeometry()
00157 {
00158
00159
00160
00161 if (fLevel>0)
00162 cout << "--- Construct geometry " << endl;
00163 }
00164
00165
00166 void TMCVerbose::ConstructOpGeometry()
00167 {
00168
00169
00170
00171 if (fLevel>0)
00172 cout << "--- Construct geometry for optical processes" << endl;
00173 }
00174
00175
00176 void TMCVerbose::InitGeometry()
00177 {
00178
00179
00180
00181 if (fLevel>0)
00182 cout << "--- Init geometry " << endl;
00183 }
00184
00185
00186 void TMCVerbose::AddParticles()
00187 {
00188
00189
00190
00191 if (fLevel>0)
00192 cout << "--- Add particles " << endl;
00193 }
00194
00195
00196 void TMCVerbose::AddIons()
00197 {
00198
00199
00200
00201 if (fLevel>0)
00202 cout << "--- Add ions " << endl;
00203 }
00204
00205
00206 void TMCVerbose::GeneratePrimaries()
00207 {
00208
00209
00210
00211 if (fLevel>0)
00212 cout << "--- Generate primaries " << endl;
00213 }
00214
00215
00216 void TMCVerbose::BeginEvent()
00217 {
00218
00219
00220
00221 if (fLevel>0)
00222 cout << "--- Begin event " << endl;
00223 }
00224
00225
00226 void TMCVerbose::BeginPrimary()
00227 {
00228
00229
00230
00231 if (fLevel>1)
00232 cout << "--- Begin primary " << endl;
00233 }
00234
00235
00236 void TMCVerbose::PreTrack()
00237 {
00238
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
00260
00261
00262 if (fLevel>2) {
00263
00264 #if __GNUC__ >= 3
00265 cout << std::fixed;
00266 #endif
00267
00268
00269
00270 cout << "#" << setw(4) << fStepNumber++ << " ";
00271
00272
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
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
00288
00289 cout << setw(9) << setprecision(4) << gMC->Edep()*1e03 << " ";
00290
00291
00292
00293 cout << setw(8) << setprecision(3) << gMC->TrackStep() << " ";
00294
00295
00296
00297 cout << setw(8) << setprecision(3) << gMC->TrackLength() << " ";
00298
00299
00300
00301 if (gMC->CurrentVolName() != 0)
00302 cout << setw(4) << gMC->CurrentVolName() << " ";
00303 else
00304 cout << setw(4) << "None" << " ";
00305
00306
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
00321
00322
00323 if (fLevel==2)
00324 cout << "--- Post track " << endl;
00325 }
00326
00327
00328 void TMCVerbose::FinishPrimary()
00329 {
00330
00331
00332
00333 if (fLevel==2)
00334 cout << "--- Finish primary " << endl;
00335 }
00336
00337
00338 void TMCVerbose::FinishEvent()
00339 {
00340
00341
00342
00343 if (fLevel>0)
00344 cout << "--- Finish event " << endl;
00345 }
00346