28 using std::cout, std::endl,
std::string, std::ofstream, std::ostream;
45 hitsetitr != hitsetrange.second;
57 unsigned short NPhiBins = (
unsigned short) layergeom->
get_phibins();
58 unsigned short NPhiBinsSector = NPhiBins/12;
59 unsigned short NTBins = (
unsigned short)layergeom->
get_zbins();
60 unsigned short NTBinsSide = NTBins;
61 unsigned short NTBinsMin = 0;
62 unsigned short PhiOffset = NPhiBinsSector * sector;
63 unsigned short TOffset = NTBinsMin;
67 unsigned short phibins = NPhiBinsSector;
68 unsigned short phioffset = PhiOffset;
69 unsigned short tbins = NTBinsSide;
70 unsigned short toffset = TOffset ;
77 double iphi_sum = 0.0;
84 int phibinlo = INT_MAX;
88 auto ihit_list = hitset->
getHits();
90 const int iphi_max = phioffset+
phibins;
91 const int it_max = toffset+tbins;
93 double sum_adc { 0. };
96 for(
auto iter = ihit_list.first; iter != ihit_list.second; ++iter){
99 if (iphi < phioffset || iphi > iphi_max || it < toffset || it > it_max)
continue;
100 sum_adc += iter->second->getAdc();
105 std::set<int> v_iphi, v_it;
106 std::map<int,unsigned int> m_iphi, m_it, m_iphiCut, m_itCut;
107 for(
auto iter = ihit_list.first; iter != ihit_list.second; ++iter)
109 unsigned int adc = iter->second->getAdc();
110 if (adc <= 0)
continue;
113 if (iphi < phioffset || iphi > iphi_max) {
114 std::cout <<
"WARNING phibin out of range: " << iphi <<
" | " << phibins << std::endl;
117 if (it < toffset || it > it_max) {
118 std::cout <<
"WARNING z bin out of range: " << it <<
" | " << tbins << std::endl;
123 auto pnew = m_iphiCut.try_emplace(iphi,adc);
124 if (!pnew.second) pnew.first->second += adc;
126 pnew = m_itCut.try_emplace(it,adc);
127 if (!pnew.second) pnew.first->second += adc;
136 auto pnew = m_iphi.try_emplace(iphi,adc);
137 if (!pnew.second) pnew.first->second += adc;
138 pnew = m_it.try_emplace(it,adc);
139 if (!pnew.second) pnew.first->second += adc;
141 if (iphi > phibinhi) phibinhi = iphi;
142 if (iphi < phibinlo) phibinlo = iphi;
143 if (it > tbinhi) tbinhi =
it;
144 if (it < tbinlo) tbinlo =
it;
146 iphi_sum += iphi * adc;
158 for (
auto& hit : m_iphi) {
159 cout <<
" m_phi(" << hit.first <<
" : " << hit.second<<
") ";
175 double clusiphi = iphi_sum / adc_sum;
176 double clusphi = layergeom->
get_phi(clusiphi);
178 float clusx = radius * cos(clusphi);
179 float clusy = radius * sin(clusphi);
180 double clust = t_sum / adc_sum;
184 if (side == 0) clusz = -clusz;
186 char tsize = tbinhi - tbinlo + 1;
187 char phisize = phibinhi - phibinlo + 1;
189 if (tsize < 0 && verbosity > 1) std::cout <<
" FIXME z4 tsize: " << ((int)tsize) <<
" " << tbinlo <<
" to " << tbinhi << std::endl;
198 if ((
int)phisize > 10 || (int)tsize > 8) {
199 int _size_phi = ((int)phisize);
200 int _nbins_phi = v_iphi.size();
201 int _delta_phi = abs(_size_phi-_nbins_phi);
202 int _size_z = ((int)tsize);
203 int _nbins_z = v_it.size();
204 int _delta_z = abs(_size_z - _nbins_z);
207 cout <<
" x|"<<_delta_phi<<
"|"<<_delta_z
208 <<
"| new node FIXME A1 layer("<< layer
209 <<
") (nset:size) phi("
210 << _nbins_phi<<
":"<<_size_phi <<
") z("
211 <<_nbins_z<<
":"<<_size_z<<
") "
215 cout <<
" iphi-from-(";
218 for (
auto _ : v_iphi) {
222 int _diff = ((int)
_-_prev-1);
223 if (_diff != 0) cout<<
">"<<_diff<<
">";
226 double _rat = (float)m_iphi[
_] / (
float)adc_sum;
227 fmt.Form(
"%.2f",_rat);
232 if (tempsum < 0.999) cout <<
" Z3 sumphirat: " << tempsum;
238 cout <<
" iz-from-(";
239 for (
auto _ : v_it) {
243 int _diff = ((int)
_-_prev-1);
244 if (_diff != 0) cout<<
">"<<_diff<<
">";
247 double _rat = (float)m_it[
_] / (
float)adc_sum;
248 fmt.Form(
"%.2f",_rat);
253 if (tempsum < 0.999) cout <<
" Z3 sumzrat: " << tempsum;
264 hitsetkey, global, subsurfkey);
267 if (
verbosity) std::cout <<
"Can't find the surface! with hitsetkey " << ((int)hitsetkey) << std::endl;
284 cluster->setPhiSize(phisize);
285 cluster->setZSize(tsize);
286 cluster->setSubSurfKey(subsurfkey);
287 cluster->setLocalX(local(0));
288 cluster->setLocalY(clust);
292 if (!empl.second) empl.first->second += 1;
324 hit = hitsetit->second->getHit(hitkey);
329 hitsetit->second->addHitSpecificKey(hitkey, hit);
341 cout <<
" ------------- content of TrkrTruthTrackContainer ---------- " << endl;
342 auto& tmap = truth_tracks->
getMap();
343 cout <<
" Number of tracks: xyz db : " << tmap.size() << endl;
344 for (
auto& _pair : tmap) {
345 auto& track = _pair.second;
347 printf(
"id(%2i) phi:eta:pt(", (
int)track->getTrackid());
348 cout <<
"phi:eta:pt(";
349 printf(
"%5.2f:%5.2f:%5.2f", track->getPhi(), track->getPseudoRapidity(), track->getPt());
352 cout <<
") nclusters(" << track->getClusters().size() <<
") ";
356 for (
auto cluskey : track->getClusters()) {
361 if (nclusprint > 0 && nclus >= nclusprint) {
368 cout <<
" ----- end of tracks in TrkrrTruthTrackContainer ------ " << endl;
375 fout.open(ofile_name.c_str());
376 fout <<
" ------------- content of TrkrTruthTrackContainer ---------- " << endl;
377 auto& tmap = truth_tracks->
getMap();
378 fout <<
" Number of tracks: " << tmap.size() << endl;
379 for (
auto& _pair : tmap) {
380 auto &track = _pair.second;
381 fout <<
" id( " << track->getTrackid() <<
") phi:eta:pt("<<
382 track->getPhi()<<
":"<<track->getPseudoRapidity()<<
":"<<track->getPt() <<
") nclusters("
383 << track->getClusters().size() <<
") ";
385 for (
auto cluskey : track->getClusters()) {
391 <<
C->getLocalX() <<
":"
392 <<
C->getPhiSize() <<
":"
393 <<
C->getLocalY() <<
":"
394 <<
C->getZSize() <<
") ";
399 fout <<
" ----- end of tracks in TrkrrTruthTrackContainer ------ " << endl;