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[ 10.5.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 /particles/management/src/G4PrimaryVertex.cc (Version 11.3.0) and /particles/management/src/G4PrimaryVertex.cc (Version 10.4.p3)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // G4PrimaryVertex                             << 
 27 //                                                 26 //
 28 // Authors: G.Cosmo, 2 December 1995 - Design, <<  27 // $Id$
 29 //          M.Asai, 29 January 1996 - First im <<  28 //
 30 // ------------------------------------------- << 
 31                                                    29 
 32 #include "G4PrimaryVertex.hh"                      30 #include "G4PrimaryVertex.hh"
 33                                                << 
 34 #include "G4SystemOfUnits.hh"                      31 #include "G4SystemOfUnits.hh"
 35 #include "G4VUserPrimaryVertexInformation.hh"      32 #include "G4VUserPrimaryVertexInformation.hh"
 36 #include "G4ios.hh"                                33 #include "G4ios.hh"
 37                                                    34 
 38 G4Allocator<G4PrimaryVertex>*& aPrimaryVertexA <<  35 G4ThreadLocal G4Allocator<G4PrimaryVertex> *aPrimaryVertexAllocator = 0;
                                                   >>  36 
                                                   >>  37 G4PrimaryVertex::G4PrimaryVertex()
                                                   >>  38 :X0(0.),Y0(0.),Z0(0.),T0(0.),theParticle(0),theTail(0),
                                                   >>  39  nextVertex(0),tailVertex(0),numberOfParticle(0),Weight0(1.0),userInfo(0)
 39 {                                                  40 {
 40   G4ThreadLocalStatic G4Allocator<G4PrimaryVer << 
 41   return _instance;                            << 
 42 }                                                  41 }
 43                                                    42 
 44 G4PrimaryVertex::G4PrimaryVertex(G4double x0,  <<  43 G4PrimaryVertex::G4PrimaryVertex(
 45   : X0(x0), Y0(y0), Z0(z0), T0(t0)             <<  44           G4double x0,G4double y0,G4double z0,G4double t0)
 46 {}                                             <<  45 :X0(x0),Y0(y0),Z0(z0),T0(t0),theParticle(0),theTail(0),
                                                   >>  46  nextVertex(0),tailVertex(0),numberOfParticle(0),Weight0(1.0),userInfo(0)
                                                   >>  47 {
                                                   >>  48 }
 47                                                    49 
 48 G4PrimaryVertex::G4PrimaryVertex(G4ThreeVector <<  50 G4PrimaryVertex::G4PrimaryVertex(G4ThreeVector xyz0,G4double t0)
 49   : X0(xyz0.x()), Y0(xyz0.y()), Z0(xyz0.z()),  <<  51 :T0(t0),theParticle(0),theTail(0),
 50 {}                                             <<  52  nextVertex(0),tailVertex(0),numberOfParticle(0),Weight0(1.0),userInfo(0)
                                                   >>  53 {
                                                   >>  54   X0=xyz0.x();
                                                   >>  55   Y0=xyz0.y();
                                                   >>  56   Z0=xyz0.z();
                                                   >>  57 }
 51                                                    58 
 52 G4PrimaryVertex::G4PrimaryVertex(const G4Prima <<  59 G4PrimaryVertex::G4PrimaryVertex(const G4PrimaryVertex & right)
                                                   >>  60 :theParticle(0),theTail(0),
                                                   >>  61  nextVertex(0),tailVertex(0),userInfo(0)
 53 {                                                  62 {
                                                   >>  63   numberOfParticle = right.numberOfParticle;
 54   *this = right;                                   64   *this = right;
 55 }                                                  65 }
 56                                                    66 
 57 G4PrimaryVertex::~G4PrimaryVertex()                67 G4PrimaryVertex::~G4PrimaryVertex()
 58 {                                                  68 {
 59   if (theParticle != nullptr) {                <<  69   if(theParticle != 0) {
 60     G4PrimaryParticle* theNext = theParticle;      70     G4PrimaryParticle* theNext = theParticle;
 61     while (theNext != nullptr) {               <<  71     while(theNext)
                                                   >>  72     {
 62       G4PrimaryParticle* thisPrimary = theNext     73       G4PrimaryParticle* thisPrimary = theNext;
 63       theNext = thisPrimary->GetNext();            74       theNext = thisPrimary->GetNext();
 64       thisPrimary->ClearNext();                    75       thisPrimary->ClearNext();
 65       delete thisPrimary;                          76       delete thisPrimary;
 66     }                                              77     }
 67     theParticle = nullptr;                     <<  78     theParticle = 0;
                                                   >>  79   }
                                                   >>  80   if(nextVertex != 0) { 
                                                   >>  81     delete nextVertex; 
                                                   >>  82     nextVertex =0;
                                                   >>  83   }
                                                   >>  84   if(userInfo != 0) { 
                                                   >>  85     delete userInfo; 
                                                   >>  86     userInfo = 0;
 68   }                                                87   }
 69   delete nextVertex;                           << 
 70   nextVertex = nullptr;                        << 
 71                                                << 
 72   theTail = nullptr;                           << 
 73   tailVertex = nullptr;                        << 
 74                                                << 
 75   delete userInfo;                             << 
 76   userInfo = nullptr;                          << 
 77 }                                                  88 }
 78                                                    89 
 79 G4PrimaryVertex& G4PrimaryVertex::operator=(co <<  90 G4PrimaryVertex &  G4PrimaryVertex::operator=(const G4PrimaryVertex & right)
 80 {                                              <<  91 {  
 81   if (this != &right) {                            92   if (this != &right) {
 82     X0 = right.X0;                             <<  93     X0       = right.X0;
 83     Y0 = right.Y0;                             <<  94     Y0       = right.Y0;
 84     Z0 = right.Z0;                             <<  95     Z0       = right.Z0;
 85     T0 = right.T0;                             <<  96     T0       = right.T0;
 86     Weight0 = right.Weight0;                   <<  97     Weight0  = right.Weight0;
 87     numberOfParticle = right.numberOfParticle; <<  98 
 88                                                <<  99     numberOfParticle = 0;
 89     delete theParticle;                        << 100     if (theParticle !=0) delete theParticle;
 90     theParticle = nullptr;                     << 101     theParticle =0;
 91     theTail = nullptr;                         << 102     theTail     =0;
 92     if (right.theParticle != nullptr) {        << 103     if (right.theParticle !=0 ) {
 93       theParticle = new G4PrimaryParticle(*(ri    104       theParticle = new G4PrimaryParticle(*(right.theParticle));
                                                   >> 105       numberOfParticle += 1;
 94       theTail = theParticle;                      106       theTail = theParticle;
 95       G4PrimaryParticle* np = theParticle->Get << 107       G4PrimaryParticle * np = theParticle->GetNext();
 96       while (np != nullptr)  // Loop checking, << 108       while (np !=0) { // Loop checking, 09.08.2015, K.Kurashige
 97       {                                        << 109   numberOfParticle += 1;
 98         theTail = np;                          << 110   theTail = np;
 99         np = np->GetNext();                    << 111   np = np->GetNext();
100       }                                           112       }
101     }                                             113     }
102                                                << 114     
103     delete nextVertex;                         << 115     if (nextVertex !=0 ) delete nextVertex;
104     nextVertex = nullptr;                      << 116     nextVertex = 0;
105     tailVertex = nullptr;                      << 117     tailVertex =0;
106     if (right.nextVertex != nullptr) {         << 118     if (right.nextVertex !=0 ) {
107       nextVertex = new G4PrimaryVertex(*(right    119       nextVertex = new G4PrimaryVertex(*(right.nextVertex));
108       tailVertex = nextVertex;                    120       tailVertex = nextVertex;
109       G4PrimaryVertex* nv = nextVertex->GetNex    121       G4PrimaryVertex* nv = nextVertex->GetNext();
110       while (nv != nullptr)  // Loop checking, << 122       while (nv !=0) { // Loop checking, 09.08.2015, K.Kurashige
111       {                                        << 123   tailVertex = nv;
112         tailVertex = nv;                       << 124   nv = nv->GetNext();
113         nv = nv->GetNext();                    << 
114       }                                           125       }
115     }                                             126     }
116                                                   127 
117     // userInfo cannot be copied               << 128     // userInfo can not be copied
118     userInfo = nullptr;                        << 129     userInfo = 0;
119   }                                               130   }
120   return *this;                                << 131   return *this; 
121 }                                                 132 }
122                                                   133 
123 G4bool G4PrimaryVertex::operator==(const G4Pri << 134 G4int G4PrimaryVertex::operator==(const G4PrimaryVertex &right) const
124 {                                              << 135 { return (this==&right); }
125   return (this == &right);                     << 
126 }                                              << 
127                                                   136 
128 G4bool G4PrimaryVertex::operator!=(const G4Pri << 137 G4int G4PrimaryVertex::operator!=(const G4PrimaryVertex &right) const
129 {                                              << 138 { return (this!=&right); }
130   return (this != &right);                     << 
131 }                                              << 
132                                                   139 
133 G4PrimaryParticle* G4PrimaryVertex::GetPrimary    140 G4PrimaryParticle* G4PrimaryVertex::GetPrimary(G4int i) const
134 {                                              << 141 {  
135   if (i >= 0 && i < numberOfParticle) {        << 142   if( i >= 0 && i < numberOfParticle ) {
136     G4PrimaryParticle* particle = theParticle;    143     G4PrimaryParticle* particle = theParticle;
137     for (G4int j = 0; j < i; ++j) {            << 144     for( G4int j=0; j<i; j++ ){ 
138       if (particle == nullptr) return nullptr; << 145       if( particle == 0 ) return 0;
139       particle = particle->GetNext();             146       particle = particle->GetNext();
140     }                                             147     }
141     return particle;                              148     return particle;
142   }                                            << 149   } else { 
143                                                << 150     return 0; }
144   return nullptr;                              << 
145 }                                                 151 }
146                                                   152 
147 void G4PrimaryVertex::Print() const               153 void G4PrimaryVertex::Print() const
148 {                                              << 154 { 
149   G4cout << "Vertex  ( " << X0 / mm << "[mm],  << 155   G4cout << "Vertex  ( "
150          << T0 / ns << "[ns] )"                << 156    << X0/mm  << "[mm], " 
151          << " Weight " << Weight0 << G4endl;   << 157    << Y0/mm << "[mm], " 
152   if (userInfo != nullptr) userInfo->Print();  << 158    << Z0/mm << "[mm], " 
153   G4cout << "  -- Primary particles :: "       << 159    << T0/ns  << "[ns] )" 
154          << "   # of primaries =" << numberOfP << 160    << " Weight " << Weight0 << G4endl;
155   if (theParticle != nullptr) theParticle->Pri << 161   if(userInfo!=0) userInfo->Print();
156   if (nextVertex != nullptr) {                 << 162   G4cout << "  -- Primary particles :: " 
                                                   >> 163    << "   # of primaries =" << numberOfParticle << G4endl;
                                                   >> 164   if( theParticle != 0)  theParticle->Print();
                                                   >> 165   if (nextVertex !=0 ) {
157     G4cout << "Next Vertex " << G4endl;           166     G4cout << "Next Vertex " << G4endl;
158     nextVertex->Print();                          167     nextVertex->Print();
159   }                                               168   }
160 }                                                 169 }
161                                                   170