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