10#include <klm/modules/MCMatcherKLMClusters/MCMatcherKLMClustersModule.h>
13#include <klm/dataobjects/bklm/BKLMHit1d.h>
14#include <klm/dataobjects/KLMDigit.h>
15#include <klm/dataobjects/KLMHit2d.h>
16#include <klm/dataobjects/KLMSimHit.h>
19#include <mdst/dataobjects/MCParticle.h>
33 "Add also relations for KLMHit2d and KLMHit2d.",
false);
66 int i1, i2, i3, i4, i5, i6, n1, n2, n3, n4, n5, n6;
67 std::map<MCParticle*, double> mcParticles, mcParticlesHit;
68 std::map<MCParticle*, double>::iterator it;
70 for (i1 = 0; i1 < n1; i1++) {
74 n2 = bklmHit2ds.
size();
75 for (i2 = 0; i2 < n2; i2++) {
77 mcParticlesHit.clear();
79 bklmHit2ds[i2]->getRelationsTo<
BKLMHit1d>();
80 n3 = bklmHit1ds.
size();
81 for (i3 = 0; i3 < n3; i3++) {
83 bklmHit1ds[i3]->getRelationsTo<
KLMDigit>();
84 n4 = bklmDigits.
size();
85 for (i4 = 0; i4 < n4; i4++) {
87 bklmDigits[i4]->getRelationsTo<
KLMSimHit>();
88 n5 = bklmSimHits.
size();
89 for (i5 = 0; i5 < n5; i5++) {
91 bklmSimHits[i5]->getRelationsFrom<
MCParticle>();
92 n6 = bklmMCParticles.
size();
93 for (i6 = 0; i6 < n6; i6++) {
94 it = mcParticles.find(bklmMCParticles[i6]);
95 if (it == mcParticles.end()) {
96 mcParticles.insert(std::pair<MCParticle*, double>(
98 bklmSimHits[i5]->getEnergyDeposit()));
100 it->second = it->second + bklmSimHits[i5]->getEnergyDeposit();
103 it = mcParticlesHit.find(bklmMCParticles[i6]);
104 if (it == mcParticlesHit.end()) {
105 mcParticlesHit.insert(std::pair<MCParticle*, double>(
107 bklmSimHits[i5]->getEnergyDeposit()));
109 it->second = it->second + bklmSimHits[i5]->getEnergyDeposit();
118 for (it = mcParticlesHit.begin(); it != mcParticlesHit.end(); ++it)
119 weightSum = weightSum + it->second;
120 for (it = mcParticlesHit.begin(); it != mcParticlesHit.end(); ++it)
121 bklmHit2ds[i2]->addRelationTo(it->first, it->second / weightSum);
126 n2 = eklmHit2ds.
size();
127 for (i2 = 0; i2 < n2; i2++) {
129 mcParticlesHit.clear();
131 eklmHit2ds[i2]->getRelationsTo<
KLMDigit>();
132 n3 = eklmDigits.
size();
133 for (i3 = 0; i3 < n3; i3++) {
135 eklmDigits[i3]->getRelationsTo<
KLMSimHit>();
136 n4 = eklmSimHits.
size();
137 for (i4 = 0; i4 < n4; i4++) {
139 eklmSimHits[i4]->getRelationsFrom<
MCParticle>();
140 n5 = eklmMCParticles.
size();
141 for (i5 = 0; i5 < n5; i5++) {
142 it = mcParticles.find(eklmMCParticles[i5]);
143 if (it == mcParticles.end()) {
144 mcParticles.insert(std::pair<MCParticle*, double>(
146 eklmSimHits[i4]->getEnergyDeposit()));
148 it->second = it->second + eklmSimHits[i4]->getEnergyDeposit();
151 it = mcParticlesHit.find(eklmMCParticles[i5]);
152 if (it == mcParticlesHit.end()) {
153 mcParticlesHit.insert(std::pair<MCParticle*, double>(
155 eklmSimHits[i4]->getEnergyDeposit()));
157 it->second = it->second + eklmSimHits[i4]->getEnergyDeposit();
165 for (it = mcParticlesHit.begin(); it != mcParticlesHit.end(); ++it)
166 weightSum = weightSum + it->second;
167 for (it = mcParticlesHit.begin(); it != mcParticlesHit.end(); ++it)
168 eklmHit2ds[i2]->addRelationTo(it->first, it->second / weightSum);
172 for (it = mcParticles.begin(); it != mcParticles.end(); ++it)
173 weightSum = weightSum + it->second;
174 for (it = mcParticles.begin(); it != mcParticles.end(); ++it)
175 m_KLMClusters[i1]->addRelationTo(it->first, it->second / weightSum);
Store one reconstructed BKLM 1D hit as a ROOT object.
KLM digit (class representing a digitized hit in RPCs or scintillators).
bool m_Hit2dRelations
Add relations for KLMHit2d and KLMHit2d.
void initialize() override
Initializer.
void event() override
This method is called for each event.
~MCMatcherKLMClustersModule()
Destructor.
StoreArray< KLMCluster > m_KLMClusters
KLM clusters.
MCMatcherKLMClustersModule()
Constructor.
StoreArray< MCParticle > m_MCParticles
MCParticles StoreArray.
A Class to store the Monte Carlo particle information.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
Accessor to arrays stored in the data store.
bool isValid() const
Check wether the array was registered.
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.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.