File indexing completed on 2025-08-06 08:13:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #define SCORRELATORQAMAKER_SMAKECLUSTQATREE_CC
0011
0012
0013 #include "SMakeClustQATree.h"
0014
0015
0016 using namespace std;
0017 using namespace findNode;
0018
0019
0020
0021 namespace SColdQcdCorrelatorAnalysis {
0022
0023
0024
0025
0026
0027 int SMakeClustQATree::Init(PHCompositeNode* topNode) {
0028
0029 InitOutput();
0030 InitTree();
0031 return Fun4AllReturnCodes::EVENT_OK;
0032
0033 }
0034
0035
0036
0037 int SMakeClustQATree::process_event(PHCompositeNode* topNode) {
0038
0039
0040 m_output.Reset();
0041
0042
0043
0044 m_output.recInfo.SetInfo(topNode);
0045 m_output.genInfo.SetInfo(topNode, m_config.isEmbed, {2});
0046
0047
0048 DoClustLoop(topNode, "CLUSTER_CEMC");
0049 DoClustLoop(topNode, "CLUSTER_HCALIN");
0050 DoClustLoop(topNode, "CLUSTER_HCALOUT");
0051
0052
0053 m_tClustQA -> Fill();
0054 return Fun4AllReturnCodes::EVENT_OK;
0055
0056 }
0057
0058
0059
0060 int SMakeClustQATree::End(PHCompositeNode* topNode) {
0061
0062 SaveOutput();
0063 CloseOutput();
0064 return Fun4AllReturnCodes::EVENT_OK;
0065
0066 }
0067
0068
0069
0070
0071
0072 void SMakeClustQATree::InitTree() {
0073
0074 if (m_isDebugOn && (m_verbosity > 2)) {
0075 cout << "SColdQcdCorrelatorAnalysis::SMakeClustQATree::InitTree(): initializing output tree." << endl;
0076 }
0077
0078
0079
0080 m_tClustQA = new TTree("tClustQA", "Cluster QA");
0081 m_tClustQA -> Branch("EvtRecoInfo", "Types::RecoInfo", &m_output.recInfo, 6400, 99);
0082 m_tClustQA -> Branch("EvtGenInfo", "Types::GenInfo", &m_output.genInfo, 6400, 99);
0083 m_tClustQA -> Branch("EMCalInfo", "vector<Types::ClustInfo>", &m_output.emCalInfo, 6400, 99);
0084 m_tClustQA -> Branch("IHCalInfo", "vector<Types::ClustInfo>", &m_output.ihCalInfo, 6400, 99);
0085 m_tClustQA -> Branch("OHCalInfo", "vector<Types::ClustInfo>", &m_output.ohCalInfo, 6400, 99);
0086 return;
0087
0088 }
0089
0090
0091
0092 void SMakeClustQATree::SaveOutput() {
0093
0094 if (m_isDebugOn && (m_verbosity > 2)) {
0095 cout << "SColdQcdCorrelatorAnalysis::SMakeClustQATree::SaveOutput(): saving output." << endl;
0096 }
0097
0098 m_outDir -> cd();
0099 m_tClustQA -> Write();
0100 return;
0101
0102 }
0103
0104
0105
0106 void SMakeClustQATree::DoClustLoop(PHCompositeNode* topNode, const string node) {
0107
0108 if (m_isDebugOn && (m_verbosity > 2)) {
0109 cout << "SColdQcdCorrelatorAnalysis::SMakeClustQATree::DoClustLoop(PHCompositeNode*, string): looping over clusters." << endl;
0110 }
0111
0112
0113 RawClusterContainer::ConstRange clusters = Interfaces::GetClusters(topNode, node);
0114
0115
0116 for (
0117 RawClusterContainer::ConstIterator itClust = clusters.first;
0118 itClust != clusters.second;
0119 itClust++
0120 ) {
0121
0122
0123 const RawCluster* cluster = itClust -> second;
0124 if (!cluster) continue;
0125
0126
0127 const bool isGoodClust = IsGoodCluster(cluster);
0128 if (!isGoodClust) continue;
0129
0130
0131 Types::ClustInfo clustInfo(cluster, ROOT::Math::XYZVector(0., 0., 0.), Const::MapNodeOntoIndex()[node]);
0132
0133
0134 switch (Const::MapNodeOntoIndex()[node]) {
0135
0136 case Const::Subsys::EMCal:
0137 m_output.emCalInfo.push_back(clustInfo);
0138 break;
0139
0140 case Const::Subsys::IHCal:
0141 m_output.ihCalInfo.push_back(clustInfo);
0142 break;
0143
0144 case Const::Subsys::OHCal:
0145 m_output.ohCalInfo.push_back(clustInfo);
0146 break;
0147
0148 default:
0149 cerr << "SColdQcdCorrealtorAnalysis::SMakeClustQATree::DoClustLoop(PHCompositeNode*, string) WARNING: trying to add clusters from unknown node to output!" << endl;
0150 break;
0151 }
0152 }
0153 return;
0154
0155 }
0156
0157
0158
0159 bool SMakeClustQATree::IsGoodCluster(const RawCluster* cluster) {
0160
0161
0162 if (m_isDebugOn && (m_verbosity > 4)) {
0163 cout << "SMakeClustQATree::IsGoodCluster(RawCluster*) Checking if cluster is good..." << endl;
0164 }
0165
0166
0167 Types::ClustInfo info(cluster);
0168
0169
0170 const bool isInAccept = info.IsInAcceptance(m_config.clustAccept);
0171 return isInAccept;
0172
0173 }
0174
0175 }
0176
0177