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.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /event/src/G4TrackStack.cc (Version 11.3.0) and /event/src/G4TrackStack.cc (Version 6.0.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                    <<   3 // * DISCLAIMER                                                       *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th <<   5 // * The following disclaimer summarizes all the specific disclaimers *
  6 // * the Geant4 Collaboration.  It is provided <<   6 // * of contributors to this software. The specific disclaimers,which *
  7 // * conditions of the Geant4 Software License <<   7 // * govern, are listed with their locations in:                      *
  8 // * LICENSE and available at  http://cern.ch/ <<   8 // *   http://cern.ch/geant4/license                                  *
  9 // * include a list of copyright holders.      << 
 10 // *                                                9 // *                                                                  *
 11 // * Neither the authors of this software syst     10 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     11 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     12 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     13 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  <<  14 // * use.                                                             *
 16 // * for the full disclaimer and the limitatio << 
 17 // *                                               15 // *                                                                  *
 18 // * This  code  implementation is the result  <<  16 // * This  code  implementation is the  intellectual property  of the *
 19 // * technical work of the GEANT4 collaboratio <<  17 // * GEANT4 collaboration.                                            *
 20 // * By using,  copying,  modifying or  distri <<  18 // * By copying,  distributing  or modifying the Program (or any work *
 21 // * any work based  on the software)  you  ag <<  19 // * based  on  the Program)  you indicate  your  acceptance of  this *
 22 // * use  in  resulting  scientific  publicati <<  20 // * statement, and all its terms.                                    *
 23 // * acceptance of all terms of the Geant4 Sof << 
 24 // *******************************************     21 // ********************************************************************
 25 //                                                 22 //
 26 // G4TrackStack class implementation           << 
 27 //                                                 23 //
 28 // Author: Makoto Asai (SLAC)                  <<  24 // $Id: G4TrackStack.cc,v 1.5 2002/12/03 17:04:22 asaim Exp $
 29 // ------------------------------------------- <<  25 // GEANT4 tag $Name: geant4-05-02-patch-01 $
                                                   >>  26 //
 30                                                    27 
 31 #include "G4TrackStack.hh"                         28 #include "G4TrackStack.hh"
 32 #include "G4SmartTrackStack.hh"                << 
 33 #include "G4VTrajectory.hh"                        29 #include "G4VTrajectory.hh"
 34 #include "G4Track.hh"                          <<  30 
                                                   >>  31 G4TrackStack::G4TrackStack()
                                                   >>  32 :n_stackedTrack(0),firstStackedTrack(0),lastStackedTrack(0)
                                                   >>  33 {;}
 35                                                    34 
 36 G4TrackStack::~G4TrackStack()                      35 G4TrackStack::~G4TrackStack()
 37 {                                                  36 {
 38   clearAndDestroy();                           <<  37   if( n_stackedTrack != 0 )
                                                   >>  38   {
                                                   >>  39     G4StackedTrack * aStackedTrack = firstStackedTrack;
                                                   >>  40     G4StackedTrack * nextStackedTrack;
                                                   >>  41 
                                                   >>  42     // delete tracks in the stack
                                                   >>  43     while( aStackedTrack != 0 )
                                                   >>  44     {
                                                   >>  45       nextStackedTrack = aStackedTrack->GetNext();
                                                   >>  46       delete aStackedTrack->GetTrack();
                                                   >>  47       delete aStackedTrack->GetTrajectory();
                                                   >>  48       delete aStackedTrack;
                                                   >>  49       aStackedTrack = nextStackedTrack;
                                                   >>  50     }
                                                   >>  51   }
                                                   >>  52 }
                                                   >>  53 
                                                   >>  54 const G4TrackStack & G4TrackStack::operator=(const G4TrackStack &right) 
                                                   >>  55 {
                                                   >>  56   n_stackedTrack = right.n_stackedTrack;
                                                   >>  57   firstStackedTrack = right.firstStackedTrack;
                                                   >>  58   lastStackedTrack = right.lastStackedTrack;
                                                   >>  59   return *this; 
 39 }                                                  60 }
 40                                                    61 
 41 void G4TrackStack::clearAndDestroy()           <<  62 int G4TrackStack::operator==(const G4TrackStack &right) const
                                                   >>  63 { return (firstStackedTrack==right.firstStackedTrack); }
                                                   >>  64 int G4TrackStack::operator!=(const G4TrackStack &right) const
                                                   >>  65 { return (firstStackedTrack!=right.firstStackedTrack); }
                                                   >>  66 
                                                   >>  67 void G4TrackStack::TransferTo(G4TrackStack * aStack)
 42 {                                                  68 {
 43   for(auto & i : *this)                        <<  69   if(n_stackedTrack==0) return;
                                                   >>  70 
                                                   >>  71   if(aStack->n_stackedTrack == 0)
                                                   >>  72   {
                                                   >>  73     *aStack = *this;
                                                   >>  74   }
                                                   >>  75   else
 44   {                                                76   {
 45     delete i.GetTrack();                       <<  77     aStack->lastStackedTrack->SetNext( firstStackedTrack );
 46     delete i.GetTrajectory();                  <<  78     firstStackedTrack->SetPrevious( aStack->lastStackedTrack );
                                                   >>  79     aStack->lastStackedTrack = lastStackedTrack;
                                                   >>  80     aStack->n_stackedTrack += n_stackedTrack;
 47   }                                                81   }
 48   clear();                                     <<  82 
                                                   >>  83   n_stackedTrack = 0;
                                                   >>  84   firstStackedTrack = 0;
                                                   >>  85   lastStackedTrack = 0;
                                                   >>  86 }
                                                   >>  87 
                                                   >>  88 G4StackedTrack * G4TrackStack::PopFromStack()
                                                   >>  89 {
                                                   >>  90   if( n_stackedTrack == 0 ) return 0;
                                                   >>  91   G4StackedTrack * aStackedTrack = lastStackedTrack;
                                                   >>  92   GrabFromStack( aStackedTrack );
                                                   >>  93   return aStackedTrack;
 49 }                                                  94 }
 50                                                    95 
 51 void G4TrackStack::TransferTo(G4TrackStack* aS <<  96 void G4TrackStack::PushToStack( G4StackedTrack * aStackedTrack )
 52 {                                                  97 {
 53   for(auto & i : *this)                        <<  98   if( n_stackedTrack == 0 )
                                                   >>  99   {
                                                   >> 100     aStackedTrack->SetPrevious( 0 );
                                                   >> 101     firstStackedTrack = aStackedTrack;
                                                   >> 102   }
                                                   >> 103   else
 54   {                                               104   {
 55     aStack->push_back(i);                      << 105     lastStackedTrack->SetNext( aStackedTrack );
                                                   >> 106     aStackedTrack->SetPrevious( lastStackedTrack );
 56   }                                               107   }
 57   clear();                                     << 108   lastStackedTrack = aStackedTrack;
                                                   >> 109   n_stackedTrack++;
 58 }                                                 110 }
 59                                                   111 
 60 void G4TrackStack::TransferTo(G4SmartTrackStac << 112 void G4TrackStack::GrabFromStack( G4StackedTrack * aStackedTrack )
 61 {                                                 113 {
 62   while (!this->empty())                       << 114   if( n_stackedTrack == 1 )
 63   {                                               115   {
 64     aStack->PushToStack(PopFromStack());       << 116     firstStackedTrack = 0;
                                                   >> 117     lastStackedTrack = 0;
 65   }                                               118   }
                                                   >> 119   else
                                                   >> 120   {
                                                   >> 121     if( aStackedTrack == firstStackedTrack )
                                                   >> 122     {
                                                   >> 123       firstStackedTrack = aStackedTrack->GetNext();
                                                   >> 124       firstStackedTrack->SetPrevious( 0 );
                                                   >> 125     }
                                                   >> 126     else
                                                   >> 127     {
                                                   >> 128       if( aStackedTrack == lastStackedTrack )
                                                   >> 129       {
                                                   >> 130         lastStackedTrack = aStackedTrack->GetPrevious();
                                                   >> 131         lastStackedTrack->SetNext( 0 );
                                                   >> 132       }
                                                   >> 133       else
                                                   >> 134       {
                                                   >> 135         aStackedTrack->GetPrevious()
                                                   >> 136           ->SetNext( aStackedTrack->GetNext() );
                                                   >> 137         aStackedTrack->GetNext()
                                                   >> 138           ->SetPrevious( aStackedTrack->GetPrevious() );
                                                   >> 139       }
                                                   >> 140     }
                                                   >> 141   }
                                                   >> 142   n_stackedTrack--;
 66 }                                                 143 }
 67                                                   144 
 68 G4double G4TrackStack::getTotalEnergy() const  << 145 void G4TrackStack::clear()
 69 {                                                 146 {
 70   G4double totalEnergy = 0.0;                  << 147   G4StackedTrack * aStackedTrack = firstStackedTrack;
 71   for (const auto & i : *this)                 << 148   G4StackedTrack * nextStackedTrack;
                                                   >> 149 
                                                   >> 150   if ( n_stackedTrack == 0 ) return;
                                                   >> 151 
                                                   >> 152   // delete tracks in the stack
                                                   >> 153   while( aStackedTrack != 0 )
 72   {                                               154   {
 73     totalEnergy += i.GetTrack()->GetDynamicPar << 155     nextStackedTrack = aStackedTrack->GetNext();
                                                   >> 156     delete aStackedTrack->GetTrack();
                                                   >> 157     delete aStackedTrack->GetTrajectory();
                                                   >> 158     delete aStackedTrack;
                                                   >> 159     aStackedTrack = nextStackedTrack;
 74   }                                               160   }
 75   return totalEnergy;                          << 161   n_stackedTrack = 0;
                                                   >> 162   firstStackedTrack = 0;
                                                   >> 163   lastStackedTrack = 0;
 76 }                                                 164 }
                                                   >> 165 
                                                   >> 166 
 77                                                   167