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 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,15,6)
19 #include <TMCParticle.h>
20 #else
21 #include <TMCParticle6.h>
22 #endif
23 #include <TIterator.h>
24 
28 
29 using namespace genie;
30 
31 //____________________________________________________________________________
33  int pdg_code, const TClonesArray * const particle_list)
34 {
35  int nparticles = 0;
36  TMCParticle* p = 0;
37 
38  TObjArrayIter particle_iter(particle_list);
39 
40  while( (p = (TMCParticle *) particle_iter.Next()) ) {
41  if(p->GetKF() == pdg_code) {
42  if(p->GetKS()<10) nparticles++;
43  }
44  }
45  return nparticles;
46 }
47 //____________________________________________________________________________
49  int pdg_code, int status, const TClonesArray * const particle_list)
50 {
51  int nparticles = 0;
52  TMCParticle* p = 0;
53 
54  TObjArrayIter particle_iter(particle_list);
55 
56  while( (p = (TMCParticle *) particle_iter.Next()) )
57  if(p->GetKF() == pdg_code && p->GetKS() == status) nparticles++;
58 
59  return nparticles;
60 }
61 //____________________________________________________________________________
62 int genie::utils::fragmrec::NPositives(const TClonesArray * const part_list)
63 {
64 // Find out the number of negative particles in the particle container
65 
66  TIter piter(part_list);
67 
68  TMCParticle * p = 0;
69  int npos = 0;
70 
71  while( (p = (TMCParticle *) piter.Next()) )
72  if( PDGLibrary::Instance()->Find(p->GetKF())->Charge() > 0 ) npos++;
73 
74  return npos;
75 }
76 //____________________________________________________________________________
77 int genie::utils::fragmrec::NNegatives(const TClonesArray * const part_list)
78 {
79 // Find out the number of negative particles in the particle container
80 
81  TIter piter(part_list);
82 
83  TMCParticle * p = 0;
84  int nneg = 0;
85 
86  while( (p = (TMCParticle *) piter.Next()) )
87  if( PDGLibrary::Instance()->Find(p->GetKF())->Charge() < 0 ) nneg++;
88 
89  return nneg;
90 }
91 //____________________________________________________________________________
92 void genie::utils::fragmrec::Print(const TClonesArray * const part_list)
93 {
94  TIter piter(part_list);
95 
96  unsigned int i=0;
97  TMCParticle * particle = 0;
98 
99  double sum_px = 0, sum_py = 0, sum_pz = 0, sum_E = 0;
100 
101 
102  while( (particle = (TMCParticle *) piter.Next()) ) {
103 
104  sum_E += (particle->GetEnergy());
105  sum_px += (particle->GetPx());
106  sum_py += (particle->GetPy());
107  sum_pz += (particle->GetPz());
108 
109  SLOG("FragmRecUtils", pINFO)
110  << "-> " << i++ << " " << particle->GetName()
111  << " KF = " << particle->GetKF()
112  << " KS = " << particle->GetKS()
113  << " mom = " << particle->GetParent()
114  << " kids = {"
115  << particle->GetFirstChild() << ", " << particle->GetLastChild()
116  << "}(E = " << particle->GetEnergy()
117  << ",Px = " << particle->GetPx()
118  << ",Py = " << particle->GetPy()
119  << ",Pz = " << particle->GetPz() << ")";
120  }
121 
122  SLOG("FragmRecUtils", pINFO)
123  << "SUMS: E = " << sum_E
124  << ", px = " << sum_px << ", py = " << sum_py << ", pz = " << sum_pz;
125 
126 }
127 //__________________________________________________________________________
128 
int status
Definition: fabricate.py:1613
THE MAIN GENIE PROJECT NAMESPACE
Definition: GeneratorBase.h:8
const char * p
Definition: xmltok.h:285
int NNegatives(const TClonesArray *const particle_list)
#define pINFO
Definition: Messenger.h:63
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
int NPositives(const TClonesArray *const particle_list)
int NParticles(int pdg_code, const TClonesArray *const particle_list)