FragmRecUtils.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2019, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5  or see $GENIE/LICENSE
6 
7  Author: Costas Andreopoulos <costas.andreopoulos \at stfc.ac.uk>
8  University of Liverpool & STFC Rutherford Appleton Lab - November 26, 2004
9 
10  For documentation see the corresponding header file.
11 
12  Important revisions after version 2.0.0 :
13 
14 */
15 //____________________________________________________________________________
16 
17 #include <RVersion.h>
18 #include <TIterator.h>
19 
26 
27 using namespace genie;
28 
29 //____________________________________________________________________________
31  int pdg_code, const TClonesArray * const particle_list)
32 {
33  int nparticles = 0;
34  GHepParticle* p = 0;
35 
36  TObjArrayIter particle_iter(particle_list);
37 
38  while( (p = (GHepParticle *) particle_iter.Next()) ) {
39  if(p->Pdg() == pdg_code) {
40  if(p->Status()<10) nparticles++;
41  }
42  }
43  return nparticles;
44 }
45 //____________________________________________________________________________
47  int pdg_code, GHepStatus_t status, const TClonesArray * const particle_list)
48 {
49  int nparticles = 0;
50  GHepParticle* p = 0;
51 
52  TObjArrayIter particle_iter(particle_list);
53 
54  while( (p = (GHepParticle *) particle_iter.Next()) )
55  if(p->Pdg() == pdg_code && p->Status() == status) nparticles++;
56 
57  return nparticles;
58 }
59 //____________________________________________________________________________
60 int genie::utils::fragmrec::NPositives(const TClonesArray * const part_list)
61 {
62 // Find out the number of negative particles in the particle container
63 
64  TIter piter(part_list);
65 
66  GHepParticle * p = 0;
67  int npos = 0;
68 
69  while( (p = (GHepParticle *) piter.Next()) )
70  if( PDGLibrary::Instance()->Find(p->Pdg())->Charge() > 0 ) npos++;
71 
72  return npos;
73 }
74 //____________________________________________________________________________
75 int genie::utils::fragmrec::NNegatives(const TClonesArray * const part_list)
76 {
77 // Find out the number of negative particles in the particle container
78 
79  TIter piter(part_list);
80 
81  GHepParticle * p = 0;
82  int nneg = 0;
83 
84  while( (p = (GHepParticle *) piter.Next()) )
85  if( PDGLibrary::Instance()->Find(p->Pdg())->Charge() < 0 ) nneg++;
86 
87  return nneg;
88 }
89 //____________________________________________________________________________
90 void genie::utils::fragmrec::Print(const TClonesArray * const part_list)
91 {
92  TIter piter(part_list);
93 
94  unsigned int i=0;
95  GHepParticle * particle = 0;
96 
97  double sum_px = 0, sum_py = 0, sum_pz = 0, sum_E = 0;
98 
99 
100  while( (particle = (GHepParticle *) piter.Next()) ) {
101 
102  sum_E += (particle->Energy());
103  sum_px += (particle->Px());
104  sum_py += (particle->Py());
105  sum_pz += (particle->Pz());
106 
107  SLOG("FragmRecUtils", pINFO)
108  << "-> " << i++ << " " << particle->Name()
109  << " PDG = " << particle->Pdg()
110  << " status = " << particle->Status()
111  << " moms = {"
112  << particle->FirstMother() << ", " << particle->LastMother()
113  << "} kids = {"
114  << particle->FirstDaughter() << ", " << particle->LastDaughter()
115  << "}(E = " << particle->Energy()
116  << ",Px = " << particle->Px()
117  << ",Py = " << particle->Py()
118  << ",Pz = " << particle->Pz() << ")";
119  }
120 
121  SLOG("FragmRecUtils", pINFO)
122  << "SUMS: E = " << sum_E
123  << ", px = " << sum_px << ", py = " << sum_py << ", pz = " << sum_pz;
124 
125 }
126 //__________________________________________________________________________
THE MAIN GENIE PROJECT NAMESPACE
Definition: AlgCmp.h:26
int FirstDaughter(void) const
Definition: GHepParticle.h:69
enum genie::EGHepStatus GHepStatus_t
double Pz(void) const
Get Pz.
Definition: GHepParticle.h:91
GHepStatus_t Status(void) const
Definition: GHepParticle.h:65
double Energy(void) const
Get energy.
Definition: GHepParticle.h:93
double Px(void) const
Get Px.
Definition: GHepParticle.h:89
int LastMother(void) const
Definition: GHepParticle.h:68
int Pdg(void) const
Definition: GHepParticle.h:64
int FirstMother(void) const
Definition: GHepParticle.h:67
string Name(void) const
Name that corresponds to the PDG code.
int LastDaughter(void) const
Definition: GHepParticle.h:70
int NNegatives(const TClonesArray *const particle_list)
#define pINFO
Definition: Messenger.h:63
p
Definition: test.py:223
static PDGLibrary * Instance(void)
Definition: PDGLibrary.cxx:43
TParticlePDG * Find(int pdgc)
Definition: PDGLibrary.cxx:61
void Print(const TClonesArray *const part_list)
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:85
STDHEP-like event record entry that can fit a particle or a nucleus.
Definition: GHepParticle.h:40
int NPositives(const TClonesArray *const particle_list)
int NParticles(int pdg_code, const TClonesArray *const particle_list)
double Py(void) const
Get Py.
Definition: GHepParticle.h:90