Belle II Software development
SVDShaperDigitsFromTracksModule.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
9#include <svd/modules/svdPerformance/SVDShaperDigitsFromTracksModule.h>
10
11#include <svd/dataobjects/SVDCluster.h>
12#include <svd/dataobjects/SVDRecoDigit.h>
13
14#include <tracking/dataobjects/RecoTrack.h>
15#include <mdst/dataobjects/Track.h>
16
17#include <framework/datastore/StoreArray.h>
18
19
20using namespace Belle2;
21
22//-----------------------------------------------------------------
23// Register the Module
24//-----------------------------------------------------------------
25REG_MODULE(SVDShaperDigitsFromTracks);
26
27//-----------------------------------------------------------------
28// Implementation
29//-----------------------------------------------------------------
30
32{
33 B2DEBUG(1, "Constructor");
34 // Set module properties
35 setDescription("generates two new StoreArray from the input StoreArray. One contains all ShaperDigits related to Tracks and the other contains all SahperDigits not related to tracks");
36
37 // Parameter definitions
38 addParam("SVDShaperDigits", m_svdshaper, "StoreArray with the input shaperdigits", std::string("SVDShaperDigits"));
39 addParam("SVDRecoDigits", m_svdreco, "StoreArray with the input recodigits", std::string("SVDRecoDigits"));
40 addParam("SVDClusters", m_svdcluster, "StoreArray with the input clusters", std::string("SVDClusters"));
41 addParam("Tracks", m_track, "StoreArray with the input tracks", std::string("Tracks"));
42 addParam("RecoTracks", m_recotrack, "StoreArray with the input recotracks", std::string("RecoTracks"));
43 addParam("outputINArrayName", m_outputINArrayName, "StoreArray with the output shaperdigits",
44 std::string("SVDShaperDigitsFromTracks"));
45 addParam("outputOUTArrayName", m_outputOUTArrayName, "StoreArray with the output shaperdigits",
46 std::string("SVDShaperDigitsNotFromTracks"));
47 addParam("InheritAllRelations", m_inheritance,
48 "Set true if you want to inherit all relations between StoreArray, the default is false", bool(false));
49 addParam("useWithRel5Reconstruction", m_useWithRel5Reco,
50 "Set true if you are using this module with release-05 svd reconstruction (or older)", bool(false));
51
52}
53
58
59
61{
62
63 B2DEBUG(10, "SVDShaperDigits: " << m_svdshaper);
65 B2DEBUG(10, "SVDRecoDigits: " << m_svdreco);
66 B2DEBUG(10, "SVDClusters: " << m_svdcluster);
67 B2DEBUG(10, "Tracks: " << m_track);
68 B2DEBUG(10, "RecoTracks: " << m_recotrack);
69 B2DEBUG(10, "outputINArrayName: " << m_outputINArrayName);
70 B2DEBUG(10, "outputOUTArrayName: " << m_outputOUTArrayName);
71 B2DEBUG(10, "InheritAllRelations: " << m_inheritance);
72
78 ShaperDigits.isRequired();
79 Clusters.isRequired();
81 RecoDigits.isRequired();
82 recoTracks.isRequired();
83 tracks.isRequired();
84 m_selectedShaperDigits.registerSubset(ShaperDigits, m_outputINArrayName);
85 if (m_inheritance) {
86 m_selectedShaperDigits.inheritAllRelations();
87 }
88 if (m_outputOUTArrayName != "") {
89 m_notSelectedShaperDigits.registerSubset(ShaperDigits, m_outputOUTArrayName);
90 if (m_inheritance) {
91 m_notSelectedShaperDigits.inheritAllRelations();
92 }
93 }
94
95}
96
97
98
100{
102
103 m_selectedShaperDigits.select([this](const SVDShaperDigit * theSVDShaperDigit) {
105 return isRelatedToTrackRel5(theSVDShaperDigit);
106 return isRelatedToTrack(theSVDShaperDigit);
107 });
108
109
110 m_notSelectedShaperDigits.select([this](const SVDShaperDigit * theSVDShaperDigit) {
112 return !isRelatedToTrackRel5(theSVDShaperDigit);
113 return !isRelatedToTrack(theSVDShaperDigit);
114 });
115}
116
118{
119
120 RelationVector<SVDCluster> cluster_rel_shaper = shaperdigit->getRelationsFrom<SVDCluster>();
121 if (cluster_rel_shaper.size() == 0) {return false;}
122 else {
123 RelationVector<RecoTrack> recotrack_rel_cluster = cluster_rel_shaper[0]->getRelationsTo<RecoTrack>();
124 if (recotrack_rel_cluster.size() == 0) {return false;}
125 else {
126 RelationVector<Track> track_rel_recotrack = recotrack_rel_cluster[0]->getRelationsFrom<Track>();
127 if (track_rel_recotrack.size() == 0) {return false;}
128 else {return true;}
129 }
130 }
131}
132
134{
135 RelationVector<SVDRecoDigit> reco_rel_shape = shaperdigit->getRelationsFrom<SVDRecoDigit>();
136 if (reco_rel_shape.size() == 0) {return false;}
137 else {
138 RelationVector<SVDCluster> cluster_rel_reco = reco_rel_shape[0]->getRelationsFrom<SVDCluster>();
139 if (cluster_rel_reco.size() == 0) {return false;}
140 else {
141 RelationVector<RecoTrack> recotrack_rel_cluster = cluster_rel_reco[0]->getRelationsTo<RecoTrack>();
142 if (recotrack_rel_cluster.size() == 0) {return false;}
143 else {
144 RelationVector<Track> track_rel_recotrack = recotrack_rel_cluster[0]->getRelationsFrom<Track>();
145 if (track_rel_recotrack.size() == 0) {return false;}
146 else {return true;}
147 }
148 }
149 }
150}
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
Module()
Constructor.
Definition Module.cc:30
This is the Reconstruction Event-Data Model Track.
Definition RecoTrack.h:79
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
RelationVector< FROM > getRelationsFrom(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from another store array to this object.
The SVD Cluster class This class stores all information about reconstructed SVD clusters.
Definition SVDCluster.h:29
The SVD RecoDigit class.
The SVD ShaperDigit class.
std::string m_outputOUTArrayName
StoreArray with the NOT selected output shaperdigits.
std::string m_outputINArrayName
StoreArray with the selected output shaperdigits.
SelectSubset< SVDShaperDigit > m_selectedShaperDigits
all shaperdigits
std::string m_svdshaper
StoreArray with the input shaperdigits.
virtual void initialize() override
init the module
SVDShaperDigitsFromTracksModule()
Constructor: Sets the description, the properties and the parameters of the module.
virtual void event() override
processes the event
SelectSubset< SVDShaperDigit > m_notSelectedShaperDigits
all shaperdigits from tracks
static bool isRelatedToTrackRel5(const SVDShaperDigit *shaperdigit)
select the shaperdigits related to tracks using SVDRecoDigits
bool m_inheritance
if true all relations are inherited
bool m_useWithRel5Reco
if true uses SVDRecoDigits relations
static bool isRelatedToTrack(const SVDShaperDigit *shaperdigit)
select the shaperdigits related to tracks
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Accessor to arrays stored in the data store.
Definition StoreArray.h:113
Class that bundles various TrackFitResults.
Definition Track.h:25
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:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
Abstract base class for different kinds of events.