G4RichTrajectoryPoint.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id: G4RichTrajectoryPoint.cc 67009 2013-01-29 16:00:21Z gcosmo $
00028 //
00029 //
00030 // ---------------------------------------------------------------
00031 //
00032 // G4RichTrajectoryPoint.cc
00033 //
00034 // Contact:
00035 //   Questions and comments on G4TrajectoryPoint, on which this is based,
00036 //   should be sent to
00037 //     Katsuya Amako  (e-mail: Katsuya.Amako@kek.jp)
00038 //     Makoto  Asai   (e-mail: asai@kekvax.kek.jp)
00039 //     Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
00040 //   and on the extended code to:
00041 //     John Allison   (e-mail: John.Allison@manchester.ac.uk)
00042 //     Joseph Perl    (e-mail: perl@slac.stanford.edu)
00043 //
00044 // ---------------------------------------------------------------
00045 
00046 #include "G4RichTrajectoryPoint.hh"
00047 
00048 #include "G4Track.hh"
00049 #include "G4Step.hh"
00050 #include "G4VProcess.hh"
00051 
00052 #include "G4AttDefStore.hh"
00053 #include "G4AttDef.hh"
00054 #include "G4AttValue.hh"
00055 #include "G4UnitsTable.hh"
00056 
00057 //#define G4ATTDEBUG
00058 #ifdef G4ATTDEBUG
00059 #include "G4AttCheck.hh"
00060 #endif
00061 
00062 #include <sstream>
00063 
00064 G4Allocator<G4RichTrajectoryPoint> aRichTrajectoryPointAllocator;
00065 
00066 G4RichTrajectoryPoint::G4RichTrajectoryPoint():
00067   fpAuxiliaryPointVector(0),
00068   fTotEDep(0.),
00069   fRemainingEnergy(0.),
00070   fpProcess(0),
00071   fPreStepPointStatus(fUndefined),
00072   fPostStepPointStatus(fUndefined),
00073   fPreStepPointGlobalTime(0),
00074   fPostStepPointGlobalTime(0),
00075   fPreStepPointWeight(1.),
00076   fPostStepPointWeight(1.)
00077 {}
00078 
00079 G4RichTrajectoryPoint::G4RichTrajectoryPoint(const G4Track* aTrack):
00080   G4TrajectoryPoint(aTrack->GetPosition()),
00081   fpAuxiliaryPointVector(0),
00082   fTotEDep(0.),
00083   fRemainingEnergy(aTrack->GetKineticEnergy()),
00084   fpProcess(0),
00085   fPreStepPointStatus(fUndefined),
00086   fPostStepPointStatus(fUndefined),
00087   fPreStepPointGlobalTime(aTrack->GetGlobalTime()),
00088   fPostStepPointGlobalTime(aTrack->GetGlobalTime()),
00089   fpPreStepPointVolume(aTrack->GetTouchableHandle()),
00090   fpPostStepPointVolume(aTrack->GetNextTouchableHandle()),
00091   fPreStepPointWeight(aTrack->GetWeight()),
00092   fPostStepPointWeight(aTrack->GetWeight())
00093 {}
00094 
00095 G4RichTrajectoryPoint::G4RichTrajectoryPoint(const G4Step* aStep):
00096   G4TrajectoryPoint(aStep->GetPostStepPoint()->GetPosition()),
00097   fpAuxiliaryPointVector(aStep->GetPointerToVectorOfAuxiliaryPoints()),
00098   fTotEDep(aStep->GetTotalEnergyDeposit())
00099 {
00100   G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
00101   G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
00102   if (aStep->GetTrack()->GetCurrentStepNumber() <= 0) {  // First step
00103     fRemainingEnergy = aStep->GetTrack()->GetKineticEnergy();
00104   } else {
00105     fRemainingEnergy = preStepPoint->GetKineticEnergy() - fTotEDep;
00106   }
00107   fpProcess = postStepPoint->GetProcessDefinedStep();
00108   fPreStepPointStatus = preStepPoint->GetStepStatus();
00109   fPostStepPointStatus = postStepPoint->GetStepStatus();
00110   fPreStepPointGlobalTime = preStepPoint->GetGlobalTime();
00111   fPostStepPointGlobalTime = postStepPoint->GetGlobalTime();
00112   fpPreStepPointVolume = preStepPoint->GetTouchableHandle();
00113   fpPostStepPointVolume = postStepPoint->GetTouchableHandle();
00114   fPreStepPointWeight = preStepPoint->GetWeight();
00115   fPostStepPointWeight = postStepPoint->GetWeight();
00116 
00117   /*
00118   G4cout << "fpAuxiliaryPointVector "
00119          << (void*) fpAuxiliaryPointVector;
00120   G4cout << ": ";
00121   if (fpAuxiliaryPointVector) {
00122     G4cout << "size: " << fpAuxiliaryPointVector->size();
00123     for (size_t i = 0; i < fpAuxiliaryPointVector->size(); ++i)
00124       G4cout << "\n  " << (*fpAuxiliaryPointVector)[i];
00125   } else {
00126     G4cout << "non-existent";
00127   }
00128   G4cout << G4endl;
00129 
00130   static const G4Step* lastStep = 0;
00131   if (aStep && aStep == lastStep) {
00132     G4cout << "********* aStep is same as last" << G4endl;
00133   }
00134   lastStep = aStep;
00135 
00136   static std::vector<G4ThreeVector>*  lastAuxiliaryPointVector = 0;
00137   if (fpAuxiliaryPointVector &&
00138       fpAuxiliaryPointVector == lastAuxiliaryPointVector) {
00139     G4cout << "********* fpAuxiliaryPointVector is same as last" << G4endl;
00140   }
00141   lastAuxiliaryPointVector = fpAuxiliaryPointVector;
00142   */
00143 }
00144 
00145 G4RichTrajectoryPoint::G4RichTrajectoryPoint
00146 (const G4RichTrajectoryPoint &right):
00147   G4TrajectoryPoint(right),
00148   fpAuxiliaryPointVector(right.fpAuxiliaryPointVector),
00149   fTotEDep(right.fTotEDep),
00150   fRemainingEnergy(right.fRemainingEnergy),
00151   fpProcess(right.fpProcess),
00152   fPreStepPointStatus(right.fPreStepPointStatus),
00153   fPostStepPointStatus(right.fPostStepPointStatus),
00154   fPreStepPointGlobalTime(right.fPreStepPointGlobalTime),
00155   fPostStepPointGlobalTime(right.fPostStepPointGlobalTime),
00156   fpPreStepPointVolume(right.fpPreStepPointVolume),
00157   fpPostStepPointVolume(right.fpPostStepPointVolume),
00158   fPreStepPointWeight(right.fPreStepPointWeight),
00159   fPostStepPointWeight(right.fPostStepPointWeight)
00160 {}
00161 
00162 G4RichTrajectoryPoint::~G4RichTrajectoryPoint()
00163 {
00164   if(fpAuxiliaryPointVector) {
00165     /*
00166     G4cout << "Deleting fpAuxiliaryPointVector at "
00167            << (void*) fpAuxiliaryPointVector
00168            << G4endl;
00169     */
00170     delete fpAuxiliaryPointVector;
00171   }
00172 }
00173 
00174 const std::map<G4String,G4AttDef>*
00175 G4RichTrajectoryPoint::GetAttDefs() const
00176 {
00177   G4bool isNew;
00178   std::map<G4String,G4AttDef>* store
00179     = G4AttDefStore::GetInstance("G4RichTrajectoryPoint",isNew);
00180   if (isNew) {
00181 
00182     // Copy base class att defs...
00183     *store = *(G4TrajectoryPoint::GetAttDefs());
00184 
00185     G4String ID;
00186 
00187     ID = "Aux";
00188     (*store)[ID] = G4AttDef(ID, "Auxiliary Point Position",
00189                             "Physics","G4BestUnit","G4ThreeVector");
00190     ID = "TED";
00191     (*store)[ID] = G4AttDef(ID,"Total Energy Deposit",
00192                             "Physics","G4BestUnit","G4double");
00193     ID = "RE";
00194     (*store)[ID] = G4AttDef(ID,"Remaining Energy",
00195                             "Physics","G4BestUnit","G4double");
00196     ID = "PDS";
00197     (*store)[ID] = G4AttDef(ID,"Process Defined Step",
00198                             "Physics","","G4String");
00199     ID = "PTDS";
00200     (*store)[ID] = G4AttDef(ID,"Process Type Defined Step",
00201                             "Physics","","G4String");
00202     ID = "PreStatus";
00203     (*store)[ID] = G4AttDef(ID,"Pre-step-point status",
00204                             "Physics","","G4String");
00205     ID = "PostStatus";
00206     (*store)[ID] = G4AttDef(ID,"Post-step-point status",
00207                             "Physics","","G4String");
00208     ID = "PreT";
00209     (*store)[ID] = G4AttDef(ID,"Pre-step-point global time",
00210                             "Physics","G4BestUnit","G4double");
00211     ID = "PostT";
00212     (*store)[ID] = G4AttDef(ID,"Post-step-point global time",
00213                             "Physics","G4BestUnit","G4double");
00214     ID = "PreVPath";
00215     (*store)[ID] = G4AttDef(ID,"Pre-step Volume Path",
00216                             "Physics","","G4String");
00217     ID = "PostVPath";
00218     (*store)[ID] = G4AttDef(ID,"Post-step Volume Path",
00219                             "Physics","","G4String");
00220     ID = "PreW";
00221     (*store)[ID] = G4AttDef(ID,"Pre-step-point weight",
00222                             "Physics","","G4double");
00223     ID = "PostW";
00224     (*store)[ID] = G4AttDef(ID,"Post-step-point weight",
00225                             "Physics","","G4double");
00226   }
00227   return store;
00228 }
00229 
00230 static G4String Status(G4StepStatus stps)
00231 {
00232   G4String status;
00233   switch (stps) {
00234   case fWorldBoundary:         status = "fWorldBoundary"; break;
00235   case fGeomBoundary:          status = "fGeomBoundary"; break;
00236   case fAtRestDoItProc:        status = "fAtRestDoItProc"; break;
00237   case fAlongStepDoItProc:     status = "fAlongStepDoItProc"; break;
00238   case fPostStepDoItProc:      status = "fPostStepDoItProc"; break;
00239   case fUserDefinedLimit:      status = "fUserDefinedLimit"; break;
00240   case fExclusivelyForcedProc: status = "fExclusivelyForcedProc"; break;
00241   case fUndefined:             status = "fUndefined"; break;
00242   default:                     status = "Not recognised"; break;
00243   }
00244   return status;
00245 }
00246 
00247 static G4String Path(const G4TouchableHandle& th)
00248 {
00249   std::ostringstream oss;
00250   G4int depth = th->GetHistoryDepth();
00251   for (G4int i = depth; i >= 0; --i) {
00252     oss << th->GetVolume(i)->GetName()
00253         << ':' << th->GetCopyNumber(i);
00254     if (i != 0) oss << '/';
00255   }
00256   return oss.str();
00257 }
00258 
00259 std::vector<G4AttValue>* G4RichTrajectoryPoint::CreateAttValues() const
00260 {
00261   // Create base class att values...
00262   std::vector<G4AttValue>* values = G4TrajectoryPoint::CreateAttValues();
00263 
00264   if (fpAuxiliaryPointVector) {
00265     std::vector<G4ThreeVector>::iterator iAux;
00266     for (iAux = fpAuxiliaryPointVector->begin();
00267          iAux != fpAuxiliaryPointVector->end(); ++iAux) {
00268       values->push_back(G4AttValue("Aux",G4BestUnit(*iAux,"Length"),""));
00269     }
00270   }
00271 
00272   values->push_back(G4AttValue("TED",G4BestUnit(fTotEDep,"Energy"),""));
00273 
00274   values->push_back(G4AttValue("RE",G4BestUnit(fRemainingEnergy,"Energy"),""));
00275 
00276   if (fpProcess) {
00277     values->push_back
00278       (G4AttValue("PDS",fpProcess->GetProcessName(),""));
00279     values->push_back
00280       (G4AttValue
00281        ("PTDS",G4VProcess::GetProcessTypeName(fpProcess->GetProcessType()),
00282         ""));
00283   } else {
00284     values->push_back(G4AttValue("PDS","None",""));
00285     values->push_back(G4AttValue("PTDS","None",""));
00286   }
00287 
00288   values->push_back
00289     (G4AttValue("PreStatus",Status(fPreStepPointStatus),""));
00290 
00291   values->push_back
00292     (G4AttValue("PostStatus",Status(fPostStepPointStatus),""));
00293 
00294   values->push_back
00295     (G4AttValue("PreT",G4BestUnit(fPreStepPointGlobalTime,"Time"),""));
00296 
00297   values->push_back
00298     (G4AttValue("PostT",G4BestUnit(fPostStepPointGlobalTime,"Time"),""));
00299 
00300   if (fpPreStepPointVolume && fpPreStepPointVolume->GetVolume()) {
00301     values->push_back(G4AttValue("PreVPath",Path(fpPreStepPointVolume),""));
00302   } else {
00303     values->push_back(G4AttValue("PreVPath","None",""));
00304   }
00305 
00306   if (fpPostStepPointVolume && fpPostStepPointVolume->GetVolume()) {
00307     values->push_back(G4AttValue("PostVPath",Path(fpPostStepPointVolume),""));
00308   } else {
00309     values->push_back(G4AttValue("PostVPath","None",""));
00310   }
00311 
00312   {
00313     std::ostringstream oss;
00314     oss << fPreStepPointWeight;
00315     values->push_back
00316       (G4AttValue("PreW",oss.str(),""));
00317   }
00318 
00319   {
00320     std::ostringstream oss;
00321     oss << fPostStepPointWeight;
00322     values->push_back
00323       (G4AttValue("PostW",oss.str(),""));
00324   }
00325 
00326 #ifdef G4ATTDEBUG
00327   G4cout << G4AttCheck(values,GetAttDefs());
00328 #endif
00329 
00330   return values;
00331 }

Generated on Mon May 27 17:49:43 2013 for Geant4 by  doxygen 1.4.7