9 #include <ecl/modules/MCMatcherECLClusters/MCMatcherECLClustersModule.h>
12 #include <mdst/dataobjects/ECLCluster.h>
13 #include <mdst/dataobjects/MCParticle.h>
16 #include <ecl/dataobjects/ECLHit.h>
17 #include <ecl/dataobjects/ECLCalDigit.h>
18 #include <ecl/dataobjects/ECLDigit.h>
19 #include <ecl/dataobjects/ECLShower.h>
20 #include <ecl/dataobjects/ECLSimHit.h>
34 m_eclCalDigits(eclCalDigitArrayName()),
35 m_eclDigits(eclDigitArrayName()),
36 m_eclClusters(eclClusterArrayName()),
37 m_eclShowers(eclShowerArrayName()),
38 m_mcParticleToECLHitRelationArray(m_mcParticles, m_eclHits),
39 m_mcParticleToECLSimHitRelationArray(m_mcParticles, m_eclSimHits)
42 setDescription(
"MCMatcherECLClustersModule");
43 setPropertyFlags(c_ParallelProcessingCertified);
75 short int Index[8736];
76 std::fill_n(Index, 8736, -1);
78 TObject** ocd = cd->GetObjectRef();
79 for (
int i = 0, imax = cd->GetEntries(); i < imax; i++) {
81 double calEnergy = t.getEnergy();
82 if (calEnergy < 0)
continue;
83 Index[t.getCellId() - 1] = i;
91 for (
int i = 0, imax = p2sh.
getEntries(); i < imax; i++) {
93 const std::vector<unsigned int>& simhitindx = re.getToIndices();
94 std::map<int, double> e;
95 for (
unsigned int j : simhitindx) {
97 int id = h->getCellId() - 1;
98 e[id] += h->getEnergyDep();
102 for (std::pair<int, double> t : e) {
103 int ind = Index[t.first];
117 double shower_mcParWeight = 0;
121 for (
unsigned int iRelation = 0; iRelation < shower_CalDigitRelations.size(); ++iRelation) {
124 const ECLCalDigit* calDigit = shower_CalDigitRelations.object(iRelation);
128 const double calDigit_showerWeight = shower_CalDigitRelations.weight(iRelation);
131 auto it = e.find(
id);
133 const double calDigit_mcParWeight = (*it).second;
134 shower_mcParWeight += (calDigit_mcParWeight * calDigit_showerWeight);
137 if (shower_mcParWeight > 0)
138 shower.addRelationTo(mcs[re.getFromIndex()], shower_mcParWeight);
143 std::fill_n(Index, 8736, -1);
145 TObject** oed = ed->GetObjectRef();
146 for (
int i = 0, imax = ed->GetEntries(); i < imax; i++) {
148 if (t.getAmp() <= 0)
continue;
149 Index[t.getCellId() - 1] = i;
155 for (
int i = 0, imax = p2eh.
getEntries(); i < imax; i++) {
157 const std::vector<unsigned int>& eclhitindx = re.getToIndices();
158 for (
unsigned int j : eclhitindx) {
159 const ECLHit* t = eclhits[j];
160 int id = t->getCellId() - 1;
161 if (t->getBackgroundTag() == 0
174 if (!eclCluster)
continue;
177 for (
unsigned int i = 0; i < mcParticles.
size(); ++i) {
178 const auto mcParticle = mcParticles.
object(i);
179 const auto weight = mcParticles.
weight(i);
Class to store calibrated ECLDigits: ECLCalDigits.
int getCellId() const
Get Cell ID.
Class to store ECL digitized hits (output of ECLDigi) relation to ECLHit filled in ecl/modules/eclDig...
Class to store simulated hits which equate to average of ECLSImHit on crystals input for digitization...
Class to store ECL Showers.
ClassECLSimHit - Geant4 simulated hit for the ECL.
Class to represent the hit of one cell.
virtual const char * eclDigitArrayName() const
Default name ECLDigits.
StoreArray< ECLShower > m_eclShowers
ECLShowers StoreArray.
RelationArray m_mcParticleToECLSimHitRelationArray
MCParticles to ECLSimHits RelationArray.
virtual void initialize() override
Initialize variables, print info, and start CPU clock.
RelationArray m_mcParticleToECLHitRelationArray
MCParticles to ECLHits RelationArray.
virtual void event() override
Actual digitization of all hits in the ECL.
virtual const char * eclShowerArrayName() const
Default name ECLShowers.
virtual void endRun() override
Nothing so far.
virtual void terminate() override
Stopping of CPU clock.
StoreArray< ECLSimHit > m_eclSimHits
ECLSimHits StoreArray.
StoreArray< ECLDigit > m_eclDigits
ECLDigits StoreArray.
virtual const char * eclClusterArrayName() const
Default name ECLClusters.
virtual void beginRun() override
Nothing so far.
StoreArray< ECLCluster > m_eclClusters
ECLClusters StoreArray.
StoreArray< ECLHit > m_eclHits
ECLHits StoreArray.
StoreArray< MCParticle > m_mcParticles
MCParticles StoreArray.
virtual ~MCMatcherECLClustersModule()
Destructor.
virtual const char * eclCalDigitArrayName() const
Default name ECLCalDigits.
StoreArray< ECLCalDigit > m_eclCalDigits
ECLCalDigits StoreArray.
A Class to store the Monte Carlo particle information.
Low-level class to create/modify relations between StoreArrays.
int getEntries() const
Get the number of elements.
Class to store a single element of a relation.
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
T * object(int index) const
Get object with index.
float weight(int index) const
Get weight with index.
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
FROM * getRelatedFrom(const std::string &name="", const std::string &namedRelation="") const
Get the object from which this object has a relation.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
TClonesArray * getPtr() const
Raw access to the underlying TClonesArray.
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.