24 #include <phparameter/PHParameterInterface.h>
61 , m_crossingPeriod(NAN)
91 std::cout <<
PHWHERE <<
"DST Node missing, exiting." << std::endl;
100 std::cout <<
Name() <<
"RUN Node missing, exiting." << std::endl;
107 std::cout <<
Name() <<
"PAR Node missing, exiting." << std::endl;
124 std::cout <<
"Could not locate g4 hit node " <<
m_HitNodeName << std::endl;
128 auto hitsetcontainer = findNode::getClass<TrkrHitSetContainer>(topNode,
"TRKR_HITSET");
129 if (!hitsetcontainer)
144 auto hittruthassoc = findNode::getClass<TrkrHitTruthAssoc>(topNode,
"TRKR_HITTRUTHASSOC");
163 std::cout <<
"Could not locate geometry node " <<
m_GeoNodeName << std::endl;
188 m_truthtracks = findNode::getClass<TrkrTruthTrackContainer>(topNode,
"TRKR_TRUTHTRACKCONTAINER");
197 m_truthclusters = findNode::getClass<TrkrClusterContainer>(topNode,
"TRKR_TRUTHCLUSTERCONTAINER");
205 m_truthinfo = findNode::getClass<PHG4TruthInfoContainer>(topNode,
"G4TruthInfo");
208 std::cout <<
PHWHERE <<
" PHG4TruthInfoContainer node not found on node tree" << std::endl;
215 mClusHitsVerbose = findNode::getClass<ClusHitsVerbosev1>(topNode,
"Trkr_TruthClusHitsVerbose");
227 DetNode->addNode(newNode);
239 std::cout <<
"Could not locate g4 hit node " <<
m_HitNodeName << std::endl;
244 auto hitsetcontainer = findNode::getClass<TrkrHitSetContainer>(topNode,
"TRKR_HITSET");
245 if (!hitsetcontainer)
247 std::cout <<
"Could not locate TRKR_HITSET node, quit! " << std::endl;
252 auto hittruthassoc = findNode::getClass<TrkrHitTruthAssoc>(topNode,
"TRKR_HITTRUTHASSOC");
255 std::cout <<
"Could not locate TRKR_HITTRUTHASSOC node, quit! " << std::endl;
262 std::cout <<
"Could not locate geometry node " <<
m_GeoNodeName << std::endl;
267 if (
Verbosity() > 2) std::cout <<
" PHG4InttHitReco: Loop over hits" << std::endl;
273 const int sphxlayer = hiter->second->get_detid();
280 if (hiter->second->get_t(0) >
m_Tmax)
continue;
281 if (hiter->second->get_t(1) <
m_Tmin)
continue;
285 float time = (hiter->second->get_t(0) + hiter->second->get_t(1)) / 2.0;
288 double diffusion_width = 5.0e-04;
290 const int ladder_z_index = hiter->second->get_ladder_z_index();
291 const int ladder_phi_index = hiter->second->get_ladder_phi_index();
297 int strip_y_index_in = -99999;
298 int strip_z_index_in = -99999;
299 int strip_y_index_out = -99999;
300 int strip_z_index_out = -99999;
302 layergeom->
find_strip_index_values(ladder_z_index, hiter->second->get_local_y(0), hiter->second->get_local_z(0), strip_y_index_in, strip_z_index_in);
303 layergeom->
find_strip_index_values(ladder_z_index, hiter->second->get_local_y(1), hiter->second->get_local_z(1), strip_y_index_out, strip_z_index_out);
304 if (strip_y_index_in == -99999 ||
305 strip_z_index_in == -99999 ||
306 strip_y_index_out == -99999 ||
307 strip_z_index_out == -99999)
309 std::cout <<
"setting of strip indices failed" << std::endl;
310 std::cout <<
"strip_y_index_in: " << strip_y_index_in << std::endl;
311 std::cout <<
"strip_z_index_in: " << strip_z_index_in << std::endl;
312 std::cout <<
"strip_y_index_out: " << strip_y_index_out << std::endl;
313 std::cout <<
"strip_z_index_out: " << strip_y_index_out << std::endl;
320 double check_location[3] = {-1, -1, -1};
322 std::cout <<
" G4 entry location = " << hiter->second->get_local_x(0) <<
" " << hiter->second->get_local_y(0) <<
" " << hiter->second->get_local_z(0) << std::endl;
323 std::cout <<
" Check entry location = " << check_location[0] <<
" " << check_location[1] <<
" " << check_location[2] << std::endl;
325 std::cout <<
" G4 exit location = " << hiter->second->get_local_x(1) <<
" " << hiter->second->get_local_y(1) <<
" " << hiter->second->get_local_z(1) << std::endl;
326 std::cout <<
" Check exit location = " << check_location[0] <<
" " << check_location[1] <<
" " << check_location[2] << std::endl;
330 int minstrip_z = strip_z_index_in;
331 int maxstrip_z = strip_z_index_out;
332 if (minstrip_z > maxstrip_z)
std::swap(minstrip_z, maxstrip_z);
334 int minstrip_y = strip_y_index_in;
335 int maxstrip_y = strip_y_index_out;
336 if (minstrip_y > maxstrip_y)
std::swap(minstrip_y, maxstrip_y);
340 std::vector<int> vybin;
341 std::vector<int> vzbin;
343 std::vector<std::pair<double, double> > venergy;
357 if (maxstrip_y - minstrip_y > 12 || maxstrip_z - minstrip_z > 12)
362 double stripenergy[13][13] = {};
363 double stripeion[13][13] = {};
368 gsl_vector_set(
m_PathVec, 0, hiter->second->get_local_x(0));
369 gsl_vector_set(
m_PathVec, 1, hiter->second->get_local_y(0));
370 gsl_vector_set(
m_PathVec, 2, hiter->second->get_local_z(0));
371 gsl_vector_set(
m_LocalOutVec, 0, hiter->second->get_local_x(1));
372 gsl_vector_set(
m_LocalOutVec, 1, hiter->second->get_local_y(1));
373 gsl_vector_set(
m_LocalOutVec, 2, hiter->second->get_local_z(1));
375 for (
int i = 0;
i < nsegments;
i++)
381 double frac = interval / (
double) (2 * nsegments);
387 double diffusion_radius = diffusion_width;
390 std::cout <<
" segment " <<
i
391 <<
" interval " << interval
393 <<
" local_in.X " << hiter->second->get_local_x(0)
394 <<
" local_in.Z " << hiter->second->get_local_z(0)
395 <<
" local_in.Y " << hiter->second->get_local_y(0)
396 <<
" pathvec.X " << gsl_vector_get(
m_PathVec, 0)
397 <<
" pathvec.Z " << gsl_vector_get(
m_PathVec, 2)
398 <<
" pathvec.Y " << gsl_vector_get(
m_PathVec, 1)
401 <<
" segvec.Y " << gsl_vector_get(
m_SegmentVec, 1) << std::endl
402 <<
" diffusion_radius " << diffusion_radius
406 for (
int iz = minstrip_z; iz <= maxstrip_z; iz++)
408 for (
int iy = minstrip_y; iy <= maxstrip_y; iy++)
411 double location[3] = {-1, -1, -1};
423 stripenergy[iy - minstrip_y][iz - minstrip_z] += striparea_frac * hiter->second->get_edep() / (float) nsegments;
426 stripeion[iy - minstrip_y][iz - minstrip_z] += striparea_frac * hiter->second->get_eion() / (float) nsegments;
430 std::cout <<
" strip y index " << iy <<
" strip z index " << iz
431 <<
" strip area fraction of circle " << striparea_frac <<
" accumulated pixel energy " << stripenergy[iy - minstrip_y][iz - minstrip_z]
439 for (
int iz = minstrip_z; iz <= maxstrip_z; iz++)
441 for (
int iy = minstrip_y; iy <= maxstrip_y; iy++)
443 if (stripenergy[iy - minstrip_y][iz - minstrip_z] > 0.0)
447 std::pair<double, double> tmppair = std::make_pair(stripenergy[iy - minstrip_y][iz - minstrip_z], stripeion[iy - minstrip_y][iz - minstrip_z]);
448 venergy.push_back(tmppair);
451 std::cout <<
" Added ybin " << iy <<
" zbin " << iz <<
" to vectors with energy " << stripenergy[iy - minstrip_y][iz - minstrip_z] << std::endl;
461 for (
unsigned int i1 = 0; i1 < vybin.size(); i1++)
468 if(crossing < -512) crossing = -512;
469 if(crossing > 511) crossing = 511;
480 TrkrHit *hit = hitsetit->second->getHit(hitkey);
485 hitsetit->second->addHitSpecificKey(hitkey, hit);
491 std::cout <<
"add energy " << venergy[i1].first <<
" to intthit " << std::endl;
494 double hit_energy = venergy[i1].first * TrkrDefs::InttEnergyScaleup;
500 hittruthassoc->addAssoc(hitsetkey, hitkey, hiter->first);
504 std::cout <<
"PHG4InttHitReco: added hit wirh hitsetkey " << hitsetkey <<
" hitkey " << hitkey <<
" g4hitkey " << hiter->first <<
" energy " << hit->
getEnergy() << std::endl;
512 std::cout <<
"From PHG4InttHitReco: " << std::endl;
513 hitsetcontainer->identify();
514 hittruthassoc->identify();
539 if (g4hit==
nullptr)
return;
542 bool is_new_track = (new_trkid !=
m_trkid);
543 if (
Verbosity()>5) std::cout <<
PHWHERE << std::endl <<
" -> Checking status of PHG4Hit. Track id("<<new_trkid<<
")" << std::endl;
561 if (
Verbosity()>2) std::cout <<
PHWHERE << std::endl <<
" -> Found new embedded track with id: " << new_trkid << std::endl;
595 hit = hitsetit->second->getHit(hitkey);
600 hitsetit->second->addHitSpecificKey(hitkey, hit);
688 if (
Verbosity() > 1) std::cout <<
"Clustering truth clusters" << std::endl;
695 if (!geom_container)
return;
703 hitsetitr != hitsetrange.second; ++hitsetitr)
711 if (
Verbosity() > 1 ) std::cout <<
"InttClusterizer found hitsetkey " << hitsetitr->first << std::endl;
717 std::cout <<
"Filling cluster with hitsetkey " << ((int)hitsetkey) << std::endl;
727 double xlocalsum = 0.0;
728 double ylocalsum = 0.0;
729 double zlocalsum = 0.0;
730 unsigned int clus_adc = 0.0;
736 for (
auto ihit = hitrangei.first;
ihit != hitrangei.second; ++
ihit) {
737 sum_adc +=
ihit->second->getAdc();
744 std::map<int,unsigned int> m_iphi, m_it, m_iphiCut, m_itCut;
751 for (
auto ihit = hitrangei.first;
ihit != hitrangei.second; ++
ihit)
755 auto adc =
ihit->second->getAdc();
758 std::map<int,unsigned int>& m_phi = (adc<threshold) ? m_iphiCut : m_iphi;
759 std::map<int,unsigned int>& m_z = (adc<threshold) ? m_itCut : m_it;
761 auto pnew = m_phi.try_emplace(row,adc);
762 if (!pnew.second) pnew.first->second += adc;
764 pnew = m_z.try_emplace(col,adc);
765 if (!pnew.second) pnew.first->second += adc;
767 if (adc<threshold)
continue;
771 phibins .insert(row);
774 double local_hit_location[3] = {0., 0., 0.};
778 xlocalsum += local_hit_location[0];
779 ylocalsum += local_hit_location[1];
780 zlocalsum += local_hit_location[2];
786 std::cout <<
" From geometry object: hit x " << local_hit_location[0]
787 <<
" hit y " << local_hit_location[1] <<
" hit z " << local_hit_location[2] << std::endl;
788 std::cout <<
" nhits " << nhits <<
" clusx = " << xlocalsum / nhits <<
" clusy "
789 << ylocalsum / nhits <<
" clusz " << zlocalsum / nhits << std::endl;
808 for (
auto& hit : m_iphi) {
809 std::cout <<
" m_phi(" << hit.first <<
" : " << hit.second<<
") " << std::endl;
820 if (
Verbosity() > 2) std::cout <<
" nhits = " << nhits << std::endl;
838 if (nhits == 0)
continue;
840 double cluslocaly = ylocalsum / nhits;
841 double cluslocalz = zlocalsum / nhits;
852 auto clus = std::make_unique<TrkrClusterv4>();
853 clus->setAdc(clus_adc);
854 clus->setPhiSize(phibins.size());
859 clus->setLocalX(cluslocaly);
860 clus->setLocalY(cluslocalz);
862 clus->setSubSurfKey(0);
871 if (
Verbosity()>10) std::cout <<
" ClusHitsVerbose.size (in INTT): "