File indexing completed on 2025-01-30 10:29:37
0001
0002
0003
0004
0005
0006 #include "ExampleClusterFactory.h"
0007 #include "PodioDatamodel/ExampleClusterCollection.h"
0008 #include "PodioDatamodel/ExampleHitCollection.h"
0009 #include <JANA/JEvent.h>
0010
0011 ExampleClusterFactory::ExampleClusterFactory() {
0012 SetTag("clusters");
0013
0014 }
0015
0016 void ExampleClusterFactory::Process(const std::shared_ptr<const JEvent> &event) {
0017
0018
0019
0020 MutableExampleCluster quadrant1, quadrant2, quadrant3, quadrant4;
0021
0022 auto hits = event->GetCollection<ExampleHit>("hits");
0023 for (auto hit : *hits) {
0024 if (hit.x() > 0) {
0025 if (hit.y() > 0) {
0026 quadrant1.addHits(hit);
0027 quadrant1.energy(quadrant1.energy() + hit.energy());
0028 }
0029 else {
0030 quadrant4.addHits(hit);
0031 quadrant4.energy(quadrant4.energy() + hit.energy());
0032 }
0033 }
0034 else {
0035 if (hit.y() > 0) {
0036 quadrant2.addHits(hit);
0037 quadrant2.energy(quadrant2.energy() + hit.energy());
0038
0039 }
0040 else {
0041 quadrant3.addHits(hit);
0042 quadrant3.energy(quadrant3.energy() + hit.energy());
0043 }
0044
0045 }
0046 }
0047 ExampleClusterCollection clusters;
0048 if (quadrant1.Hits_size() > 0) clusters.push_back(quadrant1);
0049 if (quadrant2.Hits_size() > 0) clusters.push_back(quadrant2);
0050 if (quadrant3.Hits_size() > 0) clusters.push_back(quadrant3);
0051 if (quadrant4.Hits_size() > 0) clusters.push_back(quadrant4);
0052
0053
0054 SetCollection(std::move(clusters));
0055 }
0056
0057