Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DBeamPhoton_factory_TRUTH.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DBeamPhoton_factory_TRUTH.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 
8 #include <iostream>
9 #include <iomanip>
10 using namespace std;
11 
13 using namespace jana;
14 
15 //------------------
16 // init
17 //------------------
19 {
20  return NOERROR;
21 }
22 
23 //------------------
24 // brun
25 //------------------
26 jerror_t DBeamPhoton_factory_TRUTH::brun(jana::JEventLoop *locEventLoop, int32_t runnumber)
27 {
28  DApplication* dapp = dynamic_cast<DApplication*>(locEventLoop->GetJApplication());
29  DGeometry* locGeometry = dapp->GetDGeometry(locEventLoop->GetJEvent().GetRunNumber());
30  dTargetCenterZ = 0.0;
31  locGeometry->GetTargetZ(dTargetCenterZ);
32 
33  return NOERROR;
34 }
35 
36 //------------------
37 // evnt
38 //------------------
39 jerror_t DBeamPhoton_factory_TRUTH::evnt(jana::JEventLoop *locEventLoop, uint64_t eventnumber)
40 {
41  DVector3 pos(0.0, 0.0, dTargetCenterZ);
42 
43  vector<const DTAGMHit*> tagm_hits;
44  locEventLoop->Get(tagm_hits, "TRUTH");
45  for (unsigned int ih=0; ih < tagm_hits.size(); ++ih)
46  {
47  if (tagm_hits[ih]->row > 0) continue;
48  DVector3 mom(0.0, 0.0, tagm_hits[ih]->E);
49  DBeamPhoton *gamma = new DBeamPhoton;
50  gamma->setPID(Gamma);
51  gamma->setMomentum(mom);
52  gamma->setPosition(pos);
53  gamma->setTime(tagm_hits[ih]->t);
54  gamma->dSystem = SYS_TAGM;
55  gamma->dCounter = tagm_hits[ih]->column;
56  gamma->AddAssociatedObject(tagm_hits[ih]);
57  _data.push_back(gamma);
58  }
59 
60  vector<const DTAGHHit*> tagh_hits;
61  locEventLoop->Get(tagh_hits, "TRUTH");
62  for (unsigned int ih=0; ih < tagh_hits.size(); ++ih)
63  {
64  DVector3 mom(0.0, 0.0, tagh_hits[ih]->E);
65  DBeamPhoton *gamma = new DBeamPhoton;
66  gamma->setPID(Gamma);
67  gamma->setMomentum(mom);
68  gamma->setPosition(pos);
69  gamma->setTime(tagh_hits[ih]->t);
70  gamma->dSystem = SYS_TAGH;
71  gamma->dCounter = tagh_hits[ih]->counter_id;
72  gamma->AddAssociatedObject(tagh_hits[ih]);
73  _data.push_back(gamma);
74  }
75 
76  return NOERROR;
77 }
78 
79 //------------------
80 // erun
81 //------------------
83 {
84  return NOERROR;
85 }
86 
87 //------------------
88 // fini
89 //------------------
91 {
92  return NOERROR;
93 }
94 
unsigned int dCounter
Definition: DBeamPhoton.h:18
void setMomentum(const DVector3 &aMomentum)
void setTime(double locTime)
DApplication * dapp
TVector3 DVector3
Definition: DVector3.h:14
Definition: GlueX.h:29
Definition: GlueX.h:24
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
DGeometry * GetDGeometry(unsigned int run_number)
jerror_t init(void)
Called once at program start.
void setPID(Particle_t locPID)
jerror_t brun(jana::JEventLoop *locEventLoop, int32_t runnumber)
Called everytime a new run number is detected.
DetectorSystem_t dSystem
Definition: DBeamPhoton.h:19
void setPosition(const DVector3 &aPosition)
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.
bool GetTargetZ(double &z_target) const
z-location of center of target
Definition: DGeometry.cc:1933