Belle II Software  release-08-01-10
CopyRecoTracksWithOverlapModule.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 <alignment/modules/CopyRecoTracksWithOverlap/CopyRecoTracksWithOverlapModule.h>
10 
11 #include <analysis/dataobjects/Particle.h>
12 #include <analysis/dataobjects/ParticleList.h>
13 #include <framework/datastore/StoreArray.h>
14 #include <framework/datastore/StoreObjPtr.h>
15 #include <mdst/dataobjects/Track.h>
16 #include <tracking/dataobjects/RecoTrack.h>
17 
18 using namespace Belle2;
19 
20 //-----------------------------------------------------------------
21 // Register the Module
22 //-----------------------------------------------------------------
23 REG_MODULE(CopyRecoTracksWithOverlap);
24 
25 //-----------------------------------------------------------------
26 // Implementation
27 //-----------------------------------------------------------------
28 
30 {
32 
33  setDescription("Copy RecoTracks with overlap hits in VXD to a new StoreArray (Will need a refit).\n"
34  "If particleList is specified, take only RecoTracks associated to the particles (allows to make prior cuts at analysis level)."
35  );
36 
37  addParam("overlapRecoTracksStoreArrayName", m_overlapRecoTracksArrayName, "Name of StoreArray with output RecoTracks with overlaps",
39  addParam("particleList", m_particleListName, "Name of particle list for which associated RecoTracks should be copied",
41 
42 }
43 
45 {
48 
49  // Register all the relations
51 
52  if (!m_particleListName.empty())
54 }
55 
57 {
58  if (!m_particleListName.empty()) {
59  auto nParticles = m_ParticleList->getListSize();
60  for (unsigned int iParticle = 0; iParticle < nParticles; ++iParticle) {
61  auto particle = m_ParticleList->getParticle(iParticle);
62  auto track = particle->getTrack();
63  if (!track) {
64  B2ERROR("No Track for particle.");
65  continue;
66  }
67  auto recoTrack = track->getRelatedTo<RecoTrack>();
68  if (!recoTrack) {
69  B2ERROR("No RecoTrack for Track");
70  continue;
71  }
72 
73  processRecoTrack(*recoTrack);
74  }
75  } else {
76  for (auto& recoTrack : m_RecoTracks)
77  processRecoTrack(recoTrack);
78  }
79 }
80 
81 
83 {
84  std::array<int, 6> nHitsInLayer = {0, 0, 0, 0, 0, 0};
85 
86  // PXD clusters
87  for (auto hit : track.getPXDHitList())
88  ++nHitsInLayer.at(hit->getSensorID().getLayerNumber() - 1);
89 
90  // SVD clusters
91  for (auto hit : track.getSVDHitList())
92  ++nHitsInLayer.at(hit->getSensorID().getLayerNumber() - 1);
93 
94  bool hasOverlap = false;
95 
96  // Let's be as explicit as possible here:
97  // NOTE: for SVD, U and V hits are stored separatelly in the RecoTrack.
98  // Therefore double hit in a layer means 4 SVD clusters (at same layer)
99  // NOTE: We ignore the possibility of curlers, non-2D SVD hits etc.
100 
101  if (nHitsInLayer[0] == 2) hasOverlap = true;
102  if (nHitsInLayer[1] == 2) hasOverlap = true;
103 
104  if (nHitsInLayer[2] == 4) hasOverlap = true;
105  if (nHitsInLayer[3] == 4) hasOverlap = true;
106  if (nHitsInLayer[4] == 4) hasOverlap = true;
107  if (nHitsInLayer[5] == 4) hasOverlap = true;
108 
109  if (hasOverlap) {
110  // copy RecoTrack to a new array
111  auto overlapTrack = track.copyToStoreArray(m_OverlappingRecoTracks);
112  overlapTrack->addHitsFromRecoTrack(&track);
113  }
114 
115 }
116 
std::string m_particleListName
Name of particle list for which associated RecoTracks should be copied.
virtual void event() override
Copy RecoTracks with overlaps (for particle if specified)
void processRecoTrack(const RecoTrack &track)
Check if RecoTrack has overlap hits -> if yes, copy to a new array.
CopyRecoTracksWithOverlapModule()
Constructor: Sets the description, the properties and the parameters of the module.
StoreArray< RecoTrack > m_OverlappingRecoTracks
Overlapping tracks.
StoreObjPtr< ParticleList > m_ParticleList
Particle list.
std::string m_overlapRecoTracksArrayName
Name of StoreArray with output RecoTracks with overlaps.
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
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
static void registerRequiredRelations(StoreArray< RecoTrack > &recoTracks, std::string const &pxdHitsStoreArrayName="", std::string const &svdHitsStoreArrayName="", std::string const &cdcHitsStoreArrayName="", std::string const &bklmHitsStoreArrayName="", std::string const &eklmHitsStoreArrayName="", std::string const &recoHitInformationStoreArrayName="")
Convenience method which registers all relations required to fully use a RecoTrack.
Definition: RecoTrack.cc:53
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
REG_MODULE(arichBtest)
Register the Module.
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
Abstract base class for different kinds of events.