Belle II Software development
ECLTriggerClusterMatcherModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8//This module
9#include <ecl/modules/eclTriggerClusterMatcher/ECLTriggerClusterMatcherModule.h>
10
11//Framework
12#include <framework/geometry/B2Vector3.h>
13
14//MDST
15#include <mdst/dataobjects/ECLCluster.h>
16
17//Trg
18#include <trg/ecl/dataobjects/TRGECLCluster.h>
19
20
21using namespace Belle2;
22using namespace std;
23
24//-----------------------------------------------------------------
25// Register the Module
26//-----------------------------------------------------------------
27REG_MODULE(ECLTriggerClusterMatcher);
28
29//-----------------------------------------------------------------
30// Implementation
31//-----------------------------------------------------------------
32
34{
35 // Set module properties
36 setDescription("Match ECLTRGClusters to ECLClusters");
37 addParam("minClusterEnergy", m_minClusterEnergy, "Minimum energy of the ECLCluster to be checked [GeV].", 0.1);
38 addParam("maxAngle", m_maxAngle, "Maximum angle between an ECLCLuster and an ECLTRGCluster [rad]", 0.15);
39 addParam("minFracEnergy", m_minFracEnergy, "Minimum energy fraction trg/cluster.", 0.);
40 addParam("maxFracEnergy", m_maxFracEnergy, "Maximal energy fraction trg/cluster.", 2.);
42}
43
45{
46 m_eclClusters.isRequired();
47 m_eclTriggers.isRequired();
48 m_eclClusters.registerRelationTo(m_eclTriggers);
49}
50
52{
53 for (auto& eclcluster : m_eclClusters) {
54 const double eclclusterTheta = eclcluster.getTheta();
55 const double eclclusterPhi = eclcluster.getPhi();
56
57 double eclclusterE = 0.0;
58 if (eclcluster.hasHypothesis(ECLCluster::EHypothesisBit::c_nPhotons)) {
59 eclclusterE = eclcluster.getEnergy(ECLCluster::EHypothesisBit::c_nPhotons);
60 } else if (eclcluster.hasHypothesis(ECLCluster::EHypothesisBit::c_neutralHadron)) {
61 eclclusterE = eclcluster.getEnergy(ECLCluster::EHypothesisBit::c_neutralHadron);
62 } else continue;
63
64 // Users can re-run this with different settings, remove this bit.
65 eclcluster.removeStatus(ECLCluster::EStatusBit::c_TriggerCluster);
66
67 // Add status bit that shows that the matcher has run
69
70 if (eclclusterE < m_minClusterEnergy) continue; // skip low energy cluster
71
72 // Lets ignore any problems from particle from non-IP locations.
73 B2Vector3D cluster(1., 1., 1);
74 cluster.SetTheta(eclclusterTheta);
75 cluster.SetPhi(eclclusterPhi);
76
77 for (const auto& ecltrigger : m_eclTriggers) {
78 const double ecltriggerX = ecltrigger.getPositionX();
79 const double ecltriggerY = ecltrigger.getPositionY();
80 const double ecltriggerZ = ecltrigger.getPositionZ();
81 const double ecltriggerE = ecltrigger.getEnergyDep();
82
83 B2Vector3D trigger(ecltriggerX, ecltriggerY, ecltriggerZ);
84
85 const double angle = cluster.Angle(trigger);
86
87 double fracEnergy = -1.;
88 if (eclclusterE > 0.0) fracEnergy = ecltriggerE / eclclusterE;
89
90 // set relation(s) and status bit
91 if (angle < m_maxAngle and fracEnergy > m_minFracEnergy and fracEnergy < m_maxFracEnergy) {
92 eclcluster.addStatus(ECLCluster::EStatusBit::c_TriggerCluster);
93 eclcluster.addRelationTo(&ecltrigger);
94 }
95
96 }
97 }
98}
@ c_TriggerCluster
bit 0: ECLCluster is matched to a ECL trigger cluster
@ c_TriggerClusterMatching
bit 1: ECLCluster to ECLTRGCluster matcher was run
@ c_nPhotons
CR is split into n photons (N1)
@ c_neutralHadron
CR is reconstructed as a neutral hadron (N2)
double m_minFracEnergy
minimum energy fraction tr/cluster
virtual void initialize() override
Register input and output data.
double m_maxFracEnergy
maximal energy fraction trg/cluster
ECLTriggerClusterMatcherModule()
Constructor: Sets the description, the properties and the parameters of the module.
StoreArray< TRGECLCluster > m_eclTriggers
eclTriggers
StoreArray< ECLCluster > m_eclClusters
eclClusters
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.
STL namespace.