File indexing completed on 2025-01-18 10:17:19
0001
0002
0003
0004
0005
0006 #include "ExampleMultifactory.h"
0007 #include <JANA/JEvent.h>
0008 #include <PodioDatamodel/ExampleHitCollection.h>
0009 #include <PodioDatamodel/ExampleClusterCollection.h>
0010
0011 ExampleMultifactory::ExampleMultifactory() {
0012
0013
0014 DeclarePodioOutput<ExampleHit>("hits_filtered", false);
0015 DeclarePodioOutput<ExampleCluster>("clusters_from_hits_filtered");
0016 DeclarePodioOutput<ExampleCluster>("clusters_filtered", false);
0017 }
0018
0019 void ExampleMultifactory::Process(const std::shared_ptr<const JEvent> & event) {
0020
0021 auto hits = event->GetCollection<ExampleHit>("hits");
0022
0023
0024
0025
0026 ExampleHitCollection hits_filtered;
0027 hits_filtered.setSubsetCollection(true);
0028 for (auto hit : *hits) {
0029 if (hit.energy() > 10) {
0030 hits_filtered.push_back(hit);
0031 }
0032 }
0033
0034 ExampleClusterCollection clusters_from_hits_filtered;
0035 MutableExampleCluster quadrant1, quadrant2, quadrant3, quadrant4;
0036
0037 for (const auto& hit : hits_filtered) {
0038 if (hit.x() > 0 && hit.y() > 0) {
0039 quadrant1.addHits(hit);
0040 quadrant1.energy(quadrant1.energy() + hit.energy());
0041 }
0042 else if (hit.x() > 0 && hit.y() <= 0) {
0043 quadrant4.addHits(hit);
0044 quadrant4.energy(quadrant4.energy() + hit.energy());
0045 }
0046 else if (hit.x() <= 0 && hit.y() > 0) {
0047 quadrant2.addHits(hit);
0048 quadrant2.energy(quadrant2.energy() + hit.energy());
0049 }
0050 else if (hit.x() <= 0 && hit.y() <= 0) {
0051 quadrant3.addHits(hit);
0052 quadrant3.energy(quadrant3.energy() + hit.energy());
0053 }
0054 }
0055
0056 if (quadrant1.Hits_size() > 0) clusters_from_hits_filtered.push_back(quadrant1);
0057 if (quadrant2.Hits_size() > 0) clusters_from_hits_filtered.push_back(quadrant2);
0058 if (quadrant3.Hits_size() > 0) clusters_from_hits_filtered.push_back(quadrant3);
0059 if (quadrant4.Hits_size() > 0) clusters_from_hits_filtered.push_back(quadrant4);
0060
0061
0062 auto clusters = event->GetCollection<ExampleCluster>("clusters");
0063 ExampleClusterCollection clusters_filtered;
0064 clusters_filtered.setSubsetCollection(true);
0065
0066 for (auto cluster : *clusters) {
0067 if (cluster.energy() > 50) {
0068 clusters_filtered.push_back(cluster);
0069 }
0070 }
0071
0072
0073
0074 SetCollection<ExampleHit>("hits_filtered", std::move(hits_filtered));
0075 SetCollection<ExampleCluster>("clusters_from_hits_filtered", std::move(clusters_from_hits_filtered));
0076 SetCollection<ExampleCluster>("clusters_filtered", std::move(clusters_filtered));
0077
0078 }