Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/digits_hits/utils/src/G4VScoringMesh.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.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 /digits_hits/utils/src/G4VScoringMesh.cc (Version 11.3.0) and /digits_hits/utils/src/G4VScoringMesh.cc (Version 11.0.p4)


  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 // G4VScoringMesh                              <<  26 //
                                                   >>  27 //
                                                   >>  28 // ---------------------------------------------------------------------
                                                   >>  29 // Modifications
                                                   >>  30 // 17-Apr-2012 T.Aso SetSize() and SetNumberOfSegments() is not allowed
                                                   >>  31 //                   to call twice in same geometrical mesh. Add warning
                                                   >>  32 //                   message to notify.
                                                   >>  33 //
 27 // -------------------------------------------     34 // ---------------------------------------------------------------------
 28                                                    35 
 29 #include "G4VScoringMesh.hh"                       36 #include "G4VScoringMesh.hh"
 30 #include "G4THitsMap.hh"                           37 #include "G4THitsMap.hh"
 31 #include "G4SystemOfUnits.hh"                      38 #include "G4SystemOfUnits.hh"
 32 #include "G4VPhysicalVolume.hh"                    39 #include "G4VPhysicalVolume.hh"
 33 #include "G4MultiFunctionalDetector.hh"            40 #include "G4MultiFunctionalDetector.hh"
 34 #include "G4VPrimitiveScorer.hh"                   41 #include "G4VPrimitiveScorer.hh"
 35 #include "G4VSDFilter.hh"                          42 #include "G4VSDFilter.hh"
 36 #include "G4SDManager.hh"                          43 #include "G4SDManager.hh"
 37                                                    44 
 38 G4VScoringMesh::G4VScoringMesh(const G4String&     45 G4VScoringMesh::G4VScoringMesh(const G4String& wName)
 39   : fWorldName(wName)                              46   : fWorldName(wName)
 40   , fCurrentPS(nullptr)                            47   , fCurrentPS(nullptr)
 41   , fConstructed(false)                            48   , fConstructed(false)
 42   , fActive(true)                                  49   , fActive(true)
 43   , fShape(MeshShape::undefined)                   50   , fShape(MeshShape::undefined)
 44   , fRotationMatrix(nullptr)                       51   , fRotationMatrix(nullptr)
 45   , fMFD(new G4MultiFunctionalDetector(wName))     52   , fMFD(new G4MultiFunctionalDetector(wName))
 46   , verboseLevel(0)                                53   , verboseLevel(0)
 47   , sizeIsSet(false)                               54   , sizeIsSet(false)
 48   , nMeshIsSet(false)                              55   , nMeshIsSet(false)
 49   , fDrawUnit("")                                  56   , fDrawUnit("")
 50   , fDrawUnitValue(1.)                             57   , fDrawUnitValue(1.)
 51   , fMeshElementLogical(nullptr)                   58   , fMeshElementLogical(nullptr)
 52   , fParallelWorldProcess(nullptr)                 59   , fParallelWorldProcess(nullptr)
 53   , fGeometryHasBeenDestroyed(false)               60   , fGeometryHasBeenDestroyed(false)
 54   , copyNumberLevel(0)                             61   , copyNumberLevel(0)
 55   , layeredMassFlg(false)                          62   , layeredMassFlg(false)
 56 {                                                  63 {
 57   G4SDManager::GetSDMpointer()->AddNewDetector     64   G4SDManager::GetSDMpointer()->AddNewDetector(fMFD);
 58                                                    65 
 59   fSize[0] = fSize[1] = fSize[2] = 0.;             66   fSize[0] = fSize[1] = fSize[2] = 0.;
 60   fAngle[0]                      = 0.0;            67   fAngle[0]                      = 0.0;
 61   fAngle[1]                      = CLHEP::twop     68   fAngle[1]                      = CLHEP::twopi * rad;
 62   fNSegment[0] = fNSegment[1] = fNSegment[2] =     69   fNSegment[0] = fNSegment[1] = fNSegment[2] = 1;
 63   fDivisionAxisNames[0] = fDivisionAxisNames[1     70   fDivisionAxisNames[0] = fDivisionAxisNames[1] = fDivisionAxisNames[2] = "";
 64 }                                                  71 }
 65                                                    72 
                                                   >>  73 G4VScoringMesh::~G4VScoringMesh() { ; }
                                                   >>  74 
 66 void G4VScoringMesh::ResetScore()                  75 void G4VScoringMesh::ResetScore()
 67 {                                                  76 {
 68   if(verboseLevel > 9)                             77   if(verboseLevel > 9)
 69     G4cout << "G4VScoringMesh::ResetScore() is     78     G4cout << "G4VScoringMesh::ResetScore() is called." << G4endl;
 70   for(const auto& mp : fMap)                   <<  79   for(auto mp : fMap)
 71   {                                                80   {
 72     if(verboseLevel > 9)                           81     if(verboseLevel > 9)
 73       G4cout << "G4VScoringMesh::ResetScore()"     82       G4cout << "G4VScoringMesh::ResetScore()" << mp.first << G4endl;
 74     mp.second->clear();                            83     mp.second->clear();
 75   }                                                84   }
 76 }                                                  85 }
 77                                                    86 
 78 void G4VScoringMesh::SetSize(G4double size[3])     87 void G4VScoringMesh::SetSize(G4double size[3])
 79 {                                                  88 {
 80   if(!sizeIsSet)                                   89   if(!sizeIsSet)
 81   {                                                90   {
 82     sizeIsSet = true;                              91     sizeIsSet = true;
 83     for(G4int i = 0; i < 3; ++i)               <<  92     for(int i = 0; i < 3; i++)
 84     {                                              93     {
 85       fSize[i] = size[i];                          94       fSize[i] = size[i];
 86     }                                              95     }
 87   }                                                96   }
 88   else                                             97   else
 89   {                                                98   {
 90     G4String message = "   Mesh size has alrea     99     G4String message = "   Mesh size has already been set and it cannot be changed.\n";
 91     message += "  This method is ignored.";       100     message += "  This method is ignored.";
 92     G4Exception("G4VScoringMesh::SetSize()",      101     G4Exception("G4VScoringMesh::SetSize()",
 93                 "DigiHitsUtilsScoreVScoringMes    102                 "DigiHitsUtilsScoreVScoringMesh000", JustWarning, message);
 94   }                                               103   }
 95 }                                                 104 }
 96                                                << 
 97 G4ThreeVector G4VScoringMesh::GetSize() const     105 G4ThreeVector G4VScoringMesh::GetSize() const
 98 {                                                 106 {
 99   if(sizeIsSet)                                   107   if(sizeIsSet)
100     return G4ThreeVector(fSize[0], fSize[1], f    108     return G4ThreeVector(fSize[0], fSize[1], fSize[2]);
101   return G4ThreeVector(0., 0., 0.);            << 109   else
                                                   >> 110     return G4ThreeVector(0., 0., 0.);
102 }                                                 111 }
103                                                << 
104 void G4VScoringMesh::SetAngles(G4double startA    112 void G4VScoringMesh::SetAngles(G4double startAngle, G4double spanAngle)
105 {                                                 113 {
106   fAngle[0] = startAngle;                         114   fAngle[0] = startAngle;
107   fAngle[1] = spanAngle;                          115   fAngle[1] = spanAngle;
108 }                                                 116 }
109                                                   117 
110 void G4VScoringMesh::SetCenterPosition(G4doubl    118 void G4VScoringMesh::SetCenterPosition(G4double centerPosition[3])
111 {                                                 119 {
112   fCenterPosition =                               120   fCenterPosition =
113     G4ThreeVector(centerPosition[0], centerPos    121     G4ThreeVector(centerPosition[0], centerPosition[1], centerPosition[2]);
114 }                                                 122 }
115                                                << 
116 void G4VScoringMesh::SetNumberOfSegments(G4int    123 void G4VScoringMesh::SetNumberOfSegments(G4int nSegment[3])
117 {                                                 124 {
118   if(!nMeshIsSet || fShape == MeshShape::realW    125   if(!nMeshIsSet || fShape == MeshShape::realWorldLogVol ||
119      fShape == MeshShape::probe)                  126      fShape == MeshShape::probe)
120   {                                               127   {
121     for(G4int i = 0; i < 3; ++i)               << 128     for(int i = 0; i < 3; i++)
122       fNSegment[i] = nSegment[i];                 129       fNSegment[i] = nSegment[i];
123     nMeshIsSet = true;                            130     nMeshIsSet = true;
124   }                                               131   }
125   else                                            132   else
126   {                                               133   {
127     G4String message = "   Number of bins has     134     G4String message = "   Number of bins has already been set and it cannot be changed.\n";
128     message += "  This method is ignored.";       135     message += "  This method is ignored.";
129     G4Exception("G4VScoringMesh::SetNumberOfSe    136     G4Exception("G4VScoringMesh::SetNumberOfSegments()",
130                 "DigiHitsUtilsScoreVScoringMes    137                 "DigiHitsUtilsScoreVScoringMesh000", JustWarning, message);
131   }                                               138   }
132 }                                                 139 }
133                                                << 
134 void G4VScoringMesh::GetNumberOfSegments(G4int    140 void G4VScoringMesh::GetNumberOfSegments(G4int nSegment[3])
135 {                                                 141 {
136   for(G4int i = 0; i < 3; ++i)                 << 142   for(int i = 0; i < 3; i++)
137     nSegment[i] = fNSegment[i];                   143     nSegment[i] = fNSegment[i];
138 }                                                 144 }
139                                                << 
140 void G4VScoringMesh::RotateX(G4double delta)      145 void G4VScoringMesh::RotateX(G4double delta)
141 {                                                 146 {
142   if(fRotationMatrix == nullptr)               << 147   if(!fRotationMatrix)
143     fRotationMatrix = new G4RotationMatrix();     148     fRotationMatrix = new G4RotationMatrix();
144   fRotationMatrix->rotateX(delta);                149   fRotationMatrix->rotateX(delta);
145 }                                                 150 }
146                                                   151 
147 void G4VScoringMesh::RotateY(G4double delta)      152 void G4VScoringMesh::RotateY(G4double delta)
148 {                                                 153 {
149   if(fRotationMatrix == nullptr)               << 154   if(!fRotationMatrix)
150     fRotationMatrix = new G4RotationMatrix();     155     fRotationMatrix = new G4RotationMatrix();
151   fRotationMatrix->rotateY(delta);                156   fRotationMatrix->rotateY(delta);
152 }                                                 157 }
153                                                   158 
154 void G4VScoringMesh::RotateZ(G4double delta)      159 void G4VScoringMesh::RotateZ(G4double delta)
155 {                                                 160 {
156   if(fRotationMatrix == nullptr)               << 161   if(!fRotationMatrix)
157     fRotationMatrix = new G4RotationMatrix();     162     fRotationMatrix = new G4RotationMatrix();
158   fRotationMatrix->rotateZ(delta);                163   fRotationMatrix->rotateZ(delta);
159 }                                                 164 }
160                                                   165 
161 void G4VScoringMesh::SetPrimitiveScorer(G4VPri    166 void G4VScoringMesh::SetPrimitiveScorer(G4VPrimitiveScorer* prs)
162 {                                                 167 {
163   if(!ReadyForQuantity())                         168   if(!ReadyForQuantity())
164   {                                               169   {
165     G4cerr << "ERROR : G4VScoringMesh::SetPrim    170     G4cerr << "ERROR : G4VScoringMesh::SetPrimitiveScorer() : "
166            << prs->GetName()                      171            << prs->GetName()
167            << " does not yet have mesh size or    172            << " does not yet have mesh size or number of bins. Set them first."
168            << G4endl << "This Method is ignore    173            << G4endl << "This Method is ignored." << G4endl;
169     return;                                       174     return;
170   }                                               175   }
171   if(verboseLevel > 0)                            176   if(verboseLevel > 0)
172     G4cout << "G4VScoringMesh::SetPrimitiveSco    177     G4cout << "G4VScoringMesh::SetPrimitiveScorer() : " << prs->GetName()
173            << " is registered."                   178            << " is registered."
174            << " 3D size: (" << fNSegment[0] <<    179            << " 3D size: (" << fNSegment[0] << ", " << fNSegment[1] << ", "
175            << fNSegment[2] << ")" << G4endl;      180            << fNSegment[2] << ")" << G4endl;
176                                                   181 
177   prs->SetNijk(fNSegment[0], fNSegment[1], fNS    182   prs->SetNijk(fNSegment[0], fNSegment[1], fNSegment[2]);
178   fCurrentPS = prs;                               183   fCurrentPS = prs;
179   fMFD->RegisterPrimitive(prs);                   184   fMFD->RegisterPrimitive(prs);
180   auto  map =                                  << 185   G4THitsMap<G4StatDouble>* map =
181     new G4THitsMap<G4StatDouble>(fWorldName, p    186     new G4THitsMap<G4StatDouble>(fWorldName, prs->GetName());
182   fMap[prs->GetName()] = map;                     187   fMap[prs->GetName()] = map;
183 }                                                 188 }
184                                                   189 
185 void G4VScoringMesh::SetFilter(G4VSDFilter* fi    190 void G4VScoringMesh::SetFilter(G4VSDFilter* filter)
186 {                                                 191 {
187   if(fCurrentPS == nullptr)                    << 192   if(!fCurrentPS)
188   {                                               193   {
189     G4cerr << "ERROR : G4VScoringMesh::SetSDFi    194     G4cerr << "ERROR : G4VScoringMesh::SetSDFilter() : a quantity must be "
190               "defined first. This method is i    195               "defined first. This method is ignored."
191            << G4endl;                             196            << G4endl;
192     return;                                       197     return;
193   }                                               198   }
194   if(verboseLevel > 0)                            199   if(verboseLevel > 0)
195     G4cout << "G4VScoringMesh::SetFilter() : "    200     G4cout << "G4VScoringMesh::SetFilter() : " << filter->GetName()
196            << " is set to " << fCurrentPS->Get    201            << " is set to " << fCurrentPS->GetName() << G4endl;
197                                                   202 
198   G4VSDFilter* oldFilter = fCurrentPS->GetFilt    203   G4VSDFilter* oldFilter = fCurrentPS->GetFilter();
199   if(oldFilter != nullptr)                     << 204   if(oldFilter)
200   {                                               205   {
201     G4cout << "WARNING : G4VScoringMesh::SetFi    206     G4cout << "WARNING : G4VScoringMesh::SetFilter() : " << oldFilter->GetName()
202            << " is overwritten by " << filter-    207            << " is overwritten by " << filter->GetName() << G4endl;
203   }                                               208   }
204   fCurrentPS->SetFilter(filter);                  209   fCurrentPS->SetFilter(filter);
205 }                                                 210 }
206                                                   211 
207 void G4VScoringMesh::SetCurrentPrimitiveScorer    212 void G4VScoringMesh::SetCurrentPrimitiveScorer(const G4String& name)
208 {                                                 213 {
209   fCurrentPS = GetPrimitiveScorer(name);          214   fCurrentPS = GetPrimitiveScorer(name);
210   if(fCurrentPS == nullptr)                    << 215   if(!fCurrentPS)
211   {                                               216   {
212     G4cerr << "ERROR : G4VScoringMesh::SetCurr    217     G4cerr << "ERROR : G4VScoringMesh::SetCurrentPrimitiveScorer() : The "
213               "primitive scorer <"                218               "primitive scorer <"
214            << name << "> does not found." << G    219            << name << "> does not found." << G4endl;
215   }                                               220   }
216 }                                                 221 }
217                                                   222 
218 G4bool G4VScoringMesh::FindPrimitiveScorer(con    223 G4bool G4VScoringMesh::FindPrimitiveScorer(const G4String& psname)
219 {                                                 224 {
220   const auto itr = fMap.find(psname);          << 225   MeshScoreMap::iterator itr = fMap.find(psname);
221   return itr != fMap.cend();                   << 226   if(itr == fMap.end())
                                                   >> 227     return false;
                                                   >> 228   return true;
222 }                                                 229 }
223                                                   230 
224 G4String G4VScoringMesh::GetPSUnit(const G4Str    231 G4String G4VScoringMesh::GetPSUnit(const G4String& psname)
225 {                                                 232 {
226   const auto itr = fMap.find(psname);          << 233   MeshScoreMap::iterator itr = fMap.find(psname);
227   if(itr == fMap.cend())                       << 234   if(itr == fMap.end())
228   {                                               235   {
229     return G4String("");                          236     return G4String("");
230   }                                               237   }
231                                                << 238   else
232   return GetPrimitiveScorer(psname)->GetUnit() << 239   {
                                                   >> 240     return GetPrimitiveScorer(psname)->GetUnit();
                                                   >> 241   }
233 }                                                 242 }
234                                                   243 
235 G4String G4VScoringMesh::GetCurrentPSUnit()       244 G4String G4VScoringMesh::GetCurrentPSUnit()
236 {                                                 245 {
237   G4String unit = "";                             246   G4String unit = "";
238   if(fCurrentPS == nullptr)                    << 247   if(!fCurrentPS)
239   {                                               248   {
240     G4String msg = "ERROR : G4VScoringMesh::Ge    249     G4String msg = "ERROR : G4VScoringMesh::GetCurrentPSUnit() : ";
241     msg += " Current primitive scorer is null.    250     msg += " Current primitive scorer is null.";
242     G4cerr << msg << G4endl;                      251     G4cerr << msg << G4endl;
243   }                                               252   }
244   else                                            253   else
245   {                                               254   {
246     unit = fCurrentPS->GetUnit();                 255     unit = fCurrentPS->GetUnit();
247   }                                               256   }
248   return unit;                                    257   return unit;
249 }                                                 258 }
250                                                   259 
251 void G4VScoringMesh::SetCurrentPSUnit(const G4    260 void G4VScoringMesh::SetCurrentPSUnit(const G4String& unit)
252 {                                                 261 {
253   if(fCurrentPS == nullptr)                    << 262   if(!fCurrentPS)
254   {                                               263   {
255     G4String msg = "ERROR : G4VScoringMesh::Ge    264     G4String msg = "ERROR : G4VScoringMesh::GetCurrentPSUnit() : ";
256     msg += " Current primitive scorer is null.    265     msg += " Current primitive scorer is null.";
257     G4cerr << msg << G4endl;                      266     G4cerr << msg << G4endl;
258   }                                               267   }
259   else                                            268   else
260   {                                               269   {
261     fCurrentPS->SetUnit(unit);                    270     fCurrentPS->SetUnit(unit);
262   }                                               271   }
263 }                                                 272 }
264                                                   273 
265 G4double G4VScoringMesh::GetPSUnitValue(const     274 G4double G4VScoringMesh::GetPSUnitValue(const G4String& psname)
266 {                                                 275 {
267   const auto itr = fMap.find(psname);          << 276   MeshScoreMap::iterator itr = fMap.find(psname);
268   if(itr == fMap.cend())                       << 277   if(itr == fMap.end())
269   {                                               278   {
270     return 1.;                                    279     return 1.;
271   }                                               280   }
272                                                << 281   else
273   return GetPrimitiveScorer(psname)->GetUnitVa << 282   {
                                                   >> 283     return GetPrimitiveScorer(psname)->GetUnitValue();
                                                   >> 284   }
274 }                                                 285 }
275                                                   286 
276 void G4VScoringMesh::GetDivisionAxisNames(G4St    287 void G4VScoringMesh::GetDivisionAxisNames(G4String divisionAxisNames[3])
277 {                                                 288 {
278   for(G4int i = 0; i < 3; ++i)                 << 289   for(int i = 0; i < 3; i++)
279     divisionAxisNames[i] = fDivisionAxisNames[    290     divisionAxisNames[i] = fDivisionAxisNames[i];
280 }                                                 291 }
281                                                   292 
282 G4VPrimitiveScorer* G4VScoringMesh::GetPrimiti    293 G4VPrimitiveScorer* G4VScoringMesh::GetPrimitiveScorer(const G4String& name)
283 {                                                 294 {
284   if(fMFD == nullptr)                          << 295   if(!fMFD)
285     return nullptr;                               296     return nullptr;
286                                                   297 
287   G4int nps = fMFD->GetNumberOfPrimitives();      298   G4int nps = fMFD->GetNumberOfPrimitives();
288   for(G4int i = 0; i < nps; ++i)               << 299   for(G4int i = 0; i < nps; i++)
289   {                                               300   {
290     G4VPrimitiveScorer* prs = fMFD->GetPrimiti    301     G4VPrimitiveScorer* prs = fMFD->GetPrimitive(i);
291     if(name == prs->GetName())                    302     if(name == prs->GetName())
292       return prs;                                 303       return prs;
293   }                                               304   }
294                                                   305 
295   return nullptr;                                 306   return nullptr;
296 }                                                 307 }
297                                                << 
298 void G4VScoringMesh::List() const                 308 void G4VScoringMesh::List() const
299 {                                                 309 {
300   G4cout << " # of segments: (" << fNSegment[0    310   G4cout << " # of segments: (" << fNSegment[0] << ", " << fNSegment[1] << ", "
301          << fNSegment[2] << ")" << G4endl;        311          << fNSegment[2] << ")" << G4endl;
302   G4cout << " displacement: (" << fCenterPosit    312   G4cout << " displacement: (" << fCenterPosition.x() / cm << ", "
303          << fCenterPosition.y() / cm << ", " <    313          << fCenterPosition.y() / cm << ", " << fCenterPosition.z() / cm
304          << ") [cm]" << G4endl;                   314          << ") [cm]" << G4endl;
305   if(fRotationMatrix != nullptr)               << 315   if(fRotationMatrix != 0)
306   {                                               316   {
307     G4cout << " rotation matrix: " << fRotatio    317     G4cout << " rotation matrix: " << fRotationMatrix->xx() << "  "
308            << fRotationMatrix->xy() << "  " <<    318            << fRotationMatrix->xy() << "  " << fRotationMatrix->xz() << G4endl
309            << "                  " << fRotatio    319            << "                  " << fRotationMatrix->yx() << "  "
310            << fRotationMatrix->yy() << "  " <<    320            << fRotationMatrix->yy() << "  " << fRotationMatrix->yz() << G4endl
311            << "                  " << fRotatio    321            << "                  " << fRotationMatrix->zx() << "  "
312            << fRotationMatrix->zy() << "  " <<    322            << fRotationMatrix->zy() << "  " << fRotationMatrix->zz() << G4endl;
313   }                                               323   }
314                                                   324 
315   G4cout << " registered primitve scorers : "     325   G4cout << " registered primitve scorers : " << G4endl;
316   G4int nps = fMFD->GetNumberOfPrimitives();      326   G4int nps = fMFD->GetNumberOfPrimitives();
317   G4VPrimitiveScorer* prs;                        327   G4VPrimitiveScorer* prs;
318   for(G4int i = 0; i < nps; ++i)               << 328   for(int i = 0; i < nps; i++)
319   {                                               329   {
320     prs = fMFD->GetPrimitive(i);                  330     prs = fMFD->GetPrimitive(i);
321     G4cout << "   " << i << "  " << prs->GetNa    331     G4cout << "   " << i << "  " << prs->GetName();
322     if(prs->GetFilter() != nullptr)            << 332     if(prs->GetFilter() != 0)
323       G4cout << "     with  " << prs->GetFilte    333       G4cout << "     with  " << prs->GetFilter()->GetName();
324     G4cout << G4endl;                             334     G4cout << G4endl;
325   }                                               335   }
326 }                                                 336 }
327                                                   337 
328 void G4VScoringMesh::Dump()                       338 void G4VScoringMesh::Dump()
329 {                                                 339 {
330   G4cout << "scoring mesh name: " << fWorldNam    340   G4cout << "scoring mesh name: " << fWorldName << G4endl;
331   G4cout << "# of G4THitsMap : " << fMap.size(    341   G4cout << "# of G4THitsMap : " << fMap.size() << G4endl;
332   for(const auto& mp : fMap)                   << 342   for(auto mp : fMap)
333   {                                               343   {
334     G4cout << "[" << mp.first << "]" << G4endl    344     G4cout << "[" << mp.first << "]" << G4endl;
335     mp.second->PrintAllHits();                    345     mp.second->PrintAllHits();
336   }                                               346   }
337   G4cout << G4endl;                               347   G4cout << G4endl;
338 }                                                 348 }
339                                                   349 
340 void G4VScoringMesh::DrawMesh(const G4String&     350 void G4VScoringMesh::DrawMesh(const G4String& psName,
341                               G4VScoreColorMap    351                               G4VScoreColorMap* colorMap, G4int axflg)
342 {                                                 352 {
343   fDrawPSName = psName;                        << 353   fDrawPSName                          = psName;
344   const auto fMapItr = fMap.find(psName);      << 354   MeshScoreMap::const_iterator fMapItr = fMap.find(psName);
345   if(fMapItr != fMap.cend())                   << 355   if(fMapItr != fMap.end())
346   {                                               356   {
347     fDrawUnit      = GetPSUnit(psName);           357     fDrawUnit      = GetPSUnit(psName);
348     fDrawUnitValue = GetPSUnitValue(psName);      358     fDrawUnitValue = GetPSUnitValue(psName);
349     Draw(fMapItr->second, colorMap, axflg);       359     Draw(fMapItr->second, colorMap, axflg);
350   }                                               360   }
351   else                                            361   else
352   {                                               362   {
353     G4cerr << "Scorer <" << psName << "> is no    363     G4cerr << "Scorer <" << psName << "> is not defined. Method ignored."
354            << G4endl;                             364            << G4endl;
355   }                                               365   }
356 }                                                 366 }
357                                                   367 
358 void G4VScoringMesh::DrawMesh(const G4String&     368 void G4VScoringMesh::DrawMesh(const G4String& psName, G4int idxPlane,
359                               G4int iColumn, G    369                               G4int iColumn, G4VScoreColorMap* colorMap)
360 {                                                 370 {
361   fDrawPSName = psName;                        << 371   fDrawPSName                          = psName;
362   const auto fMapItr = fMap.find(psName);      << 372   MeshScoreMap::const_iterator fMapItr = fMap.find(psName);
363   if(fMapItr != fMap.cend())                   << 373   if(fMapItr != fMap.end())
364   {                                               374   {
365     fDrawUnit      = GetPSUnit(psName);           375     fDrawUnit      = GetPSUnit(psName);
366     fDrawUnitValue = GetPSUnitValue(psName);      376     fDrawUnitValue = GetPSUnitValue(psName);
367     DrawColumn(fMapItr->second, colorMap, idxP    377     DrawColumn(fMapItr->second, colorMap, idxPlane, iColumn);
368   }                                               378   }
369   else                                            379   else
370   {                                               380   {
371     G4cerr << "Scorer <" << psName << "> is no    381     G4cerr << "Scorer <" << psName << "> is not defined. Method ignored."
372            << G4endl;                             382            << G4endl;
373   }                                               383   }
374 }                                                 384 }
375                                                   385 
376 void G4VScoringMesh::Accumulate(G4THitsMap<G4d    386 void G4VScoringMesh::Accumulate(G4THitsMap<G4double>* map)
377 {                                                 387 {
378   G4String psName = map->GetName();            << 388   G4String psName                      = map->GetName();
379   const auto fMapItr = fMap.find(psName);      << 389   MeshScoreMap::const_iterator fMapItr = fMap.find(psName);
380   if (fMapItr != fMap.cend())  { *(fMapItr->se << 390   *(fMapItr->second) += *map;
381                                                   391 
382   if(verboseLevel > 9)                            392   if(verboseLevel > 9)
383   {                                               393   {
384     G4cout << G4endl;                             394     G4cout << G4endl;
385     G4cout << "G4VScoringMesh::Accumulate()" <    395     G4cout << "G4VScoringMesh::Accumulate()" << G4endl;
386     G4cout << "  PS name : " << psName << G4en    396     G4cout << "  PS name : " << psName << G4endl;
387     if(fMapItr == fMap.cend())                 << 397     if(fMapItr == fMap.end())
388     {                                             398     {
389       G4cout << "  " << psName << " was not fo    399       G4cout << "  " << psName << " was not found." << G4endl;
390     }                                             400     }
391     else                                          401     else
392     {                                             402     {
393       G4cout << "  map size : " << map->GetSiz    403       G4cout << "  map size : " << map->GetSize() << G4endl;
394       map->PrintAllHits();                        404       map->PrintAllHits();
395     }                                             405     }
396     G4cout << G4endl;                             406     G4cout << G4endl;
397   }                                               407   }
398 }                                                 408 }
399                                                   409 
400 void G4VScoringMesh::Accumulate(G4THitsMap<G4S    410 void G4VScoringMesh::Accumulate(G4THitsMap<G4StatDouble>* map)
401 {                                                 411 {
402   G4String psName = map->GetName();            << 412   G4String psName                      = map->GetName();
403   const auto fMapItr = fMap.find(psName);      << 413   MeshScoreMap::const_iterator fMapItr = fMap.find(psName);
404   if (fMapItr != fMap.cend()) { *(fMapItr->sec << 414   *(fMapItr->second) += *map;
405                                                   415 
406   if(verboseLevel > 9)                            416   if(verboseLevel > 9)
407   {                                               417   {
408     G4cout << G4endl;                             418     G4cout << G4endl;
409     G4cout << "G4VScoringMesh::Accumulate()" <    419     G4cout << "G4VScoringMesh::Accumulate()" << G4endl;
410     G4cout << "  PS name : " << psName << G4en    420     G4cout << "  PS name : " << psName << G4endl;
411     if(fMapItr == fMap.cend())                 << 421     if(fMapItr == fMap.end())
412     {                                             422     {
413       G4cout << "  " << psName << " was not fo    423       G4cout << "  " << psName << " was not found." << G4endl;
414     }                                             424     }
415     else                                          425     else
416     {                                             426     {
417       G4cout << "  map size : " << map->GetSiz    427       G4cout << "  map size : " << map->GetSize() << G4endl;
418       map->PrintAllHits();                        428       map->PrintAllHits();
419     }                                             429     }
420     G4cout << G4endl;                             430     G4cout << G4endl;
421   }                                               431   }
422 }                                                 432 }
423                                                   433 
424 void G4VScoringMesh::Construct(G4VPhysicalVolu    434 void G4VScoringMesh::Construct(G4VPhysicalVolume* fWorldPhys)
425 {                                                 435 {
426   if(fConstructed)                                436   if(fConstructed)
427   {                                               437   {
428     if(fGeometryHasBeenDestroyed)                 438     if(fGeometryHasBeenDestroyed)
429     {                                             439     {
430       SetupGeometry(fWorldPhys);                  440       SetupGeometry(fWorldPhys);
431       fGeometryHasBeenDestroyed = false;          441       fGeometryHasBeenDestroyed = false;
432     }                                             442     }
433     if(verboseLevel > 0)                          443     if(verboseLevel > 0)
434       G4cout << fWorldName << " --- All quanti    444       G4cout << fWorldName << " --- All quantities are reset." << G4endl;
435     ResetScore();                                 445     ResetScore();
436   }                                               446   }
437   else                                            447   else
438   {                                               448   {
439     fConstructed = true;                          449     fConstructed = true;
440     SetupGeometry(fWorldPhys);                    450     SetupGeometry(fWorldPhys);
441   }                                               451   }
442 }                                                 452 }
443                                                   453 
444 void G4VScoringMesh::WorkerConstruct(G4VPhysic    454 void G4VScoringMesh::WorkerConstruct(G4VPhysicalVolume* fWorldPhys)
445 {                                                 455 {
446   if(fConstructed)                                456   if(fConstructed)
447   {                                               457   {
448     if(fGeometryHasBeenDestroyed)                 458     if(fGeometryHasBeenDestroyed)
449     {                                             459     {
450       fMeshElementLogical->SetSensitiveDetecto    460       fMeshElementLogical->SetSensitiveDetector(fMFD);
451       fGeometryHasBeenDestroyed = false;          461       fGeometryHasBeenDestroyed = false;
452     }                                             462     }
453                                                   463 
454     if(verboseLevel > 0)                          464     if(verboseLevel > 0)
455       G4cout << fWorldPhys->GetName() << " ---    465       G4cout << fWorldPhys->GetName() << " --- All quantities are reset."
456              << G4endl;                           466              << G4endl;
457     ResetScore();                                 467     ResetScore();
458   }                                               468   }
459   else                                            469   else
460   {                                               470   {
461     fConstructed = true;                          471     fConstructed = true;
462     fMeshElementLogical->SetSensitiveDetector(    472     fMeshElementLogical->SetSensitiveDetector(fMFD);
463   }                                               473   }
464 }                                                 474 }
465                                                   475 
466 void G4VScoringMesh::Merge(const G4VScoringMes    476 void G4VScoringMesh::Merge(const G4VScoringMesh* scMesh)
467 {                                                 477 {
468   const MeshScoreMap scMap = scMesh->GetScoreM    478   const MeshScoreMap scMap = scMesh->GetScoreMap();
469                                                   479 
470   auto fMapItr = fMap.cbegin();                << 480   MeshScoreMap::const_iterator fMapItr = fMap.begin();
471   auto mapItr  = scMap.cbegin();               << 481   MeshScoreMap::const_iterator mapItr  = scMap.begin();
472   for(; fMapItr != fMap.cend(); ++fMapItr)     << 482   for(; fMapItr != fMap.end(); fMapItr++)
473   {                                               483   {
474     if(verboseLevel > 9)                          484     if(verboseLevel > 9)
475       G4cout << "G4VScoringMesh::Merge()" << f    485       G4cout << "G4VScoringMesh::Merge()" << fMapItr->first << G4endl;
476     *(fMapItr->second) += *(mapItr->second);      486     *(fMapItr->second) += *(mapItr->second);
477     ++mapItr;                                  << 487     mapItr++;
478   }                                               488   }
479 }                                                 489 }
480                                                   490