12 #include <calobase/RawCluster.h>
13 #include <calobase/RawClusterContainer.h>
14 #include <calobase/RawClusterv1.h>
15 #include <calobase/RawTower.h>
16 #include <calobase/RawTowerContainer.h>
17 #include <calobase/RawTowerDefs.h>
18 #include <calobase/RawTowerGeom.h>
19 #include <calobase/RawTowerGeomContainer.h>
20 #include <calobase/TowerInfo.h>
21 #include <calobase/TowerInfoContainer.h>
68 std::cout <<
"Warning from RawClusterBuilderTemplate::Detector(): no detector specific class "
70 <<
". Default BEmcRec will be used" << std::endl;
75 float vertex[3] = {0, 0, 0};
92 std::cout <<
"Error in RawClusterBuilderTemplate::SetCylindricalGeometry()(): detector is not defined; use RawClusterBuilderTemplate::Detector() to define it" << std::endl;
103 std::cout <<
"Error in RawClusterBuilderTemplate::SetPlanarGeometry()(): detector is not defined; use RawClusterBuilderTemplate::Detector() to define it" << std::endl;
114 std::cout <<
"Error in RawClusterBuilderTemplate::InitRun(): detector is not defined; use RawClusterBuilderTemplate::Detector() to define it" << std::endl;
122 catch (std::exception &
e)
124 std::cout <<
PHWHERE <<
": " << e.what() << std::endl;
129 RawTowerGeomContainer *towergeom = findNode::getClass<RawTowerGeomContainer>(topNode, towergeomnodename);
132 std::cout <<
PHWHERE <<
": Could not find node " << towergeomnodename << std::endl;
146 for (; itr_geom != begin_end_geom.second; ++itr_geom)
172 std::cout <<
"Info from RawClusterBuilderTemplate::InitRun(): Init geometry for "
173 <<
detector <<
": N of geom towers: " << ngeom <<
"; ix = "
174 << ixmin <<
"-" << ixmax <<
", iy = "
175 << iymin <<
"-" << iymax << std::endl;
177 if (ixmax < ixmin || iymax < iymin)
179 std::cout <<
"Error in RawClusterBuilderTemplate::InitRun(): wrong geometry data for detector "
185 NBINX = ixmax - ixmin + 1;
187 NBINY = iymax - iymin + 1;
191 itr_geom = begin_end_geom.first;
192 for (; itr_geom != begin_end_geom.second; ++itr_geom)
232 if (!outfile.is_open())
234 std::cout <<
"Error in BEmcRec::RawClusterBuilderTemplate::PrintCylGeom(): Failed to open file "
235 << fname << std::endl;
238 outfile <<
NBINX <<
" " <<
NBINY << std::endl;
239 for (
int ip = 0; ip <
NBINX; ip++)
241 outfile << ip <<
" " << towergeom->
get_phicenter(ip) << std::endl;
243 for (
int ip = 0; ip <
NBINY; ip++)
245 outfile << ip <<
" " << towergeom->
get_etacenter(ip) << std::endl;
260 std::cout <<
"Error in RawClusterBuilderTemplate::process_event(): detector is not defined; use RawClusterBuilderTemplate::Detector() to define it" << std::endl;
270 towers = findNode::getClass<RawTowerContainer>(topNode, towernodename);
273 std::cout <<
PHWHERE <<
": Could not find node " << towernodename << std::endl;
279 RawTowerGeomContainer *towergeom = findNode::getClass<RawTowerGeomContainer>(topNode, towergeomnodename);
282 std::cout <<
PHWHERE <<
": Could not find node " << towergeomnodename << std::endl;
294 calib_towerinfos = findNode::getClass<TowerInfoContainer>(topNode, towerinfoNodename);
295 if (!calib_towerinfos)
297 std::cerr <<
Name() <<
"::" <<
detector <<
"::" << __PRETTY_FUNCTION__
298 <<
" " << towerinfoNodename <<
" Node missing, doing bail out!"
309 GlobalVertexMap *vertexmap = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
313 if (!vertexmap->
empty())
316 vx = vertex->
get_x();
317 vy = vertex->
get_y();
318 vz = vertex->
get_z();
322 MbdVertexMap *mbdmap = findNode::getClass<MbdVertexMap>(topNode,
"MbdVertexMap");
326 std::cout <<
" in mbdmap " << std::endl;
330 mbditer != mbdmap->
end();
333 bvertex = mbditer->second;
342 vz = bvertex->
get_z();
358 std::vector<EmcModule> HitList;
359 HitList.erase(HitList.begin(), HitList.end());
368 for (; itr != begin_end.second; ++itr)
386 if (ix >= 0 && ix < NBINX && iy >= 0 && iy <
NBINY)
388 ich = iy *
NBINX + ix;
392 HitList.push_back(vhit);
402 unsigned int nchannels = calib_towerinfos->
size();
424 if (ix >= 0 && ix < NBINX && iy >= 0 && iy <
NBINY)
426 ich = iy *
NBINX + ix;
432 HitList.push_back(vhit);
444 std::cout <<
"!!! Error in BEmcRec::FindClusters(): numbers of cluster "
445 << ncl <<
" ?" << std::endl;
451 std::vector<EmcCluster>::iterator pc;
453 std::vector<EmcCluster>::iterator pp;
454 float ecl, ecore, xcg, ycg, xx,
xy, yy;
459 std::vector<EmcCluster> PList;
460 std::vector<EmcModule> Peaks;
466 std::vector<EmcModule>::iterator ph;
467 std::vector<EmcModule> hlist;
470 for (pc = ClusterList->begin(); pc != ClusterList->end(); ++pc)
475 int npk = pc->GetSubClusters(PList, Peaks);
484 for (pp = PList.begin(); pp != PList.end(); ++pp)
487 ecl = pp->GetTotalEnergy();
488 ecore = pp->GetECoreCorrected();
494 pp->GetMoments(xcg, ycg, xx, xy, yy);
499 pp->GetGlobalPos(xg, yg, zg);
504 pp->GetGlobalPos(xg, yg, zg);
508 hmax = pp->GetMaxTower();
525 prob = pp->GetProb(chi2, ndf);
533 cluster->
set_r(std::sqrt(xg * xg + yg * yg));
534 cluster->
set_phi(std::atan2(yg, xg));
546 hlist = pp->GetHitList();
548 while (ph != hlist.end())
551 int iy = ich /
NBINX;
552 int ix = ich %
NBINX;
582 if (fabs(etower - ecluster) / ecluster > 1
e-9)
584 std::cout <<
"energy conservation violation: ETower: " << etower
585 <<
" ECluster: " << ecluster
586 <<
" diff: " << etower - ecluster << std::endl;
593 std::cout <<
"energy conservation violation: ETower: " << etower
594 <<
" ECluster: " << ecluster << std::endl;
600 std::cout <<
"RawClusterBuilderTemplate : energy conservation check asked for but tower or cluster container is NULL" << std::endl;
614 std::cout <<
PHWHERE <<
"DST Node missing, doing nothing." << std::endl;
615 throw std::runtime_error(
"Failed to find DST node in EmcRawTowerBuilder::CreateNodes");
641 cemcNode->
addNode(clusterNode);