Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:21:14

0001 #include "SpinDBNode.h"
0002 
0003 #include <fun4all/Fun4AllReturnCodes.h>
0004 
0005 #include <phool/PHCompositeNode.h>
0006 #include <phool/PHIODataNode.h>
0007 #include <phool/PHNode.h>
0008 #include <phool/PHNodeIterator.h>
0009 #include <phool/PHObject.h>
0010 #include <phool/getClass.h>
0011 
0012 #include <ffaobjects/RunHeader.h>
0013 
0014 #include <fun4all/Fun4AllBase.h>
0015 #include <fun4all/SubsysReco.h>
0016 
0017 #include "SpinDBContent.h"
0018 #include "SpinDBContentv1.h"
0019 #include "SpinDBOutput.h"
0020 
0021 SpinDBNode::SpinDBNode(const std::string &name)
0022   : SubsysReco(name)
0023 {
0024 }
0025 
0026 int SpinDBNode::InitRun(PHCompositeNode *topNode)
0027 {
0028   RunHeader *runHeader = findNode::getClass<RunHeader>(topNode, "RunHeader");
0029 
0030   if (!runHeader)
0031   {
0032     std::cout << PHWHERE << ":: RunHeader node missing! Skipping run XXX" << std::endl;
0033     return Fun4AllReturnCodes::ABORTRUN;
0034   }
0035 
0036   PHNodeIterator iter(topNode);
0037 
0038   PHCompositeNode *lowerNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "RUN"));
0039   if (!lowerNode)
0040   {
0041     lowerNode = new PHCompositeNode("RUN");
0042     topNode->addNode(lowerNode);
0043   }
0044 
0045   SpinDBContent *spin_cont = findNode::getClass<SpinDBContent>(topNode, "SpinDBContent");
0046   if (!spin_cont)
0047   {
0048     int runnumber = runHeader->get_RunNumber();
0049     spin_cont = new SpinDBContentv1;
0050     SpinDBOutput spin_out("phnxrc");
0051     spin_out.StoreDBContent(runnumber, runnumber);
0052     spin_out.GetDBContentStore(spin_cont, runnumber);
0053     PHIODataNode<PHObject> *spindbcontentNode = new PHIODataNode<PHObject>(spin_cont, "SpinDBContent", "PHObject");
0054     lowerNode->addNode(spindbcontentNode);
0055   }
0056 
0057   return Fun4AllReturnCodes::EVENT_OK;
0058 }