Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RawClusterZVertexRecorrect.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file RawClusterZVertexRecorrect.cc
2 
5 
8 
9 #include <calobase/RawCluster.h>
10 #include <calobase/RawClusterContainer.h>
11 
13 #include <fun4all/SubsysReco.h>
14 
15 #include <phool/getClass.h>
16 
17 #include <fstream>
18 #include <iostream>
19 #include <map>
20 #include <sstream>
21 #include <string>
22 #include <utility> // for pair
23 
25  : SubsysReco(std::string("RawClusterZVertexRecorrect_") + name)
26  , _det_name("CEMC") // not tested for hcal yet
27  , m_UseTowerInfo(0)
28  , m_UseBbcZVtx(false)
29 {
30 
31 }
32 
34 {
35  if (!topNode && Verbosity())
36  {
37  std::cout << "RawClusZVtxRecorrect::InitRun : NO TOPNODE" << std::endl;
38  }
39 
40  // CreateNodeTree(topNode);
43 }
44 
46 {
47  if (Verbosity())
48  {
49  std::cout << "RawClusZVtxRecorrect::Processing a NEW EVENT" << std::endl;
50  }
51 
52  std::string rawClusNodeName = "CLUSTER_" + _det_name;
53  if (m_UseTowerInfo)
54  {
55  rawClusNodeName = "CLUSTERINFO_" + _det_name;
56  }
57 
58  RawClusterContainer *rawclusters = findNode::getClass<RawClusterContainer>(topNode, rawClusNodeName.c_str());
59  if (!rawclusters)
60  {
61  std::cout << "No " << _det_name << " Cluster Container found while in RawClusterZVertexRecorrect, can't proceed!!!" << std::endl;
63  }
64 
65  // Get Vertex
66  //float vx = 0;
67  // float vy = 0;
68  float vz = 0;
69 
70 
71  GlobalVertexMap *vertexmap = findNode::getClass<GlobalVertexMap>(topNode, "GlobalVertexMap");
72 
73  if (vertexmap && m_UseTowerInfo < 0)
74  // if (vertexmap)
75  {
76  if (!vertexmap->empty())
77  {
78  GlobalVertex *vertex = (vertexmap->begin()->second);
79  // vx = vertex->get_x();
80  // vy = vertex->get_y();
81  vz = vertex->get_z();
82  }
83  }
84 
85 
86  MbdVertexMap *mbdmap = findNode::getClass<MbdVertexMap>(topNode, "MbdVertexMap");
87 
88  if (m_UseBbcZVtx && mbdmap && m_UseTowerInfo < 2)
89  {
90  // std::cout << " in mbdmap ccpi0 " << std::endl;
91 
92  MbdVertex *bvertex = nullptr;
93  for (MbdVertexMap::ConstIter mbditer = mbdmap->begin();
94  mbditer != mbdmap->end();
95  ++mbditer)
96  {
97 
98  bvertex = mbditer->second;
99  }
100  // MbdVertex *bvertex = (mbdmap->begin()->second);
101  if (!bvertex)
102  {
104  }
105  vz = bvertex->get_z();
106  }
107 
109 
110  // loop over the clusters
111  RawClusterContainer::ConstRange begin_end = rawclusters->getClusters();
113 
114  for (iter = begin_end.first; iter != begin_end.second; ++iter)
115  {
116  // RawClusterDefs::keytype key = iter->first;
117  RawCluster *cluster = iter->second;
118 
119  float clus_energy = cluster->get_energy();
120  float clus_savz = cluster->get_z();
121  float clus_chi2 = cluster->get_chi2();
122 
125 
126 
127  /*
128  // for if it is desired in future to make new copied node instead of
129  // changing clusterNode "in Situ"
130 
131  RawCluster *recalibcluster = dynamic_cast<RawCluster *>(cluster->CloneMe());
132  assert(recalibcluster);
133  // if (m_UseTowerInfo)
134  // std::cout << "and here" << std::endl;
135  recalibcluster->set_energy(clus_energy / eclus_recalib_val);
136  recalibcluster->set_ecore(cluster->get_ecore() / ecore_recalib_val);
137  _recalib_clusters->AddCluster(recalibcluster);
138  */
139 
140  if (Verbosity() && clus_energy > 18.0)
141  {
142  std::cout << "Input,out eclus cluster energies: " << clus_energy
143  << " " << cluster->get_energy() << std::endl;
144  std::cout << "Input, out cluster z:" << clus_savz
145  << " " << cluster->get_z() << std::endl;
146 
147  std::cout << "Input, out cluster ch2:" << clus_chi2
148  << " " << cluster->get_chi2() << std::endl;
149  }
150 
151  }
152 
154 }
155 
156 
157 /*
158 
159  //keeping this for if we want to make a new node like CLUSTER_POS_CORR
160 void RawClusterZVertexRecorrect::CreateNodeTree(PHCompositeNode *topNode)
161 {
162 
163  // Check that it is there
164  if (!dstNode)
165  {
166  std::cout << "DST Node missing, quitting" << std::endl;
167  throw std::runtime_error("failed to find DST node in RawClusterZVertexRecorrect::CreateNodeTree");
168  }
169 
170  // Get the _det_name subnode
171  PHCompositeNode *cemcNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", _det_name));
172 
173  // Check that it is there
174  if (!cemcNode)
175  {
176  cemcNode = new PHCompositeNode(_det_name);
177  dstNode->addNode(cemcNode);
178  }
179 
180 
181  // Check to see if the cluster recalib node is on the nodetree
182  _recalib_clusters = findNode::getClass<RawClusterContainer>(topNode, "CLUSTER_RECALIB_" + _det_name);
183  std::string ClusterCorrNodeName = "CLUSTER_POS_COR_" + _det_name;
184  ;
185 
186  // If not, make it and add it to the _det_name subnode
187  if (!_recalib_clusters)
188  {
189  _recalib_clusters = new RawClusterContainer();
190  if (m_UseTowerInfo)
191  {
192  ClusterCorrNodeName = "CLUSTERINFO_POS_COR_" + _det_name;
193  }
194 
195  PHIODataNode<PHObject> *clusterNode = new PHIODataNode<PHObject>(_recalib_clusters, ClusterCorrNodeName.c_str(), "PHObject");
196  cemcNode->addNode(clusterNode);
197  }
198 
199 
200 }
201 
202 */
203 
205 {
207 }