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5 ] [ 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 /persistency/mctruth/src/G4MCTSimParticle.cc (Version 11.3.0) and /persistency/mctruth/src/G4MCTSimParticle.cc (Version 10.4.p1)


  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 // G4MCTSimParticle implementation             <<  26 //   G4MCTSimParticle.cc
 27 //                                                 27 //
 28 // Author: Youhei Morita, 12.09.2001           <<  28 // ====================================================================
 29 // ------------------------------------------- << 
 30                                                    29 
 31 #include <sstream>                                 30 #include <sstream>
 32 #include <iomanip>                                 31 #include <iomanip>
 33                                                    32 
 34 #include "G4MCTSimParticle.hh"                     33 #include "G4MCTSimParticle.hh"
 35                                                    34 
 36 #include "globals.hh"                              35 #include "globals.hh"
 37 #include "G4SystemOfUnits.hh"                      36 #include "G4SystemOfUnits.hh"
 38 #include "G4ios.hh"                                37 #include "G4ios.hh"
 39 #include "G4MCTSimVertex.hh"                       38 #include "G4MCTSimVertex.hh"
 40                                                    39 
 41 // ------------------------------------------- <<  40 // ====================================================================
                                                   >>  41 //
                                                   >>  42 // class description
                                                   >>  43 //
                                                   >>  44 // ====================================================================
                                                   >>  45 
                                                   >>  46 /////////////////////////////////
 42 G4MCTSimParticle::G4MCTSimParticle()               47 G4MCTSimParticle::G4MCTSimParticle()
                                                   >>  48   : parentParticle(0), pdgID(0),
                                                   >>  49     trackID(0), parentTrackID(0),
                                                   >>  50     primaryFlag(false), 
                                                   >>  51     vertex(0), storeFlag(false)
                                                   >>  52 /////////////////////////////////
 43 {                                                  53 {
 44 }                                                  54 }
 45                                                    55 
 46 // ------------------------------------------- <<  56 /////////////////////////////////////////////////////////////
 47 G4MCTSimParticle::G4MCTSimParticle(const G4Str <<  57 G4MCTSimParticle::G4MCTSimParticle(std::string aname, int apcode, 
 48                                    G4int apcod <<  58              int atid, int ptid,
 49                                    const G4Lor <<  59              const G4LorentzVector& p)
 50   : name(aname)                                <<  60   : parentParticle(0), 
 51   , momentumAtVertex(p)                        <<  61     name(aname), pdgID(apcode), 
 52   , pdgID(apcode)                              <<  62     trackID(atid), parentTrackID(ptid),
 53   , trackID(atid)                              <<  63     primaryFlag(false),momentumAtVertex(p),
 54   , parentTrackID(ptid)                        <<  64     vertex(0), storeFlag(false)
                                                   >>  65 ///////////////////////////////////////////////////////////////
 55 {                                                  66 {
 56 }                                                  67 }
 57                                                    68 
 58 // ------------------------------------------- <<  69 /////////////////////////////////////////////////////////////
 59 G4MCTSimParticle::G4MCTSimParticle(const G4Str <<  70 G4MCTSimParticle::G4MCTSimParticle(std::string aname, int apcode, 
 60                                    G4int apcod <<  71              int atid, int ptid,
 61                                    const G4Lor <<  72              const G4LorentzVector& p,
 62                                    const G4MCT <<  73              const G4MCTSimVertex* v )
 63   : name(aname)                                <<  74   : parentParticle(0), 
 64   , momentumAtVertex(p)                        <<  75     name(aname), pdgID(apcode), 
 65   , vertex(const_cast<G4MCTSimVertex*>(v))     <<  76     trackID(atid), parentTrackID(ptid),
 66   , pdgID(apcode)                              <<  77     primaryFlag(false),momentumAtVertex(p), 
 67   , trackID(atid)                              <<  78     vertex(const_cast<G4MCTSimVertex*>(v)), storeFlag(false)
 68   , parentTrackID(ptid)                        <<  79 ///////////////////////////////////////////////////////////////
 69 {                                                  80 {
 70 }                                                  81 }
 71                                                    82 
 72 // ------------------------------------------- <<  83 /////////////////////////////////
 73 G4MCTSimParticle::~G4MCTSimParticle()              84 G4MCTSimParticle::~G4MCTSimParticle()
                                                   >>  85 /////////////////////////////////
 74 {                                                  86 {
 75   associatedParticleList.clear();                  87   associatedParticleList.clear();
 76 }                                                  88 }
 77                                                    89 
 78 // ------------------------------------------- <<  90 ////////////////////////////////////////////////////////
 79 G4int G4MCTSimParticle::AssociateParticle(G4MC <<  91 int G4MCTSimParticle::AssociateParticle(G4MCTSimParticle* p)
                                                   >>  92 ////////////////////////////////////////////////////////
 80 {                                                  93 {
 81   associatedParticleList.push_back(p);             94   associatedParticleList.push_back(p);
 82   p->SetParentParticle(this);                  <<  95   p-> SetParentParticle(this);
 83   return (G4int)associatedParticleList.size(); <<  96   return associatedParticleList.size();
 84 }                                                  97 }
 85                                                    98 
 86 // ------------------------------------------- <<  99 /////////////////////////////////////////////////////
 87 G4int G4MCTSimParticle::GetNofAssociatedPartic << 100 int G4MCTSimParticle::GetNofAssociatedParticles() const
                                                   >> 101 /////////////////////////////////////////////////////
 88 {                                                 102 {
 89   return (G4int)associatedParticleList.size(); << 103   return associatedParticleList.size();
 90 }                                                 104 }
 91                                                   105 
 92 // ------------------------------------------- << 106 //////////////////////////////////////////////////////////////////
 93 G4MCTSimParticle* G4MCTSimParticle::GetAssocia << 107 G4MCTSimParticle* G4MCTSimParticle::GetAssociatedParticle(int i) const
                                                   >> 108 //////////////////////////////////////////////////////////////////
 94 {                                                 109 {
 95   G4int size = (G4int)associatedParticleList.s << 110   int size= associatedParticleList.size();
 96   if(i >= 0 && i < size)                       << 111   if(i>=0 && i< size) return associatedParticleList[i];
 97     return associatedParticleList[i];          << 112   else return 0;
 98   else                                         << 
 99     return nullptr;                            << 
100 }                                                 113 }
101                                                   114 
102 // ------------------------------------------- << 115 ////////////////////////////////////////
103 G4int G4MCTSimParticle::GetTreeLevel() const   << 116 int G4MCTSimParticle::GetTreeLevel() const
                                                   >> 117 ////////////////////////////////////////
104 {                                                 118 {
105   const G4MCTSimParticle* p = this;            << 119   const G4MCTSimParticle* p= this;
106   G4int nlevel;                                << 120   int nlevel;
107   for(nlevel = 1;; ++nlevel)                   << 121   for(nlevel=1;;nlevel++) {
108   {                                            << 122     p= p-> GetParentParticle();
109     p = p->GetParentParticle();                << 123     if(p==0) return nlevel;
110     if(p == nullptr)                           << 
111       return nlevel;                           << 
112   }                                               124   }
113 }                                                 125 }
114                                                   126 
115 // ------------------------------------------- << 127 /////////////////////////////////////////////////////
116 void G4MCTSimParticle::SetStoreFlagToParentTre    128 void G4MCTSimParticle::SetStoreFlagToParentTree(G4bool q)
                                                   >> 129 /////////////////////////////////////////////////////
117 {                                                 130 {
118   storeFlag = q;                               << 131   storeFlag=q;
119   if(vertex)                                   << 132   if(vertex) vertex-> SetStoreFlag(q);
120     vertex->SetStoreFlag(q);                   << 133   if(primaryFlag) return;
121   if(primaryFlag)                              << 134   if(parentParticle) parentParticle-> SetStoreFlagToParentTree(q);
122     return;                                    << 
123   if(parentParticle)                           << 
124     parentParticle->SetStoreFlagToParentTree(q << 
125 }                                                 135 }
126                                                   136 
127 // ------------------------------------------- << 137 
                                                   >> 138 //////////////////////////////////////////////////////////
128 void G4MCTSimParticle::PrintSingle(std::ostrea    139 void G4MCTSimParticle::PrintSingle(std::ostream& ostr) const
                                                   >> 140 //////////////////////////////////////////////////////////
129 {                                                 141 {
130   std::ostringstream os;                          142   std::ostringstream os;
131   char cqp = ' ';                              << 143   char cqp=' ';
132   if(storeFlag)                                << 144   if(storeFlag) cqp='+';
133     cqp = '+';                                 << 
134   os << cqp << trackID << '\0';                   145   os << cqp << trackID << '\0';
135   std::string stid(os.str());                     146   std::string stid(os.str());
136   ostr << std::setw(6) << stid;                   147   ostr << std::setw(6) << stid;
137   // ostr << std::setw(4) << trackID;          << 148   //ostr << std::setw(4) << trackID;
138                                                   149 
139   if(primaryFlag)                              << 150   if(primaryFlag) ostr << "*";
140     ostr << "*";                               << 151   else ostr << " ";
141   else                                         << 
142     ostr << " ";                               << 
143   ostr << "<" << std::setw(5) << parentTrackID    152   ostr << "<" << std::setw(5) << parentTrackID;
144   ostr.setf(std::ios::fixed);                     153   ostr.setf(std::ios::fixed);
145   ostr << ": P(" << std::setw(7) << std::setpr << 154   ostr << ": P(" 
146        << momentumAtVertex.x() / GeV << "," << << 155       << std::setw(7) << std::setprecision(3) << momentumAtVertex.x()/GeV 
147        << std::setprecision(3) << momentumAtVe << 156       << "," << std::setw(7) << std::setprecision(3) 
148        << std::setw(7) << std::setprecision(3) << 157       << momentumAtVertex.y()/GeV  
149        << "," << std::setw(7) << std::setpreci << 158       << "," << std::setw(7) << std::setprecision(3) 
150        << momentumAtVertex.e() / GeV << ") @"; << 159       << momentumAtVertex.z()/GeV 
                                                   >> 160       << "," << std::setw(7) << std::setprecision(3) 
                                                   >> 161       << momentumAtVertex.e()/GeV << ") @";
151   ostr << name << "(" << pdgID << ")";            162   ostr << name << "(" << pdgID << ")";
152                                                   163 
153   if(vertex != nullptr)                        << 164   if(vertex) {
154   {                                            << 165     ostr << " %" << vertex-> GetCreatorProcessName() << G4endl;
155     ostr << " %" << vertex->GetCreatorProcessN << 
156                                                   166 
157     std::ostringstream osv;                       167     std::ostringstream osv;
158     char cqv = ' ';                            << 168     char cqv=' ';
159     if(vertex->GetStoreFlag())                 << 169     if(vertex->GetStoreFlag()) cqv='+';
160       cqv = '+';                               << 170     osv << cqv << vertex-> GetID() << '\0';
161     osv << cqv << vertex->GetID() << '\0';     << 
162     std::string svid(osv.str());                  171     std::string svid(osv.str());
163     ostr << "       " << std::setw(6) << svid;    172     ostr << "       " << std::setw(6) << svid;
164     // ostr << "      " << std::setw(4) << ver << 173     //ostr << "      " << std::setw(4) << vertex-> GetID();
165     ostr.unsetf(std::ios::fixed);                 174     ostr.unsetf(std::ios::fixed);
166     ostr.setf(std::ios::scientific | std::ios: << 175     ostr.setf(std::ios::scientific|std::ios::right|std::ios::showpoint);
167     ostr << "- X(" << std::setw(9) << std::set << 176     ostr << "- X(" << std::setw(9) << std::setprecision(2) 
168          << vertex->GetPosition().x() / mm <<  << 177   << vertex-> GetPosition().x()/mm 
169          << std::setprecision(2) << vertex->Ge << 178   << "," << std::setw(9) << std::setprecision(2) 
170          << std::setw(9) << std::setprecision( << 179   << vertex-> GetPosition().y()/mm
171          << vertex->GetPosition().z() / mm <<  << 180   << "," << std::setw(9) << std::setprecision(2) 
172          << std::setprecision(2) << vertex->Ge << 181   << vertex-> GetPosition().z()/mm 
                                                   >> 182   << "," << std::setw(9) << std::setprecision(2) 
                                                   >> 183   << vertex-> GetTime()/ns << ")";
173     ostr.unsetf(std::ios::scientific);            184     ostr.unsetf(std::ios::scientific);
174                                                << 185     
175     ostr << " @" << vertex->GetVolumeName() << << 186     ostr << " @" << vertex-> GetVolumeName()
176   }                                            << 187   << "-" << vertex-> GetVolumeNumber();
                                                   >> 188   } 
177   ostr << G4endl;                                 189   ostr << G4endl;
                                                   >> 190   
178 }                                                 191 }
179                                                   192 
180 // ------------------------------------------- << 193 ////////////////////////////////////////////////////////////////////
181 void G4MCTSimParticle::Print(std::ostream& ost    194 void G4MCTSimParticle::Print(std::ostream& ostr, G4bool qrevorder) const
                                                   >> 195 ////////////////////////////////////////////////////////////////////
182 {                                                 196 {
183   PrintSingle(ostr);                              197   PrintSingle(ostr);
184                                                   198 
185   // recursively print associated particles       199   // recursively print associated particles
186   if(!qrevorder)                               << 200   if (!qrevorder) { // parent -> child
187   {  // parent -> child                        << 201     SimParticleList::const_iterator itr;
188     for(auto itr = associatedParticleList.cbeg << 202     for(itr= associatedParticleList.begin(); 
189         itr != associatedParticleList.cend();  << 203   itr!= associatedParticleList.end(); ++itr) {
190     {                                          << 204       (*itr)-> Print(ostr);
191       (*itr)->Print(ostr);                     << 
192     }                                             205     }
193   }                                            << 206   } else { // child -> parent
194   else                                         << 207     if(parentParticle) parentParticle-> Print(ostr, true);
195   {  // child -> parent                        << 
196     if(parentParticle)                         << 
197       parentParticle->Print(ostr, true);       << 
198   }                                               208   }
199 }                                                 209 }
200                                                   210