10 #include <top/modules/TOPMCTrackMaker/TOPMCTrackMakerModule.h>
13 #include <framework/datastore/StoreArray.h>
16 #include <framework/gearbox/Unit.h>
17 #include <framework/gearbox/Const.h>
18 #include <framework/geometry/BFieldManager.h>
21 #include <mdst/dataobjects/Track.h>
22 #include <mdst/dataobjects/TrackFitResult.h>
23 #include <tracking/dataobjects/ExtHit.h>
24 #include <mdst/dataobjects/MCParticle.h>
25 #include <top/dataobjects/TOPBarHit.h>
49 setDescription(
"Constructs Tracks and ExtHits from MCParticles and TOPBarHits. "
50 "Utility needed for testing and debugging of TOP reconstruction.");
51 setPropertyFlags(c_ParallelProcessingCertified);
57 TOPMCTrackMakerModule::~TOPMCTrackMakerModule()
61 void TOPMCTrackMakerModule::initialize()
75 tracks.registerInDataStore();
78 fitResults.registerInDataStore();
83 tracks.registerRelationTo(mcParticles);
84 tracks.registerRelationTo(extHits);
88 void TOPMCTrackMakerModule::beginRun()
92 void TOPMCTrackMakerModule::event()
102 for (
const auto& mcParticle : mcParticles) {
103 if (mcParticle.getStatus(MCParticle::c_PrimaryParticle) == 0)
continue;
104 if (mcParticle.getCharge() == 0)
continue;
105 const auto* barHit = mcParticle.getRelated<
TOPBarHit>();
106 if (!barHit)
continue;
109 fitResults.appendNew(mcParticle.getVertex(),
110 mcParticle.getMomentum(),
112 mcParticle.getCharge(),
115 BFieldManager::getField(0, 0, 0).Z() / Unit::T,
118 auto* track = tracks.appendNew();
119 track->setTrackFitResultIndex(Const::pion, fitResults.getEntries() - 1);
120 track->addRelationTo(&mcParticle);
123 double pmom = barHit->getMomentum().Mag();
124 double mass = chargedStable.
getMass();
125 double beta = pmom / sqrt(pmom * pmom + mass * mass);
126 double tof = barHit->getLength() / beta / Const::speedOfLight;
129 barHit->getModuleID(),
133 barHit->getPosition(),
134 barHit->getMomentum(),
136 track->addRelationTo(extHit);
142 void TOPMCTrackMakerModule::endRun()
146 void TOPMCTrackMakerModule::terminate()
Provides a type-safe way to pass members of the chargedStableSet set.
int getPDGCode() const
PDG code.
double getMass() const
Particle mass.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
T * appendNew()
Construct a new T object at the end of the array.
Class to store track parameters of incoming MC particles relation to MCParticle filled in top/simulat...
Constructs Tracks and ExtHits from MCParticles and TOPBarHits Utility needed for testing and debuggin...
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.