JHUGen MELA  JHUGen v7.5.6, MELA v2.4.2
Matrix element calculations as used in JHUGen.
MELAOutputStreamer.cc
Go to the documentation of this file.
1 #include "MELAOutputStreamer.h"
2 
3 
4 using namespace std;
5 
6 
7 MELAOutputStreamer::MELAOutputStreamer(const char* fname, std::ios_base::openmode fmode, bool printError) :
8 theFile(fname, fmode)
9 {
10  if (!printError) stdout_ptr = &std::cout;
11  else stdout_ptr = &std::cerr;
12 }
14 
15 MELAOutputStreamer& MELAOutputStreamer::operator<<(std::ostream& (*fcn)(std::ostream&)){
16  fcn(theFile);
17  if (stdout_ptr) fcn(*stdout_ptr);
18  return *this;
19 }
20 MELAOutputStreamer& MELAOutputStreamer::operator<<(std::ios& (*fcn)(std::ios&)){
21  fcn(theFile);
22  if (stdout_ptr) fcn(*stdout_ptr);
23  return *this;
24 }
25 MELAOutputStreamer& MELAOutputStreamer::operator<<(std::ios_base& (*fcn)(std::ios_base&)){
26  fcn(theFile);
27  if (stdout_ptr) fcn(*stdout_ptr);
28  return *this;
29 }
30 template<> MELAOutputStreamer& MELAOutputStreamer::operator<< <TLorentzVector>(TLorentzVector const& val){
31  theFile << "{" << val.X() << ", " << val.Y() << ", " << val.Z() << ", " << val.T() << ", " << val.M() << "}";
32  if (stdout_ptr) *stdout_ptr << "{" << val.X() << ", " << val.Y() << ", " << val.Z() << ", " << val.T() << ", " << val.M() << "}";
33  return *this;
34 }
35 template<> MELAOutputStreamer& MELAOutputStreamer::operator<< <MELAParticle>(MELAParticle const& val){
36  *this << "(" << val.id << ") (X,Y,Z,T,M)=( "
37  << val.x() << " , "
38  << val.y() << " , "
39  << val.z() << " , "
40  << val.t() << " , "
41  << val.m()
42  << " )";
43  return *this;
44 }
45 template<> MELAOutputStreamer& MELAOutputStreamer::operator<< <int, TLorentzVector>(SimpleParticle_t const& val){
46  *this << "(" << val.first << ") (X,Y,Z,T,M)=( "
47  << val.second.X() << " , "
48  << val.second.Y() << " , "
49  << val.second.Z() << " , "
50  << val.second.T() << " , "
51  << val.second.M() << " )";
52  return *this;
53 }
54 template<> MELAOutputStreamer& MELAOutputStreamer::operator<< <MELAThreeBodyDecayCandidate>(MELAThreeBodyDecayCandidate const& val){
55  *this << "(" << val.id << ") (X,Y,Z,T,M)=( "
56  << val.x() << " , "
57  << val.y() << " , "
58  << val.z() << " , "
59  << val.t() << " , "
60  << val.m()
61  << " )"
62  << endl;
63 
64  int ip=0;
65  *this << "\tHas " << val.getNMothers() << " mothers" << endl;
66  for (auto const& part:val.getMothers()){
67  *this << "\t\tV" << ip << ' ' << *part << endl;
68  ip++;
69  }
70 
71  *this << "\tHas " << val.getNDaughters() << " daughters" << endl;
72  *this << "\t\tPartner particle "; if (val.getPartnerParticle()) *this << *(val.getPartnerParticle()); else *this << "N/A"; *this << endl;
73  *this << "\t\tW fermion "; if (val.getWFermion()) *this << *(val.getWFermion()); else *this << "N/A"; *this << endl;
74  *this << "\t\tW antifermion "; if (val.getWAntifermion()) *this << *(val.getWAntifermion()); else *this << "N/A"; *this << endl;
75 
76  return *this;
77 }
78 template<> MELAOutputStreamer& MELAOutputStreamer::operator<< <MELACandidate>(MELACandidate const& val){
79  int ip=0;
80  *this << "\tHas " << val.getNMothers() << " mothers" << endl;
81  for (auto const& part:val.getMothers()){
82  *this << "\t\tV" << ip << ' ' << *part << endl;
83  ip++;
84  }
85 
86  *this << "\tHas " << val.getNSortedVs() << " sorted Vs" << endl;
87  ip=0;
88  for (auto const& part:val.getSortedVs()){
89  *this << "\t\tV" << ip << ' ' << *part << endl;
90  unsigned int ivd=0;
91  for (auto const& dau:part->getDaughters()){
92  *this << "\t\t- V" << ip << ivd << ' ' << *dau << endl;
93  ivd++;
94  }
95  ip++;
96  }
97 
98  *this << "\tHas " << val.getNAssociatedLeptons() << " leptons or neutrinos" << endl;
99  ip=0;
100  for (auto const& part:val.getAssociatedLeptons()){
101  *this << "\t\tV" << ip << ' ' << *part << endl;
102  ip++;
103  }
104 
105  *this << "\tHas " << val.getNAssociatedPhotons() << " photons" << endl;
106  ip=0;
107  for (auto const& part:val.getAssociatedPhotons()){
108  *this << "\t\tV" << ip << ' ' << *part << endl;
109  ip++;
110  }
111 
112  *this << "\tHas " << val.getNAssociatedJets() << " jets" << endl;
113  ip=0;
114  for (auto const& part:val.getAssociatedJets()){
115  *this << "\t\tV" << ip << ' ' << *part << endl;
116  ip++;
117  }
118 
119  *this << "\tHas " << val.getNAssociatedTops() << " tops" << endl;
120  ip=0;
121  for (auto const& part:val.getAssociatedTops()){
122  *this << "\t\tTop" << ip << ' ' << static_cast<MELAParticle const>(*part) << endl;
123  { MELAParticle* bottom=part->getPartnerParticle(); if (bottom) *this << "\t\t- Top" << ip << " b " << ' ' << *bottom << endl; }
124  { MELAParticle* Wf=part->getWFermion(); if (Wf) *this << "\t\t- Top" << ip << " Wf " << ' ' << *Wf << endl; }
125  { MELAParticle* Wfb=part->getWAntifermion(); if (Wfb) *this << "\t\t- Top" << ip << " Wfb " << ' ' << *Wfb << endl; }
126  ip++;
127  }
128 
129  return *this;
130 }
131 
132 
133 std::streamsize MELAOutputStreamer::width() const{ return theFile.width(); }
134 std::streamsize MELAOutputStreamer::width(std::streamsize wide){
135  if (stdout_ptr) stdout_ptr->width(wide);
136  return theFile.width(wide);
137 }
138 
139 char MELAOutputStreamer::fill() const{ return theFile.fill(); }
140 char MELAOutputStreamer::fill(char fillch){
141  if (stdout_ptr) stdout_ptr->fill(fillch);
142  return theFile.fill(fillch);
143 }
144 
146  theFile.close();
147 }
148 void MELAOutputStreamer::open(const char* fname, std::ios_base::openmode fmode){
149  this->close();
150  theFile.open(fname, fmode);
151 }
MELAThreeBodyDecayCandidate::getWAntifermion
MELAParticle * getWAntifermion()
Definition: MELAThreeBodyDecayCandidate.h:23
SimpleParticle_t
std::pair< int, TLorentzVector > SimpleParticle_t
Definition: TVar.hh:24
MELACandidate::getSortedVs
std::vector< MELAParticle * > & getSortedVs()
Definition: MELACandidate.cc:178
MELAOutputStreamer::width
std::streamsize width() const
Definition: MELAOutputStreamer.cc:133
MELAParticle::getNDaughters
int getNDaughters() const
Definition: MELAParticle.h:50
MELAOutputStreamer::MELAOutputStreamer
MELAOutputStreamer(const char *fname, std::ios_base::openmode fmode=std::ios_base::out, bool printError=false)
Definition: MELAOutputStreamer.cc:7
MELACandidate::getNAssociatedJets
int getNAssociatedJets() const
Definition: MELACandidate.h:60
MELACandidate::getNAssociatedPhotons
int getNAssociatedPhotons() const
Definition: MELACandidate.h:59
MELACandidate::getNAssociatedTops
int getNAssociatedTops() const
Definition: MELACandidate.h:61
MELAOutputStreamer::fill
char fill() const
Definition: MELAOutputStreamer.cc:139
MELAParticle::t
double t() const
Definition: MELAParticle.h:70
MELAOutputStreamer::close
void close()
Definition: MELAOutputStreamer.cc:145
MELAParticle::getMothers
std::vector< MELAParticle * > & getMothers()
Definition: MELAParticle.h:58
MELAParticle::y
double y() const
Definition: MELAParticle.h:68
MELAParticle::x
double x() const
Definition: MELAParticle.h:67
MELAThreeBodyDecayCandidate::getPartnerParticle
MELAParticle * getPartnerParticle()
Definition: MELAThreeBodyDecayCandidate.h:21
MELAParticle::m
double m() const
Definition: MELAParticle.h:66
MELACandidate::getAssociatedPhotons
std::vector< MELAParticle * > & getAssociatedPhotons()
Definition: MELACandidate.cc:181
MELAParticle::z
double z() const
Definition: MELAParticle.h:69
MELAOutputStreamer::operator<<
MELAOutputStreamer & operator<<(T const &val)
Definition: MELAOutputStreamer.h:50
MELACandidate::getAssociatedLeptons
std::vector< MELAParticle * > & getAssociatedLeptons()
Definition: MELACandidate.cc:179
MELAParticle
Definition: MELAParticle.h:13
MELAOutputStreamer::theFile
std::ofstream theFile
Definition: MELAOutputStreamer.h:23
MELAOutputStreamer::open
void open(const char *fname, std::ios_base::openmode fmode=std::ios_base::out)
Definition: MELAOutputStreamer.cc:148
MELAThreeBodyDecayCandidate::getWFermion
MELAParticle * getWFermion()
Definition: MELAThreeBodyDecayCandidate.h:22
MELAOutputStreamer::stdout_ptr
std::ostream * stdout_ptr
Definition: MELAOutputStreamer.h:24
MELAOutputStreamer::~MELAOutputStreamer
~MELAOutputStreamer()
Definition: MELAOutputStreamer.cc:13
MELACandidate::getAssociatedTops
std::vector< MELATopCandidate_t * > & getAssociatedTops()
Definition: MELACandidate.cc:183
dd_global::cout
integer cout
Definition: DD_global.F90:21
MELAOutputStreamer
Definition: MELAOutputStreamer.h:21
MELACandidate::getNSortedVs
int getNSortedVs() const
Definition: MELACandidate.h:62
MELACandidate::getAssociatedJets
std::vector< MELAParticle * > & getAssociatedJets()
Definition: MELACandidate.cc:182
MELACandidate
Definition: MELACandidate.h:7
MELAThreeBodyDecayCandidate
Definition: MELAThreeBodyDecayCandidate.h:7
MELAParticle::id
int id
Definition: MELAParticle.h:17
MELAOutputStreamer.h
MELACandidate::getNAssociatedLeptons
int getNAssociatedLeptons() const
Definition: MELACandidate.h:57
MELAParticle::getNMothers
int getNMothers() const
Definition: MELAParticle.h:49