Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DNeutralParticle_factory_Combo.cc
Go to the documentation of this file.
2 
3 //------------------
4 // init
5 //------------------
7 {
8  //Get preselect tag
9  dShowerSelectionTag = "PreSelect";
10  gPARMS->SetDefaultParameter("COMBO:SHOWER_SELECT_TAG", dShowerSelectionTag);
11 
12  return NOERROR;
13 }
14 
15 //------------------
16 // brun
17 //------------------
18 jerror_t DNeutralParticle_factory_Combo::brun(jana::JEventLoop *locEventLoop, int32_t runnumber)
19 {
20  vector<const DNeutralParticleHypothesis*> locNeutralParticleHypotheses;
21  locEventLoop->Get(locNeutralParticleHypotheses); //make sure that brun() is called for the default factory!!!
22  dNeutralParticleHypothesisFactory = static_cast<DNeutralParticleHypothesis_factory*>(locEventLoop->GetFactory("DNeutralParticleHypothesis"));
23 
24  //Get Needed PIDs
25  auto locReactions = DAnalysis::Get_Reactions(locEventLoop);
26  for(size_t loc_i = 0; loc_i < locReactions.size(); ++loc_i)
27  {
28  auto locNeutralPIDs = locReactions[loc_i]->Get_FinalPIDs(-1, false, false, d_Neutral, false);
29  for(auto locPID : locNeutralPIDs)
30  {
31  if(locPID != Gamma) //already created by default!
32  dNeutralPIDs.insert(locPID);
33  }
34  }
35 
36  //Setting this flag makes it so that JANA does not delete the objects in _data. This factory will manage this memory.
37  if(dNeutralPIDs.empty())
38  SetFactoryFlag(NOT_OBJECT_OWNER);
39 
40  return NOERROR;
41 }
42 
43 //------------------
44 // evnt
45 //------------------
46 jerror_t DNeutralParticle_factory_Combo::evnt(jana::JEventLoop *locEventLoop, uint64_t eventnumber)
47 {
48  vector<const DNeutralParticle*> locNeutralParticles;
49  locEventLoop->Get(locNeutralParticles, dShowerSelectionTag.c_str());
50 
51  //Nothing to do! Pass them through
52  if(dNeutralPIDs.empty())
53  {
54  _data.clear();
55  for(auto& locNeutralParticle : locNeutralParticles)
56  _data.push_back(const_cast<DNeutralParticle*>(locNeutralParticle));
57  return NOERROR;
58  }
59 
60  const DEventRFBunch* locEventRFBunch = nullptr;
61  locEventLoop->GetSingle(locEventRFBunch);
62 
63  const DVertex* locVertex = nullptr;
64  locEventLoop->GetSingle(locVertex);
65 
67 
68  //create and add new hypos
69  for(auto& locNeutralParticle : locNeutralParticles)
70  {
71  auto locNewNeutralParticle = new DNeutralParticle(*locNeutralParticle);
72  for(auto& locPID : dNeutralPIDs)
73  {
74  //create new DNeutralParticleHypothesis object
75  auto locNewHypothesis = dNeutralParticleHypothesisFactory->Create_DNeutralParticleHypothesis(locNeutralParticle->dNeutralShower, locPID, locEventRFBunch, locVertex->dSpacetimeVertex, &locVertex->dCovarianceMatrix);
76  dCreatedHypotheses.push_back(locNewHypothesis);
77  locNewNeutralParticle->dNeutralParticleHypotheses.push_back(locNewHypothesis);
78  }
79  _data.push_back(locNewNeutralParticle);
80  }
81 
82  return NOERROR;
83 }
DNeutralParticleHypothesis * Create_DNeutralParticleHypothesis(const DNeutralShower *locNeutralShower, Particle_t locPID, const DEventRFBunch *locEventRFBunch, const DLorentzVector &dSpacetimeVertex, const TMatrixFSym *locVertexCovMatrix)
vector< const DReaction * > Get_Reactions(JEventLoop *locEventLoop)
Definition: DReaction.cc:218
vector< DNeutralParticleHypothesis * > dCreatedHypotheses
jerror_t evnt(jana::JEventLoop *locEventLoop, uint64_t eventnumber)
Called every event.
DLorentzVector dSpacetimeVertex
Definition: DVertex.h:28
jerror_t init(void)
Called once at program start.
TMatrixFSym dCovarianceMatrix
Definition: DVertex.h:29
jerror_t brun(jana::JEventLoop *locEventLoop, int32_t runnumber)
Called everytime a new run number is detected.
void Recycle_Hypotheses(vector< DNeutralParticleHypothesis * > &locHypos)
DNeutralParticleHypothesis_factory * dNeutralParticleHypothesisFactory