Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHNodeDump.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHNodeDump.cc
1 #include "PHNodeDump.h"
2 #include "DumpObject.h"
3 
5 #include "DumpBbcVertexMap.h"
6 #include "DumpCaloTriggerInfo.h"
7 #include "DumpCdbUrlSave.h"
8 #include "DumpCentralityInfo.h"
9 #include "DumpEpdGeom.h"
10 #include "DumpEventHeader.h"
11 #include "DumpFlagSave.h"
12 #include "DumpGl1RawHit.h"
13 #include "DumpGlobalVertexMap.h"
14 #include "DumpInttDeadMap.h"
16 #include "DumpJetMap.h"
17 #include "DumpJetContainer.h"
18 #include "DumpMbdGeom.h"
19 #include "DumpMbdOut.h"
20 #include "DumpMbdPmtContainer.h"
21 #include "DumpMbdVertexMap.h"
23 #include "DumpMvtxRawEvtHeader.h"
25 #include "DumpPHFieldConfig.h"
28 #include "DumpPHG4CellContainer.h"
32 #include "DumpPHG4HitContainer.h"
33 #include "DumpPHG4InEvent.h"
38 #include "DumpPHGenIntegral.h"
39 #include "DumpPHHepMCGenEventMap.h"
41 #include "DumpPdbParameterMap.h"
44 #include "DumpRawTowerContainer.h"
46 #include "DumpRunHeader.h"
48 #include "DumpSvtxTrackMap.h"
49 #include "DumpSvtxVertexMap.h"
50 #include "DumpSyncObject.h"
51 #include "DumpTowerBackground.h"
52 #include "DumpTowerInfoContainer.h"
53 #include "DumpTpcRawHitContainer.h"
54 #include "DumpTpcSeedTrackMap.h"
55 #include "DumpTrackSeedContainer.h"
60 #include "DumpTrkrHitTruthAssoc.h"
61 #include "DumpVariableArray.h"
62 
63 #include <ffaobjects/EventHeader.h>
64 #include <ffaobjects/RunHeader.h>
65 
66 #include <phool/PHIODataNode.h>
67 #include <phool/PHNode.h>
68 #include <phool/getClass.h>
69 #include <phool/phool.h>
70 
71 #include <TObject.h>
72 
73 #include <iostream>
74 #include <string>
75 #include <utility>
76 
78 {
79  ignore.clear();
80  exclusive.clear();
81  while (dumpthis.begin() != dumpthis.end())
82  {
83  delete dumpthis.begin()->second;
84  dumpthis.erase(dumpthis.begin());
85  }
86  return;
87 }
88 
90 {
91  if (ignore.find(name) != ignore.end())
92  {
93  std::cout << PHWHERE << " "
94  << name << "already in ignore list" << std::endl;
95  return -1;
96  }
97  ignore.insert(name);
98  return 0;
99 }
100 
102 {
103  if (exclusive.find(name) != exclusive.end())
104  {
105  std::cout << PHWHERE << " "
106  << name << "already in exclusive list" << std::endl;
107  return -1;
108  }
109  exclusive.insert(name);
110  return 0;
111 }
112 
114 {
115  RunHeader *runheader = findNode::getClass<RunHeader>(topNode, "RunHeader");
116  if (runheader)
117  {
118  runnumber = runheader->get_RunNumber();
119  }
120  EventHeader *eventheader = findNode::getClass<EventHeader>(topNode, "EventHeader");
121  if (eventheader)
122  {
123  evtsequence = eventheader->get_EvtSequence();
124  }
125  return 0;
126 }
127 
129 {
130  std::map<std::string, DumpObject *>::iterator iter;
131  if (node->getType() == "PHIODataNode")
132  {
133  std::string NodeName = node->getName();
134  iter = dumpthis.find(NodeName);
135  if (iter == dumpthis.end())
136  {
137  std::cout << "Adding Dump Object for " << NodeName << std::endl;
138  AddDumpObject(NodeName, node);
139  iter = dumpthis.find(NodeName); // update iterator
140  }
141 
142  if (iter != dumpthis.end())
143  {
144  iter->second->process_event(node);
145  }
146  else
147  {
148  // for (iter = dumpthis.begin(); iter != dumpthis.end(); iter++)
149  // {
150  // std::cout << "registered: " << iter->second->Name() << std::endl;
151  // }
152  std::cout << "Something went wrong with adding Dump Object for " << NodeName
153  << ", it should exist !! Trying to create it again" << std::endl;
154  AddDumpObject(NodeName, node);
155  }
156  }
157  return;
158 }
159 
161 {
162  std::map<std::string, DumpObject *>::iterator iter;
163  for (iter = dumpthis.begin(); iter != dumpthis.end(); ++iter)
164  {
165  iter->second->CloseOutputFile();
166  }
167  return 0;
168 }
169 
171 {
172  DumpObject *newdump;
173  if (!exclusive.empty())
174  {
175  if (exclusive.find(NodeName) == exclusive.end())
176  {
177  std::cout << "Exclusive find: Ignoring " << NodeName << std::endl;
178  newdump = new DumpObject(NodeName);
179  newdump->NoOutput();
180  return initdump(NodeName, newdump);
181  }
182  }
183  if (ignore.find(NodeName) != ignore.end())
184  {
185  std::cout << "Ignoring " << NodeName << std::endl;
186  newdump = new DumpObject(NodeName);
187  newdump->NoOutput();
188  }
189  else
190  {
191  if (node->getType() == "PHIODataNode")
192  {
193  // need a static cast since only from DST these guys are of type PHIODataNode<TObject*>
194  // when created they are normally PHIODataNode<PHObject*> but can be anything else as well
195  TObject *tmp = static_cast<TObject *>((static_cast<PHIODataNode<TObject> *>(node))->getData());
196  if (tmp->InheritsFrom("BbcPmtInfoContainerV1"))
197  {
198  newdump = new DumpBbcPmtInfoContainer(NodeName);
199  }
200  else if (tmp->InheritsFrom("BbcVertexMap"))
201  {
202  newdump = new DumpBbcVertexMap(NodeName);
203  }
204  else if (tmp->InheritsFrom("CaloTriggerInfo"))
205  {
206  newdump = new DumpCaloTriggerInfo(NodeName);
207  }
208  else if (tmp->InheritsFrom("CdbUrlSave"))
209  {
210  newdump = new DumpCdbUrlSave(NodeName);
211  }
212  else if (tmp->InheritsFrom("CentralityInfo"))
213  {
214  newdump = new DumpCentralityInfo(NodeName);
215  }
216  else if (tmp->InheritsFrom("EpdGeom"))
217  {
218  newdump = new DumpEpdGeom(NodeName);
219  }
220  else if (tmp->InheritsFrom("EventHeader"))
221  {
222  newdump = new DumpEventHeader(NodeName);
223  }
224  else if (tmp->InheritsFrom("FlagSave"))
225  {
226  newdump = new DumpFlagSave(NodeName);
227  }
228  else if (tmp->InheritsFrom("Gl1RawHit"))
229  {
230  newdump = new DumpGl1RawHit(NodeName);
231  }
232  else if (tmp->InheritsFrom("GlobalVertexMap"))
233  {
234  newdump = new DumpGlobalVertexMap(NodeName);
235  }
236  else if (tmp->InheritsFrom("InttDeadMap"))
237  {
238  newdump = new DumpInttDeadMap(NodeName);
239  }
240  else if (tmp->InheritsFrom("InttRawHitContainer"))
241  {
242  newdump = new DumpInttRawHitContainer(NodeName);
243  }
244  else if (tmp->InheritsFrom("JetMap"))
245  {
246  newdump = new DumpJetMap(NodeName);
247  }
248  else if (tmp->InheritsFrom("JetContainer"))
249  {
250  newdump = new DumpJetContainer(NodeName);
251  }
252  else if (tmp->InheritsFrom("MbdGeom"))
253  {
254  newdump = new DumpMbdGeom(NodeName);
255  }
256  else if (tmp->InheritsFrom("MbdOut"))
257  {
258  newdump = new DumpMbdOut(NodeName);
259  }
260  else if (tmp->InheritsFrom("MbdPmtContainer"))
261  {
262  newdump = new DumpMbdPmtContainer(NodeName);
263  }
264  else if (tmp->InheritsFrom("MbdVertexMap"))
265  {
266  newdump = new DumpMbdVertexMap(NodeName);
267  }
268  else if (tmp->InheritsFrom("MicromegasRawHitContainer"))
269  {
270  newdump = new DumpMicromegasRawHitContainer(NodeName);
271  }
272  else if (tmp->InheritsFrom("MvtxRawEvtHeader"))
273  {
274  newdump = new DumpMvtxRawEvtHeader(NodeName);
275  }
276  else if (tmp->InheritsFrom("MvtxRawHitContainer"))
277  {
278  newdump = new DumpMvtxRawHitContainer(NodeName);
279  }
280  else if (tmp->InheritsFrom("ParticleFlowElementContainer"))
281  {
282  newdump = new DumpParticleFlowElementContainer(NodeName);
283  }
284  else if (tmp->InheritsFrom("PdbParameterMap"))
285  {
286  newdump = new DumpPdbParameterMap(NodeName);
287  }
288  else if (tmp->InheritsFrom("PdbParameterMapContainer"))
289  {
290  newdump = new DumpPdbParameterMapContainer(NodeName);
291  }
292  else if (tmp->InheritsFrom("PHFieldConfig"))
293  {
294  newdump = new DumpPHFieldConfig(NodeName);
295  }
296  else if (tmp->InheritsFrom("PHG4BlockGeomContainer"))
297  {
298  newdump = new DumpPHG4BlockGeomContainer(NodeName);
299  }
300  else if (tmp->InheritsFrom("PHG4BlockCellGeomContainer"))
301  {
302  newdump = new DumpPHG4BlockCellGeomContainer(NodeName);
303  }
304  else if (tmp->InheritsFrom("PHG4CellContainer"))
305  {
306  newdump = new DumpPHG4CellContainer(NodeName);
307  }
308  else if (tmp->InheritsFrom("PHG4CylinderCellContainer"))
309  {
310  newdump = new DumpPHG4CylinderCellContainer(NodeName);
311  }
312  else if (tmp->InheritsFrom("PHG4CylinderGeomContainer"))
313  {
314  newdump = new DumpPHG4CylinderGeomContainer(NodeName);
315  }
316  else if (tmp->InheritsFrom("PHG4CylinderCellGeomContainer"))
317  {
318  newdump = new DumpPHG4CylinderCellGeomContainer(NodeName);
319  }
320  else if (tmp->InheritsFrom("PHG4HitContainer"))
321  {
322  newdump = new DumpPHG4HitContainer(NodeName);
323  }
324  else if (tmp->InheritsFrom("PHG4InEvent"))
325  {
326  newdump = new DumpPHG4InEvent(NodeName);
327  }
328  else if (tmp->InheritsFrom("PHG4ParticleSvtxMap"))
329  {
330  newdump = new DumpPHG4ParticleSvtxMap(NodeName);
331  }
332  else if (tmp->InheritsFrom("PHG4ScintillatorSlatContainer"))
333  {
334  newdump = new DumpPHG4ScintillatorSlatContainer(NodeName);
335  }
336  else if (tmp->InheritsFrom("PHG4TpcCylinderGeomContainer"))
337  {
338  newdump = new DumpPHG4TpcCylinderGeomContainer(NodeName);
339  }
340  else if (tmp->InheritsFrom("PHG4TruthInfoContainer"))
341  {
342  newdump = new DumpPHG4TruthInfoContainer(NodeName);
343  }
344  else if (tmp->InheritsFrom("PHGenIntegral"))
345  {
346  newdump = new DumpPHGenIntegral(NodeName);
347  }
348  else if (tmp->InheritsFrom("PHHepMCGenEventMap"))
349  {
350  newdump = new DumpPHHepMCGenEventMap(NodeName);
351  }
352  else if (tmp->InheritsFrom("RawClusterContainer"))
353  {
354  newdump = new DumpRawClusterContainer(NodeName);
355  }
356  else if (tmp->InheritsFrom("RawTowerContainer"))
357  {
358  newdump = new DumpRawTowerContainer(NodeName);
359  }
360  else if (tmp->InheritsFrom("RawTowerGeomContainer"))
361  {
362  newdump = new DumpRawTowerGeomContainer(NodeName);
363  }
364  else if (tmp->InheritsFrom("RunHeader"))
365  {
366  newdump = new DumpRunHeader(NodeName);
367  }
368  else if (tmp->InheritsFrom("SvtxPHG4ParticleMap"))
369  {
370  newdump = new DumpSvtxPHG4ParticleMap(NodeName);
371  }
372  else if (tmp->InheritsFrom("SvtxTrackMap"))
373  {
374  newdump = new DumpSvtxTrackMap(NodeName);
375  }
376  else if (tmp->InheritsFrom("SvtxVertexMap"))
377  {
378  newdump = new DumpSvtxVertexMap(NodeName);
379  }
380  else if (tmp->InheritsFrom("SyncObject"))
381  {
382  newdump = new DumpSyncObject(NodeName);
383  }
384  else if (tmp->InheritsFrom("TowerBackground"))
385  {
386  newdump = new DumpTowerBackground(NodeName);
387  }
388  else if (tmp->InheritsFrom("TowerInfoContainer"))
389  {
390  newdump = new DumpTowerInfoContainer(NodeName);
391  }
392  else if (tmp->InheritsFrom("TpcRawHitContainer"))
393  {
394  newdump = new DumpTpcRawHitContainer(NodeName);
395  }
396  else if (tmp->InheritsFrom("TpcSeedTrackMap"))
397  {
398  newdump = new DumpTpcSeedTrackMap(NodeName);
399  }
400  else if (tmp->InheritsFrom("TrackSeedContainer"))
401  {
402  newdump = new DumpTrackSeedContainer(NodeName);
403  }
404  else if (tmp->InheritsFrom("TrkrClusterContainer"))
405  {
406  newdump = new DumpTrkrClusterContainer(NodeName);
407  }
408  else if (tmp->InheritsFrom("TrkrClusterCrossingAssoc"))
409  {
410  newdump = new DumpTrkrClusterCrossingAssoc(NodeName);
411  }
412  else if (tmp->InheritsFrom("TrkrClusterHitAssoc"))
413  {
414  newdump = new DumpTrkrClusterHitAssoc(NodeName);
415  }
416  else if (tmp->InheritsFrom("TrkrHitSetContainer"))
417  {
418  newdump = new DumpTrkrHitSetContainer(NodeName);
419  }
420  else if (tmp->InheritsFrom("TrkrHitTruthAssoc"))
421  {
422  newdump = new DumpTrkrHitTruthAssoc(NodeName);
423  }
424  else if (tmp->InheritsFrom("VariableArray"))
425  {
426  newdump = new DumpVariableArray(NodeName);
427  }
428  else
429  {
430  std::cout << "Registering Dummy for " << NodeName
431  << ", Class: " << tmp->ClassName() << std::endl;
432  newdump = new DumpObject(NodeName);
433  }
434  }
435  else
436  {
437  std::cout << "ignoring PHDataNode: " << NodeName << std::endl;
438  newdump = new DumpObject(NodeName);
439  }
440  }
441  newdump->PrintEvtSeq(print_evtseq);
442  return initdump(NodeName, newdump);
443 }
444 
445 int PHNodeDump::initdump(const std::string &newnode, DumpObject *dmp)
446 {
447  dmp->SetParentNodeDump(this);
448  dmp->SetOutDir(outdir);
450  dmp->Init();
451  dumpthis[newnode] = dmp;
452  return 0;
453 }