Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DBCALCluster_factory_SINGLE.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DBCALCluster_factory_SINGLE.cc
4 // Created: Fri Sep 7 12:13:07 EDT 2012
5 // Creator: davidl (on Darwin harriet.jlab.org 11.4.0 i386)
6 //
7 
8 
9 #include <iostream>
10 #include <iomanip>
11 using namespace std;
12 
14 #include <BCAL/DBCALPoint.h>
15 #include <DANA/DApplication.h>
16 using namespace jana;
17 
18 //------------------
19 // init
20 //------------------
22 {
23  return NOERROR;
24 }
25 
26 //------------------
27 // brun
28 //------------------
29 jerror_t DBCALCluster_factory_SINGLE::brun(jana::JEventLoop *eventLoop, int32_t runnumber)
30 {
31  DApplication* app = dynamic_cast<DApplication*>(eventLoop->GetJApplication());
32  DGeometry* geom = app->GetDGeometry(runnumber);
33  geom->GetTargetZ(m_z_target_center);
34 
35  // load BCAL geometry
36  vector<const DBCALGeometry *> BCALGeomVec;
37  eventLoop->Get(BCALGeomVec);
38  if(BCALGeomVec.size() == 0)
39  throw JException("Could not load DBCALGeometry object!");
40  dBCALGeom = BCALGeomVec[0];
41 
42  return NOERROR;
43 }
44 
45 //------------------
46 // evnt
47 //------------------
48 jerror_t DBCALCluster_factory_SINGLE::evnt(JEventLoop *loop, uint64_t eventnumber)
49 {
50  // Get DBCALPoint objects
51  vector<const DBCALPoint*> bcalpoints;
52  loop->Get(bcalpoints);
53 
54  // Need at least one DBCALPoint object to make a cluster
55  if(bcalpoints.size() == 0) return NOERROR;
56 
57  // Create DBCALCluster object and add all DBCALPoint objects to it
58  DBCALCluster *cluster = new DBCALCluster(m_z_target_center, dBCALGeom);
59  int q = 0;
60  for(unsigned int i=0; i<bcalpoints.size(); i++){
61  cluster->addPoint(bcalpoints[i], q);
62  }
63 
64  // Store in _data so it is published to JANA
65  _data.push_back(cluster);
66 
67  return NOERROR;
68 }
69 
70 //------------------
71 // erun
72 //------------------
74 {
75  return NOERROR;
76 }
77 
78 //------------------
79 // fini
80 //------------------
82 {
83  return NOERROR;
84 }
85 
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
jerror_t init(void)
Called once at program start.
DGeometry * GetDGeometry(unsigned int run_number)
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
void addPoint(const DBCALPoint *point, int q)
Definition: DBCALCluster.cc:36
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
jerror_t fini(void)
Called after last event of last event source has been processed.
bool GetTargetZ(double &z_target) const
z-location of center of target
Definition: DGeometry.cc:1933