Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TreeMakerUseFastJet.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TreeMakerUseFastJet.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 // --- fast jet
18 #include <fastjet/ClusterSequence.hh>
19 
20 // --- stuff
21 #include <TLorentzVector.h>
22 
23 using std::cout;
24 using std::endl;
25 using std::vector;
26 
27 using fastjet::PseudoJet;
28 using fastjet::ClusterSequence;
29 using fastjet::JetDefinition;
31 
32 
33 
35 {
36 
37  // -----------------------------------------------------------------------------------------------------
38  // ---
39  // -----------------------------------------------------------------------------------------------------
40 
41  // --- calorimeter tower containers
42  // RawTowerContainer* cemc_towers = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_CEMC");
43  // RawTowerContainer* hcalin_towers = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_HCALIN");
44  // RawTowerContainer* hcalout_towers = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_HCALOUT");
45 
46  // --- calorimeter geometry objects
47  // RawTowerGeomContainer* cemc_geom = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_CEMC");
48  // RawTowerGeomContainer* hcalin_geom = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_HCALIN");
49  // RawTowerGeomContainer* hcalout_geom = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_HCALOUT");
50 
51  // --- calorimeter cluster containers
52  RawClusterContainer* cemc_clusters = findNode::getClass<RawClusterContainer>(topNode,"CLUSTER_CEMC");
53  RawClusterContainer* hcalin_clusters = findNode::getClass<RawClusterContainer>(topNode,"CLUSTER_HCALIN");
54  RawClusterContainer* hcalout_clusters = findNode::getClass<RawClusterContainer>(topNode,"CLUSTER_HCALOUT");
55 
56  if ( verbosity > 3 )
57  {
58  cout << "cemc_clusters " << cemc_clusters << endl;
59  cout << "hcalin_clusters " << hcalin_clusters << endl;
60  cout << "hcalout_clusters " << hcalout_clusters << endl;
61  }
62 
63  // --- these nodes are created in CreateNode and filled in CopyAndMakeClusters
64  RawClusterContainer* new_cemc_clusters = findNode::getClass<RawClusterContainer>(topNode,"CLUSTER_CEMC_MOD");
65  RawClusterContainer* new_hcalin_clusters = findNode::getClass<RawClusterContainer>(topNode,"CLUSTER_HCALIN_MOD");
66  RawClusterContainer* new_hcalout_clusters = findNode::getClass<RawClusterContainer>(topNode,"CLUSTER_HCALOUT_MOD");
67 
68  if ( verbosity > 3 )
69  {
70  cout << "new_cemc_clusters " << new_cemc_clusters << endl;
71  cout << "new_hcalin_clusters " << new_hcalin_clusters << endl;
72  cout << "new_hcalout_clusters " << new_hcalout_clusters << endl;
73  }
74 
75  vector<PseudoJet> clusters;
76  vector<PseudoJet> mod_clusters;
77  double R = 0.4;
78  JetDefinition jet_def(antikt_algorithm, R);
79  // PseudoJet pj_cluster;
80  // PseudoJet pj_mod_cluster;
81 
82  // --- loop over cemc clusters
83  int cluster_counter = 0;
84  RawClusterContainer::Range cemc_range = cemc_clusters->getClusters();
85  for ( RawClusterContainer::Iterator cemc_iter = cemc_range.first; cemc_iter != cemc_range.second; ++cemc_iter )
86  {
87  // --- get the current cluster
88  RawCluster* cluster = cemc_iter->second;
89  double e = cluster->get_energy();
90  double phi = cluster->get_phi();
91  double r = cluster->get_r();
92  double z = cluster->get_z();
93  double eta = -log(tan(atan2(r,z)/2.0));
94  double pt = e/cosh(eta);
95  TLorentzVector tlv_cluster;
96  tlv_cluster.SetPtEtaPhiE(pt,eta,phi,e);
97  clusters.push_back(PseudoJet(tlv_cluster));
98  ++cluster_counter;
99  }
100  ClusterSequence cs_cluster(clusters, jet_def);
101  vector<PseudoJet> clusterjets = sorted_by_pt(cs_cluster.inclusive_jets());
102  if ( verbosity > 1 ) cout << "number of clusters " << cluster_counter << " number of cluster jets" << clusterjets.size() << endl;
103 
104  // --- loop over new_cemc clusters
105  int mod_cluster_counter = 0;
106  RawClusterContainer::Range new_cemc_range = new_cemc_clusters->getClusters();
107  for ( RawClusterContainer::Iterator new_cemc_iter = new_cemc_range.first; new_cemc_iter != new_cemc_range.second; ++new_cemc_iter )
108  {
109  // --- get the current cluster
110  RawCluster* cluster = new_cemc_iter->second;
111  double e = cluster->get_energy();
112  double phi = cluster->get_phi();
113  double r = cluster->get_r();
114  double z = cluster->get_z();
115  double eta = -log(tan(atan2(r,z)/2.0));
116  double pt = e/cosh(eta);
117  TLorentzVector tlv_cluster;
118  tlv_cluster.SetPtEtaPhiE(pt,eta,phi,e);
119  mod_clusters.push_back(PseudoJet(tlv_cluster));
120  ++mod_cluster_counter;
121  }
122  ClusterSequence cs_mod_cluster(mod_clusters, jet_def);
123  vector<PseudoJet> mod_clusterjets = sorted_by_pt(cs_mod_cluster.inclusive_jets());
124  if ( verbosity > 1 ) cout << "number of clusters " << cluster_counter << " number of cluster jets" << mod_clusterjets.size() << endl;
125 
126 
127  // clusterJet_n = 0;
128  // for (unsigned i = 0; i < clusterjets.size(); i++) {
129  // if (clusterjets[i].pt() < 5) continue;
130  // clusterJet_e[i] = clusterjets[i].e();
131  // clusterJet_pt[i] = clusterjets[i].pt();
132  // clusterJet_eta[i] = clusterjets[i].eta();
133  // clusterJet_phi[i] = clusterjets[i].phi_std();
134  // vector<PseudoJet> constituents = clusterjets[i].constituents();
135  // clusterJet_nConst[i] = constituents.size();
136  // clusterJet_n++;
137  // }
138 
139  // if ( verbosity > 1 )
140  // {
141  // cout << "process_event: cemc_esum " << cemc_esum << endl;
142  // cout << "process_event: new_cemc_esum " << new_cemc_esum << endl;
143  // }
144 
145 
146 
147  return 0;
148 
149 }