Belle II Software  release-08-01-10
CDCCosmicTrackMergeModule.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 <cdc/modules/cdcRecoTrackFilter/CDCCosmicTrackMergeModule.h>
10 #include <tracking/dataobjects/RecoTrack.h>
11 #include <framework/datastore/StoreArray.h>
12 
13 using namespace Belle2;
14 
15 REG_MODULE(CDCCosmicTrackMerger);
16 
18 {
19  setDescription("Select cosmic events containing two tracks (up/down) and merge two tracks"
20  "Old reco tracks store array will be deleted afterwards, if the parameter is set to do so.");
22 
23  addParam("recoTracksStoreArrayName", m_param_recoTracksStoreArrayName,
24  "StoreArray containing the RecoTracks to read from and delete afterwards.",
26  addParam("MergedRecoTracksStoreArrayName", m_param_MergedRecoTracksStoreArrayName,
27  "StoreArray to where to copy the merged RecoTrack.",
29  addParam("deleteOtherRecoTracks", m_param_deleteOtherRecoTracks,
30  "Flag to delete the not Merged RecoTracks from the input StoreArray.",
32  addParam("MinimumNumHitCut", m_MinimumNumHitCut, "Number of hit per track required for each track", m_MinimumNumHitCut);
33 }
34 
36 {
40 }
41 
43 {
44  if (m_RecoTracks.getEntries() == 2) {
45  if (m_RecoTracks[0]->getNumberOfCDCHits() > m_MinimumNumHitCut
46  && m_RecoTracks[1]->getNumberOfCDCHits() > m_MinimumNumHitCut) {
47  // if(recoTrackStoreArray[0].getPositionSeed().Y() * recoTrackStoreArray[1].getPositionSeed().Y() >0) continue;
48 
49  std::vector<RecoTrack*> recoTracks;
50  recoTracks.reserve(static_cast<unsigned int>(m_RecoTracks.getEntries()));
51 
52  for (RecoTrack& recoTrack : m_RecoTracks) {
53  recoTracks.push_back(&recoTrack);
54  }
55 
56  std::function < bool (RecoTrack*, RecoTrack*)> lmdSort = [](RecoTrack * lhs, RecoTrack * rhs) {
57  return (lhs->getPositionSeed().Y() > rhs->getPositionSeed().Y());
58  };
59  std::sort(recoTracks.begin(), recoTracks.end(), lmdSort);
60  RecoTrack* upperTrack = recoTracks[0];
61  RecoTrack* lowerTrack = recoTracks[1];
62  B2DEBUG(99, "upper track posSeed :" << upperTrack->getPositionSeed().Y());
63  B2DEBUG(99, "Lowee track posSeed :" << lowerTrack->getPositionSeed().Y());
64  RecoTrack* MergedRecoTrack = m_MergedRecoTracks.appendNew(upperTrack->getPositionSeed(),
65  upperTrack->getMomentumSeed(),
66  upperTrack->getChargeSeed());
67  // retain the seed time of the original track. Important for t0 extraction.
68  MergedRecoTrack->setTimeSeed(upperTrack->getTimeSeed());
69  MergedRecoTrack->addHitsFromRecoTrack(upperTrack);
70  MergedRecoTrack->addHitsFromRecoTrack(lowerTrack);
72  // Delete the other RecoTracks, as they were probably found under a wrong T0 assumption.
73  recoTracks.clear();
74  }
75  }
76  }
77 }
void initialize() override
Register the store arrays and store obj pointers.
void event() override
Do the selection.
CDCCosmicTrackMergerModule()
Create a new instance of the module.
std::string m_param_recoTracksStoreArrayName
StoreArray name from which to read the reco tracks.
std::string m_param_MergedRecoTracksStoreArrayName
StoreArray name where the merged reco track is written.
double m_MinimumNumHitCut
Minium NDF required for each track (up and down).
StoreArray< RecoTrack > m_RecoTracks
Tracks.
bool m_param_deleteOtherRecoTracks
Flag to delete the not RecoTracks from the input StoreArray.
StoreArray< RecoTrack > m_MergedRecoTracks
Merged tracks.
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
size_t addHitsFromRecoTrack(const RecoTrack *recoTrack, unsigned int sortingParameterOffset=0, bool reversed=false, std::optional< double > optionalMinimalWeight=std::nullopt)
Add all hits from another RecoTrack to this RecoTrack.
Definition: RecoTrack.cc:240
ROOT::Math::XYZVector getPositionSeed() const
Return the position seed stored in the reco track. ATTENTION: This is not the fitted position.
Definition: RecoTrack.h:480
void setTimeSeed(const double timeSeed)
Set the time seed. ATTENTION: This is not the fitted time.
Definition: RecoTrack.h:604
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
short int getChargeSeed() const
Return the charge seed stored in the reco track. ATTENTION: This is not the fitted charge.
Definition: RecoTrack.h:508
ROOT::Math::XYZVector getMomentumSeed() const
Return the momentum seed stored in the reco track. ATTENTION: This is not the fitted momentum.
Definition: RecoTrack.h:487
double getTimeSeed() const
Return the time seed stored in the reco track. ATTENTION: This is not the fitted time.
Definition: RecoTrack.h:511
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.
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:246
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
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.