File indexing completed on 2025-08-06 08:17:35
0001 #include "RawClusterZVertexRecorrect.h"
0002
0003 #include <globalvertex/MbdVertex.h>
0004 #include <globalvertex/MbdVertexMap.h>
0005
0006 #include <globalvertex/GlobalVertex.h>
0007 #include <globalvertex/GlobalVertexMap.h>
0008
0009 #include <calobase/RawCluster.h>
0010 #include <calobase/RawClusterContainer.h>
0011
0012 #include <fun4all/Fun4AllReturnCodes.h>
0013 #include <fun4all/SubsysReco.h>
0014
0015 #include <phool/getClass.h>
0016
0017 #include <fstream>
0018 #include <iostream>
0019 #include <map>
0020 #include <sstream>
0021 #include <string>
0022 #include <utility> // for pair
0023
0024 RawClusterZVertexRecorrect::RawClusterZVertexRecorrect(const std::string &name)
0025 : SubsysReco(std::string("RawClusterZVertexRecorrect_") + name)
0026 , _det_name("CEMC")
0027 , m_UseTowerInfo(0)
0028 , m_UseBbcZVtx(false)
0029 {
0030
0031 }
0032
0033 int RawClusterZVertexRecorrect::InitRun(PHCompositeNode *topNode)
0034 {
0035 if (!topNode && Verbosity())
0036 {
0037 std::cout << "RawClusZVtxRecorrect::InitRun : NO TOPNODE" << std::endl;
0038 }
0039
0040
0041 m_calrecoUtilInstance.LoadProfile();
0042 return Fun4AllReturnCodes::EVENT_OK;
0043 }
0044
0045 int RawClusterZVertexRecorrect::process_event(PHCompositeNode *topNode)
0046 {
0047 if (Verbosity())
0048 {
0049 std::cout << "RawClusZVtxRecorrect::Processing a NEW EVENT" << std::endl;
0050 }
0051
0052 std::string rawClusNodeName = "CLUSTER_" + _det_name;
0053 if (m_UseTowerInfo)
0054 {
0055 rawClusNodeName = "CLUSTERINFO_" + _det_name;
0056 }
0057
0058 RawClusterContainer *rawclusters = findNode::getClass<RawClusterContainer>(topNode, rawClusNodeName);
0059 if (!rawclusters)
0060 {
0061 std::cout << "No " << _det_name << " Cluster Container found while in RawClusterZVertexRecorrect, can't proceed!!!" << std::endl;
0062 return Fun4AllReturnCodes::ABORTEVENT;
0063 }
0064
0065
0066
0067
0068 float vz = 0;
0069
0070
0071 GlobalVertexMap *vertexmap = findNode::getClass<GlobalVertexMap>(topNode, "GlobalVertexMap");
0072
0073 if (vertexmap && m_UseTowerInfo < 0)
0074
0075 {
0076 if (!vertexmap->empty())
0077 {
0078 GlobalVertex *vertex = (vertexmap->begin()->second);
0079
0080
0081 vz = vertex->get_z();
0082 }
0083 }
0084
0085
0086 MbdVertexMap *mbdmap = findNode::getClass<MbdVertexMap>(topNode, "MbdVertexMap");
0087
0088 if (m_UseBbcZVtx && mbdmap && m_UseTowerInfo < 2)
0089 {
0090
0091
0092 MbdVertex *bvertex = nullptr;
0093 for (MbdVertexMap::ConstIter mbditer = mbdmap->begin();
0094 mbditer != mbdmap->end();
0095 ++mbditer)
0096 {
0097
0098 bvertex = mbditer->second;
0099 }
0100
0101 if (!bvertex)
0102 {
0103 return Fun4AllReturnCodes::ABORTEVENT;
0104 }
0105 vz = bvertex->get_z();
0106 }
0107
0108
0109
0110
0111 RawClusterContainer::ConstRange begin_end = rawclusters->getClusters();
0112 RawClusterContainer::ConstIterator iter;
0113
0114 for (iter = begin_end.first; iter != begin_end.second; ++iter)
0115 {
0116
0117 RawCluster *cluster = iter->second;
0118
0119 float clus_energy = cluster->get_energy();
0120 float clus_savz = cluster->get_z();
0121 float clus_chi2 = cluster->get_chi2();
0122
0123 CaloRecoUtility::ShowerDepthCorrZVertex(cluster, vz);
0124 m_calrecoUtilInstance.ProbCorrsZVertex(cluster, vz);
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140 if (Verbosity() && clus_energy > 18.0)
0141 {
0142 std::cout << "Input,out eclus cluster energies: " << clus_energy
0143 << " " << cluster->get_energy() << std::endl;
0144 std::cout << "Input, out cluster z:" << clus_savz
0145 << " " << cluster->get_z() << std::endl;
0146
0147 std::cout << "Input, out cluster ch2:" << clus_chi2
0148 << " " << cluster->get_chi2() << std::endl;
0149 }
0150
0151 }
0152
0153 return Fun4AllReturnCodes::EVENT_OK;
0154 }
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204 int RawClusterZVertexRecorrect::End(PHCompositeNode * )
0205 {
0206 return Fun4AllReturnCodes::EVENT_OK;
0207 }