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>
49 , chkenergyconservation(0)
57 , fProbNoiseParam(0.04)
95 cout <<
"Warning from RawClusterBuilderTemplate::Detector(): no detector specific class "
97 <<
". Default BEmcRec will be used" << endl;
102 float vertex[3] = {0, 0, 0};
119 cout <<
"Error in RawClusterBuilderTemplate::SetCylindricalGeometry()(): detector is not defined; use RawClusterBuilderTemplate::Detector() to define it" << endl;
130 cout <<
"Error in RawClusterBuilderTemplate::SetPlanarGeometry()(): detector is not defined; use RawClusterBuilderTemplate::Detector() to define it" << endl;
141 cout <<
"Error in RawClusterBuilderTemplate::InitRun(): detector is not defined; use RawClusterBuilderTemplate::Detector() to define it" << endl;
149 catch (std::exception &
e)
151 std::cout <<
PHWHERE <<
": " << e.what() << std::endl;
155 string towergeomnodename =
"TOWERGEOM_" +
detector;
156 RawTowerGeomContainer *towergeom = findNode::getClass<RawTowerGeomContainer>(topNode, towergeomnodename);
159 cout <<
PHWHERE <<
": Could not find node " << towergeomnodename << endl;
173 for (; itr_geom != begin_end_geom.second; ++itr_geom)
179 if (ixmin > ix) ixmin = ix;
180 if (ixmax < ix) ixmax = ix;
181 if (iymin > iy) iymin = iy;
182 if (iymax < iy) iymax = iy;
187 cout <<
"Info from RawClusterBuilderTemplate::InitRun(): Init geometry for "
188 <<
detector <<
": N of geom towers: " << ngeom <<
"; ix = "
189 << ixmin <<
"-" << ixmax <<
", iy = "
190 << iymin <<
"-" << iymax << endl;
192 if (ixmax < ixmin || iymax < iymin)
194 cout <<
"Error in RawClusterBuilderTemplate::InitRun(): wrong geometry data for detector "
200 NBINX = ixmax - ixmin + 1;
202 NBINY = iymax - iymin + 1;
206 itr_geom = begin_end_geom.first;
207 for (; itr_geom != begin_end_geom.second; ++itr_geom)
243 ofstream outfile(fname);
244 if (!outfile.is_open())
246 cout <<
"Error in BEmcRec::RawClusterBuilderTemplate::PrintCylGeom(): Failed to open file "
251 for (
int ip = 0; ip <
NBINX; ip++)
253 outfile << ip <<
" " << towergeom->
get_phicenter(ip) << endl;
255 for (
int ip = 0; ip <
NBINY; ip++)
257 outfile << ip <<
" " << towergeom->
get_etacenter(ip) << endl;
272 cout <<
"Error in RawClusterBuilderTemplate::process_event(): detector is not defined; use RawClusterBuilderTemplate::Detector() to define it" << endl;
276 string towernodename =
"TOWER_CALIB_" +
detector;
278 RawTowerContainer *towers = findNode::getClass<RawTowerContainer>(topNode, towernodename);
281 std::cout <<
PHWHERE <<
": Could not find node " << towernodename << std::endl;
284 string towergeomnodename =
"TOWERGEOM_" +
detector;
285 RawTowerGeomContainer *towergeom = findNode::getClass<RawTowerGeomContainer>(topNode, towergeomnodename);
288 cout <<
PHWHERE <<
": Could not find node " << towergeomnodename << endl;
296 GlobalVertexMap *vertexmap = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
299 if (!vertexmap->
empty())
302 vx = vertex->
get_x();
303 vy = vertex->
get_y();
304 vz = vertex->
get_z();
309 float vertex[3] = {vx, vy, vz};
325 std::vector<EmcModule> HitList;
326 HitList.erase(HitList.begin(), HitList.end());
329 for (; itr != begin_end.second; ++itr)
347 if (ix >= 0 && ix < NBINX && iy >= 0 && iy <
NBINY)
349 ich = iy *
NBINX + ix;
353 HitList.push_back(vhit);
364 cout <<
"!!! Error in BEmcRec::FindClusters(): numbers of cluster "
365 << ncl <<
" ?" << endl;
371 std::vector<EmcCluster>::iterator
pc;
373 std::vector<EmcCluster>::iterator
pp;
374 float ecl, ecore, xcg, ycg,
xx, xy, yy;
379 std::vector<EmcCluster> PList;
380 std::vector<EmcModule> Peaks;
381 std::vector<EmcCluster> *pPList = &PList;
382 std::vector<EmcModule> *pPeaks = &Peaks;
388 vector<EmcModule>::iterator ph;
389 vector<EmcModule> hlist;
392 for (pc = ClusterList->begin(); pc != ClusterList->end(); ++
pc)
397 int npk = pc->GetSubClusters(pPList, pPeaks);
403 for (pp = pPList->begin(); pp != pPList->end(); ++
pp)
406 ecl = pp->GetTotalEnergy();
407 ecore = pp->GetECoreCorrected();
413 pp->GetMoments(xcg, ycg, xx, xy, yy);
414 pp->GetGlobalPos(xg, yg, zg);
417 hmax = pp->GetMaxTower();
434 prob = pp->GetProb(chi2, ndf);
442 cluster->
set_r(sqrt(xg * xg + yg * yg));
443 cluster->
set_phi(atan2(yg, xg));
452 hlist = pp->GetHitList();
454 while (ph != hlist.end())
457 int iy = ich /
NBINX;
458 int ix = ich %
NBINX;
487 if (fabs(etower - ecluster) / ecluster > 1
e-9)
489 cout <<
"energy conservation violation: ETower: " << etower
490 <<
" ECluster: " << ecluster
491 <<
" diff: " << etower - ecluster << endl;
498 cout <<
"energy conservation violation: ETower: " << etower
499 <<
" ECluster: " << ecluster << endl;
514 std::cerr <<
PHWHERE <<
"DST Node missing, doing nothing." << std::endl;
515 throw std::runtime_error(
"Failed to find DST node in EmcRawTowerBuilder::CreateNodes");
531 cemcNode->
addNode(clusterNode);