Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TreeMakerCreateNode.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TreeMakerCreateNode.C
1 #include <iostream>
2 
3 // --- header for this clase
4 #include <TreeMaker.h>
5 
6 // --- basic sPhenix environment stuff
8 #include <phool/getClass.h>
10 
11 // --- jet specific stuff
12 #include <g4jets/JetMap.h>
13 #include <g4jets/JetMapV1.h>
14 
15 // --- calorimeter clusters
16 #include <calobase/RawClusterContainer.h>
17 
18 using std::cout;
19 using std::endl;
20 
21 
22 
24 {
25 
26  cout << "TreeMaker::CreateNode called" << endl;
27 
28  PHNodeIterator iter(topNode);
29 
30  // -----------------------------
31  // --- Make the new jet node ---
32  // -----------------------------
33 
34  // --- Look for the DST node
35  PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "DST"));
36  if ( !dstNode )
37  {
38  cout << PHWHERE << "DST node not found, doing nothing." << endl;
39  return -2;
40  }
41 
42  // --- Look for the ANTIKT node
43  PHCompositeNode *antiktNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "ANTIKT"));
44  if ( !antiktNode )
45  {
46  cout << PHWHERE << "ANTIKT node not found, doing nothing." << endl;
47  return -2;
48  }
49 
50  // --- Look for the TOWER node
51  PHCompositeNode *towerNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "TOWER"));
52  if ( !towerNode )
53  {
54  cout << PHWHERE << "TOWER node not found, doing nothing." << endl;
55  return -2;
56  }
57 
58  // --- Check if the new node exists (it should not) and then store the new jet collection
59  JetMap* check_jets = findNode::getClass<JetMap>(topNode,"AntiKt_Tower_Mod_r02");
60  if ( !check_jets )
61  {
62  // --- If the new node doesn't already exist (good) then make it
63  cout << "TreeMaker::CreateNode : creating AntiKt_Tower_Mod_r02 node " << endl;
64  JetMap *mod_jets = new JetMapV1();
65  PHIODataNode<PHObject> *modjetNode = new PHIODataNode<PHObject>( mod_jets, "AntiKt_Tower_Mod_r02", "PHObject");
66  // --- node structure for jets is DST -> ANTIKT -> TOWER (or CLUSTER or TRACK or whatever) -> specific jet node
67  towerNode->addNode(modjetNode);
68  }
69  else
70  {
71  // --- If the new node already exists (bad) issue a warning and then do nothing
72  cout << "TreeMaker::CreateNode : AntiKt_Tower_Mod_r02 already exists! " << endl;
73  }
74 
75  // --------------------------------------
76  // --- Make the new cemc cluster node ---
77  // --------------------------------------
78 
79  // --- Look for the CEMC node (main node for us)
80  PHCompositeNode *cemcNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "CEMC"));
81  if ( !cemcNode )
82  {
83  cout << PHWHERE << "CEMC node not found, doing nothing." << endl;
84  return -2;
85  }
86 
87  // --- Check if the new node exists (it should not) and then store the new cluster collection
88  RawClusterContainer* check_cemc_clusters = findNode::getClass<RawClusterContainer>(topNode,"CLUSTER_CEMC_MOD");
89  if ( !check_cemc_clusters )
90  {
91  // --- If the new node doesn't already exist (good) then make it
92  cout << "TreeMaker::CreateNode : creating CLUSTER_CEMC_MOD node " << endl;
93  RawClusterContainer *mod_cemc_clusters = new RawClusterContainer();
94  PHIODataNode<PHObject> *clusterNode = new PHIODataNode<PHObject>( mod_cemc_clusters, "CLUSTER_CEMC_MOD", "PHObject");
95  // --- node structure for clusters is CEMC -> CLUSTER_CEMC
96  cemcNode->addNode(clusterNode);
97  }
98  else
99  {
100  // --- If the new node already exists (bad) issue a warning and then do nothing
101  cout << "TreeMaker::CreateNode : CLUSTER_CEMC_MOD already exists! " << endl;
102  }
103 
104  // --- Look for the HCALIN node (main node for us)
105  PHCompositeNode *hcalinNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "HCALIN"));
106  if ( !hcalinNode )
107  {
108  cout << PHWHERE << "HCALIN node not found, doing nothing." << endl;
109  return -2;
110  }
111 
112  // --- Check if the new node exists (it should not) and then store the new cluster collection
113  RawClusterContainer* check_hcalin_clusters = findNode::getClass<RawClusterContainer>(topNode,"CLUSTER_HCALIN_MOD");
114  if ( !check_hcalin_clusters )
115  {
116  // --- If the new node doesn't already exist (good) then make it
117  cout << "TreeMaker::CreateNode : creating CLUSTER_HCALIN_MOD node " << endl;
118  RawClusterContainer *mod_hcalin_clusters = new RawClusterContainer();
119  PHIODataNode<PHObject> *clusterNode = new PHIODataNode<PHObject>( mod_hcalin_clusters, "CLUSTER_HCALIN_MOD", "PHObject");
120  // --- node structure for clusters is HCALIN -> CLUSTER_HCALIN
121  hcalinNode->addNode(clusterNode);
122  }
123  else
124  {
125  // --- If the new node already exists (bad) issue a warning and then do nothing
126  cout << "TreeMaker::CreateNode : CLUSTER_HCALIN_MOD already exists! " << endl;
127  }
128 
129  // --- Look for the HCALOUT node (main node for us)
130  PHCompositeNode *hcaloutNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "HCALOUT"));
131  if ( !hcaloutNode )
132  {
133  cout << PHWHERE << "HCALOUT node not found, doing nothing." << endl;
134  return -2;
135  }
136 
137  // --- Check if the new node exists (it should not) and then store the new cluster collection
138  RawClusterContainer* check_hcalout_clusters = findNode::getClass<RawClusterContainer>(topNode,"CLUSTER_HCALOUT_MOD");
139  if ( !check_hcalout_clusters )
140  {
141  // --- If the new node doesn't already exist (good) then make it
142  cout << "TreeMaker::CreateNode : creating CLUSTER_HCALOUT_MOD node " << endl;
143  RawClusterContainer *mod_hcalout_clusters = new RawClusterContainer();
144  PHIODataNode<PHObject> *clusterNode = new PHIODataNode<PHObject>( mod_hcalout_clusters, "CLUSTER_HCALOUT_MOD", "PHObject");
145  // --- node structure for clusters is HCALOUT -> CLUSTER_HCALOUT
146  hcaloutNode->addNode(clusterNode);
147  }
148  else
149  {
150  // --- If the new node already exists (bad) issue a warning and then do nothing
151  cout << "TreeMaker::CreateNode : CLUSTER_HCALOUT_MOD already exists! " << endl;
152  }
153 
154  // ------------
155  // --- All done
156  // ------------
157 
158  return 0;
159 
160 }