Skip to content

Commit bad1602

Browse files
committed
Add example calibrations factory
1 parent b6dbaca commit bad1602

File tree

4 files changed

+44
-9
lines changed

4 files changed

+44
-9
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22

3-
#add_jana_plugin(podio_calibrations)
3+
add_jana_plugin(podio_calibrations)
44

5-
#target_link_libraries(podio_calibrations PUBLIC podio_datamodel)
5+
target_link_libraries(podio_calibrations PUBLIC jana2_tutorial_podio_datamodel)
66

77

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
#include <jana2_tutorial_podio_datamodel/CalorimeterClusterCollection.h>
3+
4+
#include <JANA/Components/JOmniFactory.h>
5+
#include <JANA/Calibrations/JCalibrationManager.h>
6+
7+
8+
struct CalorimeterCluster_factory_filtered:
9+
public JOmniFactory<CalorimeterCluster_factory_filtered> {
10+
11+
PodioInput<CalorimeterCluster> m_clusters_in {this};
12+
PodioOutput<CalorimeterCluster> m_clusters_out {this};
13+
14+
Service<JCalibrationManager> m_calib_manager {this};
15+
double threshold = 100.0;
16+
17+
void Configure() {}
18+
19+
void ChangeRun(int32_t run_nr) {
20+
m_clusters_out.SetCollectionName("filtered_clusters");
21+
m_calib_manager->GetJCalibration(run_nr)
22+
->Get("MyCAL/cluster_threshold", threshold);
23+
}
24+
25+
void Execute(int32_t /*run_nr*/, uint64_t /*evt_nr*/) {
26+
m_clusters_out()->setSubsetCollection(true);
27+
for (auto cluster : *m_clusters_in()) {
28+
if (cluster.getEnergy() >= threshold) {
29+
m_clusters_out()->push_back(cluster);
30+
}
31+
}
32+
}
33+
};
34+
35+

src/libraries/JANA/Topology/JEventPool.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void JEventPool::Ingest(JEvent* event, size_t location) {
7070
// This is necessary for interleaved events
7171
auto incoming_event_level = event->GetLevel();
7272
if (incoming_event_level != m_level) {
73-
LOG << "Pool " << toString(m_level) << " forwarding event " << event->GetEventNumber() << " to parent pool " << toString(event->GetLevel());
73+
//LOG << "Pool " << toString(m_level) << " forwarding event " << event->GetEventNumber() << " to parent pool " << toString(event->GetLevel());
7474
m_parent_pools.at(incoming_event_level)->Ingest(event, location);
7575
return;
7676
}
@@ -79,32 +79,32 @@ void JEventPool::Ingest(JEvent* event, size_t location) {
7979
auto finished_parents = event->ReleaseAllParents();
8080
// TODO: I'd prefer to not have to do an allocation each time, but this will work for now
8181
for (auto* parent : finished_parents) {
82-
LOG << "JEventPool::Ingest: Found finished parent of level " << toString(parent->GetLevel());
82+
//LOG << "JEventPool::Ingest: Found finished parent of level " << toString(parent->GetLevel());
8383
m_parent_pools.at(parent->GetLevel())->NotifyThatAllChildrenFinished(parent, location);
8484
// TODO: This is likely the wrong location. Obtain from parent event?
8585
}
8686

8787
if (event->GetChildCount() == 0) {
8888
// There's no way for additional children to appear because Ingest takes the "original" parent
8989
//LOG << "JEventPool::Ingest: event at level " << toString(m_level) << " is PUSHED";
90-
LOG << "JEventPool::Ingest: " << toString(m_level) << " event is pushed";
90+
//LOG << "JEventPool::Ingest: " << toString(m_level) << " event is pushed";
9191
Push(event, location);
9292
}
9393
else {
9494
// We've received the original but we can't push it until all children have been pushed to
9595
// _their_ pools, in which case we push once we receive the notification
96-
LOG << "JEventPool::Ingest: " << toString(m_level) << " event is pending";
96+
//LOG << "JEventPool::Ingest: " << toString(m_level) << " event is pending";
9797
m_pending.insert(event);
9898
}
9999
}
100100

101101

102102
void JEventPool::NotifyThatAllChildrenFinished(JEvent* event, size_t location) {
103-
LOG << "JEventPool::Notify called for level " << toString(m_level);
103+
//LOG << "JEventPool::Notify called for level " << toString(m_level);
104104
size_t was_present = m_pending.erase(event);
105105
if (was_present == 1) {
106106
Push(event, location);
107-
LOG << "JEventPool at level " << toString(m_level) << " has pushed a parent event";
107+
//LOG << "JEventPool at level " << toString(m_level) << " has pushed a parent event";
108108
}
109109
}
110110

src/libraries/JANA/Topology/JMultilevelSourceArrow.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void JMultilevelSourceArrow::fire(JEvent* input, OutputData& outputs, size_t& ou
8080
// Note that this only attaches parents that we already, so if the parents arrive in the wrong order they
8181
// will just be missing. If this is expected behavior, you'll need to set your downstream parent inputs to be optional.
8282
if (parent_pair.first != nullptr) {
83-
LOG_INFO(get_logger()) << "JMultilevelSourceArrow: Attaching parent: " << parent_pair.first->GetEventStamp() << " to event " << input->GetEventStamp();
83+
LOG_TRACE(get_logger()) << "JMultilevelSourceArrow: Attaching parent: " << parent_pair.first->GetEventStamp() << " to event " << input->GetEventStamp();
8484
input->SetParent(parent_pair.first);
8585
}
8686
}

0 commit comments

Comments
 (0)