Belle II Software  release-05-02-19
CopyRecoTracksWithOverlapModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2013 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Tadeas Bilka *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <alignment/modules/CopyRecoTracksWithOverlap/CopyRecoTracksWithOverlapModule.h>
12 
13 #include <analysis/dataobjects/Particle.h>
14 #include <analysis/dataobjects/ParticleList.h>
15 #include <framework/datastore/StoreArray.h>
16 #include <framework/datastore/StoreObjPtr.h>
17 #include <mdst/dataobjects/Track.h>
18 #include <tracking/dataobjects/RecoTrack.h>
19 
20 using namespace Belle2;
21 
22 //-----------------------------------------------------------------
23 // Register the Module
24 //-----------------------------------------------------------------
25 REG_MODULE(CopyRecoTracksWithOverlap)
26 
27 //-----------------------------------------------------------------
28 // Implementation
29 //-----------------------------------------------------------------
30 
32 {
33  setPropertyFlags(c_ParallelProcessingCertified);
34 
35  setDescription("Copy RecoTracks with overlap hits in VXD to a new StoreArray (Will need a refit).\n"
36  "If particleList is specified, take only RecoTracks associated to the particles (allows to make prior cuts at analysis level)."
37  );
38 
39  addParam("overlapRecoTracksStoreArrayName", m_overlapRecoTracksArrayName, "Name of StoreArray with output RecoTracks with overlaps",
40  m_overlapRecoTracksArrayName);
41  addParam("particleList", m_particleList, "Name of particle list for which associated RecoTracks should be copied", m_particleList);
42 
43 }
44 
46 {
47  StoreArray<RecoTrack> tracks;
49 
50  tracks.isRequired();
51  overlapTracks.registerInDataStore();
52 
53  // Register all the relations
55 
56  if (!m_particleList.empty()) {
58  particleList.isRequired();
59  }
60 
61 }
62 
64 {
65  if (!m_particleList.empty()) {
67 
68  auto nParticles = particleList->getListSize();
69  for (unsigned int iParticle = 0; iParticle < nParticles; ++iParticle) {
70  auto particle = particleList->getParticle(iParticle);
71  auto track = particle->getTrack();
72  if (!track) {
73  B2ERROR("No Track for particle.");
74  continue;
75  }
76  auto recoTrack = track->getRelatedTo<RecoTrack>();
77  if (!recoTrack) {
78  B2ERROR("No RecoTrack for Track");
79  continue;
80  }
81 
82  processRecoTrack(*recoTrack);
83  }
84  } else {
85  StoreArray<RecoTrack> recoTracks;
86  for (auto& recoTrack : recoTracks) {
87  processRecoTrack(recoTrack);
88  }
89  }
90 }
91 
92 
94 {
96 
97  std::array<int, 6> nHitsInLayer = {0, 0, 0, 0, 0, 0};
98 
99  // PXD clusters
100  for (auto hit : track.getPXDHitList())
101  ++nHitsInLayer.at(hit->getSensorID().getLayerNumber() - 1);
102 
103  // SVD clusters
104  for (auto hit : track.getSVDHitList())
105  ++nHitsInLayer.at(hit->getSensorID().getLayerNumber() - 1);
106 
107  bool hasOverlap = false;
108 
109  // Let's be as explicit as possible here:
110  // NOTE: for SVD, U and V hits are stored separatelly in the RecoTrack.
111  // Therefore double hit in a layer means 4 SVD clusters (at same layer)
112  // NOTE: We ignore the possibility of curlers, non-2D SVD hits etc.
113 
114  if (nHitsInLayer[0] == 2) hasOverlap = true;
115  if (nHitsInLayer[1] == 2) hasOverlap = true;
116 
117  if (nHitsInLayer[2] == 4) hasOverlap = true;
118  if (nHitsInLayer[3] == 4) hasOverlap = true;
119  if (nHitsInLayer[4] == 4) hasOverlap = true;
120  if (nHitsInLayer[5] == 4) hasOverlap = true;
121 
122  if (hasOverlap) {
123  // copy RecoTrack to a new array
124  auto overlapTrack = track.copyToStoreArray(overlapTracks);
125  overlapTrack->addHitsFromRecoTrack(&track);
126  }
127 
128 }
129 
Belle2::RecoTrack::registerRequiredRelations
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:42
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::CopyRecoTracksWithOverlapModule::processRecoTrack
void processRecoTrack(const RecoTrack &track) const
Check if RecoTrack has overlap hits -> if yes, copy to a new array.
Definition: CopyRecoTracksWithOverlapModule.cc:93
Belle2::CopyRecoTracksWithOverlapModule::initialize
virtual void initialize() override
init
Definition: CopyRecoTracksWithOverlapModule.cc:45
Belle2::CopyRecoTracksWithOverlapModule::event
virtual void event() override
Copy RecoTracks with overlaps (for particle if specified)
Definition: CopyRecoTracksWithOverlapModule.cc:63
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::CopyRecoTracksWithOverlapModule::m_particleList
std::string m_particleList
Name of particle list for which associated RecoTracks should be copied.
Definition: CopyRecoTracksWithOverlapModule.h:55
Belle2::RecoTrack
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:78
Belle2::CopyRecoTracksWithOverlapModule::m_overlapRecoTracksArrayName
std::string m_overlapRecoTracksArrayName
Name of StoreArray with output RecoTracks with overlaps.
Definition: CopyRecoTracksWithOverlapModule.h:53
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::StoreObjPtr
Type-safe access to single objects in the data store.
Definition: ParticleList.h:33
Belle2::CopyRecoTracksWithOverlapModule
Copy RecoTracks with overlap hits in VXD to a new StoreArray (Will need a refit).
Definition: CopyRecoTracksWithOverlapModule.h:35
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33