Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TreeMakerCopyAndMakeClusters.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TreeMakerCopyAndMakeClusters.C
1 #include <TreeMaker.h>
2 
3 #include <phool/getClass.h>
5 
6 // --- calorimeter towers
7 #include <calobase/RawTower.h>
8 #include <calobase/RawTowerContainer.h>
9 #include <calobase/RawTowerGeom.h>
10 #include <calobase/RawTowerGeomContainer.h>
11 
12 // --- calorimeter clusters
13 #include <calobase/RawCluster.h>
14 #include <calobase/RawClusterv1.h>
15 #include <calobase/RawClusterContainer.h>
16 
17 using std::cout;
18 using std::endl;
19 
20 
21 
23 {
24 
25  // -----------------------------------------------------------------------------------------------------
26  // ---
27  // -----------------------------------------------------------------------------------------------------
28 
29  // --- calorimeter tower containers
30  // RawTowerContainer* towersEM3 = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_CEMC");
31  // RawTowerContainer* towersIH3 = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_HCALIN");
32  // RawTowerContainer* towersOH3 = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_HCALOUT");
33 
34  // --- calorimeter geometry objects
35  // RawTowerGeomContainer* geomEM = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_CEMC");
36  // RawTowerGeomContainer* geomIH = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_HCALIN");
37  // RawTowerGeomContainer* geomOH = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_HCALOUT");
38 
39  // --- clorimeter cluster containers
40  RawClusterContainer* clustersEM3 = findNode::getClass<RawClusterContainer>(topNode,"CLUSTER_CEMC");
41  RawClusterContainer* clustersIH3 = findNode::getClass<RawClusterContainer>(topNode,"CLUSTER_HCALIN");
42  RawClusterContainer* clustersOH3 = findNode::getClass<RawClusterContainer>(topNode,"CLUSTER_HCALOUT");
43 
44  if ( verbosity > 3 )
45  {
46  cout << "clustersEM3 " << clustersEM3 << endl;
47  cout << "clustersIH3 " << clustersIH3 << endl;
48  cout << "clustersOH3 " << clustersOH3 << endl;
49  }
50 
51 
52 
53  // --------
54  // --- CEMC
55  // --------
56 
57  // --- make new cluster object
58  RawClusterContainer* new_cemc_clusters = findNode::getClass<RawClusterContainer>(topNode,"CLUSTER_CEMC_MOD"); // this node is created in createnode
59  if ( verbosity > 0 )
60  {
61  cout << "Regular clusters node: " << clustersEM3 << endl;
62  cout << "Modified clusters node: " << new_cemc_clusters << endl;
63  }
64  if ( !clustersEM3 || !new_cemc_clusters )
65  {
66  cout << "One or more invalid pointers, exiting event" << endl;
67  return 0;
68  }
69 
70  // --- print sizes of old and new objects for diagnostic purposes
71  if ( verbosity > 0 )
72  {
73  cout << "process_event: entering with # original clusters = " << clustersEM3->size() << endl;
74  cout << "process_event: entering with # new clusters = " << new_cemc_clusters->size() << endl;
75  }
76 
77  // --- loop over cemc clusters
78  RawClusterContainer::Range cemc_range = clustersEM3->getClusters();
79  for ( RawClusterContainer::Iterator cemc_iter = cemc_range.first; cemc_iter != cemc_range.second; ++cemc_iter )
80  {
81  // --- get the current cluster
82  RawCluster* old_cluster = cemc_iter->second;
83  double energy = old_cluster->get_energy();
84  //double eta = old_cluster->get_eta(); // no longer a member of RawCluster class. why?
85  double r = old_cluster->get_r();
86  double z = old_cluster->get_z();
87  double phi = old_cluster->get_phi();
88  double ecore = old_cluster->get_ecore();
89  double chi2 = old_cluster->get_chi2();
90  double prob = old_cluster->get_prob();
91  if ( verbosity > 10 )
92  {
93  cout << "for old cluster:" << endl;
94  cout << "energy " << energy << endl;
95  //cout << "eta " << eta << endl;
96  cout << "r " << r << endl;
97  cout << "z " << z << endl;
98  cout << "phi " << phi << endl;
99  cout << "ecore " << ecore << endl;
100  cout << "chi2 " << chi2 << endl;
101  cout << "prob " << prob << endl;
102  }
103  // --- make the new cluster
104  RawCluster* new_cluster = new RawClusterv1();
105  // --- set the cluster variables
106  new_cluster->set_id(old_cluster->get_id());
107  new_cluster->set_energy(energy);
108  //new_cluster->set_eta(eta);
109  new_cluster->set_r(r);
110  new_cluster->set_z(z);
111  new_cluster->set_phi(phi);
112  new_cluster->set_ecore(ecore);
113  new_cluster->set_chi2(chi2);
114  new_cluster->set_prob(prob);
115  // --- add the new cluster to the new cluster container
116  new_cemc_clusters->AddCluster(new_cluster);
117  }
118 
119 
120 
121  // --------
122  // --- HCALIN
123  // --------
124 
125  // --- make new cluster object
126  RawClusterContainer* new_hcalin_clusters = findNode::getClass<RawClusterContainer>(topNode,"CLUSTER_HCALIN_MOD"); // this node is created in createnode
127  if ( verbosity > 0 )
128  {
129  cout << "Regular clusters node: " << clustersIH3 << endl;
130  cout << "Modified clusters node: " << new_hcalin_clusters << endl;
131  }
132  if ( !clustersIH3 || !new_hcalin_clusters )
133  {
134  cout << "One or more invalid pointers, exiting event" << endl;
135  return 0;
136  }
137 
138  // --- print sizes of old and new objects for diagnostic purposes
139  if ( verbosity > 0 )
140  {
141  cout << "process_event: entering with # original clusters = " << clustersIH3->size() << endl;
142  cout << "process_event: entering with # new clusters = " << new_hcalin_clusters->size() << endl;
143  }
144 
145  // --- loop over hcalin clusters
146  RawClusterContainer::Range hcalin_range = clustersIH3->getClusters();
147  for ( RawClusterContainer::Iterator hcalin_iter = hcalin_range.first; hcalin_iter != hcalin_range.second; ++hcalin_iter )
148  {
149  // --- get the current cluster
150  RawCluster* old_cluster = hcalin_iter->second;
151  double energy = old_cluster->get_energy();
152  //double eta = old_cluster->get_eta();
153  double r = old_cluster->get_r();
154  double z = old_cluster->get_z();
155  double phi = old_cluster->get_phi();
156  double ecore = old_cluster->get_ecore();
157  double chi2 = old_cluster->get_chi2();
158  double prob = old_cluster->get_prob();
159  if ( verbosity > 10 )
160  {
161  cout << "for old cluster:" << endl;
162  cout << "energy " << energy << endl;
163  //cout << "eta " << eta << endl;
164  cout << "r " << r << endl;
165  cout << "z " << z << endl;
166  cout << "phi " << phi << endl;
167  cout << "ecore " << ecore << endl;
168  cout << "chi2 " << chi2 << endl;
169  cout << "prob " << prob << endl;
170  }
171  // --- make the new cluster
172  RawCluster* new_cluster = new RawClusterv1();
173  // --- set the cluster variables
174  new_cluster->set_id(old_cluster->get_id());
175  new_cluster->set_energy(energy);
176  //new_cluster->set_eta(eta);
177  new_cluster->set_r(r);
178  new_cluster->set_z(z);
179  new_cluster->set_phi(phi);
180  new_cluster->set_ecore(ecore);
181  new_cluster->set_chi2(chi2);
182  new_cluster->set_prob(prob);
183  // --- add the new cluster to the new cluster container
184  new_hcalin_clusters->AddCluster(new_cluster);
185  }
186 
187 
188 
189  // --------
190  // --- HCALOUT
191  // --------
192 
193  // --- make new cluster object
194  RawClusterContainer* new_hcalout_clusters = findNode::getClass<RawClusterContainer>(topNode,"CLUSTER_HCALOUT_MOD"); // this node is created in createnode
195  if ( verbosity > 0 )
196  {
197  cout << "Regular clusters node: " << clustersOH3 << endl;
198  cout << "Modified clusters node: " << new_hcalout_clusters << endl;
199  }
200  if ( !clustersOH3 || !new_hcalout_clusters )
201  {
202  cout << "One or more invalid pointers, exiting event" << endl;
203  return 0;
204  }
205 
206  // --- print sizes of old and new objects for diagnostic purposes
207  if ( verbosity > 0 )
208  {
209  cout << "process_event: entering with # original clusters = " << clustersOH3->size() << endl;
210  cout << "process_event: entering with # new clusters = " << new_hcalout_clusters->size() << endl;
211  }
212 
213  // --- loop over hcalout clusters
214  RawClusterContainer::Range hcalout_range = clustersOH3->getClusters();
215  for ( RawClusterContainer::Iterator hcalout_iter = hcalout_range.first; hcalout_iter != hcalout_range.second; ++hcalout_iter )
216  {
217  // --- get the current cluster
218  RawCluster* old_cluster = hcalout_iter->second;
219  double energy = old_cluster->get_energy();
220  //double eta = old_cluster->get_eta();
221  double r = old_cluster->get_r();
222  double z = old_cluster->get_z();
223  double phi = old_cluster->get_phi();
224  double ecore = old_cluster->get_ecore();
225  double chi2 = old_cluster->get_chi2();
226  double prob = old_cluster->get_prob();
227  if ( verbosity > 10 )
228  {
229  cout << "for old cluster:" << endl;
230  cout << "energy " << energy << endl;
231  //cout << "eta " << eta << endl;
232  cout << "r " << r << endl;
233  cout << "z " << z << endl;
234  cout << "phi " << phi << endl;
235  cout << "ecore " << ecore << endl;
236  cout << "chi2 " << chi2 << endl;
237  cout << "prob " << prob << endl;
238  }
239  // --- make the new cluster
240  RawCluster* new_cluster = new RawClusterv1();
241  // --- set the cluster variables
242  new_cluster->set_id(old_cluster->get_id());
243  new_cluster->set_energy(energy);
244  //new_cluster->set_eta(eta);
245  new_cluster->set_r(r);
246  new_cluster->set_z(z);
247  new_cluster->set_phi(phi);
248  new_cluster->set_ecore(ecore);
249  new_cluster->set_chi2(chi2);
250  new_cluster->set_prob(prob);
251  // --- add the new cluster to the new cluster container
252  new_hcalout_clusters->AddCluster(new_cluster);
253  }
254 
255 
256 
257  if ( verbosity > 0 )
258  {
259  cout << "process_event: exiting with # original cemc clusters = " << clustersEM3->size() << endl;
260  cout << "process_event: exiting with # new cemc clusters = " << new_cemc_clusters->size() << endl;
261  cout << "process_event: exiting with # original hcalin clusters = " << clustersIH3->size() << endl;
262  cout << "process_event: exiting with # new hcalin clusters = " << new_hcalin_clusters->size() << endl;
263  cout << "process_event: exiting with # original hcalout clusters = " << clustersOH3->size() << endl;
264  cout << "process_event: exiting with # new hcalout clusters = " << new_hcalout_clusters->size() << endl;
265  }
266 
267  return 0;
268 
269 }