File indexing completed on 2025-08-05 08:13:21
0001 #include "PPG04EventSelector.h"
0002
0003 #include <fun4all/Fun4AllReturnCodes.h>
0004
0005
0006 #include <phool/PHCompositeNode.h>
0007 #include <phool/getClass.h>
0008
0009
0010 #include <calobase/TowerInfo.h>
0011 #include <calobase/TowerInfoContainer.h>
0012
0013
0014 #include <utility>
0015 #include <string>
0016 #include <cmath>
0017
0018
0019 #include <jetbase/Jet.h>
0020 #include <jetbase/JetMap.h>
0021 #include <jetbase/Jetv1.h>
0022 #include <jetbase/JetMapv1.h>
0023 #include <jetbase/JetContainer.h>
0024 #include <jetbase/JetContainerv1.h>
0025
0026
0027 #include <calotrigger/MinimumBiasInfo.h>
0028 #include <calotrigger/MinimumBiasInfov1.h>
0029
0030
0031 #include <globalvertex/GlobalVertex.h>
0032 #include <globalvertex/GlobalVertexMap.h>
0033 #include <globalvertex/GlobalVertexMapv1.h>
0034
0035 int PPG04EventSelector::process_event(PHCompositeNode *topNode)
0036 {
0037
0038 if(m_do_A_cut)
0039 {
0040 if(!A_cut(topNode))
0041 {
0042 return Fun4AllReturnCodes::ABORTEVENT;
0043 }
0044 }
0045
0046
0047 if(m_do_badChi2_cut)
0048 {
0049 if(!badChi2_cut(topNode))
0050 {
0051 return Fun4AllReturnCodes::ABORTEVENT;
0052 }
0053 }
0054
0055
0056
0057 if(m_do_MCLeadingTruthJetpT_cut)
0058 {
0059 if(!MCLeadingTruthJetpT_cut(topNode))
0060 {
0061 return Fun4AllReturnCodes::ABORTEVENT;
0062 }
0063 }
0064
0065
0066 if(m_do_minBias_cut)
0067 {
0068 if(!minBias_cut(topNode))
0069 {
0070 return Fun4AllReturnCodes::ABORTEVENT;
0071 }
0072 }
0073
0074
0075 if(m_do_zvtx_cut)
0076 {
0077 if(!zvtx_cut(topNode))
0078 {
0079 return Fun4AllReturnCodes::ABORTEVENT;
0080 }
0081 }
0082
0083
0084
0085 return Fun4AllReturnCodes::EVENT_OK;
0086 }
0087
0088
0089 bool PPG04EventSelector::A_cut(PHCompositeNode *)
0090 {
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103 return true;
0104 }
0105
0106
0107 bool PPG04EventSelector::badChi2_cut(PHCompositeNode *topNode)
0108 {
0109
0110
0111 TowerInfoContainer *towers[3];
0112 towers[0] = findNode::getClass<TowerInfoContainer>(topNode, "TOWERINFO_CALIB_CEMC");
0113 if (!towers[0])
0114 {
0115 std::cout << "PPG04EventSelector::badChi2_cut(PHCompositeNode *topNode) Could not find CEMC Tower Info node" << std::endl;
0116 exit(-1);
0117 }
0118
0119 towers[1] = findNode::getClass<TowerInfoContainer>(topNode, "TOWERINFO_CALIB_HCALIN");
0120 if (!towers[1])
0121 {
0122 std::cout << "PPG04EventSelector::badChi2_cut(PHCompositeNode *topNode) Could not find IHCal Tower Info node" << std::endl;
0123 exit(-1);
0124 }
0125
0126 towers[2] = findNode::getClass<TowerInfoContainer>(topNode, "TOWERINFO_CALIB_HCALOUT");
0127 if (!towers[2])
0128 {
0129 std::cout << "PPG04EventSelector::badChi2_cut(PHCompositeNode *topNode) Could not find OHCal Tower Info node" << std::endl;
0130 exit(-1);
0131 }
0132
0133
0134
0135 for(int i=0; i<3; i++)
0136 {
0137 unsigned int nChannels = towers[i]->size();
0138 for(unsigned int channel = 0; channel < nChannels; channel++)
0139 {
0140 TowerInfo *tower = towers[i]->get_tower_at_channel(channel);
0141
0142 if (tower->get_isBadChi2() && !tower->get_isHot() && !tower->get_isNoCalib())
0143 {
0144 if(Verbosity() > 0)
0145 {
0146 std::cout << "PPG04EventSelector::badChi2_cut(PHCompositeNode *topNode) Tower is bad chi2" << std::endl;
0147 }
0148 return false;
0149 }
0150 }
0151 }
0152
0153 return true;
0154 }
0155
0156
0157 bool PPG04EventSelector::MCLeadingTruthJetpT_cut(PHCompositeNode *topNode)
0158 {
0159
0160 JetContainer *truthjets = findNode::getClass<JetContainer>(topNode, "AntiKt_Truth_r04");
0161 if(!truthjets)
0162 {
0163 std::cout << "PPG04EventSelector::MCLeadingTruthJetpT_cut(PHCompositeNode *topNode) Could not find truth jet nodes" << std::endl;
0164 exit(-1);
0165 }
0166
0167
0168 float leading_truth_pt = -1;
0169
0170
0171
0172 for(auto jet: *truthjets)
0173 {
0174 if(jet->get_pt() > leading_truth_pt) leading_truth_pt = jet->get_pt();
0175 }
0176
0177
0178 if( (leading_truth_pt < m_MCLeadingTruthJetpT_range.first) || (leading_truth_pt > m_MCLeadingTruthJetpT_range.second))
0179 {
0180 if(Verbosity() > 0) {std::cout << "PPG04EventSelector::MC_event_select(PHCompositeNode *topNode) Event failed MC event selection. Leading truth jet pT: " << leading_truth_pt << std::endl;}
0181 return false;
0182 }
0183
0184 return true;
0185 }
0186
0187
0188 bool PPG04EventSelector::minBias_cut(PHCompositeNode *topNode)
0189 {
0190
0191 MinimumBiasInfo *minbias = findNode::getClass<MinimumBiasInfov1>(topNode, "MinimumBiasInfo");
0192 if(!minbias)
0193 {
0194 std::cout << "PPG04EventSelector::minBias_cut(PHCompositeNode *topNode) Could not find MinBiasInfo node" << std::endl;
0195 exit(-1);
0196 }
0197
0198
0199 if(!minbias->isAuAuMinimumBias())
0200 {
0201 if(Verbosity() > 0) {std::cout << "PPG04EventSelector::minBias_cut(PHCompositeNode *topNode) Event failed MinBias event selection" << std::endl;}
0202 return false;
0203 }
0204 return true;
0205 }
0206
0207
0208 bool PPG04EventSelector::zvtx_cut(PHCompositeNode *topNode)
0209 {
0210
0211 GlobalVertexMap *vtxMap = findNode::getClass<GlobalVertexMapv1>(topNode,"GlobalVertexMap");
0212 if (!vtxMap)
0213 {
0214 std::cout << "PPG04EventSelector::zvtx_cut(PHCompositeNode *topNode) Could not find global vertex map node" << std::endl;
0215 exit(-1);
0216 }
0217
0218 if (!vtxMap->get(0))
0219 {
0220 if(Verbosity() > 0) {std::cout << "PPG04EventSelector::zvtx_cut(PHCompositeNode *topNode) No primary vertex" << std::endl;}
0221 return false;
0222 }
0223
0224 if( (vtxMap->get(0)->get_z() < m_zvtx_range.first) || (vtxMap->get(0)->get_z() > m_zvtx_range.second))
0225 {
0226 if(Verbosity() > 0){std::cout << "PPG04EventSelector::zvtx_cut(PHCompositeNode *topNode) Vertex cut failed: " << vtxMap->get(0)->get_z() << std::endl;}
0227 return false;
0228 }
0229
0230 return true;
0231 }