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();
The pointer G4MolecularConfiguration will be shared by all the molecules having the same molecule def...
void WriteWithAnalysisManager(G4VAnalysisManager *)
Write results to whatever chosen file format.
virtual G4bool ProcessHits(G4Step *, G4TouchableHistory *)
const G4String & GetName() const
Returns the name of the molecule.
G4double GetWeight() const
G4int CreateNtupleIColumn(const G4String &name)
G4bool FillNtupleSColumn(G4int id, const G4String &value)
void ResetCounter() override
std::set< G4double > fTimeToRecord
G4MultiFunctionalDetector * GetMultiFunctionalDetector() const
virtual void Initialize(G4HCofThisEvent *)
G4int CreateNtuple(const G4String &name, const G4String &title)
static G4XmlAnalysisManager * Instance()
const char * name(G4int ptype)
void ASCII()
Write results to an text file.
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4int CreateNtupleSColumn(const G4String &name)
G4bool OpenFile(const G4String &fileName="")
static G4CsvAnalysisManager * Instance()
static constexpr double picosecond
int GetNMoleculesAtTime(G4MolecularConfiguration *molecule, double time)
SpeciesMap fSpeciesInfoPerTime
G4StepPoint * GetPreStepPoint() const
RecordedMolecules GetRecordedMolecules()
G4bool FillNtupleIColumn(G4int id, G4int value)
This is a primitive scorer class for molecular species.
G4GLOB_DLL std::ostream G4cout
static G4MoleculeCounter * Instance()
G4bool FillNtupleDColumn(G4int id, G4double value)
G4double GetUnitValue() const
virtual G4int GetIndex(G4Step *)
static constexpr double eV
void AddTimeToRecord(double time)
Add a time at which the number of species should be recorded.
G4int GetCollectionID(G4int)
virtual void EndOfEvent(G4HCofThisEvent *)
G4double GetTotalEnergyDeposit() const
void AddHitsCollection(G4int HCID, G4VHitsCollection *aHC)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
virtual void OutputAndClear()
G4int add(const G4int &key, T *&aHit) const
static G4EventManager * GetEventManager()
static G4RootAnalysisManager * Instance()
std::map< G4int, T * > * GetMap() const
std::map< Species, SpeciesInfo > InnerSpeciesMap
virtual void AbsorbResultsFromWorkerScorer(G4VPrimitiveScorer *)
Method used in multithreading mode in order to merge the results.
G4MultiFunctionalDetector * detector
G4int CreateNtupleDColumn(const G4String &name)
const G4Event * GetConstCurrentEvent()
const G4String & GetUnit() const
G4THitsMap< G4double > * fEvtMap
G4GLOB_DLL std::ostream G4cerr
ScoreSpecies(G4String name, G4int depth=0)