12 #include <phparameter/PHParameterContainerInterface.h>
13 #include <phparameter/PHParametersContainer.h>
44 , chkenergyconservation(0)
64 cout <<
Name() <<
" DST Node missing, doing nothing." << std::endl;
81 cout <<
Name() <<
"DST Node missing, doing nothing." << endl;
98 cout <<
Name() <<
" Could not locate g4 hit node " <<
hitnodename << endl;
115 cout <<
Name() <<
" Could not locate geometry node " <<
geonodename << endl;
136 map<int, PHG4BlockGeom *>::const_iterator miter;
137 pair<map<int, PHG4BlockGeom *>::const_iterator, map<int, PHG4BlockGeom *>::const_iterator> begin_end = geo->
get_begin_end();
138 map<int, std::pair<double, double> >::iterator sizeiter;
139 for (miter = begin_end.first; miter != begin_end.second; ++miter)
145 cout <<
Name() <<
": No parameters for detid/layer " << layer
146 <<
", hits from this detid/layer will not be accumulated into cells" << endl;
153 double zmin = layergeom->
get_center_z() - length_in_z / 2.;
154 double zmax = zmin + length_in_z;
160 cout <<
Name() <<
"no cell sizes for layer " << layer << endl;
177 double etastepsize = (sizeiter->second).first;
179 double fract = modf((etamax - etamin) / etastepsize, &d_etabins);
184 etastepsize = (etamax -
etamin) / d_etabins;
185 (sizeiter->second).first = etastepsize;
186 int etabins = d_etabins;
187 double etahi = etamin + etastepsize;
188 for (
int i = 0;
i < etabins;
i++)
190 if (etahi > (etamax + 1.
e-6))
192 cout <<
"etahi: " << etahi <<
", etamax: " << etamax << endl;
194 etahi += etastepsize;
199 double xstepsize = (sizeiter->second).second;
201 fract = modf(width / xstepsize, &d_xbins);
207 xstepsize = width / d_xbins;
208 (sizeiter->second).second = xstepsize;
223 pair<int, int> x_z_bin = make_pair(xbins, etabins);
253 cout <<
"Could not locate g4 hit node " <<
hitnodename << endl;
259 cout <<
"could not locate cell node " <<
cellnodename << endl;
271 pair<PHG4HitContainer::LayerIter, PHG4HitContainer::LayerIter> layer_begin_end = g4hit->
getLayers();
279 for (layer = layer_begin_end.first; layer != layer_begin_end.second; layer++)
291 unsigned int nbins = nxbins * nzbins;
301 for (hiter = hit_begin_end.first; hiter != hit_begin_end.second; hiter++)
304 if (hiter->second->get_t(0) >
tmin_max[*
layer].second)
continue;
305 if (hiter->second->get_t(1) <
tmin_max[*
layer].first)
continue;
307 pair<double, double> etax[2];
310 for (
int i = 0;
i < 2;
i++)
318 if (xbin[0] < 0 || xbin[0] >= nxbins || xbin[1] < 0 || xbin[1] >= nxbins)
322 if (etabin[0] < 0 || etabin[0] >= nzbins || etabin[1] < 0 || etabin[1] >= nzbins)
331 hiter->second->identify();
337 int intxbin = xbin[0];
338 int intetabin = etabin[0];
339 int intxbinout = xbin[1];
340 int intetabinout = etabin[1];
344 double ax = (etax[0]).second;
345 double ay = (etax[0]).first;
346 double bx = (etax[1]).second;
347 double by = (etax[1]).first;
348 if (intxbin > intxbinout)
351 intxbin = intxbinout;
355 if (intetabin > intetabinout)
358 intetabin = intetabinout;
362 double trklen = sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by));
375 vector<double> vdedx;
377 if (intxbin == intxbinout && intetabin == intetabinout)
379 if (
Verbosity() > 0) cout <<
"SINGLE CELL FIRED: " << intxbin <<
" " << intetabin << endl;
380 vx.push_back(intxbin);
381 veta.push_back(intetabin);
382 vdedx.push_back(trklen);
386 for (
int ibp = intxbin; ibp <= intxbinout; ibp++)
388 for (
int ibz = intetabin; ibz <= intetabinout; ibz++)
399 if (
Verbosity() > 0) cout <<
"CELL FIRED: " << ibp <<
" " << ibz <<
" " << intersect.second << endl;
402 vdedx.push_back(intersect.second);
407 if (
Verbosity() > 0) cout <<
"NUMBER OF FIRED CELLS = " << vx.size() << endl;
410 for (
unsigned int ii = 0; ii < vx.size(); ii++)
413 vdedx[ii] = vdedx[ii] / trklen;
414 if (
Verbosity() > 0) cout <<
" CELL " << ii <<
" dE/dX = " << vdedx[ii] << endl;
416 if (
Verbosity() > 0) cout <<
" TOTAL TRACK LENGTH = " << tmpsum <<
" " << trklen << endl;
418 for (
unsigned int i1 = 0; i1 < vx.size(); i1++)
421 int ietabin = veta[i1];
422 int ibin = ixbin * nzbins + ietabin;
428 cellptarray[
ibin]->add_edep(hiter->first, hiter->second->get_edep() * vdedx[i1]);
432 cellptarray[
ibin]->add_light_yield(hiter->second->get_light_yield() * vdedx[i1]);
434 cellptarray[
ibin]->add_shower_edep(hiter->second->get_shower_id(), hiter->second->get_edep() * vdedx[i1]);
437 if (!isfinite(hiter->second->get_edep() * vdedx[i1]))
439 cout <<
PHWHERE <<
" invalid energy dep " << hiter->second->get_edep()
440 <<
" or path length: " << vdedx[i1] << endl;
449 for (
int ix = 0; ix < nxbins; ix++)
451 for (
int iz = 0; iz < nzbins; iz++)
453 int ibin = ix * nzbins + iz;
461 cout <<
"Adding cell in bin x: " << ix
463 <<
", eta bin: " << iz
476 cout <<
Name() <<
": found " << numcells <<
" eta/x cells with energy deposition" << endl;
507 cout <<
"size for layer " << i <<
" already set" << endl;
522 double sum_energy_cells = 0.;
523 double sum_energy_stored_hits = 0.;
524 double sum_energy_stored_showers = 0.;
528 for (citer = cell_begin_end.first; citer != cell_begin_end.second; ++citer)
530 sum_energy_cells += citer->second->get_edep();
534 sum_energy_stored_hits += iter->second;
539 sum_energy_stored_showers += iter->second;
544 if (sum_energy_stored_hits > 0)
546 if (fabs(sum_energy_cells - sum_energy_stored_hits) / sum_energy_cells > 1
e-6)
548 cout <<
"energy mismatch between cell energy " << sum_energy_cells
549 <<
" and stored hit energies " << sum_energy_stored_hits
553 if (sum_energy_stored_showers > 0)
555 if (fabs(sum_energy_cells - sum_energy_stored_showers) / sum_energy_cells > 1
e-6)
557 cout <<
"energy mismatch between cell energy " << sum_energy_cells
558 <<
" and stored shower energies " << sum_energy_stored_showers
565 cout <<
"energy mismatch between cells: " << sum_energy_cells
577 cout <<
Name() <<
": sum cell energy: " << sum_energy_cells <<
" GeV" << endl;
578 cout <<
Name() <<
": sum shower energy: " << sum_energy_stored_showers <<
" GeV" << endl;
579 cout <<
Name() <<
": sum stored hit energy: " << sum_energy_stored_hits <<
" GeV" << endl;