Belle II Software  release-06-00-14
TrackAna.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 #include <daq/dqm/modules/TrackAna.h>
10 
11 #include <framework/dataobjects/EventMetaData.h>
12 #include <framework/datastore/StoreObjPtr.h>
13 #include <framework/datastore/StoreArray.h>
14 #include <mdst/dataobjects/Track.h>
15 #include <mdst/dataobjects/TrackFitResult.h>
16 
17 using namespace std;
18 using namespace Belle2;
19 
20 //-----------------------------------------------------------------
21 // Register the Module
22 //-----------------------------------------------------------------
23 REG_MODULE(TrackAna)
24 
25 //-----------------------------------------------------------------
26 // Implementation
27 //-----------------------------------------------------------------
28 
30 {
31  //Set module properties
32  setDescription("The simplest physics analysis");
33  setPropertyFlags(c_ParallelProcessingCertified);
34 
35  //Parameter definition
36  B2INFO("TrackAna: Constructor done.");
37 }
38 
39 
40 TrackAnaModule::~TrackAnaModule()
41 {
42 }
43 
44 void TrackAnaModule::initialize()
45 {
46  REG_HISTOGRAM
47 }
48 
49 void TrackAnaModule::defineHisto()
50 {
51  h_multi = new TH1F("Multi", "Particle Multiplicity", 50, 0.0, 50.0);
52  h_p[0] = new TH1F("Px", "Particle Momentum X", 100, -5.0, 5.0);
53  h_p[1] = new TH1F("Py", "Particle Momentum Y", 100, -5.0, 5.0);
54  h_p[2] = new TH1F("Pz", "Particle Momentum Z", 100, -5.0, 5.0);
55  h_p[3] = new TH1F("E", "Particle Energy", 100, 0.0, 10.0);
56 }
57 
58 void TrackAnaModule::beginRun()
59 {
60  B2INFO("TrackAna: started to measure elapsed time.");
61 }
62 
63 
64 void TrackAnaModule::event()
65 {
66  // Get Event Info
68  int expno = evt->getExperiment();
69  int runno = evt->getRun();
70  int subrno = evt->getSubrun();
71  int evtno = evt->getEvent();
72 
73  // Get List of Tracks
74  StoreArray<Track> trklist;
75 
76  int ntrk = trklist.getEntries();
77  h_multi->Fill((float)ntrk);
78  // printf ( "***** Generator Event List : Event %d ; multi = %d *****\n", evtno, npart );
79  for (int i = 0; i < ntrk; i++) {
80  Track* trk = trklist[i];
81  const TrackFitResult* fit = trk->getTrackFitResult(Const::pion);
82  TLorentzVector p4 = fit->get4Momentum();
83  for (int j = 0; j < 4; j++) {
84  h_p[j]->Fill(p4[j]);
85  }
86  }
87 }
88 
89 void TrackAnaModule::endRun()
90 {
91 }
92 
93 
94 void TrackAnaModule::terminate()
95 {
96  B2INFO("TrackAna: terminate called");
97 }
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:95
A class definition of an input module for Sequential ROOT I/O.
Definition: TrackAna.h:24
Values of the result of a track fit with a given particle hypothesis.
Class that bundles various TrackFitResults.
Definition: Track.h:25
const TrackFitResult * getTrackFitResult(const Const::ChargedStable &chargedStable) const
Access to TrackFitResults.
Definition: Track.cc:17
#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.