G4RichTrajectory.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: G4RichTrajectory.cc 67009 2013-01-29 16:00:21Z gcosmo $
00028 //
00029 // ---------------------------------------------------------------
00030 //
00031 // G4RichTrajectory.cc
00032 //
00033 // Contact:
00034 //   Questions and comments on G4Trajectory, on which this is based,
00035 //   should be sent to
00036 //     Katsuya Amako  (e-mail: Katsuya.Amako@kek.jp)
00037 //     Makoto  Asai   (e-mail: asai@kekvax.kek.jp)
00038 //     Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
00039 //   and on the extended code to:
00040 //     John Allison   (e-mail: John.Allison@manchester.ac.uk)
00041 //     Joseph Perl    (e-mail: perl@slac.stanford.edu)
00042 //
00043 // ---------------------------------------------------------------
00044 
00045 #include "G4RichTrajectory.hh"
00046 #include "G4RichTrajectoryPoint.hh"
00047 #include "G4AttDefStore.hh"
00048 #include "G4AttDef.hh"
00049 #include "G4AttValue.hh"
00050 #include "G4UnitsTable.hh"
00051 #include "G4VProcess.hh"
00052 
00053 //#define G4ATTDEBUG
00054 #ifdef G4ATTDEBUG
00055 #include "G4AttCheck.hh"
00056 #endif
00057 
00058 #include <sstream>
00059 
00060 G4Allocator<G4RichTrajectory> aRichTrajectoryAllocator;
00061 
00062 G4RichTrajectory::G4RichTrajectory():
00063   fpRichPointsContainer(0),
00064   fpCreatorProcess(0),
00065   fpEndingProcess(0),
00066   fFinalKineticEnergy(0.)
00067 {}
00068 
00069 G4RichTrajectory::G4RichTrajectory(const G4Track* aTrack):
00070   G4Trajectory(aTrack)  // Note: this initialises the base class data
00071                         // members and, unfortunately but never mind,
00072                         // creates a G4TrajectoryPoint in
00073                         // TrajectoryPointContainer that we cannot
00074                         // access because it's private.  We store the
00075                         // same information (plus more) in a
00076                         // G4RichTrajectoryPoint in the
00077                         // RichTrajectoryPointsContainer
00078 {
00079   fpInitialVolume = aTrack->GetTouchableHandle();
00080   fpInitialNextVolume = aTrack->GetNextTouchableHandle();
00081   fpCreatorProcess = aTrack->GetCreatorProcess();
00082   // On construction, set final values to initial values.
00083   // Final values are updated at the addition of every step - see AppendStep.
00084   fpFinalVolume = aTrack->GetTouchableHandle();
00085   fpFinalNextVolume = aTrack->GetNextTouchableHandle();
00086   fpEndingProcess = aTrack->GetCreatorProcess();
00087   fFinalKineticEnergy = aTrack->GetKineticEnergy();
00088   // Insert the first rich trajectory point (see note above)...
00089   fpRichPointsContainer = new RichTrajectoryPointsContainer;
00090   fpRichPointsContainer->push_back(new G4RichTrajectoryPoint(aTrack));
00091 }
00092 
00093 G4RichTrajectory::G4RichTrajectory(G4RichTrajectory & right):
00094   G4Trajectory(right)
00095 {
00096   fpInitialVolume = right.fpInitialVolume;
00097   fpInitialNextVolume = right.fpInitialNextVolume;
00098   fpCreatorProcess = right.fpCreatorProcess;
00099   fpFinalVolume = right.fpFinalVolume;
00100   fpFinalNextVolume = right.fpFinalNextVolume;
00101   fpEndingProcess = right.fpEndingProcess;
00102   fFinalKineticEnergy = right.fFinalKineticEnergy;
00103   fpRichPointsContainer = new RichTrajectoryPointsContainer;
00104   for(size_t i=0;i<right.fpRichPointsContainer->size();i++)
00105   {
00106     G4RichTrajectoryPoint* rightPoint =
00107       (G4RichTrajectoryPoint*)((*(right.fpRichPointsContainer))[i]);
00108     fpRichPointsContainer->push_back(new G4RichTrajectoryPoint(*rightPoint));
00109   }
00110 }
00111 
00112 G4RichTrajectory::~G4RichTrajectory()
00113 {
00114   if (fpRichPointsContainer) {
00115     //  fpRichPointsContainer->clearAndDestroy();
00116     size_t i;
00117     for(i=0;i<fpRichPointsContainer->size();i++){
00118       delete  (*fpRichPointsContainer)[i];
00119     }
00120     fpRichPointsContainer->clear();
00121     delete fpRichPointsContainer;
00122   }
00123 }
00124 
00125 void G4RichTrajectory::AppendStep(const G4Step* aStep)
00126 {
00127   fpRichPointsContainer->push_back(new G4RichTrajectoryPoint(aStep));
00128   // Except for first step, which is a sort of virtual step to start
00129   // the track, compute the final values...
00130   const G4Track* track = aStep->GetTrack();
00131   const G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
00132   if (track->GetCurrentStepNumber() > 0) {
00133     fpFinalVolume = track->GetTouchableHandle();
00134     fpFinalNextVolume = track->GetNextTouchableHandle();
00135     fpEndingProcess = postStepPoint->GetProcessDefinedStep();
00136     fFinalKineticEnergy =
00137       aStep->GetPreStepPoint()->GetKineticEnergy() -
00138       aStep->GetTotalEnergyDeposit();
00139   }
00140 }
00141   
00142 void G4RichTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
00143 {
00144   if(!secondTrajectory) return;
00145 
00146   G4RichTrajectory* seco = (G4RichTrajectory*)secondTrajectory;
00147   G4int ent = seco->GetPointEntries();
00148   for(G4int i=1;i<ent;i++) {
00149     // initial point of the second trajectory should not be merged
00150     fpRichPointsContainer->push_back((*(seco->fpRichPointsContainer))[i]);
00151     //    fpRichPointsContainer->push_back(seco->fpRichPointsContainer->removeAt(1));
00152   }
00153   delete (*seco->fpRichPointsContainer)[0];
00154   seco->fpRichPointsContainer->clear();
00155 }
00156 
00157 const std::map<G4String,G4AttDef>* G4RichTrajectory::GetAttDefs() const
00158 {
00159   G4bool isNew;
00160   std::map<G4String,G4AttDef>* store
00161     = G4AttDefStore::GetInstance("G4RichTrajectory",isNew);
00162   if (isNew) {
00163 
00164     // Get att defs from base class...
00165     *store = *(G4Trajectory::GetAttDefs());
00166 
00167     G4String ID;
00168 
00169     ID = "IVPath";
00170     (*store)[ID] = G4AttDef(ID,"Initial Volume Path",
00171                             "Physics","","G4String");
00172 
00173     ID = "INVPath";
00174     (*store)[ID] = G4AttDef(ID,"Initial Next Volume Path",
00175                             "Physics","","G4String");
00176 
00177     ID = "CPN";
00178     (*store)[ID] = G4AttDef(ID,"Creator Process Name",
00179                             "Physics","","G4String");
00180 
00181     ID = "CPTN";
00182     (*store)[ID] = G4AttDef(ID,"Creator Process Type Name",
00183                             "Physics","","G4String");
00184 
00185     ID = "FVPath";
00186     (*store)[ID] = G4AttDef(ID,"Final Volume Path",
00187                             "Physics","","G4String");
00188 
00189     ID = "FNVPath";
00190     (*store)[ID] = G4AttDef(ID,"Final Next Volume Path",
00191                             "Physics","","G4String");
00192 
00193     ID = "EPN";
00194     (*store)[ID] = G4AttDef(ID,"Ending Process Name",
00195                             "Physics","","G4String");
00196 
00197     ID = "EPTN";
00198     (*store)[ID] = G4AttDef(ID,"Ending Process Type Name",
00199                             "Physics","","G4String");
00200 
00201     ID = "FKE";
00202     (*store)[ID] = G4AttDef(ID,"Final kinetic energy",
00203                             "Physics","G4BestUnit","G4double");
00204 
00205   }
00206 
00207   return store;
00208 }
00209 
00210 static G4String Path(const G4TouchableHandle& th)
00211 {
00212   std::ostringstream oss;
00213   G4int depth = th->GetHistoryDepth();
00214   for (G4int i = depth; i >= 0; --i) {
00215     oss << th->GetVolume(i)->GetName()
00216         << ':' << th->GetCopyNumber(i);
00217     if (i != 0) oss << '/';
00218   }
00219   return oss.str();
00220 }
00221 
00222 std::vector<G4AttValue>* G4RichTrajectory::CreateAttValues() const
00223 {
00224   // Create base class att values...
00225   std::vector<G4AttValue>* values = G4Trajectory::CreateAttValues();
00226 
00227   if (fpInitialVolume && fpInitialVolume->GetVolume()) {
00228     values->push_back(G4AttValue("IVPath",Path(fpInitialVolume),""));
00229   } else {
00230     values->push_back(G4AttValue("IVPath","None",""));
00231   }
00232 
00233   if (fpInitialNextVolume && fpInitialNextVolume->GetVolume()) {
00234     values->push_back(G4AttValue("INVPath",Path(fpInitialNextVolume),""));
00235   } else {
00236     values->push_back(G4AttValue("INVPath","None",""));
00237   }
00238 
00239   if (fpCreatorProcess) {
00240     values->push_back(G4AttValue("CPN",fpCreatorProcess->GetProcessName(),""));
00241     G4ProcessType type = fpCreatorProcess->GetProcessType();
00242     values->push_back(G4AttValue("CPTN",G4VProcess::GetProcessTypeName(type),""));
00243   } else {
00244     values->push_back(G4AttValue("CPN","None",""));
00245     values->push_back(G4AttValue("CPTN","None",""));
00246   }
00247 
00248   if (fpFinalVolume && fpFinalVolume->GetVolume()) {
00249     values->push_back(G4AttValue("FVPath",Path(fpFinalVolume),""));
00250   } else {
00251     values->push_back(G4AttValue("FVPath","None",""));
00252   }
00253 
00254   if (fpFinalNextVolume && fpFinalNextVolume->GetVolume()) {
00255     values->push_back(G4AttValue("FNVPath",Path(fpFinalNextVolume),""));
00256   } else {
00257     values->push_back(G4AttValue("FNVPath","None",""));
00258   }
00259 
00260   if (fpEndingProcess) {
00261     values->push_back(G4AttValue("EPN",fpEndingProcess->GetProcessName(),""));
00262     G4ProcessType type = fpEndingProcess->GetProcessType();
00263     values->push_back(G4AttValue("EPTN",G4VProcess::GetProcessTypeName(type),""));
00264   } else {
00265     values->push_back(G4AttValue("EPN","None",""));
00266     values->push_back(G4AttValue("EPTN","None",""));
00267   }
00268 
00269   values->push_back
00270     (G4AttValue("FKE",G4BestUnit(fFinalKineticEnergy,"Energy"),""));
00271 
00272 #ifdef G4ATTDEBUG
00273   G4cout << G4AttCheck(values,GetAttDefs());
00274 #endif
00275 
00276   return values;
00277 }

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