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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 /digits_hits/utils/src/G4ScoringProbe.cc (Version 11.3.0) and /digits_hits/utils/src/G4ScoringProbe.cc (Version 10.7.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 // G4ScoringProbe                              <<  26 //
 27 // ------------------------------------------- << 
 28                                                << 
 29 #include "G4ScoringProbe.hh"                       27 #include "G4ScoringProbe.hh"
 30                                                    28 
 31 #include "G4Box.hh"                                29 #include "G4Box.hh"
 32 #include "G4LogicalVolume.hh"                      30 #include "G4LogicalVolume.hh"
 33 #include "G4LogicalVolumeStore.hh"                 31 #include "G4LogicalVolumeStore.hh"
 34 #include "G4VPhysicalVolume.hh"                    32 #include "G4VPhysicalVolume.hh"
 35 #include "G4PVPlacement.hh"                        33 #include "G4PVPlacement.hh"
 36 #include "G4Region.hh"                             34 #include "G4Region.hh"
 37 #include "G4RegionStore.hh"                        35 #include "G4RegionStore.hh"
 38 #include "G4Threading.hh"                          36 #include "G4Threading.hh"
 39 #include "G4Material.hh"                           37 #include "G4Material.hh"
 40 #include "G4NistManager.hh"                        38 #include "G4NistManager.hh"
 41                                                    39 
 42 #include "G4MultiFunctionalDetector.hh"            40 #include "G4MultiFunctionalDetector.hh"
                                                   >>  41 #include "G4SDParticleFilter.hh"
 43 #include "G4VPrimitiveScorer.hh"                   42 #include "G4VPrimitiveScorer.hh"
 44                                                    43 
 45 #include "G4ScoringManager.hh"                     44 #include "G4ScoringManager.hh"
 46 #include "G4StatDouble.hh"                         45 #include "G4StatDouble.hh"
 47                                                    46 
 48 #include "G4SystemOfUnits.hh"                      47 #include "G4SystemOfUnits.hh"
 49 #include "G4VisAttributes.hh"                      48 #include "G4VisAttributes.hh"
 50                                                    49 
 51 #include "G4AutoLock.hh"                       <<  50 G4ScoringProbe::G4ScoringProbe(G4String lvName, G4double half_size, G4bool checkOverlap)
 52                                                <<  51   :G4VScoringMesh(lvName), chkOverlap(checkOverlap),
 53 namespace                                      <<  52    layeredMaterialName("none"), layeredMaterial(nullptr)
 54 {                                              << 
 55   G4Mutex logvolmutex = G4MUTEX_INITIALIZER;   << 
 56 }                                              << 
 57                                                << 
 58 G4ScoringProbe::G4ScoringProbe(const G4String& << 
 59                                G4bool checkOve << 
 60   : G4VScoringMesh(lvName)                     << 
 61   , chkOverlap(checkOverlap)                   << 
 62   , layeredMaterialName("none")                << 
 63   , layeredMaterial(nullptr)                   << 
 64 {                                                  53 {
 65   fShape        = MeshShape::probe;            <<  54   fShape = MeshShape::probe;
 66   logVolName    = lvName;                      <<  55   logVolName = lvName;
 67   probeSize     = half_size;                   <<  56   probeSize = half_size;
 68   G4double hs[] = { half_size, half_size, half <<  57   G4double hs[] = {half_size,half_size,half_size};
 69   SetSize(hs);                                     58   SetSize(hs);
 70   G4int nBin[] = { 1, 1, 1 };                  <<  59   G4int nBin[] = {1,1,1};
 71   SetNumberOfSegments(nBin);                       60   SetNumberOfSegments(nBin);
 72   regName = lvName + "_region";                    61   regName = lvName + "_region";
 73   if(G4Threading::IsMasterThread())                62   if(G4Threading::IsMasterThread())
 74   {                                            <<  63   { new G4Region(regName); }
 75     new G4Region(regName);                     <<  64 }
 76   }                                            <<  65 
                                                   >>  66 G4ScoringProbe::~G4ScoringProbe()
                                                   >>  67 {
 77 }                                                  68 }
 78                                                    69 
 79 void G4ScoringProbe::List() const                  70 void G4ScoringProbe::List() const
 80 {                                                  71 {
 81   G4cout << "G4ScoringProbe : " << logVolName      72   G4cout << "G4ScoringProbe : " << logVolName << G4endl;
 82   std::size_t np = posVec.size();              <<  73   G4int np = posVec.size();
 83   for(std::size_t i = 0; i < np; ++i)          <<  74   for(G4int i=0;i<np;i++)
 84   {                                            <<  75   { G4cout << " >> probe #" << i << " at " << posVec[i] << G4endl; }
 85     G4cout << " >> probe #" << i << " at " <<  << 
 86   }                                            << 
 87   G4VScoringMesh::List();                          76   G4VScoringMesh::List();
 88 }                                                  77 }
 89                                                    78 
 90 void G4ScoringProbe::SetupGeometry(G4VPhysical <<  79 #include "G4AutoLock.hh"
                                                   >>  80 namespace { G4Mutex logvolmutex = G4MUTEX_INITIALIZER; }
                                                   >>  81 
                                                   >>  82 void G4ScoringProbe::SetupGeometry(G4VPhysicalVolume* worldPhys) 
 91 {                                                  83 {
 92   if(G4Threading::IsMasterThread())                84   if(G4Threading::IsMasterThread())
 93   {                                                85   {
 94     auto worldLog = worldPhys->GetLogicalVolum     86     auto worldLog = worldPhys->GetLogicalVolume();
 95     auto region   = G4RegionStore::GetInstance <<  87     auto region = G4RegionStore::GetInstance()->GetRegion(regName);
 96     assert(region != nullptr);                 <<  88     assert(region!=nullptr);
 97     region->AddRootLogicalVolume(worldLog);        89     region->AddRootLogicalVolume(worldLog);
 98     region->SetWorld(worldPhys);                   90     region->SetWorld(worldPhys);
 99                                                    91 
100     auto boxSolid =                            <<  92     auto boxSolid = new G4Box(logVolName+"_solid",probeSize,probeSize,probeSize);
101       new G4Box(logVolName + "_solid", probeSi <<  93     fMeshElementLogical = new G4LogicalVolume(boxSolid,layeredMaterial,logVolName+"_log");
102     fMeshElementLogical =                      <<  94 
103       new G4LogicalVolume(boxSolid, layeredMat <<  95     G4int np = posVec.size();
104                                                <<  96     for(G4int i=0;i<np;i++)
105     std::size_t np = posVec.size();            <<  97     { new G4PVPlacement(0,posVec[i],fMeshElementLogical,logVolName+"_phy",worldLog,false,i,chkOverlap); }
106     for(std::size_t i = 0; i < np; ++i)        << 
107     {                                          << 
108       new G4PVPlacement(nullptr, posVec[i], fM << 
109                         worldLog, false, (G4in << 
110     }                                          << 
111                                                    98 
112     auto  wisatt = new G4VisAttributes(G4Colou <<  99     G4VisAttributes* wisatt = new G4VisAttributes(G4Colour(.5,.5,.5));
113     wisatt->SetVisibility(false);                 100     wisatt->SetVisibility(false);
114     worldLog->SetVisAttributes(wisatt);           101     worldLog->SetVisAttributes(wisatt);
115     auto  visatt = new G4VisAttributes(G4Colou << 102     G4VisAttributes* visatt = new G4VisAttributes(G4Colour(.5,.5,.5));
116     visatt->SetVisibility(true);                  103     visatt->SetVisibility(true);
117     fMeshElementLogical->SetVisAttributes(visa    104     fMeshElementLogical->SetVisAttributes(visatt);
118   }                                               105   }
119   else                                            106   else
120   {                                            << 107   { 
121     G4AutoLock l(&logvolmutex);                   108     G4AutoLock l(&logvolmutex);
122     fMeshElementLogical =                      << 109     fMeshElementLogical = G4LogicalVolumeStore::GetInstance()->GetVolume(logVolName,false);
123       G4LogicalVolumeStore::GetInstance()->Get << 110     assert(fMeshElementLogical!=nullptr);
124     assert(fMeshElementLogical != nullptr);    << 
125     l.unlock();                                   111     l.unlock();
126   }                                               112   }
127                                                   113 
128   fMeshElementLogical->SetSensitiveDetector(fM    114   fMeshElementLogical->SetSensitiveDetector(fMFD);
                                                   >> 115 
129 }                                                 116 }
130                                                   117 
131 G4bool G4ScoringProbe::SetMaterial(G4String va    118 G4bool G4ScoringProbe::SetMaterial(G4String val)
132 {                                                 119 {
                                                   >> 120   G4AutoLock l(&logvolmutex);
133   if(val == "none")                               121   if(val == "none")
134   {                                               122   {
135     layeredMaterialName = val;                    123     layeredMaterialName = val;
136     layeredMassFlg      = false;               << 124     layeredMassFlg = false;
137     layeredMaterial     = nullptr;             << 125     layeredMaterial = nullptr;
138   }                                               126   }
139   else                                            127   else
140   {                                               128   {
141     G4AutoLock l(&logvolmutex);                << 
142     auto mat = G4NistManager::Instance()->Find    129     auto mat = G4NistManager::Instance()->FindOrBuildMaterial(val);
143     if(mat == nullptr)                         << 130     if(!mat)
144     {                                          << 131     { return false; }
145       return false;                            << 
146     }                                          << 
147     layeredMaterialName = val;                    132     layeredMaterialName = val;
148     layeredMassFlg      = true;                << 133     layeredMassFlg = true;
149     layeredMaterial     = mat;                 << 134     layeredMaterial = mat;
150     if(G4Threading::IsMasterThread())          << 
151     {                                          << 
152       auto region = G4RegionStore::GetInstance << 
153       assert(region != nullptr);               << 
154       region->UpdateMaterialList();            << 
155     }                                          << 
156     l.unlock();                                << 
157   }                                               135   }
                                                   >> 136   auto region = G4RegionStore::GetInstance()->GetRegion(regName);
                                                   >> 137   assert(region!=nullptr);
                                                   >> 138   region->UpdateMaterialList();
158   return true;                                    139   return true;
159 }                                                 140 }
                                                   >> 141 
160                                                   142