93 if ( edep == 0. )
return FALSE;
97 fEvtMap->
add(index,edep);
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)
152 for(
auto time_mol: fTimeToRecord)
165 fSpeciesInfoPerTime[time_mol][molecule];
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);
214 SpeciesMap::iterator it_map1 = right->fSpeciesInfoPerTime.begin();
215 SpeciesMap::iterator end_map1 = right->fSpeciesInfoPerTime.end();
217 for(; it_map1 != end_map1; ++it_map1)
219 InnerSpeciesMap& map2 = it_map1->second;
220 InnerSpeciesMap::iterator it_map2 = map2.begin();
221 InnerSpeciesMap::iterator end_map2 = map2.end();
223 for(; it_map2 != end_map2; ++it_map2)
226 fSpeciesInfoPerTime[it_map1->first][it_map2->first] ;
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();
278 fNEvent += right->fNEvent;
290 fSpeciesInfoPerTime.clear();
305 G4cout <<
" Number of energy deposition recorded "
308 for(
auto itr : *fEvtMap->
GetMap()) {
309 G4cout <<
" copy no.: " << itr.first
310 <<
" energy deposit: "
321 std::ofstream out(
"Species.Txt");
324 out <<
"Time is in ns" <<
G4endl;
326 for(
auto it_map1: fSpeciesInfoPerTime)
328 InnerSpeciesMap& map2 = it_map1.second;
330 out << it_map1.first <<
G4endl;
332 for(
auto it_map2: map2)
334 out << it_map2.first->GetName()<<
" "
335 << it_map2.second.fNumber <<
G4endl;
358 else if (fOutputToRoot)
362 else if(fOutputToXml)
373 fSpeciesInfoPerTime.clear();
382 analysisManager->
OpenFile(
"Species.root");
383 int fNtupleID = analysisManager->
CreateNtuple(
"species",
"species");
393 for(
auto it_map1: fSpeciesInfoPerTime)
395 InnerSpeciesMap& map2 = it_map1.second;
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();
void WriteWithAnalysisManager(G4VAnalysisManager *)
virtual G4bool ProcessHits(G4Step *, G4TouchableHistory *)
const G4String & GetName() const
G4double GetWeight() const
G4int CreateNtupleIColumn(const G4String &name)
G4bool FillNtupleSColumn(G4int id, const G4String &value)
void ResetCounter() override
G4MultiFunctionalDetector * GetMultiFunctionalDetector() const
virtual void Initialize(G4HCofThisEvent *)
G4int CreateNtuple(const G4String &name, const G4String &title)
static G4XmlAnalysisManager * Instance()
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
static constexpr double picosecond
G4int CreateNtupleSColumn(const G4String &name)
G4bool OpenFile(const G4String &fileName="")
static G4CsvAnalysisManager * Instance()
int GetNMoleculesAtTime(G4MolecularConfiguration *molecule, double time)
G4StepPoint * GetPreStepPoint() const
RecordedMolecules GetRecordedMolecules()
G4bool FillNtupleIColumn(G4int id, G4int value)
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)
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
virtual void AbsorbResultsFromWorkerScorer(G4VPrimitiveScorer *)
G4MultiFunctionalDetector * detector
G4int CreateNtupleDColumn(const G4String &name)
const G4Event * GetConstCurrentEvent()
const G4String & GetUnit() const
G4GLOB_DLL std::ostream G4cerr
ScoreSpecies(G4String name, G4int depth=0)