Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Fun4AllStreamingInputManager.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Fun4AllStreamingInputManager.cc
2 
3 #include "SingleStreamingInput.h"
4 
14 
15 #include <fun4all/Fun4AllInputManager.h> // for Fun4AllInputManager
17 #include <fun4all/Fun4AllServer.h>
19 
20 #include <ffaobjects/SyncObject.h> // for SyncObject
22 
23 #include <frog/FROG.h>
24 
25 #include <phool/PHObject.h> // for PHObject
26 #include <phool/getClass.h>
27 #include <phool/phool.h> // for PHWHERE
28 
29 #include <TSystem.h>
30 
31 #include <algorithm> // for max
32 #include <cassert>
33 #include <cstdint> // for uint64_t, uint16_t
34 #include <cstdlib>
35 #include <iostream> // for operator<<, basic_ostream, endl
36 #include <utility> // for pair
37 
39  : Fun4AllInputManager(name, dstnodename, topnodename)
40  , m_SyncObject(new SyncObjectv1())
41 {
43  m_topNode = se->topNode(TopNodeName());
44  return;
45 }
46 
48 {
49  if (IsOpen())
50  {
51  fileclose();
52  }
53  delete m_SyncObject;
54  // clear leftover event maps
55  for (auto const &mapiter : m_MvtxRawHitMap)
56  {
57  for (auto mvtxhititer : mapiter.second.MvtxRawHitVector)
58  {
59  delete mvtxhititer;
60  }
61  }
62  m_MvtxRawHitMap.clear();
63 
64  for (auto const &mapiter : m_TpcRawHitMap)
65  {
66  for (auto tpchititer : mapiter.second.TpcRawHitVector)
67  {
68  delete tpchititer;
69  }
70  }
71  m_TpcRawHitMap.clear();
72 
73  for (auto const &mapiter : m_InttRawHitMap)
74  {
75  for (auto intthititer : mapiter.second.InttRawHitVector)
76  {
77  delete intthititer;
78  }
79  }
80  m_InttRawHitMap.clear();
81 
82  for (auto iter : m_InttInputVector)
83  {
84  delete iter;
85  }
86  m_InttInputVector.clear();
87 
88  for (auto iter : m_Gl1InputVector)
89  {
90  delete iter;
91  }
92  m_Gl1InputVector.clear();
93 
94  for (auto iter : m_MicromegasInputVector)
95  {
96  delete iter;
97  }
98  m_MicromegasInputVector.clear();
99 
100  for (auto iter : m_MvtxInputVector)
101  {
102  delete iter;
103  }
104  m_MvtxInputVector.clear();
105 
106  for (auto iter : m_TpcInputVector)
107  {
108  delete iter;
109  }
110  m_TpcInputVector.clear();
111 }
112 
113 int Fun4AllStreamingInputManager::run(const int /*nevents*/)
114 {
115  int iret = 0;
116  if (m_gl1_registered_flag) // Gl1 first to get the reference
117  {
118  iret += FillGl1();
119  }
121  {
122  iret += FillIntt();
123  }
125  {
126  iret += FillMvtx();
127  }
129  {
130  iret += FillTpc();
131  }
132 
134  {
135  iret += FillMicromegas();
136  }
137 
138  // std::cout << "size m_InttRawHitMap: " << m_InttRawHitMap.size()
139  // << std::endl;
140  return iret;
141  // readagain:
142  // if (!IsOpen())
143  // {
144  // if (FileListEmpty())
145  // {
146  // if (Verbosity() > 0)
147  // {
148  // std::cout << Name() << ": No Input file open" << std::endl;
149  // }
150  // return -1;
151  // }
152  // else
153  // {
154  // if (OpenNextFile())
155  // {
156  // std::cout << Name() << ": No Input file from filelist opened" << std::endl;
157  // return -1;
158  // }
159  // }
160  // }
161  // if (Verbosity() > 3)
162  // {
163  // std::cout << "Getting Event from " << Name() << std::endl;
164  // }
165  // // Fill Event combiner
166  // unsigned int watermark = m_EventCombiner.size();
167  // if (watermark < m_LowWaterMark)
168  // {
169  // for (unsigned int i = watermark; i < m_CombinerDepth; i++)
170  // {
171  // Event *evt = m_EventIterator->getNextEvent();
172  // std::cout << "Filling combiner with event " << evt->getEvtSequence() << std::endl;
173  // m_EventCombiner.insert(std::make_pair(evt->getEvtSequence(), evt));
174  // }
175  // }
176  // // std::cout << "running event " << nevents << std::endl;
177  // PHNodeIterator iter(m_topNode);
178  // PHDataNode<Event> *EvtNode = dynamic_cast<PHDataNode<Event> *>(iter.findFirst("PHDataNode", m_EvtNodeName));
179  // if (m_SaveEvent) // if an event was pushed back, copy saved pointer and reset m_SaveEvent pointer
180  // {
181  // m_Event = m_SaveEvent;
182  // m_SaveEvent = nullptr;
183  // m_EventsThisFile--;
184  // m_EventsTotal--;
185  // }
186  // else
187  // {
188  // m_Event = m_EventCombiner.begin()->second;
189  // }
190  // EvtNode->setData(m_Event);
191  // if (!m_Event)
192  // {
193  // fileclose();
194  // goto readagain;
195  // }
196  // if (Verbosity() > 1)
197  // {
198  // std::cout << Name() << " EVT run " << m_Event->getRunNumber() << ", evt no: " << m_Event->getEvtSequence() << std::endl;
199  // }
200  // m_EventsTotal++;
201  // m_EventsThisFile++;
202  // SetRunNumber(m_Event->getRunNumber());
203  // MySyncManager()->EvtEvents(m_EventsThisFile);
204  // MySyncManager()->SegmentNumber(m_Segment);
205  // MySyncManager()->CurrentEvent(m_Event->getEvtSequence());
206  // m_SyncObject->EventCounter(m_EventsThisFile);
207  // m_SyncObject->SegmentNumber(m_Segment);
208  // m_SyncObject->RunNumber(m_Event->getRunNumber());
209  // m_SyncObject->EventNumber(m_Event->getEvtSequence());
210  // // check if the local SubsysReco discards this event
211  // if (RejectEvent() != Fun4AllReturnCodes::EVENT_OK)
212  // {
213  // ResetEvent();
214  // goto readagain;
215  // }
216  // return 0;
217 }
218 
220 {
221  return 0;
222 }
223 
225 {
226  if (what == "TPC")
227  {
228  for (auto &iter : m_TpcRawHitMap)
229  {
230  std::cout << "bco: " << std::hex << iter.first << std::dec << std::endl;
231  for (auto &itervec : iter.second.TpcRawHitVector)
232  {
233  std::cout << "hit: " << std::hex << itervec << std::dec << std::endl;
234  itervec->identify();
235  }
236  }
237  }
239  return;
240 }
241 
243 {
244  // for (auto iter : m_EvtInputVector)
245  // {
246  // iter->CleanupUsedPackets(m_CurrentBeamClock);
247  // }
248  // m_SyncObject->Reset();
249  return 0;
250 }
251 
253 {
254  return 0;
255  // PushBackEvents is supposedly pushing events back on the stack which works
256  // easily with root trees (just grab a different entry) but hard in these HepMC ASCII files.
257  // A special case is when the synchronization fails and we need to only push back a single
258  // event. In this case we save the m_Event pointer as m_SaveEvent which is used in the run method
259  // instead of getting the next event.
260  // if (i > 0)
261  // {
262  // if (i == 1 && m_Event) // check on m_Event pointer makes sure it is not done from the cmd line
263  // {
264  // m_SaveEvent = m_Event;
265  // return 0;
266  // }
267  // std::cout << PHWHERE << Name()
268  // << " Fun4AllStreamingInputManager cannot push back " << i << " events into file"
269  // << std::endl;
270  // return -1;
271  // }
272  // if (!m_EventIterator)
273  // {
274  // std::cout << PHWHERE << Name()
275  // << " no file open" << std::endl;
276  // return -1;
277  // }
278  // // Skipping events is implemented as
279  // // pushing a negative number of events on the stack, so in order to implement
280  // // the skipping of events we read -i events.
281  // int nevents = -i; // negative number of events to push back -> skip num events
282  // int errorflag = 0;
283  // while (nevents > 0 && !errorflag)
284  // {
285  // m_Event = m_EventIterator->getNextEvent();
286  // if (!m_Event)
287  // {
288  // std::cout << "Error after skipping " << i - nevents
289  // << " file exhausted?" << std::endl;
290  // errorflag = -1;
291  // fileclose();
292  // }
293  // else
294  // {
295  // if (Verbosity() > 3)
296  // {
297  // std::cout << "Skipping evt no: " << m_Event->getEvtSequence() << std::endl;
298  // }
299  // }
300  // delete m_Event;
301  // m_Event = nullptr;
302  // nevents--;
303  // }
304  // return errorflag;
305 }
306 
308 {
309  // here we copy the sync object from the current file to the
310  // location pointed to by mastersync. If mastersync is a 0 pointer
311  // the syncobject is cloned. If mastersync allready exists the content
312  // of syncobject is copied
313  if (!(*mastersync))
314  {
315  if (m_SyncObject)
316  {
317  *mastersync = dynamic_cast<SyncObject *>(m_SyncObject->CloneMe());
318  assert(*mastersync);
319  }
320  }
321  else
322  {
323  *(*mastersync) = *m_SyncObject; // copy syncobject content
324  }
326 }
327 
329 {
330  if (!mastersync)
331  {
332  std::cout << PHWHERE << Name() << " No MasterSync object, cannot perform synchronization" << std::endl;
333  std::cout << "Most likely your first file does not contain a SyncObject and the file" << std::endl;
334  std::cout << "opened by the Fun4AllDstInputManager with Name " << Name() << " has one" << std::endl;
335  std::cout << "Change your macro and use the file opened by this input manager as first input" << std::endl;
336  std::cout << "and you will be okay. Fun4All will not process the current configuration" << std::endl
337  << std::endl;
339  }
340  int iret = m_SyncObject->Different(mastersync);
341  if (iret)
342  {
343  std::cout << "big problem" << std::endl;
344  exit(1);
345  }
347 }
348 
350 {
351  std::cout << PHWHERE << " called with " << what << " , returning empty string" << std::endl;
352  return "";
353 }
354 
356 {
357  evtin->StreamingInputManager(this);
358  evtin->CreateDSTNode(m_topNode);
360  switch (system)
361  {
363  m_mvtx_registered_flag = true;
364  m_MvtxInputVector.push_back(evtin);
365  break;
367  m_intt_registered_flag = true;
368  m_InttInputVector.push_back(evtin);
369  break;
371  m_tpc_registered_flag = true;
372  m_TpcInputVector.push_back(evtin);
373  break;
376  m_MicromegasInputVector.push_back(evtin);
377  break;
379  m_gl1_registered_flag = true;
380  m_Gl1InputVector.push_back(evtin);
381  break;
382  default:
383  std::cout << "invalid subsystem flag " << system << std::endl;
384  gSystem->Exit(1);
385  exit(1);
386  }
387  if (Verbosity() > 3)
388  {
389  std::cout << "registering " << evtin->Name()
390  << " number of registered inputs: "
392  << std::endl;
393  }
394 }
395 
397 {
398  if (Verbosity() > 1)
399  {
400  std::cout << "Adding gl1 hit to bclk 0x"
401  << std::hex << bclk << std::dec << std::endl;
402  }
403  m_Gl1RawHitMap[bclk].Gl1RawHitVector.push_back(hit);
404 }
405 
407 {
408  if (Verbosity() > 1)
409  {
410  std::cout << "Adding mvtx hit to bclk 0x"
411  << std::hex << bclk << std::dec << std::endl;
412  }
413  m_MvtxRawHitMap[bclk].MvtxRawHitVector.push_back(hit);
414 }
415 
416 void Fun4AllStreamingInputManager::AddMvtxFeeId(uint64_t bclk, uint16_t feeid)
417 {
418  if (Verbosity() > 1)
419  {
420  std::cout << "Adding mvtx feeid to bclk 0x"
421  << std::hex << bclk << std::dec << std::endl;
422  }
423  m_MvtxRawHitMap[bclk].MvtxFeeIds.insert(feeid);
424 }
425 
426 void Fun4AllStreamingInputManager::AddMvtxL1TrgBco(uint64_t bclk, uint64_t lv1Bco)
427 {
428  if (Verbosity() > 1)
429  {
430  std::cout << "Adding mvtx L1Trg to bclk 0x"
431  << std::hex << bclk << std::dec << std::endl;
432  }
433  m_MvtxRawHitMap[bclk].MvtxL1TrgBco.insert(lv1Bco);
434 }
435 
437 {
438  if (Verbosity() > 1)
439  {
440  std::cout << "Adding intt hit to bclk 0x"
441  << std::hex << bclk << std::dec << std::endl;
442  }
443  m_InttRawHitMap[bclk].InttRawHitVector.push_back(hit);
444  m_InttPacketFeeBcoMap[hit->get_packetid()][hit->get_fee()] = bclk;
445 }
446 
448 {
449  if (Verbosity() > 1)
450  {
451  std::cout << "Adding micromegas hit to bclk 0x"
452  << std::hex << bclk << std::dec << std::endl;
453  }
454  m_MicromegasRawHitMap[bclk].MicromegasRawHitVector.push_back(hit);
455 }
456 
458 {
459  if (Verbosity() > 1)
460  {
461  std::cout << "Adding tpc hit to bclk 0x"
462  << std::hex << bclk << std::dec << std::endl;
463  }
464  m_TpcRawHitMap[bclk].TpcRawHitVector.push_back(hit);
465 }
466 
468 {
469  // unsigned int alldone = 0;
470  for (auto iter : m_Gl1InputVector)
471  {
472  if (Verbosity() > 0)
473  {
474  std::cout << "Fun4AllStreamingInputManager::FillGl1 - fill pool for " << iter->Name() << std::endl;
475  }
476  iter->FillPool();
477  m_RunNumber = iter->RunNumber();
479  }
480  if (m_Gl1RawHitMap.empty())
481  {
482  std::cout << "we are done" << std::endl;
483  return -1;
484  }
485  // std::cout << "stashed gl1 BCOs: " << m_Gl1RawHitMap.size() << std::endl;
486  Gl1RawHit *gl1rawhit = findNode::getClass<Gl1RawHit>(m_topNode, "GL1RAWHIT");
487  // std::cout << "before filling m_Gl1RawHitMap size: " << m_Gl1RawHitMap.size() << std::endl;
488  for (auto gl1hititer : m_Gl1RawHitMap.begin()->second.Gl1RawHitVector)
489  {
490  if (Verbosity() > 1)
491  {
492  gl1hititer->identify();
493  }
494  m_RefBCO = gl1hititer->get_bco();
495  gl1rawhit->set_bco(m_RefBCO);
496  m_RefBCO = m_RefBCO & 0xFFFFFFFFFF; // 40 bits (need to handle rollovers)
497  }
498  for (auto iter : m_Gl1InputVector)
499  {
500  iter->CleanupUsedPackets(m_Gl1RawHitMap.begin()->first);
501  }
502  m_Gl1RawHitMap.begin()->second.Gl1RawHitVector.clear();
503  m_Gl1RawHitMap.erase(m_Gl1RawHitMap.begin());
504  // std::cout << "size m_Gl1RawHitMap: " << m_Gl1RawHitMap.size()
505  // << std::endl;
506  return 0;
507 }
508 
510 {
511  int iret = FillInttPool();
512  if (iret)
513  {
514  return iret;
515  }
516  // unsigned int alldone = 0;
517  // std::cout << "stashed intt BCOs: " << m_InttRawHitMap.size() << std::endl;
518  InttRawHitContainer *inttcont = findNode::getClass<InttRawHitContainer>(m_topNode, "INTTRAWHIT");
519  // std::cout << "before filling m_InttRawHitMap size: " << m_InttRawHitMap.size() << std::endl;
520  // !m_InttRawHitMap.empty() is implicitely handled and the check is expensive
521  // FillInttPool() contains this check already and will return non zero
522  // so here m_InttRawHitMap will always contain entries
523  uint64_t select_crossings = m_intt_bco_range;
524  if (m_RefBCO > 0)
525  {
526  select_crossings += m_RefBCO;
527  }
528  else
529  {
530  select_crossings += m_InttRawHitMap.begin()->first;
531  }
532  if (Verbosity() > 2)
533  {
534  std::cout << "select INTT crossings"
535  << " from 0x" << std::hex << m_RefBCO - m_intt_negative_bco
536  << " to 0x" << select_crossings - m_intt_negative_bco
537  << " for ref BCO " << m_RefBCO
538  << std::dec << std::endl;
539  }
540  while (m_InttRawHitMap.begin()->first < m_RefBCO -m_intt_negative_bco)
541  {
542  std::cout << "Intt BCO: 0x" << std::hex << m_InttRawHitMap.begin()->first
543  << " corrected for negative offset: 0x" << m_InttRawHitMap.begin()->first + m_intt_negative_bco
544  << " smaller than GL1 BCO: 0x" << m_RefBCO
545  << " corrected for range: 0x" << select_crossings
546  << ", ditching this bco" << std::dec << std::endl;
547  for (auto iter : m_InttInputVector)
548  {
549  iter->CleanupUsedPackets(m_InttRawHitMap.begin()->first);
550  }
551  m_InttRawHitMap.begin()->second.InttRawHitVector.clear();
552  m_InttRawHitMap.erase(m_InttRawHitMap.begin());
553  iret = FillInttPool();
554  if (iret)
555  {
556  return iret;
557  }
558  }
559  while (m_InttRawHitMap.begin()->first <= select_crossings - m_intt_negative_bco )
560  {
561  for (auto intthititer : m_InttRawHitMap.begin()->second.InttRawHitVector)
562  {
563  if (Verbosity() > 1)
564  {
565  intthititer->identify();
566  }
567  inttcont->AddHit(intthititer);
568  }
569  for (auto iter : m_InttInputVector)
570  {
571  iter->CleanupUsedPackets(m_InttRawHitMap.begin()->first);
572  }
573  m_InttRawHitMap.begin()->second.InttRawHitVector.clear();
574  m_InttRawHitMap.erase(m_InttRawHitMap.begin());
575  if (m_InttRawHitMap.empty())
576  {
577  break;
578  }
579  }
580  return 0;
581 }
582 
584 {
585  int iret = FillMvtxPool();
586  if (iret)
587  {
588  return iret;
589  }
590  MvtxRawEvtHeader *mvtxEvtHeader = findNode::getClass<MvtxRawEvtHeader>(m_topNode, "MVTXRAWEVTHEADER");
591  if (!mvtxEvtHeader)
592  {
593  std::cout << "ERROR: MVTXRAWEVTHEADER node not found, exit. " << std::endl;
594  gSystem->Exit(1);
595  exit(1);
596  }
597 
598  MvtxRawHitContainer *mvtxcont = findNode::getClass<MvtxRawHitContainer>(m_topNode, "MVTXRAWHIT");
599  if (!mvtxcont)
600  {
601  std::cout << "ERROR: MVTXRAWHIT node not found, exit. " << std::endl;
602  gSystem->Exit(1);
603  exit(1);
604  }
605  // std::cout << "before filling m_MvtxRawHitMap size: " << m_MvtxRawHitMap.size() << std::endl;
606  uint64_t select_crossings = m_mvtx_bco_range;
607  if (m_RefBCO > 0)
608  {
609  select_crossings += m_RefBCO;
610  }
611  else
612  {
613  select_crossings += m_MvtxRawHitMap.begin()->first;
614  }
615  if (Verbosity() > 2)
616  {
617  std::cout << "select MVTX crossings"
618  << " from 0x" << std::hex << m_RefBCO - m_mvtx_bco_range
619  << " to 0x" << select_crossings - m_mvtx_bco_range
620  << std::dec << std::endl;
621  }
622  // m_MvtxRawHitMap.empty() does not need to be checked here, FillMvtxPool returns non zero
623  // if this map is empty which is handled above
624  while (m_MvtxRawHitMap.begin()->first < m_RefBCO - m_mvtx_bco_range)
625  {
626  if (Verbosity() > 2)
627  {
628  std::cout << "ditching mvtx bco 0x" << std::hex << m_MvtxRawHitMap.begin()->first << ", ref: 0x" << m_RefBCO << std::dec << std::endl;
629  }
630  for (auto iter : m_MvtxInputVector)
631  {
632  iter->CleanupUsedPackets(m_MvtxRawHitMap.begin()->first);
633  }
634  m_MvtxRawHitMap.begin()->second.MvtxRawHitVector.clear();
635  m_MvtxRawHitMap.erase(m_MvtxRawHitMap.begin());
636  iret = FillMvtxPool();
637  if (iret)
638  {
639  return iret;
640  }
641  }
642  // again m_MvtxRawHitMap.empty() is handled by return of FillMvtxPool()
643  if (Verbosity() > 2)
644  {
645  std::cout << "after ditching, mvtx bco: 0x" << std::hex << m_MvtxRawHitMap.begin()->first << ", ref: 0x" << m_RefBCO
646  << std::dec << std::endl;
647  }
648  auto mvtxRawHitInfoIt = m_MvtxRawHitMap.begin();
649 
650  mvtxEvtHeader->AddFeeId(mvtxRawHitInfoIt->second.MvtxFeeIds);
651  mvtxEvtHeader->AddL1Trg(mvtxRawHitInfoIt->second.MvtxL1TrgBco);
652  while (m_MvtxRawHitMap.begin()->first <= select_crossings - m_mvtx_bco_range)
653  {
654  if (Verbosity() > 2)
655  {
656  std::cout << "Adding 0x" << std::hex << m_MvtxRawHitMap.begin()->first
657  << " ref: 0x" << select_crossings << std::dec << std::endl;
658  }
659  for (auto mvtxhititer : m_MvtxRawHitMap.begin()->second.MvtxRawHitVector)
660  {
661  if (Verbosity() > 1)
662  {
663  mvtxhititer->identify();
664  }
665  mvtxcont->AddHit(mvtxhititer);
666  }
667  for (auto iter : m_MvtxInputVector)
668  {
669  iter->CleanupUsedPackets(m_MvtxRawHitMap.begin()->first);
670  }
671  m_MvtxRawHitMap.begin()->second.MvtxRawHitVector.clear();
672  m_MvtxRawHitMap.erase(m_MvtxRawHitMap.begin());
673  // m_MvtxRawHitMap.empty() need to be checked here since we do not call FillPoolMvtx()
674  if (m_MvtxRawHitMap.empty())
675  {
676  break;
677  }
678  }
679 
680  return 0;
681 }
682 
683 //_______________________________________________________
685 {
686  int iret = FillMicromegasPool();
687  if (iret)
688  {
689  return iret;
690  }
691 
692  auto container = findNode::getClass<MicromegasRawHitContainer>(m_topNode, "MICROMEGASRAWHIT");
693  uint64_t select_crossings = m_micromegas_bco_range;
694  if (m_RefBCO > 0)
695  {
696  select_crossings += m_RefBCO;
697  }
698  else
699  {
700  select_crossings += m_MicromegasRawHitMap.begin()->first;
701  }
702  if (Verbosity() > 2)
703  {
704  std::cout << "select MicroMegas crossings"
705  << " from 0x" << std::hex << m_RefBCO - m_micromegas_bco_range
706  << " to 0x" << select_crossings - m_micromegas_bco_range
707  << " for ref BCO " << m_RefBCO
708  << std::dec << std::endl;
709  }
710 
711  // m_MicromegasRawHitMap.empty() does not need to be checked here, FillMicromegasPool returns non zero
712  // if this map is empty which is handled above
713  while (m_MicromegasRawHitMap.begin()->first < m_RefBCO - m_micromegas_negative_bco)
714  {
715  std::cout << "Micromegas BCO: 0x" << std::hex << m_MicromegasRawHitMap.begin()->first
716  << " smaller than GL1 BCO: 0x" << m_RefBCO
717  << ", ditching this bco" << std::dec << std::endl;
718  for (auto iter : m_MicromegasInputVector)
719  {
720  iter->CleanupUsedPackets(m_MicromegasRawHitMap.begin()->first);
721  }
722  m_MicromegasRawHitMap.begin()->second.MicromegasRawHitVector.clear();
724  iret = FillMicromegasPool();
725  if (iret)
726  {
727  return iret;
728  }
729  }
730 
731  while ((m_MicromegasRawHitMap.begin()->first) <= select_crossings - m_micromegas_negative_bco)
732  {
733  for (const auto &hititer : m_MicromegasRawHitMap.begin()->second.MicromegasRawHitVector)
734  {
735  container->AddHit(hititer);
736  }
737 
738  for (const auto &iter : m_MicromegasInputVector)
739  {
740  iter->CleanupUsedPackets(m_MicromegasRawHitMap.begin()->first);
741  }
742 
743  m_MicromegasRawHitMap.begin()->second.MicromegasRawHitVector.clear();
745  if (m_MicromegasRawHitMap.empty())
746  {
747  break;
748  }
749  }
750 
751  return 0;
752 }
753 
755 {
756  int iret = FillTpcPool();
757  if (iret)
758  {
759  return iret;
760  }
761  TpcRawHitContainer *tpccont = findNode::getClass<TpcRawHitContainer>(m_topNode, "TPCRAWHIT");
762  // std::cout << "before filling m_TpcRawHitMap size: " << m_TpcRawHitMap.size() << std::endl;
763  uint64_t select_crossings = m_tpc_bco_range;
764  if (m_RefBCO > 0)
765  {
766  select_crossings += m_RefBCO;
767  }
768  else
769  {
770  select_crossings += m_TpcRawHitMap.begin()->first;
771  }
772  if (Verbosity() > 2)
773  {
774  std::cout << "select TPC crossings"
775  << " from 0x" << std::hex << m_RefBCO - m_tpc_negative_bco
776  << " to 0x" << select_crossings - m_tpc_negative_bco
777  << std::dec << std::endl;
778  }
779  // m_TpcRawHitMap.empty() does not need to be checked here, FillTpcPool returns non zero
780  // if this map is empty which is handled above
781  while (m_TpcRawHitMap.begin()->first < m_RefBCO - m_tpc_negative_bco)
782  {
783  for (auto iter : m_TpcInputVector)
784  {
785  iter->CleanupUsedPackets(m_TpcRawHitMap.begin()->first);
786  }
787  m_TpcRawHitMap.begin()->second.TpcRawHitVector.clear();
788  m_TpcRawHitMap.erase(m_TpcRawHitMap.begin());
789  iret = FillTpcPool();
790  if (iret)
791  {
792  return iret;
793  }
794  }
795  // again m_TpcRawHitMap.empty() is handled by return of FillTpcPool()
796  while (m_TpcRawHitMap.begin()->first <= select_crossings - m_tpc_negative_bco)
797  {
798  for (auto tpchititer : m_TpcRawHitMap.begin()->second.TpcRawHitVector)
799  {
800  if (Verbosity() > 1)
801  {
802  tpchititer->identify();
803  }
804  tpccont->AddHit(tpchititer);
805  }
806  for (auto iter : m_TpcInputVector)
807  {
808  iter->CleanupUsedPackets(m_TpcRawHitMap.begin()->first);
809  }
810  m_TpcRawHitMap.begin()->second.TpcRawHitVector.clear();
811  m_TpcRawHitMap.erase(m_TpcRawHitMap.begin());
812  if (m_TpcRawHitMap.empty())
813  {
814  break;
815  }
816  }
817  // std::cout << "size m_TpcRawHitMap: " << m_TpcRawHitMap.size()
818  // << std::endl;
819  return 0;
820 }
821 
823 {
824  m_intt_bco_range = std::max(i, m_intt_bco_range);
825 }
826 
828 {
830 }
831 
833 {
835 }
836 
838 {
840 }
841 
843 {
845 }
846 
848 {
849  m_tpc_bco_range = std::max(i, m_tpc_bco_range);
850 }
851 
853 {
854  m_tpc_negative_bco = std::max(i, m_tpc_negative_bco);
855 }
856 
858 {
859  m_mvtx_bco_range = std::max(i, m_mvtx_bco_range);
860 }
861 
863 {
864  for (auto iter : m_InttInputVector)
865  {
866  if (Verbosity() > 0)
867  {
868  std::cout << "Fun4AllStreamingInputManager::FillInttPool - fill pool for " << iter->Name() << std::endl;
869  }
870  iter->FillPool();
871  m_RunNumber = iter->RunNumber();
873  }
874  if (m_InttRawHitMap.empty())
875  {
876  std::cout << "we are done" << std::endl;
877  return -1;
878  }
879  return 0;
880 }
881 
883 {
884  for (auto iter : m_TpcInputVector)
885  {
886  if (Verbosity() > 0)
887  {
888  std::cout << "Fun4AllStreamingInputManager::FillTpcPool - fill pool for " << iter->Name() << std::endl;
889  }
890  iter->FillPool();
891  m_RunNumber = iter->RunNumber();
893  }
894  if (m_TpcRawHitMap.empty())
895  {
896  std::cout << "we are done" << std::endl;
897  return -1;
898  }
899  return 0;
900 }
901 
903 {
904  for (auto iter : m_MicromegasInputVector)
905  {
906  if (Verbosity() > 0)
907  {
908  std::cout << "Fun4AllStreamingInputManager::FillMicromegasPool - fill pool for " << iter->Name() << std::endl;
909  }
910  iter->FillPool();
911  m_RunNumber = iter->RunNumber();
913  }
914  if (m_MicromegasRawHitMap.empty())
915  {
916  std::cout << "Micromegas are done" << std::endl;
917  return -1;
918  }
919  return 0;
920 }
921 
923 {
924  for (auto iter : m_MvtxInputVector)
925  {
926  if (Verbosity() > 3)
927  {
928  std::cout << "Fun4AllStreamingInputManager::FillMvtxPool - fill pool for " << iter->Name() << std::endl;
929  }
930  iter->FillPool();
931  m_RunNumber = iter->RunNumber();
933  }
934  if (m_MvtxRawHitMap.empty())
935  {
936  std::cout << "we are done" << std::endl;
937  return -1;
938  }
939  return 0;
940 }