Belle II Software development
TOPMCTrackMakerModule.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 <top/modules/TOPMCTrackMaker/TOPMCTrackMakerModule.h>
11
12// framework - DataStore
13#include <framework/datastore/StoreArray.h>
14
15// framework aux
16#include <framework/gearbox/Unit.h>
17#include <framework/gearbox/Const.h>
18#include <framework/geometry/BFieldManager.h>
19
20// dataobjects
21#include <mdst/dataobjects/Track.h>
22#include <mdst/dataobjects/TrackFitResult.h>
23#include <tracking/dataobjects/ExtHit.h>
24#include <mdst/dataobjects/MCParticle.h>
25#include <top/dataobjects/TOPBarHit.h>
26
27using namespace std;
28
29namespace Belle2 {
34
35 //-----------------------------------------------------------------
37 //-----------------------------------------------------------------
38
39 REG_MODULE(TOPMCTrackMaker);
40
41 //-----------------------------------------------------------------
42 // Implementation
43 //-----------------------------------------------------------------
44
46
47 {
48 // set module description (e.g. insert text)
49 setDescription("Constructs Tracks and ExtHits from MCParticles and TOPBarHits. "
50 "Utility needed for testing and debugging of TOP reconstruction.");
52
53 // Add parameters
54
55 }
56
58 {
59
60 // input
61
62 StoreArray<MCParticle> mcParticles;
63 mcParticles.isRequired();
64
66 barHits.isRequired();
67
68 // output
69
70 StoreArray<Track> tracks;
71 tracks.registerInDataStore();
72
74 fitResults.registerInDataStore();
75
76 StoreArray<ExtHit> extHits;
77 extHits.registerInDataStore();
78
79 tracks.registerRelationTo(mcParticles);
80 tracks.registerRelationTo(extHits);
81
82 }
83
85 {
86
87 StoreArray<MCParticle> mcParticles;
89
90 StoreArray<Track> tracks;
92 StoreArray<ExtHit> extHits;
93
94 for (const auto& mcParticle : mcParticles) {
95 if (mcParticle.getStatus(MCParticle::c_PrimaryParticle) == 0) continue;
96 if (mcParticle.getCharge() == 0) continue;
97 const auto* barHit = mcParticle.getRelated<TOPBarHit>();
98 if (!barHit) continue;
99
100 TMatrixDSym cov(6); // infinite precision
101 fitResults.appendNew(mcParticle.getVertex(),
102 mcParticle.getMomentum(),
103 cov,
104 mcParticle.getCharge(),
106 1.0, // pValue
107 BFieldManager::getField(0, 0, 0).Z() / Unit::T,
108 0x38FFFFFFFFFFFFFF, // 56 hits, in all CDC layers
109 0, 56 - 5); // NDF = 56-5
110 auto* track = tracks.appendNew();
111 track->setTrackFitResultIndex(Const::pion, fitResults.getEntries() - 1);
112 track->addRelationTo(&mcParticle);
113
114 const Const::ChargedStable& chargedStable = Const::pion;
115 double pmom = barHit->getMomentum().R();
116 double mass = chargedStable.getMass();
117 double beta = pmom / sqrt(pmom * pmom + mass * mass);
118 double tof = barHit->getLength() / beta / Const::speedOfLight;
119 const auto* extHit = extHits.appendNew(tof,
120 chargedStable.getPDGCode(),
121 Const::TOP,
122 barHit->getModuleID(),
123 EXT_ENTER,
124 false,
125 barHit->getPosition(),
126 barHit->getMomentum(),
127 cov);
128 track->addRelationTo(extHit);
129 }
130
131 }
132
134} // end Belle2 namespace
135
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
double getMass() const
Particle mass.
Definition UnitConst.cc:353
static const ChargedStable pion
charged pion particle
Definition Const.h:661
static const double speedOfLight
[cm/ns]
Definition Const.h:695
@ c_PrimaryParticle
bit 0: Particle is primary particle.
Definition MCParticle.h:47
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
Module()
Constructor.
Definition Module.cc:30
@ 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
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.
Definition StoreArray.h:113
T * appendNew()
Construct a new T object at the end of the array.
Definition StoreArray.h:246
Class to store track parameters of incoming MC particles relation to MCParticle filled in top/simulat...
Definition TOPBarHit.h:27
static const double T
[tesla]
Definition Unit.h:120
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
static void getField(const double *pos, double *field)
return the magnetic field at a given position.
double sqrt(double a)
sqrt for double
Definition beamHelpers.h:28
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
Abstract base class for different kinds of events.
STL namespace.