10 #include <klm/modules/MCMatcherKLMClusters/MCMatcherKLMClustersModule.h>
13 #include <klm/dataobjects/bklm/BKLMHit1d.h>
14 #include <klm/dataobjects/bklm/BKLMHit2d.h>
15 #include <klm/dataobjects/bklm/BKLMSimHit.h>
16 #include <klm/dataobjects/eklm/EKLMHit2d.h>
17 #include <klm/dataobjects/eklm/EKLMSimHit.h>
18 #include <klm/dataobjects/KLMDigit.h>
21 #include <mdst/dataobjects/MCParticle.h>
32 setDescription(
"Module for MC matching for KLM clusters.");
33 setPropertyFlags(c_ParallelProcessingCertified);
34 addParam(
"Hit2dRelations", m_Hit2dRelations,
35 "Add also relations for BKLMHit2d and EKLMHit2d.",
false);
64 int i1, i2, i3, i4, i5, i6, n1, n2, n3, n4, n5, n6;
65 std::map<MCParticle*, double> mcParticles, mcParticlesHit;
66 std::map<MCParticle*, double>::iterator it;
68 for (i1 = 0; i1 < n1; i1++) {
72 n2 = bklmHit2ds.
size();
73 for (i2 = 0; i2 < n2; i2++) {
75 mcParticlesHit.clear();
77 bklmHit2ds[i2]->getRelationsTo<
BKLMHit1d>();
78 n3 = bklmHit1ds.
size();
79 for (i3 = 0; i3 < n3; i3++) {
81 bklmHit1ds[i3]->getRelationsTo<
KLMDigit>();
82 n4 = bklmDigits.
size();
83 for (i4 = 0; i4 < n4; i4++) {
86 n5 = bklmSimHits.
size();
87 for (i5 = 0; i5 < n5; i5++) {
89 bklmSimHits[i5]->getRelationsFrom<
MCParticle>();
90 n6 = bklmMCParticles.
size();
91 for (i6 = 0; i6 < n6; i6++) {
92 it = mcParticles.find(bklmMCParticles[i6]);
93 if (it == mcParticles.end()) {
94 mcParticles.insert(std::pair<MCParticle*, double>(
96 bklmSimHits[i5]->getEnergyDeposit()));
98 it->second = it->second + bklmSimHits[i5]->getEnergyDeposit();
101 it = mcParticlesHit.find(bklmMCParticles[i6]);
102 if (it == mcParticlesHit.end()) {
103 mcParticlesHit.insert(std::pair<MCParticle*, double>(
105 bklmSimHits[i5]->getEnergyDeposit()));
107 it->second = it->second + bklmSimHits[i5]->getEnergyDeposit();
116 for (it = mcParticlesHit.begin(); it != mcParticlesHit.end(); ++it)
117 weightSum = weightSum + it->second;
118 for (it = mcParticlesHit.begin(); it != mcParticlesHit.end(); ++it)
119 bklmHit2ds[i2]->addRelationTo(it->first, it->second / weightSum);
124 n2 = eklmHit2ds.
size();
125 for (i2 = 0; i2 < n2; i2++) {
127 mcParticlesHit.clear();
129 eklmHit2ds[i2]->getRelationsTo<
KLMDigit>();
130 n3 = eklmDigits.
size();
131 for (i3 = 0; i3 < n3; i3++) {
134 n4 = eklmSimHits.
size();
135 for (i4 = 0; i4 < n4; i4++) {
137 eklmSimHits[i4]->getRelationsFrom<
MCParticle>();
138 n5 = eklmMCParticles.
size();
139 for (i5 = 0; i5 < n5; i5++) {
140 it = mcParticles.find(eklmMCParticles[i5]);
141 if (it == mcParticles.end()) {
142 mcParticles.insert(std::pair<MCParticle*, double>(
144 eklmSimHits[i4]->getEnergyDeposit()));
146 it->second = it->second + eklmSimHits[i4]->getEnergyDeposit();
149 it = mcParticlesHit.find(eklmMCParticles[i5]);
150 if (it == mcParticlesHit.end()) {
151 mcParticlesHit.insert(std::pair<MCParticle*, double>(
153 eklmSimHits[i4]->getEnergyDeposit()));
155 it->second = it->second + eklmSimHits[i4]->getEnergyDeposit();
163 for (it = mcParticlesHit.begin(); it != mcParticlesHit.end(); ++it)
164 weightSum = weightSum + it->second;
165 for (it = mcParticlesHit.begin(); it != mcParticlesHit.end(); ++it)
166 eklmHit2ds[i2]->addRelationTo(it->first, it->second / weightSum);
170 for (it = mcParticles.begin(); it != mcParticles.end(); ++it)
171 weightSum = weightSum + it->second;
172 for (it = mcParticles.begin(); it != mcParticles.end(); ++it)
173 m_KLMClusters[i1]->addRelationTo(it->first, it->second / weightSum);
Store one reconstructed BKLM 1D hit as a ROOT object.
Store one BKLM strip hit as a ROOT object.
Store one simulation hit as a ROOT object.
Class for 2d hits handling.
Class EKLMSimHit stores information on particular Geant step; using information from TrackID and Pare...
KLM digit (class representing a digitized hit in RPCs or scintillators).
Module for MC matching for KLM clusters.
bool m_Hit2dRelations
Add relations for BKLMHit2d and EKLMHit2d.
void initialize() override
Initializer.
void event() override
This method is called for each event.
void endRun() override
This method is called if the current run ends.
void terminate() override
This method is called at the end of the event processing.
~MCMatcherKLMClustersModule()
Destructor.
void beginRun() override
Called when entering a new run.
StoreArray< KLMCluster > m_KLMClusters
KLM clusters.
A Class to store the Monte Carlo particle information.
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
bool registerRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut, const std::string &namedRelation="") const
Register a relation to the given StoreArray.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.