17 #include <phparameter/PHParameterInterface.h>
75 std::cout <<
PHWHERE <<
"DST Node missing, doing nothing." << std::endl;
82 std::cout <<
"PHG4FullProjSpacalCellReco::InitRun - Could not locate g4 hit node "
107 std::cout <<
"PHG4FullProjSpacalCellReco::InitRun - Could not locate geometry node "
114 std::cout <<
"PHG4FullProjSpacalCellReco::InitRun - incoming geometry:"
137 std::cout <<
"PHG4FullProjSpacalCellReco::InitRun - Fatal Error -"
138 <<
" require to work with a version of SPACAL geometry of PHG4CylinderGeom_Spacalv3 or higher. "
139 <<
"However the incoming geometry has version "
140 << layergeom_raw->ClassName() << std::endl;
166 const double deltaphi = 2. * M_PI / nphibin;
168 using map_z_tower_z_ID_t = std::map<double, int>;
169 map_z_tower_z_ID_t map_z_tower_z_ID;
172 for (
const auto &tower_pair : tower_map)
174 const int &tower_ID = tower_pair.first;
180 const int &tower_ID_z = tower_z_phi_ID.first;
181 const int &tower_ID_phi = tower_z_phi_ID.second;
183 if (tower_ID_phi == 0)
187 + sector_map.begin()->second;
193 map_z_tower_z_ID[tower.
centralZ] = tower_ID_z;
198 assert(!std::isnan(phi_min));
205 for (
auto &z_tower_z_ID : map_z_tower_z_ID)
207 tower_z_ID_eta_bin_map[z_tower_z_ID.second] = eta_bin;
216 for (
const auto &tower_pair : tower_map)
218 const int &tower_ID = tower_pair.first;
223 const int &tower_ID_z = tower_z_phi_ID.first;
224 const int &tower_ID_phi = tower_z_phi_ID.second;
225 const int &
etabin = tower_z_ID_eta_bin_map[tower_ID_z];
233 auto z_to_eta = [&tower_radial](
const double &
z)
234 {
return -log(tan(0.5 * atan2(tower_radial,
z))); };
236 const double eta_central = z_to_eta(tower.
centralZ);
238 const double deta = (z_to_eta(tower.
centralZ + dz) - z_to_eta(tower.
centralZ - dz)) / 2;
241 for (
int sub_tower_ID_y = 0; sub_tower_ID_y < tower.
NSubtowerY;
246 const int sub_tower_etabin = etabin * layergeom->
get_n_subtower_eta() + sub_tower_ID_y;
248 const std::pair<double, double> etabounds(eta_central - deta + sub_tower_ID_y * 2 * deta / tower.
NSubtowerY,
249 eta_central - deta + (sub_tower_ID_y + 1) * 2 * deta / tower.
NSubtowerY);
251 const std::pair<double, double> zbounds(tower.
centralZ - dz + sub_tower_ID_y * 2 * dz / tower.
NSubtowerY,
255 layerseggeo->
set_zbounds(sub_tower_etabin, zbounds);
259 std::cout <<
"PHG4FullProjSpacalCellReco::InitRun::" <<
Name()
260 <<
"\t tower_ID_z = " << tower_ID_z
261 <<
"\t tower_ID_phi = " << tower_ID_phi
262 <<
"\t sub_tower_ID_y = " << sub_tower_ID_y
263 <<
"\t sub_tower_etabin = " << sub_tower_etabin
265 <<
"\t tower_radial = " << tower_radial
266 <<
"\t eta_central = " << eta_central
267 <<
"\t deta = " << deta
268 <<
"\t etabounds = [" << etabounds.first <<
", " << etabounds.second <<
"]"
269 <<
"\t zbounds = [" << zbounds.first <<
", " << zbounds.second <<
"]"
281 std::cout <<
"PHG4FullProjSpacalCellReco::InitRun::" <<
Name()
282 <<
" - Done layer" << (layergeom->
get_layer())
283 <<
". Print out the cell geometry:" << std::endl;
320 std::cout <<
"PHG4FullProjSpacalCellReco::process_event - Fatal Error - Could not locate g4 hit node "
327 std::cout <<
"PHG4FullProjSpacalCellReco::process_event - Fatal Error - could not locate cell node "
335 std::cout <<
"PHG4FullProjSpacalCellReco::process_event - Fatal Error - could not locate cell geometry node "
343 std::cout <<
"PHG4FullProjSpacalCellReco::process_event - Fatal Error - Could not locate sim geometry node "
361 for (hiter = hit_begin_end.first; hiter != hit_begin_end.second; ++hiter)
364 if (hiter->second->get_t(0) >
tmax)
continue;
365 if (hiter->second->get_t(1) <
tmin)
continue;
366 if (hiter->second->get_t(1) - hiter->second->get_t(0) >
m_DeltaT)
continue;
371 int scint_id = hiter->second->get_scint_id();
378 const int &tower_ID_z = tower_z_phi_ID.first;
379 const int &tower_ID_phi = tower_z_phi_ID.second;
381 PHG4CylinderGeom_Spacalv3::tower_map_t::const_iterator it_tower =
385 unsigned int key =
static_cast<unsigned int>(scint_id);
387 std::map<unsigned int, PHG4Cell *>::iterator
it =
celllist.find(key);
400 catch (std::exception &
e)
402 std::cout <<
"Print cell geometry:" << std::endl;
404 std::cout <<
"Print scint_id_coder:" << std::endl;
406 std::cout <<
"Print the hit:" << std::endl;
407 hiter->second->print();
408 std::cout <<
"PHG4FullProjSpacalCellReco::process_event::"
409 <<
Name() <<
" - Fatal Error - " << e.what() << std::endl;
413 const int sub_tower_ID_x = it_tower->second.get_sub_tower_ID_x(decoder.
fiber_ID);
414 const int sub_tower_ID_y = it_tower->second.get_sub_tower_ID_y(decoder.
fiber_ID);
415 unsigned short fiber_ID = decoder.
fiber_ID;
416 unsigned short etabinshort = etabin * layergeom->
get_n_subtower_eta() + sub_tower_ID_y;
417 unsigned short phibin = tower_ID_phi * layergeom->
get_n_subtower_phi() + sub_tower_ID_x;
429 const double z = 0.5 * (hiter->second->get_local_z(0) + hiter->second->get_local_z(1));
430 assert(not std::isnan(z));
439 const double x = it_tower->second.get_position_fraction_x_in_sub_tower(decoder.
fiber_ID);
440 const double y = it_tower->second.get_position_fraction_y_in_sub_tower(decoder.
fiber_ID);
444 cell->
add_edep(hiter->first, hiter->second->get_edep());
445 cell->
add_edep(hiter->second->get_edep());
447 cell->
add_shower_edep(hiter->second->get_shower_id(), hiter->second->get_edep());
451 for (std::map<unsigned int, PHG4Cell *>::const_iterator mapiter =
453 mapiter !=
celllist.end(); ++mapiter)
455 cells->
AddCell(mapiter->second);
459 std::cout <<
"PHG4FullProjSpacalCellReco::process_event::" <<
Name()
461 <<
"Adding cell in bin eta "
468 << mapiter->second->get_edep() <<
", light yield: "
469 << mapiter->second->get_light_yield() << std::endl;
475 std::cout <<
"PHG4FullProjSpacalCellReco::process_event::" <<
Name()
477 <<
" found " << numcells
478 <<
" fibers with energy deposition" << std::endl;
491 double sum_energy_cells = 0.;
494 for (citer = cell_begin_end.first; citer != cell_begin_end.second; ++citer)
496 sum_energy_cells += citer->second->get_edep();
502 <<
"PHG4FullProjSpacalCellReco::CheckEnergy - energy mismatch between cells: "
504 <<
" diff sum(cells) - sum(hits): "
512 std::cout <<
"PHG4FullProjSpacalCellReco::CheckEnergy::" <<
Name()
514 <<
" GeV. Passed CheckEnergy" << std::endl;