HepMC3 event record library
PhotosValidationTool.cc
1 // -*- C++ -*-
2 //
3 // This file is part of HepMC
4 // Copyright (C) 2014-2019 The HepMC collaboration (see AUTHORS for details)
5 //
6 #include "PhotosValidationTool.h"
7 
8 #include <cstring> // memset
9 #include <cstdio> // printf
10 
11 PhotosValidationTool::PhotosValidationTool():m_more_photons_added(0),m_timer("Photos++ processing time") {
12  memset(m_photons_added,0,sizeof(int)*MAX_PHOTONS_TO_KEEP_TRACK_OF);
13 }
14 
16  Photospp::Photos::initialize();
17  Photospp::Photos::setInfraredCutOff(0.001/200);
18 
19  HEPMC2CODE( Photospp::Photos::createHistoryEntries(false,3); )
20  HEPMC3CODE( Photospp::Photos::createHistoryEntries(false,3); )
21 }
22 
24 
25  HEPMC2CODE( int buf = -hepmc.particles_size(); )
26  HEPMC3CODE(
27  int buf=-hepmc.particles().size();
28  )
29  // Time only processing
30  m_timer.start();
31 
32  // Process by Photos++
33  HEPMC2CODE( Photospp::PhotosHepMCEvent *p_event = new Photospp::PhotosHepMCEvent (&hepmc); )
34  HEPMC3CODE( Photospp::PhotosHepMC3Event *p_event = new Photospp::PhotosHepMC3Event(&hepmc); )
35 
36  p_event->process();
37  delete p_event;
38 
39  m_timer.stop();
40 
41  // Check number of photons created
42  HEPMC2CODE( buf += hepmc.particles_size(); )
43 
44  HEPMC3CODE(
45  buf +=hepmc.particles().size();
46  )
47 
48  if(buf<MAX_PHOTONS_TO_KEEP_TRACK_OF) ++m_photons_added[buf];
49  else ++m_more_photons_added;
50 
51  return 0;
52 }
53 
55  Photospp::Log::Summary();
56 
57  int sum = m_more_photons_added;
58  for(int i=0; i<MAX_PHOTONS_TO_KEEP_TRACK_OF; ++i) sum += m_photons_added[i];
59 
60  if( sum == 0 ) sum = 1;
61 
62  printf("---------------------------------------------------\n");
63  printf(" Number of photons added by Photos++ (per event):\n");
64  printf("---------------------------------------------------\n");
65  for(int i=0; i<MAX_PHOTONS_TO_KEEP_TRACK_OF; ++i) {
66  printf("%5i: %7i events (%6.2f%%)\n",i,m_photons_added[i],m_photons_added[i]*100./sum );
67  }
68  printf(" more: %7i events (%6.2f%%)\n",m_more_photons_added,m_more_photons_added*100./sum );
69  printf("total: %7i events\n",sum );
70  printf("---------------------------------------------------\n");
71 }
void initialize()
Initialize.
Stores event-related information.
Definition: GenEvent.h:41
int process(GenEvent &hepmc)
Process event.
const std::vector< ConstGenParticlePtr > & particles() const
Get list of particles (const)
Definition: GenEvent.cc:39