Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:15:56

0001 #include <iostream>
0002 
0003 // --- header for this clase
0004 #include <TreeMaker.h>
0005 
0006 // --- basic sPhenix environment stuff
0007 #include <fun4all/Fun4AllServer.h>
0008 #include <phool/getClass.h>
0009 #include <phool/PHCompositeNode.h>
0010 
0011 // --- jet specific stuff
0012 #include <g4jets/JetMap.h>
0013 #include <g4jets/JetMapV1.h>
0014 
0015 // --- calorimeter clusters
0016 #include <calobase/RawClusterContainer.h>
0017 
0018 using std::cout;
0019 using std::endl;
0020 
0021 
0022 
0023 int TreeMaker::CreateNode(PHCompositeNode *topNode)
0024 {
0025 
0026   cout << "TreeMaker::CreateNode called" << endl;
0027 
0028   PHNodeIterator iter(topNode);
0029 
0030   // -----------------------------
0031   // --- Make the new jet node ---
0032   // -----------------------------
0033 
0034   // --- Look for the DST node
0035   PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "DST"));
0036   if ( !dstNode )
0037     {
0038       cout << PHWHERE << "DST node not found, doing nothing." << endl;
0039       return -2;
0040     }
0041 
0042   // --- Look for the ANTIKT node
0043   PHCompositeNode *antiktNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "ANTIKT"));
0044   if ( !antiktNode )
0045     {
0046       cout << PHWHERE << "ANTIKT node not found, doing nothing." << endl;
0047       return -2;
0048     }
0049 
0050   // --- Look for the TOWER node
0051   PHCompositeNode *towerNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "TOWER"));
0052   if ( !towerNode )
0053     {
0054       cout << PHWHERE << "TOWER node not found, doing nothing." << endl;
0055       return -2;
0056     }
0057 
0058   // --- Check if the new node exists (it should not) and then store the new jet collection
0059   JetMap* check_jets = findNode::getClass<JetMap>(topNode,"AntiKt_Tower_Mod_r02");
0060   if ( !check_jets )
0061     {
0062       // --- If the new node doesn't already exist (good) then make it
0063       cout << "TreeMaker::CreateNode : creating AntiKt_Tower_Mod_r02 node " << endl;
0064       JetMap *mod_jets = new JetMapV1();
0065       PHIODataNode<PHObject> *modjetNode = new PHIODataNode<PHObject>( mod_jets, "AntiKt_Tower_Mod_r02", "PHObject");
0066       // --- node structure for jets is DST -> ANTIKT -> TOWER (or CLUSTER or TRACK or whatever) -> specific jet node
0067       towerNode->addNode(modjetNode);
0068     }
0069   else
0070     {
0071       // --- If the new node already exists (bad) issue a warning and then do nothing
0072       cout << "TreeMaker::CreateNode : AntiKt_Tower_Mod_r02 already exists! " << endl;
0073     }
0074 
0075   // --------------------------------------
0076   // --- Make the new cemc cluster node ---
0077   // --------------------------------------
0078 
0079   // --- Look for the CEMC node (main node for us)
0080   PHCompositeNode *cemcNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "CEMC"));
0081   if ( !cemcNode )
0082     {
0083       cout << PHWHERE << "CEMC node not found, doing nothing." << endl;
0084       return -2;
0085     }
0086 
0087   // --- Check if the new node exists (it should not) and then store the new cluster collection
0088   RawClusterContainer* check_cemc_clusters = findNode::getClass<RawClusterContainer>(topNode,"CLUSTER_CEMC_MOD");
0089   if ( !check_cemc_clusters )
0090     {
0091       // --- If the new node doesn't already exist (good) then make it
0092       cout << "TreeMaker::CreateNode : creating CLUSTER_CEMC_MOD node " << endl;
0093       RawClusterContainer *mod_cemc_clusters = new RawClusterContainer();
0094       PHIODataNode<PHObject> *clusterNode = new PHIODataNode<PHObject>( mod_cemc_clusters, "CLUSTER_CEMC_MOD", "PHObject");
0095       // --- node structure for clusters is CEMC -> CLUSTER_CEMC
0096       cemcNode->addNode(clusterNode);
0097     }
0098   else
0099     {
0100       // --- If the new node already exists (bad) issue a warning and then do nothing
0101       cout << "TreeMaker::CreateNode : CLUSTER_CEMC_MOD already exists! " << endl;
0102     }
0103 
0104   // --- Look for the HCALIN node (main node for us)
0105   PHCompositeNode *hcalinNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "HCALIN"));
0106   if ( !hcalinNode )
0107     {
0108       cout << PHWHERE << "HCALIN node not found, doing nothing." << endl;
0109       return -2;
0110     }
0111 
0112   // --- Check if the new node exists (it should not) and then store the new cluster collection
0113   RawClusterContainer* check_hcalin_clusters = findNode::getClass<RawClusterContainer>(topNode,"CLUSTER_HCALIN_MOD");
0114   if ( !check_hcalin_clusters )
0115     {
0116       // --- If the new node doesn't already exist (good) then make it
0117       cout << "TreeMaker::CreateNode : creating CLUSTER_HCALIN_MOD node " << endl;
0118       RawClusterContainer *mod_hcalin_clusters = new RawClusterContainer();
0119       PHIODataNode<PHObject> *clusterNode = new PHIODataNode<PHObject>( mod_hcalin_clusters, "CLUSTER_HCALIN_MOD", "PHObject");
0120       // --- node structure for clusters is HCALIN -> CLUSTER_HCALIN
0121       hcalinNode->addNode(clusterNode);
0122     }
0123   else
0124     {
0125       // --- If the new node already exists (bad) issue a warning and then do nothing
0126       cout << "TreeMaker::CreateNode : CLUSTER_HCALIN_MOD already exists! " << endl;
0127     }
0128 
0129   // --- Look for the HCALOUT node (main node for us)
0130   PHCompositeNode *hcaloutNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "HCALOUT"));
0131   if ( !hcaloutNode )
0132     {
0133       cout << PHWHERE << "HCALOUT node not found, doing nothing." << endl;
0134       return -2;
0135     }
0136 
0137   // --- Check if the new node exists (it should not) and then store the new cluster collection
0138   RawClusterContainer* check_hcalout_clusters = findNode::getClass<RawClusterContainer>(topNode,"CLUSTER_HCALOUT_MOD");
0139   if ( !check_hcalout_clusters )
0140     {
0141       // --- If the new node doesn't already exist (good) then make it
0142       cout << "TreeMaker::CreateNode : creating CLUSTER_HCALOUT_MOD node " << endl;
0143       RawClusterContainer *mod_hcalout_clusters = new RawClusterContainer();
0144       PHIODataNode<PHObject> *clusterNode = new PHIODataNode<PHObject>( mod_hcalout_clusters, "CLUSTER_HCALOUT_MOD", "PHObject");
0145       // --- node structure for clusters is HCALOUT -> CLUSTER_HCALOUT
0146       hcaloutNode->addNode(clusterNode);
0147     }
0148   else
0149     {
0150       // --- If the new node already exists (bad) issue a warning and then do nothing
0151       cout << "TreeMaker::CreateNode : CLUSTER_HCALOUT_MOD already exists! " << endl;
0152     }
0153 
0154   // ------------
0155   // --- All done
0156   // ------------
0157 
0158   return 0;
0159 
0160 }