Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DKinFitChain.h
Go to the documentation of this file.
1 #ifndef _DKinFitChain_
2 #define _DKinFitChain_
3 
4 #include <vector>
5 #include <algorithm>
6 #include <memory>
7 
8 #include "DKinFitParticle.h"
9 #include "DKinFitChainStep.h"
10 #include "DResettable.h"
11 
12 //This class is not necessary to use the kinematic fitter, but it is necessary to use some of the setup help functions in DKinFitUtils
13  //Is mostly useful when coding for the generic situation of ANY possible decay chain (rather than handling a specific one)
14 
15 using namespace std;
16 
17 class DKinFitChain : public DResettable
18 {
19  public:
20 
21  void Reset(void);
22  void Release(void);
23 
24  //GET, ADD STEPS
25  shared_ptr<const DKinFitChainStep> Get_KinFitChainStep(size_t locStepIndex) const;
26  void Add_KinFitChainStep(const shared_ptr<DKinFitChainStep>& locKinFitChainStep){dKinFitChainSteps.push_back(locKinFitChainStep);}
27  size_t Get_NumKinFitChainSteps(void) const{return dKinFitChainSteps.size();}
28 
29  //GET ALL PARTICLES
30  vector<shared_ptr<DKinFitParticle>> Get_AllParticles(void) const;
31 
32  //GET CONTROL INFO
33  signed char Get_DefinedParticleStepIndex(void) const{return dDefinedParticleStepIndex;}
34  bool Get_IsInclusiveChannelFlag(void) const{return dIsInclusiveChannelFlag;}
35  signed char Get_DecayStepIndex(const shared_ptr<DKinFitParticle>& locKinFitParticle) const;
36 
37  //SET CONTROL INFO
38  void Set_DefinedParticleStepIndex(signed char locDefinedParticleStepIndex){dDefinedParticleStepIndex = locDefinedParticleStepIndex;}
39  void Set_IsInclusiveChannelFlag(bool locIsInclusiveChannelFlag){dIsInclusiveChannelFlag = locIsInclusiveChannelFlag;}
40  void Set_DecayStepIndex(const shared_ptr<DKinFitParticle>& locKinFitParticle, int locDecayStepIndex){dDecayStepIndices[locKinFitParticle] = locDecayStepIndex;}
41 
42  //PRINT INFO
43  void Print_InfoToScreen(void) const;
44 
45  private:
46 
47  vector<shared_ptr<DKinFitChainStep>> dKinFitChainSteps;
48  map<shared_ptr<DKinFitParticle>, char> dDecayStepIndices; //key is decaying particle, value is the step representing the particle decay
49  signed char dDefinedParticleStepIndex = -1; //step containing the missing or open-ended-decaying particle, -1 if none
50  bool dIsInclusiveChannelFlag = false; //i.e. does the missing particle have PID 0 (unknown)
51 };
52 
53 inline void DKinFitChain::Reset(void)
54 {
55  dDefinedParticleStepIndex = -1;
56  dIsInclusiveChannelFlag = false;
57  dKinFitChainSteps.clear();
58  dDecayStepIndices.clear();
59 }
60 
61 inline void DKinFitChain::Release(void)
62 {
63  dKinFitChainSteps.clear();
64  dDecayStepIndices.clear();
65 }
66 
67 inline signed char DKinFitChain::Get_DecayStepIndex(const shared_ptr<DKinFitParticle>& locKinFitParticle) const
68 {
69  auto locIterator = dDecayStepIndices.find(locKinFitParticle);
70  return ((locIterator != dDecayStepIndices.end()) ? locIterator->second : -1);
71 }
72 
73 inline shared_ptr<const DKinFitChainStep> DKinFitChain::Get_KinFitChainStep(size_t locStepIndex) const
74 {
75  return ((locStepIndex < dKinFitChainSteps.size()) ? std::const_pointer_cast<const DKinFitChainStep>(dKinFitChainSteps[locStepIndex]) : nullptr);
76 }
77 
78 inline vector<shared_ptr<DKinFitParticle>> DKinFitChain::Get_AllParticles(void) const
79 {
80  vector<shared_ptr<DKinFitParticle>> locAllParticles;
81  for(size_t loc_i = 0; loc_i < dKinFitChainSteps.size(); ++loc_i)
82  {
83  auto locStepParticles = dKinFitChainSteps[loc_i]->Get_AllParticles();
84  locAllParticles.insert(locAllParticles.end(), locStepParticles.begin(), locStepParticles.end());
85  }
86  return locAllParticles;
87 }
88 
89 inline void DKinFitChain::Print_InfoToScreen(void) const
90 {
91  for(size_t loc_i = 0; loc_i < dKinFitChainSteps.size(); ++loc_i)
92  {
93  cout << "DKinFitChain: Printing step " << loc_i << endl;
94  dKinFitChainSteps[loc_i]->Print_InfoToScreen();
95  }
96 
97  cout << "DKinFitChain: PID, Pointer, decay-step indices:" << endl;
98  auto locIterator = dDecayStepIndices.begin();
99  for(; locIterator != dDecayStepIndices.end(); ++locIterator)
100  cout << locIterator->first->Get_PID() << ", " << locIterator->first << ", " << int(locIterator->second) << endl;
101 
102  cout << "DKinFitChain: defined particle step index, inclusive channel flag = " << int(dDefinedParticleStepIndex) << ", " << dIsInclusiveChannelFlag << endl;
103 }
104 
105 #endif // _DKinFitChain_
signed char Get_DefinedParticleStepIndex(void) const
Definition: DKinFitChain.h:33
size_t Get_NumKinFitChainSteps(void) const
Definition: DKinFitChain.h:27
vector< shared_ptr< DKinFitChainStep > > dKinFitChainSteps
Definition: DKinFitChain.h:47
void Release(void)
Definition: DKinFitChain.h:61
vector< shared_ptr< DKinFitParticle > > Get_AllParticles(void) const
Definition: DKinFitChain.h:78
shared_ptr< const DKinFitChainStep > Get_KinFitChainStep(size_t locStepIndex) const
Definition: DKinFitChain.h:73
void Set_IsInclusiveChannelFlag(bool locIsInclusiveChannelFlag)
Definition: DKinFitChain.h:39
signed char Get_DecayStepIndex(const shared_ptr< DKinFitParticle > &locKinFitParticle) const
Definition: DKinFitChain.h:67
void Add_KinFitChainStep(const shared_ptr< DKinFitChainStep > &locKinFitChainStep)
Definition: DKinFitChain.h:26
map< shared_ptr< DKinFitParticle >, char > dDecayStepIndices
Definition: DKinFitChain.h:48
bool Get_IsInclusiveChannelFlag(void) const
Definition: DKinFitChain.h:34
void Set_DecayStepIndex(const shared_ptr< DKinFitParticle > &locKinFitParticle, int locDecayStepIndex)
Definition: DKinFitChain.h:40
int Get_DecayStepIndex(const DReaction *locReaction, size_t locStepIndex, size_t locParticleIndex)
Definition: DReaction.cc:135
void Print_InfoToScreen(void) const
Definition: DKinFitChain.h:89
void Set_DefinedParticleStepIndex(signed char locDefinedParticleStepIndex)
Definition: DKinFitChain.h:38
void Reset(void)
Definition: DKinFitChain.h:53