9 #include <ecl/modules/eclTrimShowersAndDigits/ECLTrimShowersAndDigitsModule.h>
10 #include <mdst/dataobjects/ECLCluster.h>
11 #include <ecl/dataobjects/ECLCalDigit.h>
12 #include <ecl/dataobjects/ECLShower.h>
13 #include <mdst/dataobjects/MCParticle.h>
14 #include <framework/datastore/DataStore.h>
32 setDescription(
"Create trimmed ECLCalDigit and ECLShower dataobjects");
39 void ECLTrimShowersAndDigitsModule::initialize()
43 m_eclClusterArray.isRequired();
44 m_eclShowerArray.isRequired();
45 m_eclCalDigitArray.isRequired();
48 m_selectedShowers.registerSubset(m_eclShowerArray, m_ShowerArrayName);
49 m_selectedShowers.inheritAllRelations();
51 m_selectedDigits.registerSubset(m_eclCalDigitArray, m_DigitArrayName, DataStore::c_WriteOut);
52 m_selectedDigits.inheritAllRelations();
58 void ECLTrimShowersAndDigitsModule::event()
62 const int nCluster = m_eclClusterArray.getEntries();
63 double clusterMaxMCE = 0.;
65 for (
int i = 0; i < nCluster; i++) {
66 if (m_eclClusterArray[i]->hasHypothesis(ECLCluster::EHypothesisBit::c_nPhotons)) {
68 const auto clusterMCRelations = m_eclClusterArray[i]->getRelationsWith<
MCParticle>();
70 for (
unsigned int ir = 0; ir < clusterMCRelations.size(); ++ir) {
71 mcE += clusterMCRelations.weight(ir);
73 if (mcE > clusterMaxMCE) {
75 maxCellID = m_eclClusterArray[i]->getMaxECellId();
82 const int nMC = m_mcParticleArray.getEntries();
83 if (nMC != 1) {maxCellID = 9999;}
86 m_selectedShowers.select([
this](
const ECLShower * shower) {
87 return this->selectShower(shower);
91 m_selectedDigits.select([
this](
const ECLCalDigit * digit) {
92 return this->selectDigit(digit);
98 void ECLTrimShowersAndDigitsModule::terminate()
104 bool ECLTrimShowersAndDigitsModule::selectShower(
const ECLShower* shower)
107 bool returnValue =
false;
109 if (clusterShowerRelations.size() > 0 and shower->
getHypothesisId() == ECLShower::c_nPhotons) {
110 const auto cluster = clusterShowerRelations.object(0);
111 const unsigned short cellID = cluster->getMaxECellId();
112 if (cellID == maxCellID) {returnValue =
true;}
119 bool ECLTrimShowersAndDigitsModule::selectDigit(
const ECLCalDigit* digit)
122 bool returnValue =
false;
124 for (
unsigned int ir = 0; ir < clusterDigitRelations.size(); ++ir) {
125 const auto cluster = clusterDigitRelations.object(ir);
126 const unsigned short cellID = cluster->getMaxECellId();
127 if (cellID == maxCellID) {returnValue =
true;}
Class to store calibrated ECLDigits: ECLCalDigits.
Class to store ECL Showers.
int getHypothesisId() const
Get Hypothesis Id.
Create new dataobjects containing only the ECLShower and ECLCalDigits associated with the selected EC...
A Class to store the Monte Carlo particle information.
RelationVector< T > getRelationsWith(const std::string &name="", const std::string &namedRelation="") const
Get the relations between this object and another store array.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.