Belle II Software  release-05-02-19
PhaseSpaceAnalysisModule.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2014 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Thomas Madlener *
7  * *
8  **************************************************************************/
9 
10 # pragma once
11 
12 // framework
13 #include <framework/core/Module.h>
14 #include <mdst/dataobjects/MCParticle.h>
15 #include <framework/datastore/StoreArray.h>
16 
17 // ROOT
18 #include <TFile.h>
19 #include <TTree.h>
20 
21 // other stuff
22 #include <string>
23 
24 // boost
25 #include <boost/any.hpp>
26 
27 namespace Belle2 {
37  class PhaseSpaceAnalysisModule : public Module {
38 
39  public:
42  void initialize() override;
43  void event() override;
44  void terminate() override;
47  struct RootVariables {
48  std::vector<double> MomX;
49  std::vector<double> MomY;
50  std::vector<double> MomZ;
53  std::vector<double> Eta;
55  std::vector<double> pT;
56 
57  std::vector<double> VertX;
58  std::vector<double> VertY;
59  std::vector<double> VertZ;
61  std::vector<int> PDG;
62  std::vector<double> Charge;
64  std::vector<double> Energy;
65  std::vector<double> Mass;
67 // std::vector<unsigned short int> RefereeStatus; /**< refereeStatus of a SPTC (if available) */
68  };
69 
73  c_sptc,
74  };
75 
76  protected:
77 
78  // ======================================== PARAMETERS ========================================================================
79  std::vector<std::string> m_PARAMcontainerNames;
81  std::vector<std::string> m_PARAMtrackCandTypes;
83  std::vector<std::string> m_PARAMrootFileName;
87 
88  // ======================================== INTERNALLY USED MEMBERS ===========================================================
89  std::vector<std::pair<boost::any, e_trackCandType> > m_tcStoreArrays;
93  std::vector<TTree*> m_treePtrs;
95  TFile* m_rootFilePtr;
97  std::vector<std::string> m_treeNames;
98  // ==================================================== COUNTERS ==============================================================
99  unsigned int m_noMcPartCtr;
101  unsigned int m_skippedTCsCtr;
103  std::vector<unsigned int> m_mcPartCtr;
106  void initializeCounters(size_t nContainers)
107  {
109  m_skippedTCsCtr = 0;
110 
111  m_mcPartCtr = std::vector<unsigned int>(nContainers, 0);
112  }
113 
115  void initializeRootFile(std::string fileName, std::string writeOption, std::vector<std::string> treeNames);
116  void getValuesForRoot(Belle2::MCParticle* mcParticle, RootVariables& rootVariables);
119  template<typename TrackCandType>
120  std::vector<int> getMCParticleIDs(Belle2::StoreArray<TrackCandType> trackCands);
121 
122 // /** get all referee statuses from all SpacePointTrackCand */
123 // std::vector<unsigned short int> getRefereeStatuses(Belle2::StoreArray<Belle2::SpacePointTrackCand> trackCands);
124 
129  std::vector<std::vector<int> > getDiffIds(const std::vector<std::vector<int> >& allIDs);
130 
131  };
133 }
Belle2::PhaseSpaceAnalysisModule::m_rootFilePtr
TFile * m_rootFilePtr
Pointer to root file.
Definition: PhaseSpaceAnalysisModule.h:102
Belle2::PhaseSpaceAnalysisModule::event
void event() override
event
Definition: PhaseSpaceAnalysisModule.cc:100
Belle2::PhaseSpaceAnalysisModule::getMCParticleIDs
std::vector< int > getMCParticleIDs(Belle2::StoreArray< TrackCandType > trackCands)
get all MCPartileIDs of tracks
Definition: PhaseSpaceAnalysisModule.cc:245
Belle2::PhaseSpaceAnalysisModule::initialize
void initialize() override
initialize
Definition: PhaseSpaceAnalysisModule.cc:54
Belle2::PhaseSpaceAnalysisModule::terminate
void terminate() override
terminate
Definition: PhaseSpaceAnalysisModule.cc:155
Belle2::PhaseSpaceAnalysisModule::initializeRootFile
void initializeRootFile(std::string fileName, std::string writeOption, std::vector< std::string > treeNames)
create a root file with file name
Definition: PhaseSpaceAnalysisModule.cc:183
Belle2::PhaseSpaceAnalysisModule::RootVariables::VertZ
std::vector< double > VertZ
z position of vertex
Definition: PhaseSpaceAnalysisModule.h:66
Belle2::PhaseSpaceAnalysisModule::m_PARAMdiffAnalysis
bool m_PARAMdiffAnalysis
take containers pair-wise and only analize those particles that are found in one container but not in...
Definition: PhaseSpaceAnalysisModule.h:93
Belle2::PhaseSpaceAnalysisModule::m_PARAMcontainerNames
std::vector< std::string > m_PARAMcontainerNames
collection name of trackCands to be investigated
Definition: PhaseSpaceAnalysisModule.h:86
Belle2::PhaseSpaceAnalysisModule::RootVariables
helper class to have all RootVariables assembled in one container
Definition: PhaseSpaceAnalysisModule.h:54
Belle2::PhaseSpaceAnalysisModule::e_trackCandType
e_trackCandType
enum to differentiate between possible trackCandidate types
Definition: PhaseSpaceAnalysisModule.h:78
Belle2::PhaseSpaceAnalysisModule::RootVariables::MomY
std::vector< double > MomY
y momentum
Definition: PhaseSpaceAnalysisModule.h:56
Belle2::PhaseSpaceAnalysisModule::m_noMcPartCtr
unsigned int m_noMcPartCtr
Counter for NULL pointers to MC Particles (should always be zero.
Definition: PhaseSpaceAnalysisModule.h:106
Belle2::PhaseSpaceAnalysisModule::c_sptc
@ c_sptc
SpacePointTrackCand.
Definition: PhaseSpaceAnalysisModule.h:80
Belle2::PhaseSpaceAnalysisModule::getDiffIds
std::vector< std::vector< int > > getDiffIds(const std::vector< std::vector< int > > &allIDs)
the first vector in allIds is used as reference to which all other vectors of allIDs are compared.
Definition: PhaseSpaceAnalysisModule.cc:257
Belle2::PhaseSpaceAnalysisModule::m_treeNames
std::vector< std::string > m_treeNames
names of the trees that are stored in the root file
Definition: PhaseSpaceAnalysisModule.h:104
Belle2::PhaseSpaceAnalysisModule::RootVariables::MomX
std::vector< double > MomX
x momentum
Definition: PhaseSpaceAnalysisModule.h:55
Belle2::PhaseSpaceAnalysisModule::c_gftc
@ c_gftc
genfit::TrackCand
Definition: PhaseSpaceAnalysisModule.h:79
Belle2::PhaseSpaceAnalysisModule::RootVariables::Eta
std::vector< double > Eta
pseudo rapidity.
Definition: PhaseSpaceAnalysisModule.h:60
Belle2::PhaseSpaceAnalysisModule::RootVariables::Mass
std::vector< double > Mass
mc particle mass
Definition: PhaseSpaceAnalysisModule.h:72
Belle2::PhaseSpaceAnalysisModule::m_PARAMtrackCandTypes
std::vector< std::string > m_PARAMtrackCandTypes
types of the track candidates in containerNames
Definition: PhaseSpaceAnalysisModule.h:88
Belle2::PhaseSpaceAnalysisModule::m_tcStoreArrays
std::vector< std::pair< boost::any, e_trackCandType > > m_tcStoreArrays
StoreArrays of the containers.
Definition: PhaseSpaceAnalysisModule.h:96
Belle2::PhaseSpaceAnalysisModule::RootVariables::pT
std::vector< double > pT
transverse momentum.
Definition: PhaseSpaceAnalysisModule.h:62
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::PhaseSpaceAnalysisModule::RootVariables::MomZ
std::vector< double > MomZ
z momentum
Definition: PhaseSpaceAnalysisModule.h:57
Belle2::PhaseSpaceAnalysisModule::RootVariables::Energy
std::vector< double > Energy
mc particle energy
Definition: PhaseSpaceAnalysisModule.h:71
Belle2::PhaseSpaceAnalysisModule::m_rootVariables
RootVariables m_rootVariables
root variables used for collecting data event-wise
Definition: PhaseSpaceAnalysisModule.h:98
Belle2::PhaseSpaceAnalysisModule::m_skippedTCsCtr
unsigned int m_skippedTCsCtr
Counter for negative MC particle ids (should always be zero.
Definition: PhaseSpaceAnalysisModule.h:108
Belle2::PhaseSpaceAnalysisModule::initializeCounters
void initializeCounters(size_t nContainers)
initialize all counters to 0 to avoid undefined behavior
Definition: PhaseSpaceAnalysisModule.h:113
Belle2::PhaseSpaceAnalysisModule::PhaseSpaceAnalysisModule
PhaseSpaceAnalysisModule()
Constructor.
Definition: PhaseSpaceAnalysisModule.cc:30
Belle2::PhaseSpaceAnalysisModule::RootVariables::Charge
std::vector< double > Charge
mc particle charge
Definition: PhaseSpaceAnalysisModule.h:69
Belle2::PhaseSpaceAnalysisModule::RootVariables::VertY
std::vector< double > VertY
y position of vertex
Definition: PhaseSpaceAnalysisModule.h:65
Belle2::PhaseSpaceAnalysisModule::m_PARAMrootFileName
std::vector< std::string > m_PARAMrootFileName
name of the output root file name
Definition: PhaseSpaceAnalysisModule.h:90
Belle2::MCParticle
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:43
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::PhaseSpaceAnalysisModule::RootVariables::PDG
std::vector< int > PDG
mc particle pdg code
Definition: PhaseSpaceAnalysisModule.h:68
Belle2::PhaseSpaceAnalysisModule::getValuesForRoot
void getValuesForRoot(Belle2::MCParticle *mcParticle, RootVariables &rootVariables)
collect the values for root output
Definition: PhaseSpaceAnalysisModule.cc:212
Belle2::PhaseSpaceAnalysisModule::RootVariables::VertX
std::vector< double > VertX
x position of vertex
Definition: PhaseSpaceAnalysisModule.h:64
Belle2::PhaseSpaceAnalysisModule::m_mcPartCtr
std::vector< unsigned int > m_mcPartCtr
container wise coutner of TrackCands / MCParticles
Definition: PhaseSpaceAnalysisModule.h:110
Belle2::PhaseSpaceAnalysisModule::m_treePtrs
std::vector< TTree * > m_treePtrs
each container name gets its own tree in the root file
Definition: PhaseSpaceAnalysisModule.h:100