File indexing completed on 2025-08-05 08:13:08
0001 #include <EventCheck.h>
0002
0003 #include <cmath>
0004 #include <iomanip>
0005 #include <iostream>
0006 #include <sstream>
0007 #include <algorithm>
0008
0009 #include <ffaobjects/EventHeader.h>
0010 #include <fun4all/Fun4AllServer.h>
0011
0012 #include <fun4all/Fun4AllReturnCodes.h>
0013
0014 #include <globalvertex/GlobalVertex.h>
0015 #include <globalvertex/GlobalVertexMap.h>
0016
0017 #include <phool/PHCompositeNode.h>
0018 #include <phool/getClass.h>
0019
0020 #include <calotrigger/TriggerRunInfo.h>
0021
0022 using std::cout;
0023 using std::endl;
0024 using std::to_string;
0025 using std::stringstream;
0026 using std::make_pair;
0027
0028
0029 EventCheck::EventCheck()
0030 : SubsysReco("EventCheck")
0031 , m_triggerBit(17)
0032 , m_zvtx_max(30)
0033 , m_doSpecificEvents(false)
0034 {
0035 cout << "EventCheck::EventCheck(const std::string &name) Calling ctor" << endl;
0036 }
0037
0038
0039 EventCheck::~EventCheck()
0040 {
0041 cout << "EventCheck::~EventCheck() Calling dtor" << endl;
0042 }
0043
0044
0045 Int_t EventCheck::Init(PHCompositeNode *topNode)
0046 {
0047 cout << "EventCheck::Init(PHCompositeNode *topNode) Initializing" << endl;
0048
0049 m_triggeranalyzer = new TriggerAnalyzer();
0050
0051 return Fun4AllReturnCodes::EVENT_OK;
0052 }
0053
0054
0055 Int_t EventCheck::process_event(PHCompositeNode *topNode)
0056 {
0057 EventHeader* eventInfo = findNode::getClass<EventHeader>(topNode,"EventHeader");
0058 if(!eventInfo)
0059 {
0060 cout << PHWHERE << "EventValidation::process_event - Fatal Error - EventHeader node is missing. " << endl;
0061 return Fun4AllReturnCodes::ABORTEVENT;
0062 }
0063
0064 int m_globalEvent = eventInfo->get_EvtSequence();
0065 int m_run = eventInfo->get_RunNumber();
0066
0067 if (m_doSpecificEvents && std::find(m_eventList_vec.begin(), m_eventList_vec.end(), make_pair(m_run,m_globalEvent)) == m_eventList_vec.end()) {
0068 return Fun4AllReturnCodes::ABORTEVENT;
0069 }
0070 else if(m_doSpecificEvents) {
0071 cout << "Event Found! Run: " << m_run << ", Event: " << m_globalEvent << endl;
0072 }
0073
0074 TriggerRunInfo* triggerruninfo = findNode::getClass<TriggerRunInfo>(topNode, "TriggerRunInfo");
0075 if (!triggerruninfo) {
0076 cout << "EventCheck::process_event - Error can not find TriggerRunInfo node " << endl;
0077 return Fun4AllReturnCodes::ABORTRUN;
0078 }
0079
0080
0081 float m_zvtx = -9999;
0082 GlobalVertexMap* vertexmap = findNode::getClass<GlobalVertexMap>(topNode, "GlobalVertexMap");
0083
0084 if (!vertexmap) {
0085 cout << "EventCheck::process_event - Error can not find global vertex node " << endl;
0086 return Fun4AllReturnCodes::ABORTRUN;
0087 }
0088
0089 if(!vertexmap->empty()) {
0090 GlobalVertex* vtx = vertexmap->begin()->second;
0091 m_zvtx = vtx->get_z();
0092 }
0093
0094
0095 if(!m_doSpecificEvents && fabs(m_zvtx) >= m_zvtx_max) {
0096 return Fun4AllReturnCodes::ABORTEVENT;
0097 }
0098
0099 m_triggeranalyzer->decodeTriggers(topNode);
0100
0101
0102 if(!m_doSpecificEvents && !m_triggeranalyzer->didTriggerFire(m_triggerBit)) {
0103 return Fun4AllReturnCodes::ABORTEVENT;
0104 }
0105
0106 return Fun4AllReturnCodes::EVENT_OK;
0107 }
0108
0109
0110 Int_t EventCheck::ResetEvent(PHCompositeNode *topNode)
0111 {
0112 return Fun4AllReturnCodes::EVENT_OK;
0113 }
0114
0115
0116 Int_t EventCheck::End(PHCompositeNode *topNode)
0117 {
0118 cout << "EventCheck::End(PHCompositeNode *topNode) This is the End..." << endl;
0119 return Fun4AllReturnCodes::EVENT_OK;
0120 }
0121