Belle II Software  release-05-02-19
GenfitVisModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2013 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Johannes Rauch *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include "tracking/modules/genfitVisModule/GenfitVisModule.h"
12 
13 #include <framework/datastore/StoreArray.h>
14 
15 #include <geometry/GeometryManager.h>
16 #include <genfit/Track.h>
17 #include <genfit/FieldManager.h>
18 #include <genfit/MaterialEffects.h>
19 
20 #include <TGeoManager.h>
21 
22 using namespace Belle2;
23 
24 //-----------------------------------------------------------------
25 // Register the Module
26 //-----------------------------------------------------------------
27 REG_MODULE(GenfitVis)
28 
29 //-----------------------------------------------------------------
30 // Implementation
31 //-----------------------------------------------------------------
32 
34 {
35  // Set module properties
36  setDescription("Visualize genfit::Tracks using the genfit::EventDisplay.");
37 
38  // Parameter definitions
39  addParam("onlyBadTracks", m_onlyBadTracks, "show only unfitted and unconverged tracks", false);
40 
41 }
42 
44 {
45  if (!genfit::MaterialEffects::getInstance()->isInitialized())
46  B2FATAL("No material effects setup. Please use SetupGenfitExtrapolationModule.");
47 
48  if (gGeoManager == NULL) {
49  B2INFO("Setting up TGeo geometry for visualization.");
51  geoManager.createTGeoRepresentation();
52  }
53  if (!gGeoManager)
54  B2FATAL("Couldn't create TGeo geometry.");
55 
56  if (!genfit::FieldManager::getInstance()->isInitialized()) {
57  B2FATAL("Magnetic field not set up. Please use SetupGenfitExtrapolationModule.");
58  }
59 
60  m_display = genfit::EventDisplay::getInstance();
61 }
62 
64 {
65  StoreArray < genfit::Track > gfTracks("GF2Tracks");
66  std::vector<const genfit::Track*> tracks;
67 
68  const int nTracks = gfTracks.getEntries();
69  for (int iTrack = 0; iTrack < nTracks; ++iTrack) {
70  const genfit::Track* tr = gfTracks[iTrack];
71  if (m_onlyBadTracks &&
72  tr->getFitStatus()->isFitted() &&
74  continue;
75  //std::cout << " =============== pushing track ======= " << std::endl;
76  tracks.push_back(tr);
77  }
78 
79  if (tracks.size() > 0)
80  m_display->addEvent(tracks);
81 }
82 
84 {
85  m_display->open();
86 }
87 
89 {
90 }
91 
92 
Belle2::GenfitVisModule::endRun
void endRun() override
Open display.
Definition: GenfitVisModule.cc:83
genfit::EventDisplay::addEvent
void addEvent(std::vector< genfit::Track * > &tracks)
Add new event.
Definition: EventDisplay.cc:164
Belle2::GenfitVisModule::event
void event() override
Add genfit::Tracks to display.
Definition: GenfitVisModule.cc:63
Belle2::GenfitVisModule::m_display
genfit::EventDisplay * m_display
pointer to the genfit::EventDisplay which gets created in initialize()
Definition: GenfitVisModule.h:63
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
genfit::Track::getFitStatus
FitStatus * getFitStatus(const AbsTrackRep *rep=nullptr) const
Get FitStatus for a AbsTrackRep. Per default, return FitStatus for cardinalRep.
Definition: Track.h:154
genfit::Track
Collection of TrackPoint objects, AbsTrackRep objects and FitStatus objects.
Definition: Track.h:71
genfit::EventDisplay::open
void open()
Open the event display.
Definition: EventDisplay.cc:246
Belle2::geometry::GeometryManager::getInstance
static GeometryManager & getInstance()
Return a reference to the instance.
Definition: GeometryManager.cc:98
Belle2::geometry::GeometryManager::createTGeoRepresentation
void createTGeoRepresentation()
Create a TGeo representation of the native geometry description.
Definition: GeometryManager.cc:351
Belle2::GenfitVisModule::m_onlyBadTracks
bool m_onlyBadTracks
if true, tracks which have been fitted and the fit converged will no be shown
Definition: GenfitVisModule.h:65
Belle2::geometry::GeometryManager
Class to manage the creation and conversion of the geometry.
Definition: GeometryManager.h:50
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::GenfitVisModule::terminate
void terminate() override
Close display.
Definition: GenfitVisModule.cc:88
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
genfit::FitStatus::isFitConverged
bool isFitConverged(bool inAllPoints=true) const
Did the fit converge (in all Points or only partially)?
Definition: FitStatus.h:105
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
genfit::FieldManager::getInstance
static FieldManager * getInstance()
Get singleton instance.
Definition: FieldManager.h:119
genfit::FitStatus::isFitted
bool isFitted() const
Has the track been fitted?
Definition: FitStatus.h:94
Belle2::GenfitVisModule::initialize
void initialize() override
Initialize the EventDisplay.
Definition: GenfitVisModule.cc:43
Belle2::StoreArray::getEntries
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:226
Belle2::GenfitVisModule
Visualize genfit::Tracks using the genfit::EventDisplay.
Definition: GenfitVisModule.h:38