Commit in projects/slic/branches/v00-00-01_SLIC-218-dev on MAIN | |||
include/MCParticleManager.hh | +40 | -3 | 2874 -> 2875 |
/StdHepGenerator.hh | +5 | -11 | 2874 -> 2875 |
src/EventAction.cc | +1 | -1 | 2874 -> 2875 |
/MCParticleManager.cc | +8 | added 2875 | |
/StdHepGenerator.cc | +16 | -20 | 2874 -> 2875 |
/TrackManager.cc | +2 | -2 | 2874 -> 2875 |
+72 | -37 |
move MCParticle collections from StdHepGenerator to MCParticleManager
--- projects/slic/branches/v00-00-01_SLIC-218-dev/include/MCParticleManager.hh 2014-01-14 00:24:24 UTC (rev 2874) +++ projects/slic/branches/v00-00-01_SLIC-218-dev/include/MCParticleManager.hh 2014-01-14 01:09:17 UTC (rev 2875) @@ -9,17 +9,27 @@
#include "IMPL/MCParticleImpl.h" #include "EVENT/MCParticle.h"
+// Geant4 +#include "globals.hh" +#include "G4PrimaryParticle.hh" +
// STL #include <map>
+#include <set>
using std::map;
+using std::set; +
using EVENT::MCParticle; using IMPL::MCParticleImpl; using IMPL::LCCollectionVec; namespace slic {
-typedef map<G4int, MCParticle*> MCParticle2TrackIDMap;
+typedef map<G4int, MCParticle*> MCParticleTrackIDMap; +typedef map<MCParticle*, G4PrimaryParticle*> MCParticleGeant4Map; +typedef MCParticleGeant4Map::iterator MCParticleGeant4MapIterator; +typedef set<MCParticle*> VisitedMCParticles;
class MCParticleManager : public Singleton<MCParticleManager> {
@@ -50,13 +60,40 @@
return _mcpMap[trackId]; }
- void clearMap() {
+ void clearMaps() {
_mcpMap.clear();
+ _particleMap.clear(); + _visitedParticles.clear();
}
+ static MCParticleGeant4Map* getMCParticleToGeant4Map() { + return &_particleMap; + } + + static std::set<MCParticle*>* getVisitedParticles() { + return &_visitedParticles; + } +
private:
- MCParticle2TrackIDMap _mcpMap;
+ /** + * Map of MCParticle to G4PrimaryParticle. + */ + static MCParticleGeant4Map _particleMap; + + /** + * Set keeping track of which MCParticles have been processed in generator. + */ + static VisitedMCParticles _visitedParticles; + + /** + * Map of MCParticle to track ID. + */ + MCParticleTrackIDMap _mcpMap; + + /** + * The output MCParticle collection. + */
LCCollectionVec* _mcpVec; };
--- projects/slic/branches/v00-00-01_SLIC-218-dev/include/StdHepGenerator.hh 2014-01-14 00:24:24 UTC (rev 2874) +++ projects/slic/branches/v00-00-01_SLIC-218-dev/include/StdHepGenerator.hh 2014-01-14 01:09:17 UTC (rev 2875) @@ -1,6 +1,9 @@
#ifndef slic_StdhepGenerator_hh_ #define slic_StdhepGenerator_hh_ 1
+// SLIC +#include "MCParticleManager.hh" +
// LCIO #include "UTIL/LCStdHepRdr.h" #include "EVENT/MCParticle.h"
@@ -27,29 +30,20 @@
public:
- typedef std::map<MCParticle*, G4PrimaryParticle*> LCIO2Geant4Map; - typedef LCIO2Geant4Map::iterator LCIO2Geant4MapIterator; - -public: -
StdHepGenerator(G4String eventFile); virtual ~StdHepGenerator(); void generateEvent(G4Event*);
- static LCIO2Geant4Map* getParticleMap() { - return &_particleMap; - } -
private: std::set<G4PrimaryParticle*> getRelevantParticles(MCParticle* p); private:
- static LCIO2Geant4Map _particleMap; - static std::set<MCParticle*> _visitedParticles;
LCStdHepRdr* _reader;
+ MCParticleManager* _particleManager; + VisitedMCParticles* _visitedParticles;
}; }
--- projects/slic/branches/v00-00-01_SLIC-218-dev/src/EventAction.cc 2014-01-14 00:24:24 UTC (rev 2874) +++ projects/slic/branches/v00-00-01_SLIC-218-dev/src/EventAction.cc 2014-01-14 01:09:17 UTC (rev 2875) @@ -34,7 +34,7 @@
TrackManager::instance()->resetTrackSummaries(); /* Clear the MCParticle map from last event. */
- MCParticleManager::instance()->clearMap();
+ MCParticleManager::instance()->clearMaps();
/* Create an empty LCEvent. */ LcioManager::instance()->createLCEvent();
--- projects/slic/branches/v00-00-01_SLIC-218-dev/src/MCParticleManager.cc (rev 0) +++ projects/slic/branches/v00-00-01_SLIC-218-dev/src/MCParticleManager.cc 2014-01-14 01:09:17 UTC (rev 2875) @@ -0,0 +1,8 @@
+#include "MCParticleManager.hh" + +namespace slic { + +MCParticleGeant4Map MCParticleManager::_particleMap; +VisitedMCParticles MCParticleManager::_visitedParticles; + +};
--- projects/slic/branches/v00-00-01_SLIC-218-dev/src/StdHepGenerator.cc 2014-01-14 00:24:24 UTC (rev 2874) +++ projects/slic/branches/v00-00-01_SLIC-218-dev/src/StdHepGenerator.cc 2014-01-14 01:09:17 UTC (rev 2875) @@ -1,10 +1,6 @@
#include "StdHepGenerator.hh"
-// SLIC -#include "MCParticleManager.hh" -
// LCIO
-#include "EVENT/MCParticle.h"
#include "IMPL/MCParticleImpl.h" // Geant4
@@ -17,11 +13,10 @@
namespace slic {
-StdHepGenerator::LCIO2Geant4Map StdHepGenerator::_particleMap; -std::set<MCParticle*> StdHepGenerator::_visitedParticles; -
StdHepGenerator::StdHepGenerator(G4String eventFile) { _reader = new LCStdHepRdr(eventFile.data());
+ _particleManager = MCParticleManager::instance(); + _visitedParticles = _particleManager->getVisitedParticles();
} StdHepGenerator::~StdHepGenerator() {
@@ -31,8 +26,7 @@
void StdHepGenerator::generateEvent(G4Event* event) { /* Clear previous state before starting event generation. */
- _particleMap.clear(); - _visitedParticles.clear();
+ MCParticleManager::instance()->clearMaps();
/* Get collection of MCParticles from the LCStdHepRdr. */ LCCollectionVec* mcpVec = _reader->readEvent();
@@ -71,16 +65,18 @@
event->AddPrimaryVertex(vertex); /* Register the collection of MCParticles that was created. */
- MCParticleManager::instance()->setMCParticleCollection(mcpVec);
+ _particleManager->setMCParticleCollection(mcpVec);
} std::set<G4PrimaryParticle*> StdHepGenerator::getRelevantParticles(MCParticle* p) { //log each particle which has been called, to avoid double counting and increase efficiency
- _visitedParticles.insert(p); - LCIO2Geant4Map::iterator mcpIT;
+ _visitedParticles->insert(p); + MCParticleGeant4Map::iterator mcpIT;
std::set<G4PrimaryParticle*> relevantParticlesSet; //holds all relevant decay particles of p
+ MCParticleGeant4Map* particleMap = _particleManager->getMCParticleToGeant4Map(); +
/* * Case #1: *
@@ -94,8 +90,8 @@
*/ if (p->getGeneratorStatus() == 1) { G4PrimaryParticle* g4p;
- mcpIT = _particleMap.find(p); - if (mcpIT != _particleMap.end()) {
+ mcpIT = particleMap->find(p); + if (mcpIT != particleMap->end()) {
g4p = mcpIT->second; } else { G4int IDHEP = p->getPDG();
@@ -106,7 +102,7 @@
// create G4PrimaryParticle object g4p = new G4PrimaryParticle(IDHEP, PHEP1 * GeV, PHEP2 * GeV, PHEP3 * GeV); g4p->SetMass(PHEP5 * GeV);
- _particleMap[p] = g4p;
+ (*particleMap)[p] = g4p;
//std::cout << "*" << std::flush; } //std::cout << g4p->GetPDGcode() << std::flush;
@@ -147,8 +143,8 @@
if (isProperTimeZero == false) { G4PrimaryParticle* g4p;
- mcpIT = _particleMap.find(p); - if (mcpIT != _particleMap.end()) {
+ mcpIT = particleMap->find(p); + if (mcpIT != particleMap->end()) {
g4p = mcpIT->second; } else { G4int IDHEP = p->getPDG();
@@ -160,10 +156,10 @@
g4p = new G4PrimaryParticle(IDHEP, PHEP1 * GeV, PHEP2 * GeV, PHEP3 * GeV); g4p->SetMass(PHEP5 * GeV); g4p->SetProperTime(proper_time * ns);
- _particleMap[p] = g4p;
+ (*particleMap)[p] = g4p;
std::set<G4PrimaryParticle*> vec3; for (size_t i = 0; i < p->getDaughters().size(); i++) {
- if (_visitedParticles.count(p->getDaughters()[i]) == 0) {
+ if (_visitedParticles->count(p->getDaughters()[i]) == 0) {
std::set<G4PrimaryParticle*> vec2 = getRelevantParticles(p->getDaughters()[i]); std::set<G4PrimaryParticle*>::iterator setit; for (setit = vec2.begin(); setit != vec2.end(); setit++) {
@@ -191,7 +187,7 @@
*/ else { for (size_t i = 0; i < p->getDaughters().size(); i++) {
- if (_visitedParticles.count(p->getDaughters()[i]) == 0) {
+ if (_visitedParticles->count(p->getDaughters()[i]) == 0) {
std::set<G4PrimaryParticle*> vec2 = getRelevantParticles(p->getDaughters()[i]); std::set<G4PrimaryParticle*>::iterator setit; for (setit = vec2.begin(); setit != vec2.end(); setit++) {
--- projects/slic/branches/v00-00-01_SLIC-218-dev/src/TrackManager.cc 2014-01-14 00:24:24 UTC (rev 2874) +++ projects/slic/branches/v00-00-01_SLIC-218-dev/src/TrackManager.cc 2014-01-14 01:09:17 UTC (rev 2875) @@ -18,10 +18,10 @@
void TrackManager::saveTrackSummaries(const G4Event* anEvent, LCEvent* lcEvent) {
- StdHepGenerator::LCIO2Geant4MapIterator it;
+ MCParticleGeant4MapIterator it;
/* Get the map of MCParticles to G4PrimaryParticles. The latter has the track IDs. */
- StdHepGenerator::LCIO2Geant4Map* particleMap = StdHepGenerator::getParticleMap();
+ MCParticleGeant4Map* particleMap = MCParticleManager::instance()->getMCParticleToGeant4Map();
/* Copy MCParticle information from generated primary particles into the corresponding TrackSummary objects. */ for (it = particleMap->begin(); it != particleMap->end(); it++) {
Use REPLY-ALL to reply to list
To unsubscribe from the LCDET-SVN list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCDET-SVN&A=1