File indexing completed on 2025-08-06 08:13:20
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #define SCORRELATORUTILITIES_CSTINFO_CC
0012
0013
0014 #include "CstInfo.h"
0015
0016
0017 using namespace std;
0018
0019
0020
0021 namespace SColdQcdCorrelatorAnalysis {
0022
0023
0024
0025
0026
0027
0028 void Types::CstInfo::Minimize() {
0029
0030 type = -1 * numeric_limits<int>::max();
0031 cstID = -1 * numeric_limits<int>::max();
0032 jetID = -1 * numeric_limits<int>::max();
0033 embedID = -1 * numeric_limits<int>::max();
0034 pid = -1 * numeric_limits<int>::max();
0035 z = -1. * numeric_limits<double>::max();
0036 dr = -1. * numeric_limits<double>::max();
0037 jt = -1. * numeric_limits<double>::max();
0038 ene = -1. * numeric_limits<double>::max();
0039 px = -1. * numeric_limits<double>::max();
0040 py = -1. * numeric_limits<double>::max();
0041 pz = -1. * numeric_limits<double>::max();
0042 pt = -1. * numeric_limits<double>::max();
0043 eta = -1. * numeric_limits<double>::max();
0044 phi = -1. * numeric_limits<double>::max();
0045 return;
0046
0047 }
0048
0049
0050
0051
0052
0053
0054 void Types::CstInfo::Maximize() {
0055
0056 type = numeric_limits<int>::max();
0057 cstID = numeric_limits<int>::max();
0058 jetID = numeric_limits<int>::max();
0059 embedID = numeric_limits<int>::max();
0060 pid = numeric_limits<int>::max();
0061 z = numeric_limits<double>::max();
0062 dr = numeric_limits<double>::max();
0063 jt = numeric_limits<double>::max();
0064 ene = numeric_limits<double>::max();
0065 px = numeric_limits<double>::max();
0066 py = numeric_limits<double>::max();
0067 pz = numeric_limits<double>::max();
0068 pt = numeric_limits<double>::max();
0069 eta = numeric_limits<double>::max();
0070 phi = numeric_limits<double>::max();
0071 return;
0072
0073 }
0074
0075
0076
0077
0078
0079
0080
0081
0082 void Types::CstInfo::Reset() {
0083
0084 Maximize();
0085 return;
0086
0087 }
0088
0089
0090
0091
0092
0093
0094 void Types::CstInfo::SetInfo(fastjet::PseudoJet& pseudojet) {
0095
0096 cstID = pseudojet.user_index();
0097 ene = pseudojet.E();
0098 px = pseudojet.px();
0099 py = pseudojet.py();
0100 pz = pseudojet.pz();
0101 pt = pseudojet.perp();
0102 eta = pseudojet.pseudorapidity();
0103 phi = pseudojet.phi_std();
0104 return;
0105
0106 }
0107
0108
0109
0110
0111
0112
0113 void Types::CstInfo::SetInfo(SvtxTrack* track) {
0114
0115 type = Const::Object::Track;
0116 cstID = track -> get_id();
0117 pt = track -> get_pt();
0118 px = track -> get_px();
0119 py = track -> get_py();
0120 pz = track -> get_pz();
0121 ene = hypot(track -> get_p(), Const::MassPion());
0122 eta = track -> get_eta();
0123 phi = track -> get_phi();
0124 return;
0125
0126 }
0127
0128
0129
0130
0131
0132
0133 void Types::CstInfo::SetInfo(const ParticleFlowElement* flow) {
0134
0135 type = Const::Object::Flow;
0136 cstID = flow -> get_id();
0137 pt = flow -> get_pt();
0138 px = flow -> get_px();
0139 py = flow -> get_py();
0140 pz = flow -> get_pz();
0141 ene = flow -> get_e();
0142 eta = flow -> get_eta();
0143 phi = flow -> get_phi();
0144 return;
0145
0146 }
0147
0148
0149
0150
0151
0152
0153 void Types::CstInfo::SetInfo(
0154 const int sys,
0155 RawTower* tower,
0156 PHCompositeNode* topNode,
0157 optional<ROOT::Math::XYZVector> vtx
0158 ) {
0159
0160
0161 ROOT::Math::XYZVector vtxToUse(0., 0., 0.);
0162 if (vtx.has_value()) {
0163 vtxToUse = vtx.value();
0164 }
0165
0166
0167 const int rawKey = tower -> get_key();
0168
0169
0170 ROOT::Math::RhoEtaPhiVector rhfPos = Tools::GetTowerPositionRhoEtaPhi(
0171 rawKey,
0172 sys,
0173 vtxToUse.z(),
0174 topNode
0175 );
0176
0177
0178 ROOT::Math::PxPyPzEVector momentum = Tools::GetTowerMomentum(
0179 tower -> get_energy(),
0180 rhfPos
0181 );
0182
0183
0184 type = Const::Object::Tower;
0185 cstID = rawKey;
0186 pt = momentum.Pt();
0187 px = momentum.Px();
0188 py = momentum.Py();
0189 pz = momentum.Pz();
0190 ene = momentum.E();
0191 eta = momentum.Eta();
0192 phi = momentum.Phi();
0193 return;
0194
0195 }
0196
0197
0198
0199
0200
0201
0202 void Types::CstInfo::SetInfo(
0203 const int sys,
0204 const int chan,
0205 TowerInfo* tower,
0206 PHCompositeNode* topNode,
0207 optional<ROOT::Math::XYZVector> vtx
0208 ) {
0209
0210
0211 ROOT::Math::XYZVector vtxToUse(0., 0., 0.);
0212 if (vtx.has_value()) {
0213 vtxToUse = vtx.value();
0214 }
0215
0216
0217 const auto indices = Tools::GetTowerIndices(chan, sys, topNode);
0218 const int rawKey = Tools::GetRawTowerKey(Const::MapIndexOntoID()[ sys ], indices);
0219
0220
0221 ROOT::Math::RhoEtaPhiVector rhfPos = Tools::GetTowerPositionRhoEtaPhi(
0222 rawKey,
0223 sys,
0224 vtxToUse.z(),
0225 topNode
0226 );
0227
0228
0229 ROOT::Math::PxPyPzEVector momentum = Tools::GetTowerMomentum(
0230 tower -> get_energy(),
0231 rhfPos
0232 );
0233
0234 type = Const::Object::Tower;
0235 cstID = get<0>(indices);
0236 pt = momentum.Pt();
0237 px = momentum.Px();
0238 py = momentum.Py();
0239 pz = momentum.Pz();
0240 ene = momentum.E();
0241 eta = momentum.Eta();
0242 phi = momentum.Phi();
0243 return;
0244
0245 }
0246
0247
0248
0249
0250
0251
0252 void Types::CstInfo::SetInfo(const RawCluster* clust, optional<ROOT::Math::XYZVector> vtx) {
0253
0254
0255 ROOT::Math::XYZVector vtxToUse(0., 0., 0.);
0256 if (vtx.has_value()) {
0257 vtxToUse = vtx.value();
0258 }
0259
0260
0261 ROOT::Math::XYZVector position(
0262 clust -> get_position().x(),
0263 clust -> get_position().y(),
0264 clust -> get_position().z()
0265 );
0266
0267
0268 ROOT::Math::PxPyPzEVector momentum = Tools::GetClustMomentum(clust -> get_energy(), position, vtxToUse);
0269
0270 type = Const::Object::Cluster;
0271 cstID = clust -> get_id();
0272 pt = momentum.Pt();
0273 px = momentum.Px();
0274 py = momentum.Py();
0275 pz = momentum.Pz();
0276 ene = momentum.E();
0277 eta = momentum.Eta();
0278 phi = momentum.Phi();
0279 return;
0280
0281 }
0282
0283
0284
0285
0286
0287
0288 void Types::CstInfo::SetInfo(PHG4Particle* particle, const int event) {
0289
0290
0291 ROOT::Math::PxPyPzEVector momentum(
0292 particle -> get_px(),
0293 particle -> get_py(),
0294 particle -> get_pz(),
0295 particle -> get_e()
0296 );
0297
0298 type = Const::Object::Particle;
0299 cstID = particle -> get_barcode();
0300 embedID = event;
0301 pid = particle -> get_pid();
0302 ene = particle -> get_e();
0303 px = particle -> get_px();
0304 py = particle -> get_py();
0305 pz = particle -> get_pz();
0306 pt = momentum.Pt();
0307 eta = momentum.Eta();
0308 phi = momentum.Phi();
0309 return;
0310
0311 }
0312
0313
0314
0315
0316
0317
0318 void Types::CstInfo::SetInfo(
0319 const pair<Jet::SRC, unsigned int>& itCst,
0320 PHCompositeNode* topNode,
0321 optional<ROOT::Math::XYZVector> vtx,
0322 optional<int> event
0323 ) {
0324
0325
0326
0327
0328 switch (itCst.first) {
0329
0330
0331 case Jet::SRC::TRACK:
0332 {
0333 SvtxTrack* track = Interfaces::FindTrack(
0334 itCst.second,
0335 topNode
0336 );
0337 SetInfo(track);
0338 }
0339 break;
0340
0341
0342 case Jet::SRC::CEMC_TOWER:
0343 [[fallthrough]];
0344
0345 case Jet::SRC::CEMC_TOWER_SUB1:
0346 [[fallthrough]];
0347
0348 case Jet::SRC::CEMC_TOWER_SUB1CS:
0349 {
0350 RawTower* raw = Interfaces::FindRawTower(
0351 itCst.second,
0352 itCst.first,
0353 topNode
0354 );
0355 SetInfo(Const::Subsys::EMCal, raw, topNode, vtx);
0356 }
0357 break;
0358
0359
0360 case Jet::SRC::CEMC_TOWER_RETOWER:
0361 {
0362 RawTower* raw = Interfaces::FindRawTower(
0363 itCst.second,
0364 itCst.first,
0365 topNode
0366 );
0367 SetInfo(Const::Subsys::RECal, raw, topNode, vtx);
0368 }
0369 break;
0370
0371
0372 case Jet::SRC::HCALIN_TOWER:
0373 [[fallthrough]];
0374
0375 case Jet::SRC::HCALIN_TOWER_SUB1:
0376 [[fallthrough]];
0377
0378 case Jet::SRC::HCALIN_TOWER_SUB1CS:
0379 {
0380 RawTower* raw = Interfaces::FindRawTower(
0381 itCst.second,
0382 itCst.first,
0383 topNode
0384 );
0385 SetInfo(Const::Subsys::IHCal, raw, topNode, vtx);
0386 }
0387 break;
0388
0389
0390 case Jet::SRC::HCALOUT_TOWER:
0391 [[fallthrough]];
0392
0393 case Jet::SRC::HCALOUT_TOWER_SUB1:
0394 [[fallthrough]];
0395
0396 case Jet::SRC::HCALOUT_TOWER_SUB1CS:
0397 {
0398 RawTower* raw = Interfaces::FindRawTower(
0399 itCst.second,
0400 itCst.first,
0401 topNode
0402 );
0403 SetInfo(Const::Subsys::OHCal, raw, topNode, vtx);
0404 }
0405 break;
0406
0407
0408 case Jet::SRC::CEMC_TOWERINFO:
0409 [[fallthrough]];
0410
0411 case Jet::SRC::CEMC_TOWERINFO_EMBED:
0412 [[fallthrough]];
0413
0414 case Jet::SRC::CEMC_TOWERINFO_SIM:
0415 [[fallthrough]];
0416
0417 case Jet::SRC::CEMC_TOWERINFO_SUB1:
0418 {
0419 TowerInfo* info = Interfaces::FindTowerInfo(
0420 itCst.second,
0421 itCst.first,
0422 topNode
0423 );
0424 SetInfo(Const::Subsys::EMCal, itCst.second, info, topNode, vtx);
0425 }
0426 break;
0427
0428
0429 case Jet::SRC::CEMC_TOWERINFO_RETOWER:
0430 {
0431 TowerInfo* info = Interfaces::FindTowerInfo(
0432 itCst.second,
0433 itCst.first,
0434 topNode
0435 );
0436 SetInfo(Const::Subsys::RECal, itCst.second, info, topNode, vtx);
0437 }
0438 break;
0439
0440
0441 case Jet::SRC::HCALIN_TOWERINFO:
0442 [[fallthrough]];
0443
0444 case Jet::SRC::HCALIN_TOWERINFO_EMBED:
0445 [[fallthrough]];
0446
0447 case Jet::SRC::HCALIN_TOWERINFO_SIM:
0448 [[fallthrough]];
0449
0450 case Jet::SRC::HCALIN_TOWERINFO_SUB1:
0451 {
0452 TowerInfo* info = Interfaces::FindTowerInfo(
0453 itCst.second,
0454 itCst.first,
0455 topNode
0456 );
0457 SetInfo(Const::Subsys::IHCal, itCst.second, info, topNode, vtx);
0458 }
0459 break;
0460
0461
0462 case Jet::SRC::HCALOUT_TOWERINFO:
0463 [[fallthrough]];
0464
0465 case Jet::SRC::HCALOUT_TOWERINFO_EMBED:
0466 [[fallthrough]];
0467
0468 case Jet::SRC::HCALOUT_TOWERINFO_SIM:
0469 [[fallthrough]];
0470
0471 case Jet::SRC::HCALOUT_TOWERINFO_SUB1:
0472 {
0473 TowerInfo* info = Interfaces::FindTowerInfo(
0474 itCst.second,
0475 itCst.first,
0476 topNode
0477 );
0478 SetInfo(Const::Subsys::OHCal, itCst.second, info, topNode, vtx);
0479 }
0480 break;
0481
0482
0483 case Jet::SRC::CEMC_CLUSTER:
0484 [[fallthrough]];
0485
0486 case Jet::SRC::HCALIN_CLUSTER:
0487 [[fallthrough]];
0488
0489 case Jet::SRC::HCALOUT_CLUSTER:
0490 [[fallthrough]];
0491
0492 case Jet::SRC::HCAL_TOPO_CLUSTER:
0493 [[fallthrough]];
0494
0495 case Jet::SRC::ECAL_TOPO_CLUSTER:
0496 [[fallthrough]];
0497
0498 case Jet::SRC::ECAL_HCAL_TOPO_CLUSTER:
0499 {
0500 RawCluster* cluster = Interfaces::FindCluster(
0501 itCst.second,
0502 itCst.first,
0503 topNode
0504 );
0505 SetInfo(cluster, vtx);
0506 }
0507 break;
0508
0509
0510 case Jet::SRC::PARTICLE:
0511 {
0512 if (event.has_value()) {
0513 PHG4Particle* particle = Interfaces::FindParticle(
0514 itCst.second,
0515 topNode
0516 );
0517 SetInfo(particle, event.value());
0518 } else {
0519 assert(event.has_value());
0520 }
0521 }
0522 break;
0523
0524
0525 default:
0526 assert(Const::MapSrcOntoNode().find(itCst.first) != Const::MapSrcOntoNode().end());
0527 break;
0528
0529 }
0530 return;
0531
0532 }
0533
0534
0535
0536
0537
0538
0539 void Types::CstInfo::SetJetInfo(const int id, const Types::JetInfo& jet) {
0540
0541
0542 ROOT::Math::XYZVector pJet(jet.GetPX(), jet.GetPY(), jet.GetPZ());
0543 ROOT::Math::XYZVector pCst(px, py, pz);
0544 ROOT::Math::XYZVector pCross = pCst.Cross(pJet);
0545
0546
0547 const double dEta = eta - jet.GetEta();
0548 const double dPhi = phi - jet.GetPhi();
0549
0550
0551 jetID = id;
0552 z = pCst.Dot(pJet) / pJet.Mag2();
0553 dr = sqrt((dEta * dEta) + (dPhi * dPhi));
0554 jt = sqrt( pCross.Mag2() ) / pJet.Mag2();
0555 return;
0556
0557 }
0558
0559
0560
0561
0562
0563
0564 bool Types::CstInfo::IsInAcceptance(const CstInfo& minimum, const CstInfo& maximum) const {
0565
0566 return ((*this >= minimum) && (*this <= maximum));
0567
0568 }
0569
0570
0571
0572
0573
0574
0575 bool Types::CstInfo::IsInAcceptance(const pair<CstInfo, CstInfo>& range) const {
0576
0577 return ((*this >= range.first) && (*this <= range.second));
0578
0579 }
0580
0581
0582
0583
0584
0585
0586
0587
0588 vector<string> Types::CstInfo::GetListOfMembers() {
0589
0590 vector<string> members = {
0591 "type",
0592 "cstID",
0593 "jetID",
0594 "embedID",
0595 "pid",
0596 "z",
0597 "dr",
0598 "jt",
0599 "ene",
0600 "px",
0601 "py",
0602 "pz",
0603 "pt",
0604 "eta",
0605 "phi"
0606 };
0607 return members;
0608
0609 }
0610
0611
0612
0613
0614
0615
0616
0617
0618 bool Types::operator <(const CstInfo& lhs, const CstInfo& rhs) {
0619
0620
0621 const bool isLessThan = (
0622 (lhs.z < rhs.z) &&
0623 (lhs.dr < rhs.dr) &&
0624 (lhs.jt < rhs.jt) &&
0625 (lhs.ene < rhs.ene) &&
0626 (lhs.px < rhs.px) &&
0627 (lhs.py < rhs.py) &&
0628 (lhs.pz < rhs.pz) &&
0629 (lhs.pt < rhs.pt) &&
0630 (lhs.eta < rhs.eta) &&
0631 (lhs.phi < rhs.phi)
0632 );
0633 return isLessThan;
0634
0635 }
0636
0637
0638
0639
0640
0641
0642 bool Types::operator >(const CstInfo& lhs, const CstInfo& rhs) {
0643
0644
0645 const bool isGreaterThan = (
0646 (lhs.z > rhs.z) &&
0647 (lhs.dr > rhs.dr) &&
0648 (lhs.jt > lhs.jt) &&
0649 (lhs.ene > rhs.ene) &&
0650 (lhs.px > rhs.px) &&
0651 (lhs.py > rhs.py) &&
0652 (lhs.pz > rhs.pz) &&
0653 (lhs.pt > rhs.pt) &&
0654 (lhs.eta > rhs.eta) &&
0655 (lhs.phi > rhs.phi)
0656 );
0657 return isGreaterThan;
0658
0659 }
0660
0661
0662
0663
0664
0665
0666 bool Types::operator <=(const CstInfo& lhs, const CstInfo& rhs) {
0667
0668
0669 const bool isLessThanOrEqualTo = (
0670 (lhs.z <= rhs.z) &&
0671 (lhs.dr <= rhs.dr) &&
0672 (lhs.jt <= rhs.jt) &&
0673 (lhs.ene <= rhs.ene) &&
0674 (lhs.px <= rhs.px) &&
0675 (lhs.py <= rhs.py) &&
0676 (lhs.pz <= rhs.pz) &&
0677 (lhs.pt <= rhs.pt) &&
0678 (lhs.eta <= rhs.eta) &&
0679 (lhs.phi <= rhs.phi)
0680 );
0681 return isLessThanOrEqualTo;
0682
0683 }
0684
0685
0686
0687
0688
0689
0690 bool Types::operator >=(const CstInfo& lhs, const CstInfo& rhs) {
0691
0692
0693 const bool isGreaterThan = (
0694 (lhs.z >= rhs.z) &&
0695 (lhs.dr >= rhs.dr) &&
0696 (lhs.jt >= rhs.jt) &&
0697 (lhs.ene >= rhs.ene) &&
0698 (lhs.px >= rhs.px) &&
0699 (lhs.py >= rhs.py) &&
0700 (lhs.pz >= rhs.pz) &&
0701 (lhs.pt >= rhs.pt) &&
0702 (lhs.eta >= rhs.eta) &&
0703 (lhs.phi >= rhs.phi)
0704 );
0705 return isGreaterThan;
0706
0707 }
0708
0709
0710
0711
0712
0713
0714
0715
0716 Types::CstInfo::CstInfo() {
0717
0718
0719
0720 }
0721
0722
0723
0724
0725
0726
0727 Types::CstInfo::~CstInfo() {
0728
0729
0730
0731 }
0732
0733
0734
0735
0736
0737
0738 Types::CstInfo::CstInfo(const Const::Init init) {
0739
0740 switch (init) {
0741 case Const::Init::Minimize:
0742 Minimize();
0743 break;
0744 case Const::Init::Maximize:
0745 Maximize();
0746 break;
0747 default:
0748 Maximize();
0749 break;
0750 }
0751
0752 }
0753
0754
0755
0756
0757
0758
0759 Types::CstInfo::CstInfo(fastjet::PseudoJet& pseudojet) {
0760
0761 SetInfo(pseudojet);
0762
0763 }
0764
0765
0766
0767
0768
0769
0770 Types::CstInfo::CstInfo(SvtxTrack* track) {
0771
0772 SetInfo(track);
0773
0774 }
0775
0776
0777
0778
0779
0780
0781 Types::CstInfo::CstInfo(const ParticleFlowElement* flow) {
0782
0783 SetInfo(flow);
0784
0785 }
0786
0787
0788
0789
0790
0791
0792 Types::CstInfo::CstInfo(
0793 const int sys,
0794 RawTower* tower,
0795 PHCompositeNode* topNode,
0796 optional<ROOT::Math::XYZVector> vtx
0797 ) {
0798
0799 SetInfo(sys, tower, topNode, vtx);
0800
0801 }
0802
0803
0804
0805
0806
0807
0808 Types::CstInfo::CstInfo(
0809 const int sys,
0810 const int chan,
0811 TowerInfo* info,
0812 PHCompositeNode* topNode,
0813 optional<ROOT::Math::XYZVector> vtx
0814 ) {
0815
0816 SetInfo(sys, chan, info, topNode, vtx);
0817
0818 }
0819
0820
0821
0822
0823
0824
0825 Types::CstInfo::CstInfo(const RawCluster* cluster, optional<ROOT::Math::XYZVector> vtx) {
0826
0827 SetInfo(cluster, vtx);
0828
0829 }
0830
0831
0832
0833
0834
0835
0836 Types::CstInfo::CstInfo(PHG4Particle* particle, const int event) {
0837
0838 SetInfo(particle, event);
0839
0840 }
0841
0842
0843
0844
0845
0846
0847 Types::CstInfo::CstInfo(
0848 const pair<Jet::SRC, unsigned int>& itCst,
0849 PHCompositeNode* topNode,
0850 optional<ROOT::Math::XYZVector> vtx,
0851 optional<int> event
0852 ) {
0853
0854 SetInfo(itCst, topNode, vtx, event);
0855
0856 }
0857
0858 }
0859
0860