36 [[maybe_unused]] std::ostream&
operator << (std::ostream&
out,
const TVector3&
v )
38 out <<
"(" << v.x() <<
", " << v.y() <<
", " << v.z() <<
")";
58 henergy =
new TH1F(
"henergy",
"cluster energy", 200, 0, 2000);
59 hxy =
new TH2F(
"hxy",
"cluster x:y",800,-100,100,800,-80,80);
60 hz =
new TH1F(
"hz",
"cluster z", 220, -2,2);
62 hz_pos =
new TH1F(
"hz_pos",
"cluster z>0", 400, 0,110);
63 hz_neg =
new TH1F(
"hz_neg",
"cluster z<0", 400, -110,0);
65 hClustE[0]=
new TH1F(
"hRawClusterEnergy",
"Cluster Energy Before Merging;E[?]",200,0,2000);
66 hClustE[1] =
new TH1F(
"hMatchedClusterEnergy",
"Pair Cluster Energy After Merging;E[?]",200,0,2000);
67 hClustE[2] =
new TH1F(
"hSoloClusterEnergy",
"Lone Cluster Energy After Merging;E[?]",200,0,2000);
69 hDist=
new TH1F(
"hDist",
"3D distance to nearby clusters on same padrow;dist[cm]",100,-1,10);
70 hDistRow=
new TH2F(
"hDistRow",
"phi distance to nearby clusters vs (lower)row;dist[rad];padrow",100,-0.001,0.01,60,-0.5,59.5);
71 hDist2=
new TH1F(
"hDist2",
"phi distance to nearby clusters on same padrow;dist[rad]",100,-0.001,0.01);
72 hDistRowAdj=
new TH2F(
"hDistRowAdj",
"phi distance to nearby clusters vs (lower)row;dist[rad];(lower) padrow",100,-0.001,0.01,60,-0.5,59.5);
73 hDist2Adj=
new TH1F(
"hDist2Adj",
"phi distance to nearby clusters on adjacent padrow;dist[rad]",100,-0.001,0.01);
76 hrPhi_reco_petalModulo_pos =
new TH2F(
"hrPhi_reco_petalModulo_pos",
"Reco R vs #phi Z > 0;#phi;R (cm)",50,0.0,M_PI/9,400,20,78);
77 hrPhi_reco_petalModulo_neg =
new TH2F(
"hrPhi_reco_petalModulo_neg",
"Reco R vs #phi;#phi Z < 0;R (cm)",50,0.0,M_PI/9,400,20,78);
79 for(
int i=0;
i<48;
i++){
80 hphi_reco_pos[
i] =
new TH1F(Form(
"hphi_reco_pos_layer%02d",7+
i),Form(
"Reco #phi for Layer %02d Z > 0;#phi;counts",7+
i),50,0.0,M_PI/9);
81 hphi_reco_neg[
i] =
new TH1F(Form(
"hphi_reco_neg_layer%02d",7+
i),Form(
"Reco #phi for Layer %02d Z < 0;#phi;counts",7+
i),50,0.0,M_PI/9);
84 hphi_reco_pair_pos[
i] =
new TH1F(Form(
"hphi_reco_pair_pos_layers%02d_%02d",7+
i,8+
i),Form(
"Reco #phi for Layers %02d and %02d Z > 0;#phi;counts",7+
i,8+
i),50,0.0,M_PI/9);
85 hphi_reco_pair_neg[
i] =
new TH1F(Form(
"hphi_reco_pair_neg_layers%02d_%02d",7+
i,8+
i),Form(
"Reco #phi for Layers %02d and %02d Z < 0;#phi;counts",7+
i,8+
i),50,0.0,M_PI/9);
98 auto tgeometry = findNode::getClass<ActsGeometry>(topNode,
"ActsGeometry");
102 std::cout <<
PHWHERE <<
"No Acts geometry on node tree. Can't continue." << std::endl;
107 std::vector<TVector3>
pos;
108 std::vector<int>
layer;
109 std::vector<unsigned int> side;
110 std::vector<int>i_pair;
112 std::vector<bool>isAcrossGap;
115 double mean_z_content_plus = 0.0;
116 double mean_z_content_minus = 0.0;
122 for (
auto clusiter = clusRange.first;
123 clusiter != clusRange.second; ++clusiter)
126 const auto& [
cluskey, cluster] = *clusiter;
127 auto glob = tgeometry->getGlobalPosition(
cluskey, cluster);
128 TVector3 tmp_pos(glob(0),glob(1),glob(2));
132 double phi = tmp_pos.Phi();
137 while(phiMod < 0.0 || phiMod > M_PI/9){
138 if(phiMod < 0.0) phiMod += M_PI/9;
139 else if(phiMod > M_PI/9) phiMod -= M_PI/9;
142 if(tmp_pos.Z() >= 0.0){
144 hz_pos->Fill(tmp_pos.Z());
155 hz_neg->Fill(tmp_pos.Z());
169 for(
int i=1;
i<
hz_pos->GetNbinsX();
i++){
170 mean_z_content_plus +=
hz_pos->GetBinContent(
i);
172 for(
int i=1;
i<
hz_neg->GetNbinsX();
i++){
173 mean_z_content_minus +=
hz_neg->GetBinContent(
i);
176 mean_z_content_plus = mean_z_content_plus/
hz_pos->GetNbinsX();
177 mean_z_content_minus = mean_z_content_minus/
hz_neg->GetNbinsX();
185 for(
int i=0;
i<47;
i++){
203 for (
auto clusiter = clusRange.first;
204 clusiter != clusRange.second; ++clusiter)
209 const auto& [
cluskey, cluster] = *clusiter;
210 auto glob = tgeometry->getGlobalPosition(
cluskey, cluster);
221 std::cout <<
" z " << z <<
" side " << side <<
" layer " << lyr <<
" Adc " << cluster->getAdc() <<
" x " << x <<
" y " << y << std::endl;
224 TVector3 tmp_pos(x,y,z);
228 double phi = tmp_pos.Phi();
231 while(phiMod < 0.0 || phiMod > M_PI/9){
232 if(phiMod < 0.0) phiMod += M_PI/9;
233 else if(phiMod > M_PI/9) phiMod -= M_PI/9;
238 bool aboveThreshold =
true;
249 if( !aboveThreshold )
continue;
255 if( (z>=0 && std::abs(z -
hz_pos->GetBinCenter(
hz_pos->GetMaximumBin())) > 1.0) || (z<0 && std::abs(z -
hz_neg->GetBinCenter(
hz_neg->GetMaximumBin())) > 1.0) )
continue;
259 i_pair.push_back(-1);
260 energy.push_back(cluster->getAdc());
262 pos.push_back(TVector3(x,y,z));
265 isAcrossGap.push_back(
false);
266 if(
Verbosity() > 0) std::cout <<
":\t" << x <<
"\t" << y <<
"\t" << z <<std::endl;
273 for (
int i=0;
i<nTpcClust; ++
i)
274 for (
int j=
i+1;
j<nTpcClust;
j++)
277 if( side[
i] != side[
j] )
continue;
279 if(layer[
i]==layer[j])
281 const TVector3
delta=pos[
i]-pos[
j];
283 hDist->Fill(delta.Mag());
288 if (std::abs(layer[
i]-layer[j])==1)
291 const TVector3
delta=pos[
i]-pos[
j];
303 const float maxphidist=0.003;
304 for (
int i=0;
i<nTpcClust;
i++)
310 if(layer[
i] >= 39) nRowsMatch = 4;
311 else if(layer[
i] >= 23) nRowsMatch = 3;
313 if( pos[
i].
Z() >= 0 ){
317 }
else if(layer[
i] == 54){
324 else layerMatch = layer[
i]-1;
332 }
else if(layer[
i] == 54){
337 else layerMatch = layer[
i]-1;
345 if(layer[
i] == 22 || layer[
i] == 23 || layer[
i] == 38 || layer[
i] == 39 || layer[
i] == 7) isAcrossGap[
i] =
true;
347 float bestphidist=maxphidist;
348 for (
int j=0;
j<nTpcClust;
j++)
352 if(layer[
j] != layerMatch)
continue;
356 if (std::abs(layer[
i]-layer[
j])!=1)
continue;
362 if( side[
i] != side[j] )
continue;
365 if(std::abs(pos[
i].
Z() - pos[j].
Z()) > 0.5)
continue;
367 const float newphidist=std::abs(pos[
i].
DeltaPhi(pos[j]));
368 if (newphidist<bestphidist)
371 bestphidist=newphidist;
378 std::vector<bool>goodPair;
382 for (
int i=0;
i<nTpcClust;
i++)
384 int myPair=i_pair[
i];
385 int itsPair=myPair<0?-1:i_pair[myPair];
391 std::cout <<
"PHTpcCentralMembraneClusterizer::process_event -"
393 <<
" myPair: " << myPair
394 <<
" itsPair: " << itsPair
398 goodPair.push_back(
false);
402 if (
i<myPair) ++nGood;
403 goodPair.push_back(
true);
409 if (allGood) std::cout <<
"PHTpcCentralMembraneClusterizer::process_event - all pairs are good" << std::endl;
410 else std::cout <<
"PHTpcCentralMembraneClusterizer::process_event - nGood: " << nGood <<
" out of " << nTpcClust/2 << std::endl;
415 std::vector<float>aveenergy;
416 std::vector<TVector3> avepos;
417 std::vector<unsigned int> nclusters;
418 std::vector<bool> isREdge;
419 std::vector<std::pair<int,int> > pairNums;
427 std::pair<int,int> tmp_pair;
429 for (
int i=0;
i<nTpcClust;++
i)
439 aveenergy.push_back(energy[i]+energy[i_pair[i]]);
453 double avePhi = (pos[
i].Phi() * energy[
i] + pos[i_pair[
i]].Phi() * energy[i_pair[
i]]) * (1./(energy[i]+energy[i_pair[i]]));
454 double aveZ = (pos[
i].Z() * energy[
i] + pos[i_pair[
i]].Z() * energy[i_pair[
i]]) * (1./(energy[i]+energy[i_pair[i]]));
459 float efrac = energy[
i] / (energy[
i] + energy[i_pair[
i]]);
466 double layer_dr = std::abs(rad1 - rad2);
468 double rad_lyr_boundary = rad1 + layer_dr / 2.0;
474 double dist_r = sqrt(dist_pos[0]*dist_pos[0] + dist_pos[1] * dist_pos[1]);
481 }
else if(dist_r >= 41.0 && dist_r < 58.0){
488 double aveR = rad_lyr_boundary - efrac * cmclus_dr + cmclus_dr/2.0;
491 std::cout <<
" efrac " << efrac <<
" _cmclus_dr "<< cmclus_dr <<
" rad_lyr_boundary " << rad_lyr_boundary <<
" aveR " << aveR
492 <<
" layer i " << layer[i] <<
" R i " << rad1 <<
" layer i_pair " << layer[i_pair[i]] <<
" R i_pair " << rad2 <<
" layer_dr " << layer_dr << std::endl;
494 TVector3 temppos(aveR*cos(avePhi), aveR*sin(avePhi), aveZ);
495 avepos.push_back(temppos);
496 nclusters.push_back(2);
497 if(isAcrossGap[i] && isAcrossGap[i_pair[i]]) isREdge.push_back(
true);
498 else isREdge.push_back(
false);
501 tmp_pair.second = i_pair[
i];
502 pairNums.push_back(tmp_pair);
507 std::cout <<
" layer i " << layer[
i] <<
" energy " << energy[
i] <<
" pos i " << pos[
i].X() <<
" " << pos[
i].Y() <<
" " << pos[
i].Z()
508 <<
" layer i_pair " << layer[i_pair[
i]] <<
" energy i_pair " << energy[i_pair[
i]]
509 <<
" pos i_pair " << pos[i_pair[
i]].X() <<
" " << pos[i_pair[
i]].Y() <<
" " << pos[i_pair[
i]].Z()
510 <<
" reco pos " << temppos.X() <<
" " << temppos.Y() <<
" " << temppos.Z()
519 aveenergy.push_back(energy[i]);
520 avepos.push_back(pos[i]);
521 nclusters.push_back(1);
522 isREdge.push_back(isAcrossGap[i]);
524 tmp_pair.second = -1;
525 pairNums.push_back(tmp_pair);
532 if(
Verbosity() > 1) std::cout <<
" vector size is " << avepos.size() << std::endl;
534 for(
unsigned int iv = 0; iv <avepos.size(); ++iv)
539 cmfc->setX(avepos[iv].
X());
540 cmfc->setY(avepos[iv].
Y());
541 cmfc->setZ(avepos[iv].
Z());
542 cmfc->setAdc(aveenergy[iv]);
543 cmfc->setNclusters(nclusters[iv]);
544 cmfc->setIsRGap(isREdge[iv]);
546 int pair1 = pairNums[iv].first;
547 int pair2 = pairNums[iv].second;
549 cmfc->setX1(pos[pair1].
X());
550 cmfc->setY1(pos[pair1].
Y());
551 cmfc->setZ1(pos[pair1].
Z());
552 cmfc->setLayer1(layer[pair1]);
553 cmfc->setAdc1(energy[pair1]);
555 cmfc->setX2(pos[pair2].
X());
556 cmfc->setY2(pos[pair2].
Y());
557 cmfc->setZ2(pos[pair2].
Z());
558 cmfc->setLayer2(layer[pair2]);
559 cmfc->setAdc2(energy[pair2]);
580 for (
auto cmitr = clusrange.first;
581 cmitr !=clusrange.second;
584 auto cmkey = cmitr->first;
585 auto cmclus = cmitr->second;
588 std::cout <<
"found CM cluster " << cmkey <<
" with adc " << cmclus->getAdc()
589 <<
" x " << cmclus->getX() <<
" y " << cmclus->getY() <<
" z " << cmclus->getZ()
590 <<
" nclusters " << cmclus->getNclusters()
595 henergy->Fill(cmclus->getAdc());
596 hxy->Fill(cmclus->getX(), cmclus->getY());
597 hz->Fill(cmclus->getZ());
628 for(
int i=0;
i<47;
i++){
640 <<
"PHTpcCentralMembraneClusterizer::End -"
647 <<
"PHTpcCentralMembraneClusterizer::End -"
652 <<
"PHTpcCentralMembraneClusterizer::End -"
657 <<
"PHTpcCentralMembraneClusterizer::End -"
671 _cluster_map = findNode::getClass<TrkrClusterContainer>(topNode,
"TRKR_CLUSTER");
674 std::cout <<
PHWHERE <<
" ERROR: Can't find node TRKR_CLUSTER" << std::endl;
678 _geom_container = findNode::getClass<PHG4TpcCylinderGeomContainer>(topNode,
"CYLINDERCELLGEOM_SVTX");
681 std::cout <<
PHWHERE <<
"ERROR: Can't find node CYLINDERCELLGEOM_SVTX" << std::endl;
686 _dcc = findNode::getClass<TpcDistortionCorrectionContainer>(topNode,
"TpcDistortionCorrectionContainer");
689 std::cout <<
"PHTpcCentralMembraneMatcher: found TPC distortion correction container" << std::endl;
695 std::cout <<
"Creating node CORRECTED_CM_CLUSTER" << std::endl;
702 std::cout <<
PHWHERE <<
"DST Node missing, doing nothing." << std::endl;
716 DetNode->
addNode(TrkrClusterContainerNode);