Geant4 Cross Reference |
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 // 26 // 27 27 28 #include "G4MoleculeCounter.hh" 28 #include "G4MoleculeCounter.hh" 29 << 30 #include "G4MolecularConfiguration.hh" << 31 #include "G4MoleculeDefinition.hh" << 32 #include "G4MoleculeTable.hh" 29 #include "G4MoleculeTable.hh" 33 #include "G4Scheduler.hh" // TODO: remove this << 34 #include "G4SystemOfUnits.hh" << 35 #include "G4UIcommand.hh" 30 #include "G4UIcommand.hh" 36 #include "G4UnitsTable.hh" 31 #include "G4UnitsTable.hh" 37 << 32 #include "G4MolecularConfiguration.hh" >> 33 #include "G4MoleculeDefinition.hh" >> 34 #include "G4SystemOfUnits.hh" >> 35 #include "G4Scheduler.hh" // TODO: remove this dependency 38 #include <iomanip> 36 #include <iomanip> 39 #include <memory> << 40 37 41 using namespace std; 38 using namespace std; 42 39 43 namespace G4{ 40 namespace G4{ 44 namespace MoleculeCounter { 41 namespace MoleculeCounter { 45 42 46 bool TimePrecision::operator()(const double& a 43 bool TimePrecision::operator()(const double& a, const double& b) const 47 { 44 { 48 if (std::fabs(a - b) < fPrecision) 45 if (std::fabs(a - b) < fPrecision) 49 { 46 { 50 return false; 47 return false; 51 } 48 } 52 << 49 else 53 return a < b; << 50 { >> 51 return a < b; >> 52 } 54 } 53 } 55 54 56 G4ThreadLocal double TimePrecision::fPrecision 55 G4ThreadLocal double TimePrecision::fPrecision = 0.5 * picosecond; 57 } 56 } 58 } 57 } 59 58 60 //-------------------------------------------- 59 //------------------------------------------------------------------------------ 61 G4MoleculeCounter* G4MoleculeCounter::Instance 60 G4MoleculeCounter* G4MoleculeCounter::Instance() 62 { 61 { 63 if (fpInstance == nullptr) << 62 if (!fpInstance) 64 { 63 { 65 fpInstance = new G4MoleculeCounter(); 64 fpInstance = new G4MoleculeCounter(); 66 } 65 } 67 return dynamic_cast<G4MoleculeCounter*>(fp 66 return dynamic_cast<G4MoleculeCounter*>(fpInstance); 68 } 67 } 69 68 70 //-------------------------------------------- 69 //------------------------------------------------------------------------------ 71 70 72 G4MoleculeCounter::G4MoleculeCounter() 71 G4MoleculeCounter::G4MoleculeCounter() 73 { 72 { 74 fVerbose = 0; 73 fVerbose = 0; 75 fCheckTimeIsConsistentWithScheduler = true 74 fCheckTimeIsConsistentWithScheduler = true; 76 } 75 } 77 76 78 //-------------------------------------------- 77 //------------------------------------------------------------------------------ 79 78 80 G4MoleculeCounter::~G4MoleculeCounter() = defa 79 G4MoleculeCounter::~G4MoleculeCounter() = default; 81 80 82 //-------------------------------------------- 81 //------------------------------------------------------------------------------ 83 82 84 void G4MoleculeCounter::Initialize() 83 void G4MoleculeCounter::Initialize() 85 { 84 { 86 auto mol_iterator = G4MoleculeTable::Insta 85 auto mol_iterator = G4MoleculeTable::Instance()->GetConfigurationIterator(); 87 while ((mol_iterator)()) 86 while ((mol_iterator)()) 88 { 87 { 89 if (!IsRegistered(mol_iterator.value() << 88 if (IsRegistered(mol_iterator.value()->GetDefinition()) == false) 90 { 89 { 91 continue; 90 continue; 92 } 91 } 93 92 94 fCounterMap[mol_iterator.value()]; // 93 fCounterMap[mol_iterator.value()]; // initialize the second map 95 } 94 } 96 } 95 } 97 96 98 //-------------------------------------------- 97 //------------------------------------------------------------------------------ 99 98 100 void G4MoleculeCounter::SetTimeSlice(double ti 99 void G4MoleculeCounter::SetTimeSlice(double timeSlice) 101 { 100 { 102 G4::MoleculeCounter::TimePrecision::fPreci 101 G4::MoleculeCounter::TimePrecision::fPrecision = timeSlice; 103 } 102 } 104 103 105 //-------------------------------------------- 104 //------------------------------------------------------------------------------ 106 105 107 G4bool G4MoleculeCounter::SearchTimeMap(Reacta 106 G4bool G4MoleculeCounter::SearchTimeMap(Reactant* molecule) 108 { 107 { 109 if (fpLastSearch == nullptr) 108 if (fpLastSearch == nullptr) 110 { 109 { 111 fpLastSearch = std::make_unique<Search << 110 fpLastSearch.reset(new Search()); 112 } 111 } 113 else 112 else 114 { 113 { 115 if (fpLastSearch->fLowerBoundSet && 114 if (fpLastSearch->fLowerBoundSet && 116 fpLastSearch->fLastMoleculeSearche 115 fpLastSearch->fLastMoleculeSearched->first == molecule) 117 { 116 { 118 return true; 117 return true; 119 } 118 } 120 } 119 } 121 120 122 auto mol_it = fCounterMap.find(molecule); 121 auto mol_it = fCounterMap.find(molecule); 123 fpLastSearch->fLastMoleculeSearched = mol_ 122 fpLastSearch->fLastMoleculeSearched = mol_it; 124 123 125 if (mol_it != fCounterMap.end()) 124 if (mol_it != fCounterMap.end()) 126 { 125 { 127 fpLastSearch->fLowerBoundTime = fpLast 126 fpLastSearch->fLowerBoundTime = fpLastSearch->fLastMoleculeSearched->second 128 .end(); 127 .end(); 129 fpLastSearch->fLowerBoundSet = true; 128 fpLastSearch->fLowerBoundSet = true; 130 } 129 } 131 else 130 else 132 { 131 { 133 fpLastSearch->fLowerBoundSet = false; 132 fpLastSearch->fLowerBoundSet = false; 134 } 133 } 135 134 136 return false; 135 return false; 137 } 136 } 138 137 139 //-------------------------------------------- 138 //------------------------------------------------------------------------------ 140 139 141 int G4MoleculeCounter::SearchUpperBoundTime(do 140 int G4MoleculeCounter::SearchUpperBoundTime(double time, 142 bo 141 bool sameTypeOfMolecule) 143 { 142 { 144 auto mol_it = fpLastSearch->fLastMoleculeS 143 auto mol_it = fpLastSearch->fLastMoleculeSearched; 145 if (mol_it == fCounterMap.end()) 144 if (mol_it == fCounterMap.end()) 146 { 145 { 147 return 0; 146 return 0; 148 } 147 } 149 148 150 NbMoleculeAgainstTime& timeMap = mol_it->s 149 NbMoleculeAgainstTime& timeMap = mol_it->second; 151 if (timeMap.empty()) 150 if (timeMap.empty()) 152 { 151 { 153 return 0; 152 return 0; 154 } 153 } 155 154 156 if (sameTypeOfMolecule) << 155 if (sameTypeOfMolecule == true) 157 { 156 { 158 if (fpLastSearch->fLowerBoundSet && fp 157 if (fpLastSearch->fLowerBoundSet && fpLastSearch->fLowerBoundTime != timeMap.end()) 159 { 158 { 160 if (fpLastSearch->fLowerBoundTime- 159 if (fpLastSearch->fLowerBoundTime->first < time) 161 { 160 { 162 auto upperToLast = fpLastSearc 161 auto upperToLast = fpLastSearch->fLowerBoundTime; 163 upperToLast++; 162 upperToLast++; 164 163 165 if (upperToLast == timeMap.end 164 if (upperToLast == timeMap.end()) 166 { 165 { 167 return fpLastSearch->fLowe 166 return fpLastSearch->fLowerBoundTime->second; 168 } 167 } 169 168 170 if (upperToLast->first > time) 169 if (upperToLast->first > time) 171 { 170 { 172 return fpLastSearch->fLowe 171 return fpLastSearch->fLowerBoundTime->second; 173 } 172 } 174 } 173 } 175 } 174 } 176 } 175 } 177 176 178 auto up_time_it = timeMap.upper_bound(time 177 auto up_time_it = timeMap.upper_bound(time); 179 178 180 if (up_time_it == timeMap.end()) 179 if (up_time_it == timeMap.end()) 181 { 180 { 182 auto last_time = timeMap.rbegin(); << 181 NbMoleculeAgainstTime::reverse_iterator last_time = timeMap.rbegin(); 183 return last_time->second; 182 return last_time->second; 184 } 183 } 185 if (up_time_it == timeMap.begin()) 184 if (up_time_it == timeMap.begin()) 186 { 185 { 187 return 0; 186 return 0; 188 } 187 } 189 188 190 up_time_it--; 189 up_time_it--; 191 190 192 fpLastSearch->fLowerBoundTime = up_time_it 191 fpLastSearch->fLowerBoundTime = up_time_it; 193 fpLastSearch->fLowerBoundSet = true; 192 fpLastSearch->fLowerBoundSet = true; 194 193 195 return fpLastSearch->fLowerBoundTime->seco 194 return fpLastSearch->fLowerBoundTime->second; 196 } 195 } 197 196 198 //-------------------------------------------- 197 //------------------------------------------------------------------------------ 199 198 200 int G4MoleculeCounter::GetNMoleculesAtTime(Rea 199 int G4MoleculeCounter::GetNMoleculesAtTime(Reactant* molecule, 201 dou 200 double time) 202 { 201 { 203 G4bool sameTypeOfMolecule = SearchTimeMap( 202 G4bool sameTypeOfMolecule = SearchTimeMap(molecule); 204 return SearchUpperBoundTime(time, sameType 203 return SearchUpperBoundTime(time, sameTypeOfMolecule); 205 } 204 } 206 205 207 //-------------------------------------------- 206 //------------------------------------------------------------------------------ 208 207 209 void G4MoleculeCounter::AddAMoleculeAtTime(Rea 208 void G4MoleculeCounter::AddAMoleculeAtTime(Reactant* molecule, 210 G4d 209 G4double time, 211 con 210 const G4ThreeVector* /*position*/, 212 int 211 int number) 213 { 212 { 214 if (fDontRegister[molecule->GetDefinition( 213 if (fDontRegister[molecule->GetDefinition()]) 215 { 214 { 216 return; 215 return; 217 } 216 } 218 217 219 if (fVerbose != 0) << 218 if (fVerbose) 220 { 219 { 221 G4cout << "G4MoleculeCounter::AddAMole 220 G4cout << "G4MoleculeCounter::AddAMoleculeAtTime : " << molecule->GetName() 222 << " at time : " << G4BestUnit( 221 << " at time : " << G4BestUnit(time, "Time") << G4endl; 223 } 222 } 224 223 225 auto counterMap_i = fCounterMap.find(molec 224 auto counterMap_i = fCounterMap.find(molecule); 226 225 227 if (counterMap_i == fCounterMap.end()) 226 if (counterMap_i == fCounterMap.end()) 228 { 227 { 229 fCounterMap[molecule][time] = number; 228 fCounterMap[molecule][time] = number; 230 } 229 } 231 else if (counterMap_i->second.empty()) 230 else if (counterMap_i->second.empty()) 232 { 231 { 233 counterMap_i->second[time] = number; 232 counterMap_i->second[time] = number; 234 } 233 } 235 else 234 else 236 { 235 { 237 auto end = counterMap_i->second.rbegin << 236 NbMoleculeAgainstTime::reverse_iterator end = counterMap_i->second.rbegin(); 238 237 239 if (end->first <= time || 238 if (end->first <= time || 240 fabs(end->first - time) <= G4::Mol 239 fabs(end->first - time) <= G4::MoleculeCounter::TimePrecision::fPrecision) 241 // Case 1 = new time comes after l 240 // Case 1 = new time comes after last recorded data 242 // Case 2 = new time is about the 241 // Case 2 = new time is about the same as the last recorded one 243 { 242 { 244 double newValue = end->second + nu 243 double newValue = end->second + number; 245 counterMap_i->second[time] = newVa 244 counterMap_i->second[time] = newValue; 246 } 245 } 247 else 246 else 248 { 247 { 249 // if(fabs(time - G4Scheduler 248 // if(fabs(time - G4Scheduler::Instance()->GetGlobalTime()) > 250 // G4Scheduler::Instance() 249 // G4Scheduler::Instance()->GetTimeTolerance()) 251 { 250 { 252 G4ExceptionDescription errMsg; 251 G4ExceptionDescription errMsg; 253 errMsg << "Time of species " 252 errMsg << "Time of species " 254 << molecule->GetName() 253 << molecule->GetName() << " is " 255 << G4BestUnit(time, "Ti 254 << G4BestUnit(time, "Time") << " while " 256 << " global time is " 255 << " global time is " 257 << G4BestUnit(G4Schedul 256 << G4BestUnit(G4Scheduler::Instance()->GetGlobalTime(), "Time") 258 << G4endl; 257 << G4endl; 259 G4Exception("G4MoleculeCounter 258 G4Exception("G4MoleculeCounter::AddAMoleculeAtTime", 260 "TIME_DONT_MATCH", 259 "TIME_DONT_MATCH", 261 FatalException, er 260 FatalException, errMsg); 262 } 261 } 263 } 262 } 264 } 263 } 265 } 264 } 266 265 267 //-------------------------------------------- 266 //------------------------------------------------------------------------------ 268 267 269 void G4MoleculeCounter::RemoveAMoleculeAtTime( 268 void G4MoleculeCounter::RemoveAMoleculeAtTime(const G4MolecularConfiguration* pMolecule, 270 269 G4double time, 271 270 const G4ThreeVector* /*position*/, 272 271 int number) 273 { 272 { 274 if (fDontRegister[pMolecule->GetDefinition 273 if (fDontRegister[pMolecule->GetDefinition()]) 275 { 274 { 276 return; 275 return; 277 } 276 } 278 277 279 if (fVerbose != 0) << 278 if (fVerbose) 280 { 279 { 281 G4cout << "G4MoleculeCounter::RemoveAM 280 G4cout << "G4MoleculeCounter::RemoveAMoleculeAtTime : " 282 << pMolecule->GetName() << " at 281 << pMolecule->GetName() << " at time : " << G4BestUnit(time, "Time") 283 << G4endl; 282 << G4endl; 284 } 283 } 285 284 286 if (fCheckTimeIsConsistentWithScheduler) 285 if (fCheckTimeIsConsistentWithScheduler) 287 { 286 { 288 if (fabs(time - G4Scheduler::Instance( 287 if (fabs(time - G4Scheduler::Instance()->GetGlobalTime()) > 289 G4Scheduler::Instance()->GetTimeTo 288 G4Scheduler::Instance()->GetTimeTolerance()) 290 { 289 { 291 G4ExceptionDescription errMsg; 290 G4ExceptionDescription errMsg; 292 errMsg << "Time of species " 291 errMsg << "Time of species " 293 << pMolecule->GetName() << 292 << pMolecule->GetName() << " is " 294 << G4BestUnit(time, "Time") 293 << G4BestUnit(time, "Time") << " while " 295 << " global time is " 294 << " global time is " 296 << G4BestUnit(G4Scheduler:: 295 << G4BestUnit(G4Scheduler::Instance()->GetGlobalTime(), "Time") 297 << G4endl; 296 << G4endl; 298 G4Exception("G4MoleculeCounter::Re 297 G4Exception("G4MoleculeCounter::RemoveAMoleculeAtTime", 299 "TIME_DONT_MATCH", 298 "TIME_DONT_MATCH", 300 FatalException, errMsg 299 FatalException, errMsg); 301 } 300 } 302 } 301 } 303 302 304 NbMoleculeAgainstTime& nbMolPerTime = fCou 303 NbMoleculeAgainstTime& nbMolPerTime = fCounterMap[pMolecule]; 305 304 306 if (nbMolPerTime.empty()) 305 if (nbMolPerTime.empty()) 307 { 306 { 308 pMolecule->PrintState(); 307 pMolecule->PrintState(); 309 Dump(); 308 Dump(); 310 G4String errMsg = 309 G4String errMsg = 311 "You are trying to remove mole 310 "You are trying to remove molecule " + pMolecule->GetName() + 312 " from the counter while this 311 " from the counter while this kind of molecules has not been registered yet"; 313 G4Exception("G4MoleculeCounter::Remove 312 G4Exception("G4MoleculeCounter::RemoveAMoleculeAtTime", "", 314 FatalErrorInArgument, errM 313 FatalErrorInArgument, errMsg); 315 314 316 return; 315 return; 317 } 316 } 318 << 317 else 319 auto it = nbMolPerTime.rbegin(); << 320 << 321 if (it == nbMolPerTime.rend()) << 322 { 318 { 323 it--; << 319 NbMoleculeAgainstTime::reverse_iterator it = nbMolPerTime.rbegin(); 324 320 325 G4String errMsg = << 321 if (it == nbMolPerTime.rend()) 326 "There was no " + pMolecule->G << 322 { 327 G4Exception("G4MoleculeCounter::Remove << 323 it--; 328 FatalErrorInArgument, errM << 329 } << 330 324 331 if (time - it->first < -G4::MoleculeCounte << 325 G4String errMsg = 332 { << 326 "There was no " + pMolecule->GetName() + " recorded at the time or even before the time asked"; 333 Dump(); << 327 G4Exception("G4MoleculeCounter::RemoveAMoleculeAtTime", "", 334 G4ExceptionDescription errMsg; << 328 FatalErrorInArgument, errMsg); 335 errMsg << "Is time going back?? " << p << 329 } 336 << " is being removed at time " << 337 << " while last recorded time w << 338 << G4BestUnit(it->first, "Time" << 339 G4Exception("G4MoleculeCounter::Remove << 340 "RETURN_TO_THE_FUTUR", << 341 FatalErrorInArgument, << 342 errMsg); << 343 } << 344 330 345 double finalN = it->second - number; << 331 if (time - it->first < -G4::MoleculeCounter::TimePrecision::fPrecision) >> 332 { >> 333 Dump(); >> 334 G4ExceptionDescription errMsg; >> 335 errMsg << "Is time going back?? " << pMolecule->GetName() >> 336 << " is being removed at time " << G4BestUnit(time, "Time") >> 337 << " while last recorded time was " >> 338 << G4BestUnit(it->first, "Time") << "."; >> 339 G4Exception("G4MoleculeCounter::RemoveAMoleculeAtTime", >> 340 "RETURN_TO_THE_FUTUR", >> 341 FatalErrorInArgument, >> 342 errMsg); >> 343 } 346 344 347 if (finalN < 0) << 345 double finalN = it->second - number; 348 { << 346 349 Dump(); << 347 if (finalN < 0) 350 G4ExceptionDescription errMsg; << 348 { 351 errMsg << "After removal of " << numbe << 349 Dump(); 352 << pMolecule->GetName() << " th << 350 G4ExceptionDescription errMsg; 353 << G4BestUnit(time, "Time") << << 351 errMsg << "After removal of " << number << " species of " 354 << " Global time is " << 352 << pMolecule->GetName() << " the final number at time " 355 << G4BestUnit(G4Scheduler::Inst << 353 << G4BestUnit(time, "Time") << " is less than zero and so not valid." 356 << ". Previous selected time is << 354 << " Global time is " 357 << G4BestUnit(it->first, "Time" << 355 << G4BestUnit(G4Scheduler::Instance()->GetGlobalTime(), "Time") 358 << G4endl; << 356 << ". Previous selected time is " 359 G4Exception("G4MoleculeCounter::Remove << 357 << G4BestUnit(it->first, "Time") 360 "N_INF_0", << 358 << G4endl; 361 FatalException, errMsg); << 359 G4Exception("G4MoleculeCounter::RemoveAMoleculeAtTime", 362 } << 360 "N_INF_0", >> 361 FatalException, errMsg); >> 362 } 363 363 364 nbMolPerTime[time] = finalN; << 364 nbMolPerTime[time] = finalN; >> 365 } 365 } 366 } 366 367 367 //-------------------------------------------- 368 //------------------------------------------------------------------------------ 368 369 369 G4MoleculeCounter::RecordedMolecules G4Molecul 370 G4MoleculeCounter::RecordedMolecules G4MoleculeCounter::GetRecordedMolecules() 370 { 371 { 371 if (fVerbose > 1) 372 if (fVerbose > 1) 372 { 373 { 373 G4cout << "Entering in G4MoleculeCount 374 G4cout << "Entering in G4MoleculeCounter::RecordMolecules" << G4endl; 374 } 375 } 375 376 376 RecordedMolecules output(new ReactantList( 377 RecordedMolecules output(new ReactantList()); 377 378 378 for (const auto & it : fCounterMap) 379 for (const auto & it : fCounterMap) 379 { 380 { 380 output->push_back(it.first); 381 output->push_back(it.first); 381 } 382 } 382 return output; 383 return output; 383 } 384 } 384 385 385 //-------------------------------------------- 386 //------------------------------------------------------------------------------ 386 387 387 RecordedTimes G4MoleculeCounter::GetRecordedTi 388 RecordedTimes G4MoleculeCounter::GetRecordedTimes() 388 { 389 { 389 RecordedTimes output(new std::set<G4double 390 RecordedTimes output(new std::set<G4double>); 390 391 391 for(const auto& it : fCounterMap) 392 for(const auto& it : fCounterMap) 392 { 393 { 393 for(const auto& it2 : it.second) 394 for(const auto& it2 : it.second) 394 { 395 { 395 //time = it2->first; 396 //time = it2->first; 396 output->insert(it2.first); 397 output->insert(it2.first); 397 } 398 } 398 } 399 } 399 400 400 return output; 401 return output; 401 } 402 } 402 403 403 //-------------------------------------------- 404 //------------------------------------------------------------------------------ 404 405 405 // >>DEV<< 406 // >>DEV<< 406 //void G4MoleculeCounter::SignalReceiver(G4Spe 407 //void G4MoleculeCounter::SignalReceiver(G4SpeciesInCM* /*speciesInCM*/, 407 // size_ 408 // size_t moleculeID, 408 // int / 409 // int /*number*/, 409 // G4Spe 410 // G4SpeciesInCM::SpeciesChange speciesChange, 410 // int d 411 // int diff) 411 //{ 412 //{ 412 // switch(speciesChange) 413 // switch(speciesChange) 413 // { 414 // { 414 // case G4SpeciesInCM::eAdd: 415 // case G4SpeciesInCM::eAdd: 415 // AddAMoleculeAtTime(G4MoleculeTable::In 416 // AddAMoleculeAtTime(G4MoleculeTable::Instance()->GetConfiguration((int)moleculeID), 416 // G4Scheduler::Instan 417 // G4Scheduler::Instance()->GetGlobalTime(), 417 // diff); 418 // diff); 418 // break; 419 // break; 419 // case G4SpeciesInCM::eRemove: 420 // case G4SpeciesInCM::eRemove: 420 // RemoveAMoleculeAtTime(G4MoleculeTable: 421 // RemoveAMoleculeAtTime(G4MoleculeTable::Instance()->GetConfiguration((int)moleculeID), 421 // G4Scheduler::Instan 422 // G4Scheduler::Instance()->GetGlobalTime(), 422 // diff); 423 // diff); 423 // break; 424 // break; 424 // } 425 // } 425 //} 426 //} 426 427 427 //-------------------------------------------- 428 //------------------------------------------------------------------------------ 428 429 429 void G4MoleculeCounter::Dump() 430 void G4MoleculeCounter::Dump() 430 { 431 { 431 for (const auto& it : fCounterMap) 432 for (const auto& it : fCounterMap) 432 { 433 { 433 auto pReactant = it.first; 434 auto pReactant = it.first; 434 435 435 G4cout << " --- > For " << pReactant-> 436 G4cout << " --- > For " << pReactant->GetName() << G4endl; 436 437 437 for (const auto& it2 : it.second) 438 for (const auto& it2 : it.second) 438 { 439 { 439 G4cout << " " << G4BestUnit(it2.fi 440 G4cout << " " << G4BestUnit(it2.first, "Time") 440 << " " << it2.second << 441 << " " << it2.second << G4endl; 441 } 442 } 442 } 443 } 443 } 444 } 444 445 445 //-------------------------------------------- 446 //------------------------------------------------------------------------------ 446 447 447 void G4MoleculeCounter::ResetCounter() 448 void G4MoleculeCounter::ResetCounter() 448 { 449 { 449 if (fVerbose != 0) << 450 if (fVerbose) 450 { 451 { 451 G4cout << " ---> G4MoleculeCounter::Re 452 G4cout << " ---> G4MoleculeCounter::ResetCounter" << G4endl; 452 } 453 } 453 fCounterMap.clear(); 454 fCounterMap.clear(); 454 fpLastSearch.reset(nullptr); << 455 fpLastSearch.reset(0); 455 } 456 } 456 457 457 //-------------------------------------------- 458 //------------------------------------------------------------------------------ 458 459 459 const NbMoleculeAgainstTime& G4MoleculeCounter 460 const NbMoleculeAgainstTime& G4MoleculeCounter::GetNbMoleculeAgainstTime(Reactant* molecule) 460 { 461 { 461 return fCounterMap[molecule]; 462 return fCounterMap[molecule]; 462 } 463 } 463 464 464 //-------------------------------------------- 465 //------------------------------------------------------------------------------ 465 466 466 void G4MoleculeCounter::SetVerbose(G4int level 467 void G4MoleculeCounter::SetVerbose(G4int level) 467 { 468 { 468 fVerbose = level; 469 fVerbose = level; 469 } 470 } 470 471 471 //-------------------------------------------- 472 //------------------------------------------------------------------------------ 472 473 473 G4int G4MoleculeCounter::GetVerbose() 474 G4int G4MoleculeCounter::GetVerbose() 474 { 475 { 475 return fVerbose; 476 return fVerbose; 476 } 477 } 477 478 478 //-------------------------------------------- 479 //------------------------------------------------------------------------------ 479 480 480 void G4MoleculeCounter::DontRegister(const G4M 481 void G4MoleculeCounter::DontRegister(const G4MoleculeDefinition* molDef) 481 { 482 { 482 fDontRegister[molDef] = true; 483 fDontRegister[molDef] = true; 483 } 484 } 484 485 485 //-------------------------------------------- 486 //------------------------------------------------------------------------------ 486 487 487 bool G4MoleculeCounter::IsRegistered(const G4M 488 bool G4MoleculeCounter::IsRegistered(const G4MoleculeDefinition* molDef) 488 { 489 { 489 return fDontRegister.find(molDef) == fDont << 490 if (fDontRegister.find(molDef) == fDontRegister.end()) >> 491 { >> 492 return true; >> 493 } >> 494 return false; 490 } 495 } 491 496 492 //-------------------------------------------- 497 //------------------------------------------------------------------------------ 493 498 494 void G4MoleculeCounter::RegisterAll() 499 void G4MoleculeCounter::RegisterAll() 495 { 500 { 496 fDontRegister.clear(); 501 fDontRegister.clear(); 497 } 502 } 498 503 499 G4bool G4MoleculeCounter::IsTimeCheckedForCons 504 G4bool G4MoleculeCounter::IsTimeCheckedForConsistency() const 500 { 505 { 501 return fCheckTimeIsConsistentWithScheduler 506 return fCheckTimeIsConsistentWithScheduler; 502 } 507 } 503 508 504 void G4MoleculeCounter::CheckTimeForConsistenc 509 void G4MoleculeCounter::CheckTimeForConsistency(G4bool flag) 505 { 510 { 506 fCheckTimeIsConsistentWithScheduler = flag 511 fCheckTimeIsConsistentWithScheduler = flag; 507 } 512 } 508 513 509 514