Belle II Software development
ARICHMCParticlesModule.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// Own header.
10#include <arich/modules/arichMCParticles/ARICHMCParticlesModule.h>
11
12// framework - DataStore
13#include <framework/datastore/DataStore.h>
14
15// framework aux
16#include <framework/gearbox/Const.h>
17#include <framework/logging/Logger.h>
18
19#include <mdst/dataobjects/Track.h>
20#include <tracking/dataobjects/ExtHit.h>
21#include <mdst/dataobjects/MCParticle.h>
22
23namespace Belle2 {
29 //-----------------------------------------------------------------
31 //-----------------------------------------------------------------
32
33 REG_MODULE(ARICHMCParticles);
34
35 //-----------------------------------------------------------------
36 // Implementation
37 //-----------------------------------------------------------------
38
40 {
41 // set module description (e.g. insert text)
42 setDescription("Creates collection of MCParticles related to tracks that hit ARICH.");
43 // Set property flags
45
46 }
47
49 {
50 }
51
53
54 {
55 // Dependecies check
56 m_tracks.isRequired();
57 m_extHits.isRequired();
58
60 m_tracks.registerRelationTo(m_arichMCPs);
61
62 }
63
65 {
66 const Const::EDetector arich = Const::EDetector::ARICH; // arich
67 const Const::ChargedStable particleHypothesis = Const::pion;
68 const int pdgCode = abs(particleHypothesis.getPDGCode());
69
70 for (int itrk = 0; itrk < m_tracks.getEntries(); ++itrk) {
71
72 const Track* track = m_tracks[itrk];
73 const TrackFitResult* fitResult = track->getTrackFitResultWithClosestMass(particleHypothesis);
74 if (!fitResult) {
75 B2ERROR("No TrackFitResult for " << particleHypothesis.getPDGCode());
76 continue;
77 }
78
79 const MCParticle* particle = track->getRelated<MCParticle>();
80 if (!particle) continue;
81
82 RelationVector<ExtHit> extHits = DataStore::getRelationsWithObj<ExtHit>(track);
83
84 for (unsigned i = 0; i < extHits.size(); i++) {
85 const ExtHit* extHit = extHits[i];
86 if (abs(extHit->getPdgCode()) != pdgCode or
87 extHit->getDetectorID() != arich or
88 extHit->getStatus() != EXT_EXIT or // particles registered at the EXIT of the Al plate
89 extHit->getMomentum().Z() < 0.0) continue; // track passes in backward
90 if (extHit->getCopyID() == 6789) {
91 //MCParticle arichMCP = *particle;
92 MCParticle* arichP = m_arichMCPs.appendNew(*particle);
93 track->addRelationTo(arichP);
94
95 }
96
97 }
98 }
99
100 }
101
103} // end Belle2 namespace
104
StoreArray< MCParticle > m_arichMCPs
Required input array of MCParticles.
StoreArray< Track > m_tracks
Required input array of Tracks.
StoreArray< ExtHit > m_extHits
Required input array of ExtHits.
Provides a type-safe way to pass members of the chargedStableSet set.
Definition: Const.h:589
int getPDGCode() const
PDG code.
Definition: Const.h:473
EDetector
Enum for identifying the detector components (detector and subdetector).
Definition: Const.h:42
static const ChargedStable pion
charged pion particle
Definition: Const.h:661
Store one Ext hit as a ROOT object.
Definition: ExtHit.h:31
int getPdgCode() const
Get PDG code of this extrapolation's hypothesis.
Definition: ExtHit.h:117
ExtHitStatus getStatus() const
Get state of extrapolation at this hit.
Definition: ExtHit.h:129
int getCopyID() const
Get detector-element ID of sensitive element within detector.
Definition: ExtHit.h:125
Const::EDetector getDetectorID() const
Get detector ID of this extrapolation hit.
Definition: ExtHit.h:121
ROOT::Math::XYZVector getMomentum() const
Get momentum at this extrapolation hit.
Definition: ExtHit.h:151
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
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
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
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
Values of the result of a track fit with a given particle hypothesis.
Class that bundles various TrackFitResults.
Definition: Track.h:25
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
virtual ~ARICHMCParticlesModule()
Destructor.
#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.