Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DNeutralParticle_factory_PreSelect.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DNeutralParticle_factory_PreSelect.cc
4 // Created: Thu Dec 3 17:27:55 EST 2009
5 // Creator: staylor (on Linux ifarml6 2.6.18-128.el5 x86_64)
6 //
7 
9 
10 //------------------
11 // init
12 //------------------
14 {
15  //Setting this flag makes it so that JANA does not delete the objects in _data. This factory will manage this memory.
16  //This is because some/all of these pointers are just copied from earlier objects, and should not be deleted.
17  SetFactoryFlag(NOT_OBJECT_OWNER);
18 
19  return NOERROR;
20 }
21 
22 //------------------
23 // brun
24 //------------------
25 jerror_t DNeutralParticle_factory_PreSelect::brun(jana::JEventLoop *locEventLoop, int32_t runnumber)
26 {
27  return NOERROR;
28 }
29 
30 //------------------
31 // evnt
32 //------------------
33 jerror_t DNeutralParticle_factory_PreSelect::evnt(jana::JEventLoop *locEventLoop, uint64_t eventnumber)
34 {
35  //Clear objects from last event
36  _data.clear();
37 
38  vector<const DNeutralParticle*> locNeutralParticles;
39  locEventLoop->Get(locNeutralParticles);
40 
41  vector<const DNeutralShower*> locNeutralShowers;
42  locEventLoop->Get(locNeutralShowers, "PreSelect");
43 
44  set<const DNeutralShower*> locNeutralShowerSet;
45  for(size_t loc_i = 0; loc_i < locNeutralShowers.size(); ++loc_i)
46  locNeutralShowerSet.insert(locNeutralShowers[loc_i]);
47 
48  //if neutral shower was good, keep particle, else ignore it
49  for(size_t loc_i = 0; loc_i < locNeutralParticles.size(); ++loc_i)
50  {
51  if(locNeutralShowerSet.find(locNeutralParticles[loc_i]->dNeutralShower) != locNeutralShowerSet.end())
52  _data.push_back(const_cast<DNeutralParticle*>(locNeutralParticles[loc_i]));
53  }
54 
55  return NOERROR;
56 }
57 
58 //------------------
59 // erun
60 //------------------
62 {
63  return NOERROR;
64 }
65 
66 //------------------
67 // fini
68 //------------------
70 {
71  return NOERROR;
72 }
73 
74 
jerror_t brun(jana::JEventLoop *locEventLoop, int32_t runnumber)
Called everytime a new run number is detected.
jerror_t evnt(jana::JEventLoop *locEventLoop, uint64_t eventnumber)
Called every event.
jerror_t fini(void)
Called after last event of last event source has been processed.
jerror_t init(void)
Called once at program start.
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.