22 if(std::isnan(locBeamPhoton1->
time()))
24 if(std::isnan(locBeamPhoton2->
time()))
26 double locT1_Picoseconds_Stripped = 1000.0*locBeamPhoton1->
time() - floor(1000.0*locBeamPhoton1->
time());
27 double locT2_Picoseconds_Stripped = 1000.0*locBeamPhoton2->
time() - floor(1000.0*locBeamPhoton2->
time());
28 return (locT1_Picoseconds_Stripped < locT2_Picoseconds_Stripped);
36 DELTA_T_DOUBLES_MAX = 1.5;
37 gPARMS->SetDefaultParameter(
"BeamPhoton:DELTA_T_DOUBLES_MAX", DELTA_T_DOUBLES_MAX,
38 "Maximum time difference in ns between a TAGM-TAGH pair of beam photons"
39 " for them to be merged into a single photon");
40 DELTA_E_DOUBLES_MAX = 0.05;
41 gPARMS->SetDefaultParameter(
"BeamPhoton:DELTA_E_DOUBLES_MAX", DELTA_E_DOUBLES_MAX,
42 "Maximum energy difference in GeV between a TAGM-TAGH pair of beam photons"
43 " for them to be merged into a single photon");
46 SetFactoryFlag(NOT_OBJECT_OWNER);
68 dResourcePool_BeamPhotons->Recycle(dCreated);
72 vector<const DTAGMHit*> tagm_hits;
73 locEventLoop->Get(tagm_hits);
75 for (
unsigned int ih=0; ih < tagm_hits.size(); ++ih)
77 if (!tagm_hits[ih]->has_fADC)
continue;
78 if (tagm_hits[ih]->row > 0)
continue;
81 Set_BeamPhoton(gamma, tagm_hits[ih], locEventNumber);
82 _data.push_back(gamma);
85 vector<const DTAGHHit*> tagh_hits;
86 locEventLoop->Get(tagh_hits);
88 for (
unsigned int ih=0; ih < tagh_hits.size(); ++ih)
90 if (!tagh_hits[ih]->has_fADC)
continue;
92 for (
unsigned int jh=0; jh < _data.size(); ++jh)
94 if (fabs(_data[jh]->momentum().Mag() - tagh_hits[ih]->E) < DELTA_E_DOUBLES_MAX
95 && fabs(_data[jh]->time() - tagh_hits[ih]->t) < DELTA_T_DOUBLES_MAX)
98 if (_data[jh]->momentum().Mag() < tagh_hits[ih]->E)
101 Set_BeamPhoton(gamma, tagh_hits[ih], locEventNumber);
105 if (gamma ==
nullptr)
107 gamma = Get_Resource();
108 Set_BeamPhoton(gamma, tagh_hits[ih], locEventNumber);
109 _data.push_back(gamma);
121 DVector3 pos(0.0, 0.0, dTargetCenterZ);
129 gamma->AddAssociatedObject(hit);
131 auto locCovarianceMatrix = dResourcePool_TMatrixFSym->Get_SharedResource();
132 locCovarianceMatrix->ResizeTo(7, 7);
133 locCovarianceMatrix->Zero();
139 DVector3 pos(0.0, 0.0, dTargetCenterZ);
147 gamma->AddAssociatedObject(hit);
149 auto locCovarianceMatrix = dResourcePool_TMatrixFSym->Get_SharedResource();
150 locCovarianceMatrix->ResizeTo(7, 7);
151 locCovarianceMatrix->Zero();
void setMomentum(const DVector3 &aMomentum)
void setTime(double locTime)
jerror_t brun(jana::JEventLoop *locEventLoop, int32_t runnumber)
Called everytime a new run number is detected.
bool DBeamPhoton_SortByTime(const DBeamPhoton *locBeamPhoton1, const DBeamPhoton *locBeamPhoton2)
void setErrorMatrix(const shared_ptr< const TMatrixFSym > &aMatrix)
DGeometry * GetDGeometry(unsigned int run_number)
void setPID(Particle_t locPID)
void Set_BeamPhoton(DBeamPhoton *gamma, const DTAGHHit *hit, uint64_t locEventNumber)
void setPosition(const DVector3 &aPosition)
jerror_t init(void)
Called once at program start.
jerror_t evnt(jana::JEventLoop *locEventLoop, uint64_t locEventNumber)
Called every event.
bool GetTargetZ(double &z_target) const
z-location of center of target