3 #include <calobase/RawCluster.h>
4 #include <calobase/RawClusterContainer.h>
5 #include <calobase/RawClusterUtility.h>
6 #include <calobase/RawTower.h>
7 #include <calobase/RawTowerContainer.h>
8 #include <calobase/RawTowerDefs.h>
9 #include <calobase/RawTowerGeomContainer.h>
10 #include <calobase/TowerInfo.h>
11 #include <calobase/TowerInfoContainer.h>
18 #include <phparameter/PHParameters.h>
66 std::string m_calibName =
"cemc_PDC_NorthSouth_8x8_23instru";
68 if (!calibdir.empty())
74 std::cout << std::endl
75 <<
"did not find CDB tree" << std::endl;
84 std::string m_fieldname =
"cemc_PDC_NorthSector_8x8_clusE";
85 std::string m_fieldname_ecore =
"cemc_PDC_NorthSector_8x8_clusEcore";
86 float calib_constant = 0;
91 std::vector<float> dumvec;
92 std::vector<float> dumvec2;
95 int key =
i * bins_eta +
j;
97 dumvec.push_back(calib_constant);
99 dumvec2.push_back(calib_constant);
105 m_fieldname =
"cemc_PDC_SouthSector_8x8_clusE";
106 m_fieldname_ecore =
"cemc_PDC_SouthSector_8x8_clusEcore";
111 std::vector<float> dumvec;
112 std::vector<float> dumvec2;
115 int key =
i * bins_eta +
j;
117 dumvec.push_back(calib_constant);
119 dumvec2.push_back(calib_constant);
127 if (!calibdir.empty())
136 std::cout << std::endl
137 <<
"did not find CDB histo" << std::endl;
151 if (
iEvent % 100 == 0) std::cout <<
"Progress: " <<
iEvent << std::endl;
158 rawClusNodeName =
"CLUSTERINFO_" +
_det_name;
161 RawClusterContainer *rawclusters = findNode::getClass<RawClusterContainer>(topNode, rawClusNodeName.c_str());
164 std::cout <<
"No " <<
_det_name <<
" Cluster Container found while in RawClusterPositionCorrection, can't proceed!!!" << std::endl;
173 _towers = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_CALIB_" +
_det_name);
176 std::cout <<
"No calibrated " <<
_det_name <<
" tower info found while in RawClusterPositionCorrection, can't proceed!!!" << std::endl;
184 _towerinfos = findNode::getClass<TowerInfoContainer>(topNode, towerinfoNodename);
187 std::cerr <<
Name() <<
"::" <<
_det_name <<
"::" << __PRETTY_FUNCTION__
188 <<
" " << towerinfoNodename <<
" Node missing, doing bail out!"
196 RawTowerGeomContainer *towergeom = findNode::getClass<RawTowerGeomContainer>(topNode, towergeomnodename);
199 std::cout <<
PHWHERE <<
": Could not find node " << towergeomnodename << std::endl;
208 for (iter = begin_end.first; iter != begin_end.second; ++iter)
215 std::vector<float> toweretas;
216 std::vector<float> towerphis;
217 std::vector<float> towerenergies;
222 for (toweriter = towers.first;
223 toweriter != towers.second;
235 toweretas.push_back(towereta);
236 towerphis.push_back(towerphi);
237 towerenergies.push_back(towerenergy);
245 unsigned int towerkey = iphi + (ieta << 16U);
249 unsigned int towerindex = _towerinfos->
decode_key(towerkey);
256 toweretas.push_back(ieta);
257 towerphis.push_back(iphi);
258 towerenergies.push_back(towerenergy);
262 int ntowers = toweretas.size();
274 for (
int j = 0;
j < ntowers;
j++)
276 float energymult = towerenergies.at(
j) * toweretas.at(
j);
277 etamult += energymult;
278 etasum += towerenergies.at(
j);
280 int phibin = towerphis.at(
j);
282 if (phibin - towerphis.at(0) < -nphibin / 2.0)
286 else if (phibin - towerphis.at(0) > +nphibin / 2.0)
290 assert(std::abs(phibin - towerphis.at(0)) <= nphibin / 2.0);
292 energymult = towerenergies.at(
j) * phibin;
293 phimult += energymult;
294 phisum += towerenergies.at(
j);
297 float avgphi = phimult / phisum;
298 if (isnan(avgphi))
continue;
300 float avgeta = etamult / etasum;
307 avgphi = fmod(avgphi, nphibin);
309 if (avgphi >= 255.5) avgphi -=
bins_phi;
311 avgphi = fmod(avgphi + 0.5, 8) - 0.5;
328 std::cout <<
"couldn't recalibrate cluster, something went wrong??" << std::endl;
331 float eclus_recalib_val = 1;
332 float ecore_recalib_val = 1;
333 if (phibin > -1 && etabin > -1)
350 recalibcluster->
set_energy(clus_energy / eclus_recalib_val);
353 CLHEP::Hep3Vector
vertex(0,0,0);
355 float clusEta = E_vec_cluster.pseudoRapidity();
366 float pdcCalib =
pdcCorrFlat -> GetBinContent(ecoreBin, etaBin);
368 if (pdcCalib < 0.1) pdcCalib = 1;
377 std::cout <<
"Input eclus cluster energy: " << clus_energy << std::endl;
378 std::cout <<
"Recalib value: " << eclus_recalib_val << std::endl;
379 std::cout <<
"phibin: " << phibin <<
", etabin: " << etabin << std::endl;
380 std::cout <<
"Recalibrated eclus cluster energy: "
381 << clus_energy / eclus_recalib_val << std::endl;
382 std::cout <<
"Input ecore cluster energy: "
384 std::cout <<
"Recalib value: " << ecore_recalib_val << std::endl;
385 std::cout <<
"Recalibrated ecore cluster energy: "
386 << cluster->
get_ecore() / ecore_recalib_val << std::endl;
404 std::cout <<
"DST Node missing, quitting" << std::endl;
405 throw std::runtime_error(
"failed to find DST node in RawClusterPositionCorrection::CreateNodeTree");
422 ClusterCorrNodeName =
"CLUSTERINFO_POS_COR_" +
_det_name;
424 _recalib_clusters = findNode::getClass<RawClusterContainer>(topNode, ClusterCorrNodeName);
433 cemcNode->
addNode(clusterNode);