Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EventNumberCheck.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EventNumberCheck.cc
1 #include "EventNumberCheck.h"
2 
6 #include <fun4all/SubsysReco.h> // for SubsysReco
7 
9 #include <phool/PHDataNode.h>
10 #include <phool/PHNode.h> // for PHNode
11 #include <phool/PHNodeIterator.h> // for PHNodeIterator
12 #include <phool/getClass.h>
13 
14 #include <Event/Event.h>
15 #include <Event/oncsEvent.h>
16 
17 #include <TSystem.h>
18 
19 #include <iostream> // for operator<<, endl, basic_ost...
20 #include <utility> // for pair
21 #include <vector> // for vector
22 
23 //____________________________________________________________________________..
25  : SubsysReco(name)
26 {
27 }
28 
29 //____________________________________________________________________________..
31 {
33 }
34 
35 //____________________________________________________________________________..
37 {
39  Event *evt = findNode::getClass<Event>(topNode,m_MyPrdfNode);
40  evt->identify();
41  int eventno = evt->getEvtSequence();
42  int nw = evt->getPacketList(plist, 10000);
43  if (nw >= 10000)
44  {
45  std::cout << "Packet array too small, need " << nw << " entries" << std::endl;
47  }
48  auto insert_chk = m_EventSeen.insert(eventno);
49  if (! insert_chk.second)
50  {
51  std::cout << "event " << eventno << " exists already"
52  << " counter: " << se->EventNumber() << std::endl;
53  }
55 }
56 
58 {
59  std::set<int> femclkcemc, clkcemc;
60  std::set<int> femclkmbd, clkmbd;
61  static int ifirst = 1;
62  for (int i=0; i<nw; i++)
63  {
64  int pktid = plist[i]->getIdentifier();
65  if (pktid > 2000)
66  {
67  clkcemc.insert(plist[i]->iValue(0, "CLOCK"));
68  }
69  else
70  {
71  clkmbd.insert(plist[i]->iValue(0, "CLOCK"));
72  }
73  if (Verbosity() > 1)
74  {
75  std::cout << "packet " << plist[i]->getIdentifier() << ", evt nr "
76  << plist[i]->iValue(0, "EVTNR") << ", bclk 0x" << std::hex
77  << plist[i]->iValue(0, "CLOCK") << std::dec << std::endl;
78  }
79  for ( int j = 0; j < plist[i]->iValue(0,"NRMODULES"); j++)
80  {
81  if (Verbosity() > 1)
82  {
83  std::cout << "FEM " << j << ", Clock 0x" << std::hex
84  << plist[i]->iValue(j,"FEMCLOCK") << std::dec << std::endl;
85  }
86  if (pktid > 2000)
87  {
88  femclkcemc.insert(plist[i]->iValue(j,"FEMCLOCK"));
89  }
90  else
91  {
92  femclkmbd.insert(plist[i]->iValue(j,"FEMCLOCK"));
93  }
94 
95  }
96  delete plist[i];
97  }
98  if (femclkcemc.size() > 1)
99  {
100  std::cout << "CEMC FEM clock mismatch, saw " << std::hex << std::endl;
101  for (auto iter : femclkcemc)
102  {
103  std::cout << iter << std::endl;
104  }
105  std::cout << std::dec;
106  }
107  if (femclkmbd.size() > 1)
108  {
109  std::cout << "MBD FEM clock mismatch, saw " << std::hex << std::endl;
110  for (auto iter : femclkmbd)
111  {
112  std::cout << iter << std::endl;
113  }
114  std::cout << std::dec;
115  }
116  if (clkcemc.size() > 1)
117  {
118  std::cout << "CEMC Packet clock mismatch, saw " << std::hex << std::endl;
119  for (auto iter : clkcemc)
120  {
121  std::cout << iter << std::endl;
122  }
123  std::cout << std::dec;
124  }
125  if (clkmbd.size() > 1)
126  {
127  std::cout << "MBD Packet clock mismatch, saw " << std::hex << std::endl;
128  for (auto iter : clkmbd)
129  {
130  std::cout << iter << std::endl;
131  }
132  std::cout << std::dec;
133  }
134 
135  int femclockcemc = *(clkcemc.begin());
136  int femclockmbd = *(clkmbd.begin());
137  if (previous_event_clkdiff != femclockcemc - femclockmbd)
138  {
139  if (ifirst)
140  {
141  ifirst = 0;
142  }
143  else
144  {
145  std::cout << "clock diff changed at event " //<< eventno
146  << " from " << previous_event_clkdiff << " to "
147  << femclockcemc - femclockmbd << std::endl;
148  }
149  previous_event_clkdiff = femclockcemc - femclockmbd;
150  }
151  return;
152 }