93 if ( edep == 0. )
return FALSE;
131 if(species.get() == 0 || species->size() == 0)
133 G4cout <<
"No molecule recorded, energy deposited= "
145 #ifdef _ScoreSpecies_FOR_ALL_EVENTS
150 for(
auto molecule: *species)
167 double gValue = (n_mol/(
fEdep/
eV)) * 100.;
168 molInfo.
fG += gValue;
169 molInfo.
fG2 += gValue*gValue;
171 #ifdef _ScoreSpecies_FOR_ALL_EVENTS
173 fSpeciesInfoPerEvent[time_mol][molecule];
174 molInfoPerEvent.fNumber.push_back(n_mol);
175 molInfoPerEvent.
fG.push_back(gValue);
176 molInfoPerEvent.fG2.push_back(gValue*gValue);
177 molInfoPerEvent.fEventID.push_back(eventID);
217 for(; it_map1 != end_map1; ++it_map1)
220 InnerSpeciesMap::iterator it_map2 = map2.begin();
221 InnerSpeciesMap::iterator end_map2 = map2.end();
223 for(; it_map2 != end_map2; ++it_map2)
227 molInfo.
fNumber += it_map2->second.fNumber;
228 molInfo.
fG += it_map2->second.fG;
229 molInfo.
fG2 += it_map2->second.fG2;
240 #ifdef _ScoreSpecies_FOR_ALL_EVENTS
242 SpeciesMapPerEvent::iterator it_map1 = right->fSpeciesInfoPerEvent.begin();
243 SpeciesMapPerEvent::iterator end_map1 = right->fSpeciesInfoPerEvent.end();
245 for(; it_map1 != end_map1; ++it_map1)
247 auto& map2 = it_map1->second;
248 InnerSpeciesMapPerEvent::iterator it_map2 = map2.begin();
249 InnerSpeciesMapPerEvent::iterator end_map2 = map2.end();
251 for(; it_map2 != end_map2; ++it_map2)
254 fSpeciesInfoPerEvent[it_map1->first][it_map2->first] ;
255 molInfo.fNumber.insert(molInfo.fNumber.end(),
256 it_map2->second.fNumber.begin(),
257 it_map2->second.fNumber.end());
258 molInfo.
fG.insert(molInfo.
fG.end(),
259 it_map2->second.fG.begin(),
260 it_map2->second.fG.end());
261 molInfo.fG2.insert(molInfo.fG2.end(),
262 it_map2->second.fG2.begin(),
263 it_map2->second.fG2.end());
264 molInfo.fEventID.insert(molInfo.fEventID.end(),
265 it_map2->second.fEventID.begin(),
266 it_map2->second.fEventID.end());
274 right->fSpeciesInfoPerEvent.
clear();
305 G4cout <<
" Number of energy deposition recorded "
309 G4cout <<
" copy no.: " << itr.first
310 <<
" energy deposit: "
321 std::ofstream out(
"Species.Txt");
324 out <<
"Time is in ns" <<
G4endl;
330 out << it_map1.first <<
G4endl;
332 for(
auto it_map2: map2)
334 out << it_map2.first->GetName()<<
" "
335 << it_map2.second.fNumber <<
G4endl;
382 analysisManager->
OpenFile(
"Species.root");
383 int fNtupleID = analysisManager->
CreateNtuple(
"species",
"species");
397 for(
auto it_map2 : map2)
399 double time = it_map1.first;
400 const Species& species = it_map2.first;
402 int molID = it_map2.
first->GetMoleculeID();
403 int number = it_map2.second.fNumber;
404 double G = it_map2.second.fG;
405 double G2 = it_map2.second.fG2;
421 #ifdef _ScoreSpecies_FOR_ALL_EVENTS
422 fNtupleID = analysisManager->
CreateNtuple(
"species_all",
"species_all");
433 for(
auto it_map1: fSpeciesInfoPerEvent)
435 InnerSpeciesMapPerEvent& map2 = it_map1.second;
437 for(
auto it_map2 : map2)
439 double time = it_map1.first;
440 const Species& species = it_map2.first;
442 int molID = it_map2.
first->GetMoleculeID();
444 size_t nG = it_map2.second.fG.size();
446 for(
size_t i=0; i<nG;++i){
447 int number = it_map2.second.fNumber[i];
448 double G = it_map2.second.fG[i];
449 double G2 = it_map2.second.fG2[i];
450 int eventID = it_map2.second.fEventID[i];
467 analysisManager->
Write();
const G4String & GetUnit() const
std::map< Species, SpeciesInfo > InnerSpeciesMap
G4int GetCollectionID(G4int)
static G4MoleculeCounter * Instance()
G4StepPoint * GetPreStepPoint() const
G4int add(const G4int &key, U *&aHit) const
static G4CsvAnalysisManager * Instance()
virtual void AbsorbResultsFromWorkerScorer(G4VPrimitiveScorer *)
void AddHitsCollection(G4int HCID, G4VHitsCollection *aHC)
RecordedMolecules GetRecordedMolecules()
G4bool OpenFile(const G4String &fileName="")
static G4XmlAnalysisManager * Instance()
G4bool FillNtupleIColumn(G4int id, G4int value)
std::set< G4double > fTimeToRecord
virtual G4int GetIndex(G4Step *)
G4int CreateNtupleIColumn(const G4String &name)
virtual void EndOfEvent(G4HCofThisEvent *)
G4bool FillNtupleDColumn(G4int id, G4double value)
void WriteWithAnalysisManager(G4VAnalysisManager *)
G4MultiFunctionalDetector * GetMultiFunctionalDetector() const
virtual void OutputAndClear()
G4bool FillNtupleSColumn(G4int id, const G4String &value)
void ResetCounter() override
static constexpr double picosecond
static G4EventManager * GetEventManager()
G4double GetTotalEnergyDeposit() const
static constexpr double eV
G4int CreateNtupleDColumn(const G4String &name)
G4GLOB_DLL std::ostream G4cerr
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
const G4Event * GetConstCurrentEvent()
ScoreSpecies(G4String name, G4int depth=0)
virtual G4bool ProcessHits(G4Step *, G4TouchableHistory *)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4int CreateNtupleSColumn(const G4String &name)
G4THitsMap< G4double > * fEvtMap
static G4RootAnalysisManager * Instance()
G4GLOB_DLL std::ostream G4cout
G4int CreateNtuple(const G4String &name, const G4String &title)
G4double GetWeight() const
G4MultiFunctionalDetector * detector
SpeciesMap fSpeciesInfoPerTime
void AddTimeToRecord(double time)
G4double GetUnitValue() const
virtual void Initialize(G4HCofThisEvent *)
const G4String & GetName() const
int GetNMoleculesAtTime(G4MolecularConfiguration *molecule, double time)