File indexing completed on 2025-12-17 09:19:36
0001 #include "FlagHandler.h"
0002
0003 #include <ffaobjects/FlagSave.h>
0004 #include <ffaobjects/FlagSavev1.h>
0005
0006 #include <fun4all/Fun4AllReturnCodes.h>
0007 #include <fun4all/SubsysReco.h>
0008
0009 #include <phool/PHCompositeNode.h>
0010 #include <phool/PHIODataNode.h> // for PHIODataNode
0011 #include <phool/PHNode.h> // for PHNode
0012 #include <phool/PHNodeIterator.h> // for PHNodeIterator
0013 #include <phool/PHObject.h> // for PHObject
0014 #include <phool/getClass.h>
0015 #include <phool/recoConsts.h>
0016
0017
0018 FlagHandler::FlagHandler(const std::string &name)
0019 : SubsysReco(name)
0020 {
0021 }
0022
0023
0024 int FlagHandler::InitRun(PHCompositeNode *topNode)
0025 {
0026 PHNodeIterator iter(topNode);
0027 PHCompositeNode *runNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "RUN"));
0028 FlagSave *flgsv = findNode::getClass<FlagSave>(runNode, "Flags");
0029 if (!flgsv)
0030 {
0031 flgsv = new FlagSavev1();
0032 PHIODataNode<PHObject> *newNode = new PHIODataNode<PHObject>(flgsv, "Flags", "PHObject");
0033 runNode->addNode(newNode);
0034 }
0035 else
0036 {
0037 recoConsts *rc = recoConsts::instance();
0038 flgsv->PutFlagsBack(rc, false);
0039 }
0040 return Fun4AllReturnCodes::EVENT_OK;
0041 }
0042
0043
0044 int FlagHandler::End(PHCompositeNode *topNode)
0045 {
0046 UpdateRunNode(topNode);
0047 FlagSave *flagsave = findNode::getClass<FlagSave>(topNode, "Flags");
0048 if (flagsave)
0049 {
0050 flagsave->identify();
0051 }
0052 return Fun4AllReturnCodes::EVENT_OK;
0053 }
0054
0055 int FlagHandler::UpdateRunNode(PHCompositeNode *topNode)
0056 {
0057 FlagSave *flagsave = findNode::getClass<FlagSave>(topNode, "Flags");
0058 if (flagsave)
0059 {
0060 recoConsts *rc = recoConsts::instance();
0061 flagsave->FillFromPHFlag(rc, true);
0062 }
0063 return Fun4AllReturnCodes::EVENT_OK;
0064 }
0065
0066
0067 void FlagHandler::Print(const std::string & ) const
0068 {
0069 recoConsts *rc = recoConsts::instance();
0070 rc->Print();
0071 }