Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DNeutralShower_factory_PreSelect.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DNeutralShower_factory_PreSelect.cc
4 // Created: Tue Aug 9 14:29:24 EST 2011
5 // Creator: pmatt (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  dMinFCALE = 0.1;
20  dMinBCALE = 0.1;
21  dMinBCALNcell = 2;
22 
23  return NOERROR;
24 }
25 
26 //------------------
27 // brun
28 //------------------
29 jerror_t DNeutralShower_factory_PreSelect::brun(jana::JEventLoop *locEventLoop, int32_t runnumber)
30 {
31  gPARMS->SetDefaultParameter("PRESELECT:MIN_FCAL_E", dMinFCALE);
32  gPARMS->SetDefaultParameter("PRESELECT:MIN_BCAL_E", dMinBCALE);
33  gPARMS->SetDefaultParameter("PRESELECT:MIN_BCAL_NCELL", dMinBCALNcell);
34 
35  return NOERROR;
36 }
37 
38 //------------------
39 // evnt
40 //------------------
41 jerror_t DNeutralShower_factory_PreSelect::evnt(jana::JEventLoop *locEventLoop, uint64_t eventnumber)
42 {
43  //Clear objects from last event
44  _data.clear();
45 
46  //Get original objects
47  vector<const DNeutralShower*> locNeutralShowers;
48  locEventLoop->Get(locNeutralShowers);
49 
50  //Cut on shower energy, BCAL cells
51  for(size_t loc_i = 0; loc_i < locNeutralShowers.size(); ++loc_i)
52  {
53  if(locNeutralShowers[loc_i]->dDetectorSystem == SYS_FCAL)
54  {
55  if(locNeutralShowers[loc_i]->dEnergy < dMinFCALE)
56  continue;
57  }
58  else if(locNeutralShowers[loc_i]->dDetectorSystem == SYS_BCAL)
59  {
60  if(locNeutralShowers[loc_i]->dEnergy < dMinBCALE)
61  continue;
62 
63  const DBCALShower* locBCALShower = NULL;
64  locNeutralShowers[loc_i]->GetSingleT(locBCALShower);
65  if(locBCALShower->N_cell < dMinBCALNcell)
66  continue;
67  }
68 
69  _data.push_back(const_cast<DNeutralShower*>(locNeutralShowers[loc_i]));
70  }
71 
72  return NOERROR;
73 }
74 
75 //------------------
76 // erun
77 //------------------
79 {
80  return NOERROR;
81 }
82 
83 //------------------
84 // fini
85 //------------------
87 {
88  return NOERROR;
89 }
jerror_t evnt(jana::JEventLoop *locEventLoop, uint64_t eventnumber)
Called every event.
jerror_t init(void)
Called once at program start.
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
Definition: GlueX.h:19
jerror_t fini(void)
Called after last event of last event source has been processed.
Definition: GlueX.h:22
jerror_t brun(jana::JEventLoop *locEventLoop, int32_t runnumber)
Called everytime a new run number is detected.