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
55{
56 B2DEBUG(20, "Destructor");
57}
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
99{
100}
101
102
104{
106
107 m_selectedShaperDigits.select([this](const SVDShaperDigit * theSVDShaperDigit) {
109 return isRelatedToTrackRel5(theSVDShaperDigit);
110 return isRelatedToTrack(theSVDShaperDigit);
111 });
112
113
114 m_notSelectedShaperDigits.select([this](const SVDShaperDigit * theSVDShaperDigit) {
116 return !isRelatedToTrackRel5(theSVDShaperDigit);
117 return !isRelatedToTrack(theSVDShaperDigit);
118 });
119}
120
122{
123}
124
126{
127}
128
130{
131
132 RelationVector<SVDCluster> cluster_rel_shaper = shaperdigit->getRelationsFrom<SVDCluster>();
133 if (cluster_rel_shaper.size() == 0) {return false;}
134 else {
135 RelationVector<RecoTrack> recotrack_rel_cluster = cluster_rel_shaper[0]->getRelationsTo<RecoTrack>();
136 if (recotrack_rel_cluster.size() == 0) {return false;}
137 else {
138 RelationVector<Track> track_rel_recotrack = recotrack_rel_cluster[0]->getRelationsFrom<Track>();
139 if (track_rel_recotrack.size() == 0) {return false;}
140 else {return true;}
141 }
142 }
143}
144
146{
147 RelationVector<SVDRecoDigit> reco_rel_shape = shaperdigit->getRelationsFrom<SVDRecoDigit>();
148 if (reco_rel_shape.size() == 0) {return false;}
149 else {
150 RelationVector<SVDCluster> cluster_rel_reco = reco_rel_shape[0]->getRelationsFrom<SVDCluster>();
151 if (cluster_rel_reco.size() == 0) {return false;}
152 else {
153 RelationVector<RecoTrack> recotrack_rel_cluster = cluster_rel_reco[0]->getRelationsTo<RecoTrack>();
154 if (recotrack_rel_cluster.size() == 0) {return false;}
155 else {
156 RelationVector<Track> track_rel_recotrack = recotrack_rel_cluster[0]->getRelationsFrom<Track>();
157 if (track_rel_recotrack.size() == 0) {return false;}
158 else {return true;}
159 }
160 }
161 }
162}
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
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.
Definition: SVDRecoDigit.h:43
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
virtual void terminate() override
terminates the module
virtual void beginRun() override
initializes the module
std::string m_svdreco
SVDRecoDigits StoreArray.
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: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.