Belle II Software development
ARICHReconstructorModule.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// Own header.
9
10#include <arich/modules/arichReconstruction/ARICHReconstructorModule.h>
11#include <time.h>
12
13// Hit classes
14#include <mdst/dataobjects/Track.h>
15#include <tracking/dataobjects/ExtHit.h>
16#include <mdst/dataobjects/MCParticle.h>
17#include <arich/dataobjects/ARICHAeroHit.h>
18#include <arich/dataobjects/ARICHLikelihood.h>
19#include <arich/dataobjects/ARICHTrack.h>
20#include <arich/dataobjects/ARICHHit.h>
21
22// framework - DataStore
23#include <framework/datastore/DataStore.h>
24#include <framework/datastore/StoreArray.h>
25
26// framework aux
27#include <framework/gearbox/Unit.h>
28#include <framework/gearbox/Const.h>
29#include <framework/logging/Logger.h>
30
31using namespace boost;
32
33namespace Belle2 {
38
39 //-----------------------------------------------------------------
41 //-----------------------------------------------------------------
42
43 REG_MODULE(ARICHReconstructor);
44
45 //-----------------------------------------------------------------
46 // Implementation
47 //-----------------------------------------------------------------
48
50 m_ana(NULL)
51 {
52 // Set description()
53 setDescription("This module calculates the ARICHLikelihood values for all particle id. hypotheses, for all tracks that enter ARICH in the event.");
54
55 // Set property flags
57
58 // Add parameters
59 addParam("trackPositionResolution", m_trackPositionResolution,
60 "Resolution of track position on aerogel plane (for additional smearing of MC tracks)", 1.0 * Unit::mm);
61 addParam("trackAngleResolution", m_trackAngleResolution,
62 "Resolution of track direction angle on aerogel plane (for additional smearing of MC tracks)", 2.0 * Unit::mrad);
63 addParam("inputTrackType", m_inputTrackType, "Input tracks switch: tracking (0), from AeroHits - MC info (1)", 0);
64 addParam("storePhotons", m_storePhot, "Set to 1 to store reconstructed photon information (Ch. angle,...)", 0);
65 addParam("useAlignment", m_align, "Use ARICH global position alignment constants", true);
66 addParam("useMirrorAlignment", m_alignMirrors, "Use ARICH mirror alignment constants", true);
67 }
68
73
75 {
76 // Initialize variables
77 if (m_ana) delete m_ana;
79 m_ana->setTrackPositionResolution(m_trackPositionResolution);
80 m_ana->setTrackAngleResolution(m_trackAngleResolution);
81 m_ana->useMirrorAlignment(m_alignMirrors);
82
83 // Input: ARICHDigits
84 m_ARICHHits.isRequired();
85
86 m_Tracks.isOptional();
87 m_ExtHits.isOptional();
88 m_aeroHits.isOptional();
89
90 if (!m_aeroHits.isOptional()) {
91 m_Tracks.isRequired();
92 m_ExtHits.isRequired();
93 }
94
95 StoreArray<MCParticle> MCParticles;
96 MCParticles.isOptional();
97
98 // Output - log likelihoods
99 m_ARICHLikelihoods.registerInDataStore();
100
101 m_ARICHTracks.registerInDataStore();
102
103 if (m_inputTrackType) m_ARICHTracks.registerRelationTo(m_ARICHLikelihoods);
104 else {
105 m_ARICHTracks.registerRelationTo(m_ExtHits);
106 m_Tracks.registerRelationTo(m_ARICHLikelihoods);
107 }
108 //m_ARICHTracks.registerInDataStore(DataStore::c_DontWriteOut);
109 //m_ARICHTracks.registerRelationTo(m_ARICHLikelihoods, DataStore::c_Event, DataStore::c_DontWriteOut);
110 m_ARICHTracks.registerRelationTo(m_aeroHits);
112 }
113
115 {
116 m_ana->initialize();
117 }
118
120 {
121 // using track information form tracking system (mdst Track)
122 if (m_inputTrackType == 0) {
123
124 Const::EDetector myDetID = Const::EDetector::ARICH; // arich
126 int pdgCode = abs(hypothesis.getPDGCode());
127
128 for (const Track& track : m_Tracks) {
129 const TrackFitResult* fitResult = track.getTrackFitResultWithClosestMass(hypothesis);
130 if (!fitResult) {
131 B2ERROR("No TrackFitResult for " << hypothesis.getPDGCode());
132 continue;
133 }
134
135 const MCParticle* mcParticle = track.getRelated<MCParticle>();
136
137 ARICHAeroHit* aeroHit = NULL;
138 if (mcParticle) aeroHit = mcParticle->getRelated<ARICHAeroHit>();
139
141 ARICHTrack* arichTrack = NULL;
142
143 //const ExtHit* arich1stHit = NULL;
144 const ExtHit* arich2ndHit = NULL;
145 const ExtHit* arichWinHit = NULL;
146
147 for (unsigned i = 0; i < extHits.size(); i++) {
148 const ExtHit* extHit = extHits[i];
149 if (abs(extHit->getPdgCode()) != pdgCode or
150 extHit->getDetectorID() != myDetID or
151 extHit->getStatus() != EXT_EXIT or // particles registered at the EXIT of the Al plate
152 extHit->getMomentum().Z() < 0.0 or // track passes in backward
153 extHit->getCopyID() == 12345) { continue;}
154 if (extHit->getCopyID() == 6789) { arich2ndHit = extHit; continue;}
155 arichWinHit = extHit;
156 }
157
158 if (arich2ndHit) {
159 // if aeroHit cannot be found using MCParticle check if it was already related to the extHit (by ARICHRelate module)
160 if (!aeroHit) aeroHit = arich2ndHit->getRelated<ARICHAeroHit>();
161
162 // make new ARICHTrack
163 arichTrack = m_ARICHTracks.appendNew(arich2ndHit);
164 if (arichWinHit) arichTrack->setHapdWindowHit(arichWinHit);
165 }
166
167 // skip if track has no extHit in ARICH
168 if (!arichTrack) continue;
169 // transform track parameters to ARICH local frame
170 m_ana->transformTrackToLocal(*arichTrack, m_align);
171 // make new ARICHLikelihood
172 ARICHLikelihood* like = m_ARICHLikelihoods.appendNew();
173 // calculate and set likelihood values
174 m_ana->likelihood2(*arichTrack, m_ARICHHits, *like);
175 // make relations
176 track.addRelationTo(like);
177 arichTrack->addRelationTo(arich2ndHit);
178 if (aeroHit) arichTrack->addRelationTo(aeroHit);
179
180 } // Tracks loop
181 } // input type if
182
183
184 // using track information form MC (stored in ARICHAeroHit)
185 else {
186
187 // Loop over all ARICHAeroHits
188 for (const ARICHAeroHit& aeroHit : m_aeroHits) {
189
190 // make new ARICHTrack
191 ARICHTrack* arichTrack = m_ARICHTracks.appendNew(&aeroHit);
192 // smearing of track parameters (to mimic tracking system resolutions)
193 m_ana->smearTrack(*arichTrack);
194 // transform track parameters to ARICH local frame
195 m_ana->transformTrackToLocal(*arichTrack, m_align);
196 // make associated ARICHLikelihood
197 ARICHLikelihood* like = m_ARICHLikelihoods.appendNew();
198 // calculate and set likelihood values
199 m_ana->likelihood2(*arichTrack, m_ARICHHits, *like);
200 // make relation
201 arichTrack->addRelationTo(like);
202 arichTrack->addRelationTo(&aeroHit);
203 } // for iTrack
204
205 }
206 }
207
209 {
210 if (m_inputTrackType == 0) { B2DEBUG(100, "ARICHReconstructorModule: track information is taken from mdst Tracks.");}
211 else B2DEBUG(100, "ARICHReconstructorModule: track information is taken from MC (ARICHAeroHit).");
212 }
213
215} // namespace Belle2
Datastore class that holds information on track parameters at the entrance in aerogel.
This is a class to store ARICH likelihoods in the datastore.
Internal ARICH track reconstruction.
StoreArray< ARICHAeroHit > m_aeroHits
Aerogel hits.
ARICHReconstruction * m_ana
Class with reconstruction tools.
bool m_alignMirrors
Whether alignment constants for mirrors are used.
int m_inputTrackType
Input tracks from the tracking (0) or from MCParticles>AeroHits (1).
bool m_align
Whether alignment constants are used for global->local track transformation.
StoreArray< ARICHTrack > m_ARICHTracks
ARICH tracks.
double m_trackAngleResolution
Track direction resolution; simulation smearing.
StoreArray< ARICHLikelihood > m_ARICHLikelihoods
Likelihoods.
StoreArray< ARICHHit > m_ARICHHits
ARICH hits.
int m_storePhot
If == 1, individual reconstruced photon information (Cherenkov angle,...) is stored in ARICHTrack.
StoreArray< ExtHit > m_ExtHits
Extrapolation hits.
double m_trackPositionResolution
Track position resolution; simulation smearing.
Datastore class that holds position and momentum information of tracks that hit ARICH.
Definition ARICHTrack.h:35
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
static RelationVector< T > getRelationsWithObj(const TObject *object, const std::string &name="", const std::string &namedRelation="")
Get the relations between an object and other objects in a store array.
Definition DataStore.h:412
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.
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
Accessor to arrays stored in the data store.
Definition StoreArray.h:113
Values of the result of a track fit with a given particle hypothesis.
Class that bundles various TrackFitResults.
Definition Track.h:25
static const double mm
[millimeters]
Definition Unit.h:70
static const double mrad
[millirad]
Definition Unit.h:108
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
virtual void beginRun() override
Called when entering a new run.
void printModuleParams()
Print module parameters.
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:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
Abstract base class for different kinds of events.