Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:16:06

0001 #include "SyncReco.h"
0002 
0003 #include <ffaobjects/SyncDefs.h>
0004 #include <ffaobjects/SyncObject.h>
0005 #include <ffaobjects/SyncObjectv1.h>
0006 
0007 #include <fun4all/Fun4AllReturnCodes.h>
0008 #include <fun4all/Fun4AllServer.h>
0009 #include <fun4all/SubsysReco.h>  // for SubsysReco
0010 
0011 #include <phool/PHCompositeNode.h>
0012 #include <phool/PHIODataNode.h>
0013 #include <phool/PHNode.h>          // for PHNode
0014 #include <phool/PHNodeIterator.h>  // for PHNodeIterator
0015 #include <phool/PHObject.h>        // for PHObject
0016 #include <phool/getClass.h>
0017 #include <phool/phool.h>  // for PHWHERE
0018 #include <phool/recoConsts.h>
0019 
0020 #include <iostream>
0021 
0022 SyncReco::SyncReco(const std::string &name)
0023   : SubsysReco(name)
0024 {
0025   return;
0026 }
0027 
0028 int SyncReco::Init(PHCompositeNode *topNode)
0029 {
0030   int iret = CreateNodeTree(topNode);
0031   return iret;
0032 }
0033 
0034 int SyncReco::InitRun(PHCompositeNode *topNode)
0035 {
0036   SyncObject *syncobject = findNode::getClass<SyncObject>(topNode, syncdefs::SYNCNODENAME);
0037   recoConsts *rc = recoConsts::instance();
0038   syncobject->RunNumber(rc->get_IntFlag("RUNNUMBER"));
0039   return Fun4AllReturnCodes::EVENT_OK;
0040 }
0041 
0042 int SyncReco::CreateNodeTree(PHCompositeNode *topNode)
0043 {
0044   PHNodeIterator iter(topNode);
0045   PHCompositeNode *dstNode;
0046   dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
0047   if (!dstNode)
0048   {
0049     std::cout << PHWHERE << " DST Node is missing doing nothing" << std::endl;
0050     return Fun4AllReturnCodes::ABORTRUN;
0051   }
0052 
0053   SyncObject *syncobject = findNode::getClass<SyncObject>(topNode, syncdefs::SYNCNODENAME);
0054   if (!syncobject)
0055   {
0056     syncobject = new SyncObjectv1();
0057     PHIODataNode<PHObject> *SyncObjectNode = new PHIODataNode<PHObject>(syncobject, syncdefs::SYNCNODENAME, "PHObject");  // contains PHObject
0058     dstNode->addNode(SyncObjectNode);
0059   }
0060 
0061   return Fun4AllReturnCodes::EVENT_OK;
0062 }
0063 
0064 int SyncReco::process_event(PHCompositeNode *topNode)
0065 {
0066   Fun4AllServer *se = Fun4AllServer::instance();
0067   SyncObject *syncobject = findNode::getClass<SyncObject>(topNode, syncdefs::SYNCNODENAME);
0068   if (!syncobject)
0069   {
0070     std::cout << PHWHERE << " No Synchronisation Object, no parallel reading of multiple inputs" << std::endl;
0071     return Fun4AllReturnCodes::ABORTEVENT;
0072   }
0073 
0074   syncobject->EventCounter(se->EventCounter());
0075   syncobject->EventNumber(se->EventNumber());
0076   syncobject->RunNumber(se->RunNumber());
0077   if (forced_segment >= 0)
0078   {
0079     syncobject->SegmentNumber(forced_segment);
0080   }
0081   else
0082   {
0083     syncobject->SegmentNumber(se->SegmentNumber());
0084   }
0085 
0086   if (Verbosity() > 0)
0087   {
0088     syncobject->identify();
0089   }
0090   return Fun4AllReturnCodes::EVENT_OK;
0091 }