Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TPCGemGainCalb.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TPCGemGainCalb.cc
1 #include "TPCGemGainCalb.h"
2 
4 
6 #include <phool/getClass.h>
7 #include <phool/phool.h>
8 #include <TNtuple.h>
9 #include <TFile.h>
10 
12 #include <trackbase/TrkrDefs.h>
19 #include <trackbase_historic/SvtxVertexMap.h>
20 
21 
22 using namespace std;
23 
24 //____________________________________________________________________________..
26  SubsysReco(name)
27 {
28 
29  fout = new TFile("readback_ntuple.root","RECREATE");
30 
31  ntp = new TNtuple("ntp", "ntp", "pt:x:y:z:dcaxy:dcaz:vtxid:nclus:qual");
32 
33  //cout << "TPCGemGainCalb::TPCGemGainCalb(const std::string &name) Calling ctor" << endl;
34 }
35 
36 //____________________________________________________________________________..
38 {
39 
40 }
41 
42 //____________________________________________________________________________..
44 {
45 
46  int ret = GetNodes(topNode);
47 
48  return ret;
49 }
50 
51 //____________________________________________________________________________..
53 {
54  if (Verbosity() >= 1)
55  cout << "TPCGemGainCalb::process_event(PHCompositeNode *topNode) Processing Event" << endl;
56 
57  double vertex_x = 0;
58  double vertex_y = 0;
59  double vertex_z = 0;
60 
61  // The vertex map
62  std::cout << "Vertex map has " << _vertex_map->size() << " entries" << std::endl;
63  for (auto vert_iter = _vertex_map->begin();
64  vert_iter != _vertex_map->end();
65  ++vert_iter)
66  {
67  auto vertex = vert_iter->second;
68  vertex_x = vertex->get_x();
69  vertex_y = vertex->get_y();
70  vertex_z = vertex->get_z();
71 
72  std::cout << " vertex (x,y,z) = " << vertex_x << " , " << vertex_y << " , " << vertex_z << std::endl;
73  }
74 
75 
76  // Loop over all SvtxTracks
77 
78  int ntracks = 0;
79  double mean_pt = 0;
80  double mean_clusters = 0;
81 
82  float pt, x, y, z, dcaxy, dcaz, vtxid, nclus, qual;
83  std::cout << "Track map has " << _track_map->size() << " entries" << std::endl;
84  for (auto phtrk_iter = _track_map->begin();
85  phtrk_iter != _track_map->end();
86  ++phtrk_iter)
87  {
88  _track = phtrk_iter->second;
89 
90  pt = _track->get_pt();
91  x = _track->get_x() ;
92  y = _track->get_y();
93  z = _track->get_z();
94  dcaxy = _track->get_dca3d_xy();
95  dcaz = _track->get_dca3d_z();
96  vtxid = (float) _track->get_vertex_id();
97  nclus = (float) _track-> size_cluster_keys();
98  qual = _track->get_chisq() / (float) _track->get_ndf();
99 
100  if(Verbosity() > 0)
101  std::cout
102  << __LINE__
103  << ": Processing itrack: " << phtrk_iter->first
104  << ": nclus: " << nclus
105  << ": pT " << pt
106  << " : x,y,z " << x
107  << ", " << y
108  << ", " << z
109  << ", dcaxy " << dcaxy
110  << ", dcaz " << dcaz
111  << ", vtxid " << vtxid
112  << endl;
113 
114  ntp->Fill(_track->get_pt(),
115  _track->get_x(),
116  _track->get_y(),
117  _track->get_z(),
118  _track->get_dca3d_xy(),
119  _track->get_dca3d_z(),
120  (float) _track->get_vertex_id(),
121  (float) _track->size_cluster_keys(),
122  qual
123  );
124 
125  ntracks ++;
126  mean_pt += _track->get_pt();
127  mean_clusters += _track->size_cluster_keys();
128 
129  double cluster_avge_adc = 0.0;
130  double cluster_avge_wt = 0.0;
131 
132  // loop over associated clusters to get hits for track
134  iter != _track->end_cluster_keys();
135  ++iter)
136  {
137  TrkrDefs::cluskey cluster_key = *iter;
138  unsigned int layer = TrkrDefs::getLayer(cluster_key);
139  unsigned int zelement = TrkrDefs::getZElement(cluster_key);
140  unsigned int phielement = TrkrDefs::getPhiElement(cluster_key);
141 
142  TrkrCluster *cluster = _cluster_map->findCluster(cluster_key);
143 
144  if(Verbosity() > 2)
145  {
146  std::cout << " cluster " << cluster_key << " layer " << layer << " zelement " << zelement << " phielement " << phielement << std::endl;
147 
148  if(cluster)
149  {
150  double radius = sqrt( cluster->getX()*cluster->getX() + cluster->getY()*cluster->getY() );
151  std::cout << " cluster radius " << radius << " cluster adc " << cluster->getAdc() << std::endl;
152  if(layer > 6)
153  {
154  cluster_avge_adc += (double) cluster->getAdc();
155  cluster_avge_wt += 1.0;
156  }
157  }
158  else
159  std::cout << "Failed to find cluster with key :" << cluster_key << std::endl;
160  }
161 
162  }
163  if(Verbosity() > 2) std::cout << " TPC cluster_avge_adc " << cluster_avge_adc/cluster_avge_wt << std::endl;
164  }
165 
166 
167  std::cout << "---- tracks with > 20 clusters " << ntracks << " mean nclusters " << mean_clusters /(double) ntracks << " mean pT " << mean_pt / (double) ntracks << std::endl;
168 
169 
170  if (Verbosity() > 0)
171  cout << "TPCGemGainCalb::process_event(PHCompositeNode *topNode) Leaving process_event" << endl;
172 
174 }
175 
176 //____________________________________________________________________________..
178 {
179 
181 }
182 
183 //____________________________________________________________________________..
185 {
186  fout->Write();
187  //ntp->Write();
188  //fout->Close();
189 
191 }
192 
193 //____________________________________________________________________________..
194 
196 {
197  //---------------------------------
198  // Get Objects off of the Node Tree
199  //---------------------------------
200 
201  _cluster_map = findNode::getClass<TrkrClusterContainer>(topNode, "TRKR_CLUSTER");
202  if (!_cluster_map)
203  {
204  cerr << PHWHERE << " ERROR: Can't find node TRKR_CLUSTER" << endl;
206  }
207 
208 
209  _vertex_map = findNode::getClass<SvtxVertexMap>(topNode, "SvtxVertexMap");
210  if (!_vertex_map)
211  {
212  cerr << PHWHERE << " ERROR: Can't find SvtxVertexMap." << endl;
214  }
215 
216 
217  _track_map = findNode::getClass<SvtxTrackMap>(topNode, "SvtxTrackMap");
218  if (!_track_map)
219  {
220  cerr << PHWHERE << " ERROR: Can't find SvtxTrackMap: " << endl;
222  }
223 
225 }
226