File indexing completed on 2025-08-03 08:15:56
0001 #include <TreeMaker.h>
0002
0003 #include <phool/getClass.h>
0004 #include <phool/PHCompositeNode.h>
0005
0006
0007 #include <calobase/RawTower.h>
0008 #include <calobase/RawTowerContainer.h>
0009 #include <calobase/RawTowerGeom.h>
0010 #include <calobase/RawTowerGeomContainer.h>
0011
0012
0013 #include <calobase/RawCluster.h>
0014 #include <calobase/RawClusterv1.h>
0015 #include <calobase/RawClusterContainer.h>
0016
0017 using std::cout;
0018 using std::endl;
0019
0020
0021
0022 int TreeMaker::CopyAndMakeClusters(PHCompositeNode *topNode)
0023 {
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 RawClusterContainer* clustersEM3 = findNode::getClass<RawClusterContainer>(topNode,"CLUSTER_CEMC");
0041 RawClusterContainer* clustersIH3 = findNode::getClass<RawClusterContainer>(topNode,"CLUSTER_HCALIN");
0042 RawClusterContainer* clustersOH3 = findNode::getClass<RawClusterContainer>(topNode,"CLUSTER_HCALOUT");
0043
0044 if ( verbosity > 3 )
0045 {
0046 cout << "clustersEM3 " << clustersEM3 << endl;
0047 cout << "clustersIH3 " << clustersIH3 << endl;
0048 cout << "clustersOH3 " << clustersOH3 << endl;
0049 }
0050
0051
0052
0053
0054
0055
0056
0057
0058 RawClusterContainer* new_cemc_clusters = findNode::getClass<RawClusterContainer>(topNode,"CLUSTER_CEMC_MOD");
0059 if ( verbosity > 0 )
0060 {
0061 cout << "Regular clusters node: " << clustersEM3 << endl;
0062 cout << "Modified clusters node: " << new_cemc_clusters << endl;
0063 }
0064 if ( !clustersEM3 || !new_cemc_clusters )
0065 {
0066 cout << "One or more invalid pointers, exiting event" << endl;
0067 return 0;
0068 }
0069
0070
0071 if ( verbosity > 0 )
0072 {
0073 cout << "process_event: entering with # original clusters = " << clustersEM3->size() << endl;
0074 cout << "process_event: entering with # new clusters = " << new_cemc_clusters->size() << endl;
0075 }
0076
0077
0078 RawClusterContainer::Range cemc_range = clustersEM3->getClusters();
0079 for ( RawClusterContainer::Iterator cemc_iter = cemc_range.first; cemc_iter != cemc_range.second; ++cemc_iter )
0080 {
0081
0082 RawCluster* old_cluster = cemc_iter->second;
0083 double energy = old_cluster->get_energy();
0084
0085 double r = old_cluster->get_r();
0086 double z = old_cluster->get_z();
0087 double phi = old_cluster->get_phi();
0088 double ecore = old_cluster->get_ecore();
0089 double chi2 = old_cluster->get_chi2();
0090 double prob = old_cluster->get_prob();
0091 if ( verbosity > 10 )
0092 {
0093 cout << "for old cluster:" << endl;
0094 cout << "energy " << energy << endl;
0095
0096 cout << "r " << r << endl;
0097 cout << "z " << z << endl;
0098 cout << "phi " << phi << endl;
0099 cout << "ecore " << ecore << endl;
0100 cout << "chi2 " << chi2 << endl;
0101 cout << "prob " << prob << endl;
0102 }
0103
0104 RawCluster* new_cluster = new RawClusterv1();
0105
0106 new_cluster->set_id(old_cluster->get_id());
0107 new_cluster->set_energy(energy);
0108
0109 new_cluster->set_r(r);
0110 new_cluster->set_z(z);
0111 new_cluster->set_phi(phi);
0112 new_cluster->set_ecore(ecore);
0113 new_cluster->set_chi2(chi2);
0114 new_cluster->set_prob(prob);
0115
0116 new_cemc_clusters->AddCluster(new_cluster);
0117 }
0118
0119
0120
0121
0122
0123
0124
0125
0126 RawClusterContainer* new_hcalin_clusters = findNode::getClass<RawClusterContainer>(topNode,"CLUSTER_HCALIN_MOD");
0127 if ( verbosity > 0 )
0128 {
0129 cout << "Regular clusters node: " << clustersIH3 << endl;
0130 cout << "Modified clusters node: " << new_hcalin_clusters << endl;
0131 }
0132 if ( !clustersIH3 || !new_hcalin_clusters )
0133 {
0134 cout << "One or more invalid pointers, exiting event" << endl;
0135 return 0;
0136 }
0137
0138
0139 if ( verbosity > 0 )
0140 {
0141 cout << "process_event: entering with # original clusters = " << clustersIH3->size() << endl;
0142 cout << "process_event: entering with # new clusters = " << new_hcalin_clusters->size() << endl;
0143 }
0144
0145
0146 RawClusterContainer::Range hcalin_range = clustersIH3->getClusters();
0147 for ( RawClusterContainer::Iterator hcalin_iter = hcalin_range.first; hcalin_iter != hcalin_range.second; ++hcalin_iter )
0148 {
0149
0150 RawCluster* old_cluster = hcalin_iter->second;
0151 double energy = old_cluster->get_energy();
0152
0153 double r = old_cluster->get_r();
0154 double z = old_cluster->get_z();
0155 double phi = old_cluster->get_phi();
0156 double ecore = old_cluster->get_ecore();
0157 double chi2 = old_cluster->get_chi2();
0158 double prob = old_cluster->get_prob();
0159 if ( verbosity > 10 )
0160 {
0161 cout << "for old cluster:" << endl;
0162 cout << "energy " << energy << endl;
0163
0164 cout << "r " << r << endl;
0165 cout << "z " << z << endl;
0166 cout << "phi " << phi << endl;
0167 cout << "ecore " << ecore << endl;
0168 cout << "chi2 " << chi2 << endl;
0169 cout << "prob " << prob << endl;
0170 }
0171
0172 RawCluster* new_cluster = new RawClusterv1();
0173
0174 new_cluster->set_id(old_cluster->get_id());
0175 new_cluster->set_energy(energy);
0176
0177 new_cluster->set_r(r);
0178 new_cluster->set_z(z);
0179 new_cluster->set_phi(phi);
0180 new_cluster->set_ecore(ecore);
0181 new_cluster->set_chi2(chi2);
0182 new_cluster->set_prob(prob);
0183
0184 new_hcalin_clusters->AddCluster(new_cluster);
0185 }
0186
0187
0188
0189
0190
0191
0192
0193
0194 RawClusterContainer* new_hcalout_clusters = findNode::getClass<RawClusterContainer>(topNode,"CLUSTER_HCALOUT_MOD");
0195 if ( verbosity > 0 )
0196 {
0197 cout << "Regular clusters node: " << clustersOH3 << endl;
0198 cout << "Modified clusters node: " << new_hcalout_clusters << endl;
0199 }
0200 if ( !clustersOH3 || !new_hcalout_clusters )
0201 {
0202 cout << "One or more invalid pointers, exiting event" << endl;
0203 return 0;
0204 }
0205
0206
0207 if ( verbosity > 0 )
0208 {
0209 cout << "process_event: entering with # original clusters = " << clustersOH3->size() << endl;
0210 cout << "process_event: entering with # new clusters = " << new_hcalout_clusters->size() << endl;
0211 }
0212
0213
0214 RawClusterContainer::Range hcalout_range = clustersOH3->getClusters();
0215 for ( RawClusterContainer::Iterator hcalout_iter = hcalout_range.first; hcalout_iter != hcalout_range.second; ++hcalout_iter )
0216 {
0217
0218 RawCluster* old_cluster = hcalout_iter->second;
0219 double energy = old_cluster->get_energy();
0220
0221 double r = old_cluster->get_r();
0222 double z = old_cluster->get_z();
0223 double phi = old_cluster->get_phi();
0224 double ecore = old_cluster->get_ecore();
0225 double chi2 = old_cluster->get_chi2();
0226 double prob = old_cluster->get_prob();
0227 if ( verbosity > 10 )
0228 {
0229 cout << "for old cluster:" << endl;
0230 cout << "energy " << energy << endl;
0231
0232 cout << "r " << r << endl;
0233 cout << "z " << z << endl;
0234 cout << "phi " << phi << endl;
0235 cout << "ecore " << ecore << endl;
0236 cout << "chi2 " << chi2 << endl;
0237 cout << "prob " << prob << endl;
0238 }
0239
0240 RawCluster* new_cluster = new RawClusterv1();
0241
0242 new_cluster->set_id(old_cluster->get_id());
0243 new_cluster->set_energy(energy);
0244
0245 new_cluster->set_r(r);
0246 new_cluster->set_z(z);
0247 new_cluster->set_phi(phi);
0248 new_cluster->set_ecore(ecore);
0249 new_cluster->set_chi2(chi2);
0250 new_cluster->set_prob(prob);
0251
0252 new_hcalout_clusters->AddCluster(new_cluster);
0253 }
0254
0255
0256
0257 if ( verbosity > 0 )
0258 {
0259 cout << "process_event: exiting with # original cemc clusters = " << clustersEM3->size() << endl;
0260 cout << "process_event: exiting with # new cemc clusters = " << new_cemc_clusters->size() << endl;
0261 cout << "process_event: exiting with # original hcalin clusters = " << clustersIH3->size() << endl;
0262 cout << "process_event: exiting with # new hcalin clusters = " << new_hcalin_clusters->size() << endl;
0263 cout << "process_event: exiting with # original hcalout clusters = " << clustersOH3->size() << endl;
0264 cout << "process_event: exiting with # new hcalout clusters = " << new_hcalout_clusters->size() << endl;
0265 }
0266
0267 return 0;
0268
0269 }