All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
GammaGammaSolutionFinder.h
Go to the documentation of this file.
1 // Boost Graph Library
2 #include <boost/graph/adjacency_list.hpp>
3 #include <boost/graph/max_cardinality_matching.hpp>
4 
5 #include "marlin/Processor.h"
6 #include "EVENT/ReconstructedParticle.h"
7 #include "lcio.h"
8 #include <vector>
9 #include <set>
10 #include <algorithm>
11 #include <bitset>
12 #include <list>
13 #include <iomanip>
14 #include <cassert>
15 #include <sys/time.h>
16 #include <stdio.h>
17 #include "IMPL/LCCollectionVec.h"
18 #include <gsl/gsl_cdf.h>
19 
20 enum {NVMAX=100, NEMAX=100};
21 std::vector< std::vector<int> > comb; // Vector of vectors to store the possible edge choices for each combination of first vertices
22 
23 using namespace lcio ;
24 
25 using namespace boost;
26 
27 
28 /** GammaGammaSolutionFinder:<br>
29  *
30  * @author Graham W. Wilson, University of Kansas
31  */
32 
33 class GammaGammaSolutionFinder : public marlin::Processor {
34 
35  public:
36 
37  virtual marlin::Processor* newProcessor() { return new GammaGammaSolutionFinder ; }
38 
40 
41  /** Called at the beginning of the job before anything is read.
42  * Use to initialize the processor, e.g. book histograms.
43  */
44  virtual void init() ;
45 
46  /** Called for every run.
47  */
48  virtual void processRunHeader( LCRunHeader* run ) ;
49 
50  /** Called for every event - the working horse.
51  */
52  virtual void processEvent( LCEvent * evt ) ;
53 
54 
55  /** Called after data processing for clean up.
56  */
57  virtual void end() ;
58 
59  bool FindPFOs( LCEvent* evt );
60  void FindGammaGammaSolutionZero(LCCollectionVec *);
61  void FindGammaGammaSolutions( LCCollectionVec *);
62  unsigned int CountIndependentPhotons();
63  unsigned long int CombinatorialFactor(int n, int k );
64  void FindCombinations(std::vector<std::vector<int> > array, unsigned int i, std::vector<int> accum);
65 
66  struct MyEdge {
67  int u{},v{}; // Edge from vertex u to vertex v with weight w
68  std::bitset<NVMAX> vbits{}; // Bitset with the vertices used in this edge
69  int pdgid{}; // PDG particle id (111 = pi0, 221 = eta, 331 = eta' )
70  double edge_pvalue{}; // Chi-squared p-value for this edge being consistent with the mass constraint (1 dof)
71  double edge_chisq{}; // Chi-squared for this edge being consistent with the mass constraint
72  double w{}; // Edge weight
73  };
74 
75  struct FirstVertex { // struct for those vertices which correspond to min(u,v)
76  int ivertex{}; // Vertex index from the initial graph definition
77  int nedges{}; // Number of edges with which this vertex is the first vertex
78  std::bitset<NEMAX> febits{}; // Bitset with the edge IDs available for this first vertex
79  std::list<int> fvelist{}; // List with the edge IDs
80  int fedge{}; // First edge ID
81  };
82 
84  int ne{}; // Number of edges used
85  int nv{}; // Number of vertices used (should always be ne/2)
86  std::bitset<NEMAX> ebits{}; // Bitset with the edges used in this solution
87  double wsum{}; // Sum of the weights of the edges in the solution
88  double pvalue{}; // Chi-squared p-value for wsum being consistent with ne edges (ne dof)
89  int icomb{}; // Combination number
90  int npi0{}; // Number of pi0s in the solution
91  int neta{}; // Number of etas in the solution
92  int netap{}; // Number of etaps in the solution
93  };
94 
95 private:
96 
97  std::vector<ReconstructedParticle*>_pfovec{};
98  int _printing{};
99  std::vector<std::string> _gammagammaCandidateCollections{};
100  std::string _outputParticleCollectionName{};
101  double _maxCombinationsCut{};
102  int _nToRemove{}; // Number of edges less than maximal to consider
103  int _algorithm{}; // Solution Finding Algorithm (1=Greedy, 2=Exhaustive)
104  static bool PfoProbabilitySortFunction(ReconstructedParticle* lhs,ReconstructedParticle* rhs);
105 
106 protected:
107 
108 } ;
virtual marlin::Processor * newProcessor()
static const float k
GammaGammaSolutionFinder:
std::vector< LCCollection * > LCCollectionVec
Definition: SiStripClus.h:55
std::vector< std::vector< int > > comb