9#include <alignment/modules/MergerCosmicTracks/MergerCosmicTracksModule.h>
11#include <cdc/geometry/CDCGeometryPar.h>
12#include <ecl/dataobjects/ECLConnectedRegion.h>
13#include <ecl/dataobjects/ECLShower.h>
14#include <framework/datastore/StoreArray.h>
15#include <framework/geometry/B2Vector3.h>
16#include <mdst/dataobjects/KLMCluster.h>
17#include <vxd/geometry/GeoCache.h>
25 setDescription(
"Select cosmic events containing two tracks (up/down) and merge two tracks");
29 "StoreArray containing the RecoTracks to read from and delete afterwards.",
32 "StoreArray to where to copy the merged RecoTrack.",
35 "Flag to using magnetic field during reconstruction.",
61 const float fittedValuesOfFunctions[3] = {50.2380, 21.9203, 19.8463};
69 upperTrack = firstRecoTrack;
70 lowerTrack = secondRecoTrack;
72 upperTrack = secondRecoTrack;
73 lowerTrack = firstRecoTrack;
78 float totalADCCount = 0;
81 for (
int i = 0; i < CDCHits; i++) {
87 for (
int i = 0; i < CDCHits; i++) {
91 if (totalADCCount / numberOfCDCHits < 115) {
94 fittedValuesOfFunctions[1]);
107 float magnitudeMomentum = momentum.Mag();
111 B2Vector3D newMomentum(newMomentumX, newMomentumY, newMomentumZ);
119 int sortingNumber = 0;
123 for (
int i = 0; i < PXDHits; i++) {
133 for (
int i = 0; i < PXDHits; i++) {
142 for (
int i = 0; i < SVDHits; i++) {
150 for (
int i = 0; i < SVDHits; i++) {
159 for (
int i = 0; i < CDCHits; i++) {
167 for (
int i = CDCHits - 1; i >= 0; i--) {
175 for (
int i = 0; i < BKLMHits; i++) {
183 for (
int i = 0; i < EKLMHits; i++) {
190 for (
int i = 0; i < BKLMHits; i++) {
198 for (
int i = 0; i < EKLMHits; i++) {
221 const float fittedValuesOfFunctions[3] = {50.2380, 21.9203, 19.8463};
226 int numberKLMClusterEnoughLayers = 0;
229 numberKLMClusterEnoughLayers++;
234 || numberKLMClusterEnoughLayers == 2 || numberKLMClusterEnoughLayers == 1) {
237 if (track.size() != 0) {
241 int numberOfCDCHits =
m_RecoTracks[0]->getNumberOfCDCHits();
242 float totalADCCount = 0;
245 for (
int i = 0; i < CDCHits; i++) {
246 totalADCCount = totalADCCount +
m_RecoTracks[0]->getSortedCDCHitList()[i]->getADCCount();
249 if (totalADCCount / numberOfCDCHits < 115) {
252 fittedValuesOfFunctions[1]);
262 float magnitudeMomentum = momentum.Mag();
266 B2Vector3D newMomentum(newMomentumX, newMomentumY, newMomentumZ);
272 int sortingNumber = 0;
275 for (
int i = 0; i < PXDHits; i++) {
283 for (
int i = 0; i < SVDHits; i++) {
290 for (
int i = 0; i < CDCHits; i++) {
297 for (
int i = 0; i < BKLMHits; i++) {
304 for (
int i = 0; i < EKLMHits; i++) {
319 if (trackFirst.
size() != 0 && trackSecond.size() != 0) {
322 if ((eclShowerFirst.
size() != 0 && eclShowerSecond.size() != 0) || ((
m_RecoTracks[0]->hasEKLMHits()
328 }
else if (eclShowerFirst.
size() != 0 || eclShowerSecond.size() != 0 ||
m_RecoTracks[0]->hasEKLMHits()
343 if (trackFirst.
size() != 0) {
346 if (trackSecond.
size() != 0) {
350 if (eclShowerFirst.
size() != 0 && eclShowerSecond.size() != 0) {
351 if (eclShowerFirst[0]->getRelationsWith<Track>().
size() == 1 && eclShowerSecond[0]->getRelationsWith<
Track>().size() == 1) {
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.
Class to store ECL Showers.
void MergingTracks(RecoTrack *, RecoTrack *, StoreArray< RecoTrack > &)
Merge cosmic tracks.
void initialize() override
Register the store arrays and store obj pointers.
unsigned int m_minimumNumHitCut
Number of CDC hit per track required for cosmic track.
void event() override
Do the selection.
StoreArray< ECLConnectedRegion > m_ECLConnectedRegions
ECL connected regions.
double m_magnitudeOfMomentumWithoutMagneticField
Magnitude of cosmic tracks if magnetic field is not used.
std::string m_param_recoTracksStoreArrayName
StoreArray name from which to read the reco tracks.
bool m_usingMagneticField
Flag to using magnetic field during reconstruction.
StoreArray< KLMCluster > m_KLMClusters
KLM clusters.
std::string m_param_mergedRecoTracksStoreArrayName
StoreArray name where the merged reco track is written.
unsigned int m_minimumClusterSize
Minimal PXD cluster size for used PXD hits in cosmic track.
StoreArray< RecoTrack > m_RecoTracks
RecoTracks.
StoreArray< Track > m_Tracks
Tracks.
MergerCosmicTracksModule()
Create a new instance of the module.
StoreArray< RecoTrack > m_MergedRecoTracks
Merged RecoTracks.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
This is the Reconstruction Event-Data Model Track.
std::vector< Belle2::RecoTrack::UsedSVDHit * > getSortedSVDHitList() const
Return a sorted list of svd hits. Sorted by the sortingParameter.
bool addBKLMHit(const UsedBKLMHit *bklmHit, const unsigned int sortingParameter, OriginTrackFinder foundByTrackFinder=OriginTrackFinder::c_undefinedTrackFinder)
Adds a bklm hit with the given information to the reco track.
bool addCDCHit(const UsedCDCHit *cdcHit, const unsigned int sortingParameter, RightLeftInformation rightLeftInformation=RightLeftInformation::c_undefinedRightLeftInformation, OriginTrackFinder foundByTrackFinder=OriginTrackFinder::c_undefinedTrackFinder)
Adds a cdc hit with the given information to the reco track.
bool hasCDCHits() const
Returns true if the track has cdc hits.
unsigned int getNumberOfBKLMHits() const
Return the number of bklm hits.
bool addEKLMHit(const UsedEKLMHit *eklmHit, const unsigned int sortingParameter, OriginTrackFinder foundByTrackFinder=OriginTrackFinder::c_undefinedTrackFinder)
Adds an eklm hit with the given information to the reco track.
bool addPXDHit(const UsedPXDHit *pxdHit, const unsigned int sortingParameter, OriginTrackFinder foundByTrackFinder=OriginTrackFinder::c_undefinedTrackFinder)
Adds a pxd hit with the given information to the reco track.
std::vector< Belle2::RecoTrack::UsedCDCHit * > getSortedCDCHitList() const
Return a sorted list of cdc hits. Sorted by the sortingParameter.
ROOT::Math::XYZVector getPositionSeed() const
Return the position seed stored in the reco track. ATTENTION: This is not the fitted position.
std::vector< Belle2::RecoTrack::UsedEKLMHit * > getSortedEKLMHitList() const
Return a sorted list of eklm hits. Sorted by the sortingParameter.
unsigned int getNumberOfEKLMHits() const
Return the number of eklm hits.
unsigned int getNumberOfSVDHits() const
Return the number of svd hits.
unsigned int getNumberOfCDCHits() const
Return the number of cdc hits.
bool hasPXDHits() const
Returns true if the track has pxd hits.
void setTimeSeed(const double timeSeed)
Set the time seed. ATTENTION: This is not the fitted time.
bool hasEKLMHits() const
Returns true if the track has eklm hits.
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.
std::vector< Belle2::RecoTrack::UsedBKLMHit * > getSortedBKLMHitList() const
Return a sorted list of bklm hits. Sorted by the sortingParameter.
std::vector< Belle2::RecoTrack::UsedPXDHit * > getSortedPXDHitList() const
Return a sorted list of pxd hits. Sorted by the sortingParameter.
bool hasBKLMHits() const
Returns true if the track has bklm hits.
short int getChargeSeed() const
Return the charge seed stored in the reco track. ATTENTION: This is not the fitted charge.
ROOT::Math::XYZVector getMomentumSeed() const
Return the momentum seed stored in the reco track. ATTENTION: This is not the fitted momentum.
unsigned int getNumberOfPXDHits() const
Return the number of pxd hits.
bool addSVDHit(const UsedSVDHit *svdHit, const unsigned int sortingParameter, OriginTrackFinder foundByTrackFinder=OriginTrackFinder::c_undefinedTrackFinder)
Adds a svd hit with the given information to the reco track.
double getTimeSeed() const
Return the time seed stored in the reco track. ATTENTION: This is not the fitted time.
bool hasSVDHits() const
Returns true if the track has svd hits.
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
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.
Accessor to arrays stored in the data store.
T * appendNew()
Construct a new T object at the end of the array.
int getEntries() const
Get the number of objects in the array.
Class that bundles various TrackFitResults.
static GeoCache & getInstance()
Return a reference to the singleton instance.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.