Belle II Software  release-06-01-15
PhaseSpaceAnalysisModule.h
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 # pragma once
10 
11 // framework
12 #include <framework/core/Module.h>
13 #include <mdst/dataobjects/MCParticle.h>
14 #include <framework/datastore/StoreArray.h>
15 
16 // ROOT
17 #include <TFile.h>
18 #include <TTree.h>
19 
20 // other stuff
21 #include <string>
22 
23 // boost
24 #include <boost/any.hpp>
25 
26 namespace Belle2 {
37 
38  public:
41  void initialize() override;
42  void event() override;
43  void terminate() override;
46  struct RootVariables {
47  std::vector<double> MomX;
48  std::vector<double> MomY;
49  std::vector<double> MomZ;
52  std::vector<double> Eta;
54  std::vector<double> pT;
55 
56  std::vector<double> VertX;
57  std::vector<double> VertY;
58  std::vector<double> VertZ;
60  std::vector<int> PDG;
61  std::vector<double> Charge;
63  std::vector<double> Energy;
64  std::vector<double> Mass;
66 // std::vector<unsigned short int> RefereeStatus; /**< refereeStatus of a SPTC (if available) */
67  };
68 
73  };
74 
75  protected:
76 
77  // ======================================== PARAMETERS ========================================================================
78  std::vector<std::string> m_PARAMcontainerNames;
80  std::vector<std::string> m_PARAMtrackCandTypes;
82  std::vector<std::string> m_PARAMrootFileName;
86 
87  // ======================================== INTERNALLY USED MEMBERS ===========================================================
88  std::vector<std::pair<boost::any, e_trackCandType> > m_tcStoreArrays;
92  std::vector<TTree*> m_treePtrs;
94  TFile* m_rootFilePtr;
96  std::vector<std::string> m_treeNames;
97  // ==================================================== COUNTERS ==============================================================
98  unsigned int m_noMcPartCtr;
100  unsigned int m_skippedTCsCtr;
102  std::vector<unsigned int> m_mcPartCtr;
105  void initializeCounters(size_t nContainers)
106  {
107  m_noMcPartCtr = 0;
108  m_skippedTCsCtr = 0;
109 
110  m_mcPartCtr = std::vector<unsigned int>(nContainers, 0);
111  }
112 
118  void initializeRootFile(std::string fileName, std::string writeOption, std::vector<std::string> treeNames);
119  void getValuesForRoot(Belle2::MCParticle* mcParticle, RootVariables& rootVariables);
122  template<typename TrackCandType>
123  std::vector<int> getMCParticleIDs(Belle2::StoreArray<TrackCandType> trackCands);
124 
125 // /** get all referee statuses from all SpacePointTrackCand */
126 // std::vector<unsigned short int> getRefereeStatuses(Belle2::StoreArray<Belle2::SpacePointTrackCand> trackCands);
127 
132  std::vector<std::vector<int> > getDiffIds(const std::vector<std::vector<int> >& allIDs);
133 
134  };
136 }
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
Base class for Modules.
Definition: Module.h:72
Module for analysing the phase space of genfit::TrackCand(s) and SpacePointTrackCand(s) NOTE: this is...
void initializeRootFile(std::string fileName, std::string writeOption, std::vector< std::string > treeNames)
create a root file with file name
std::vector< std::string > m_PARAMtrackCandTypes
types of the track candidates in containerNames
std::vector< unsigned int > m_mcPartCtr
container wise coutner of TrackCands / MCParticles
RootVariables m_rootVariables
root variables used for collecting data event-wise
bool m_PARAMdiffAnalysis
take containers pair-wise and only analize those particles that are found in one container but not in...
unsigned int m_noMcPartCtr
Counter for nullptr pointers to MC Particles (should always be zero.
std::vector< std::string > m_treeNames
names of the trees that are stored in the root file
std::vector< std::string > m_PARAMrootFileName
name of the output root file name
unsigned int m_skippedTCsCtr
Counter for negative MC particle ids (should always be zero.
e_trackCandType
enum to differentiate between possible trackCandidate types
std::vector< TTree * > m_treePtrs
each container name gets its own tree in the root file
std::vector< std::string > m_PARAMcontainerNames
collection name of trackCands to be investigated
void initializeCounters(size_t nContainers)
initialize all counters to 0 to avoid undefined behavior
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.
void getValuesForRoot(Belle2::MCParticle *mcParticle, RootVariables &rootVariables)
collect the values for root output
std::vector< int > getMCParticleIDs(Belle2::StoreArray< TrackCandType > trackCands)
get all MCPartileIDs of tracks
TFile * m_rootFilePtr
Pointer to root file.
std::vector< std::pair< boost::any, e_trackCandType > > m_tcStoreArrays
StoreArrays of the containers.
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Abstract base class for different kinds of events.
helper class to have all RootVariables assembled in one container
std::vector< double > VertZ
z position of vertex
std::vector< int > PDG
mc particle pdg code
std::vector< double > VertY
y position of vertex
std::vector< double > VertX
x position of vertex
std::vector< double > Charge
mc particle charge
std::vector< double > pT
transverse momentum.
std::vector< double > Energy
mc particle energy