ROOTPWA
interactionVertex.cc
Go to the documentation of this file.
1 
2 //
3 // Copyright 2010
4 //
5 // This file is part of rootpwa
6 //
7 // rootpwa is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // rootpwa is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with rootpwa. If not, see <http://www.gnu.org/licenses/>.
19 //
21 //-------------------------------------------------------------------------
22 // File and Version Information:
23 // $Rev:: $: revision of last commit
24 // $Author:: $: author of last commit
25 // $Date:: $: date of last commit
26 //
27 // Description:
28 // base class that desbribes general interaction vertex between particles
29 //
30 //
31 // Author List:
32 // Boris Grube TUM (original author)
33 //
34 //
35 //-------------------------------------------------------------------------
36 
37 
38 #include "TClonesArray.h"
39 
40 #include "conversionUtils.hpp"
41 #include "interactionVertex.h"
42 
43 
44 using namespace std;
45 using namespace rpwa;
46 
47 
48 bool interactionVertex::_debug = false;
49 
50 
51 interactionVertex::interactionVertex()
52  : _inParticles (),
53  _outParticles()
54 { }
55 
56 
58 {
59  *this = vert;
60 }
61 
62 
64 { }
65 
66 
69 {
70  if (this != &vert) {
73  }
74  return *this;
75 }
76 
77 
79 interactionVertex::doClone(const bool cloneInParticles,
80  const bool cloneOutParticles) const
81 {
82  interactionVertex* vertexClone = new interactionVertex(*this);
83  if (cloneInParticles)
84  vertexClone->cloneInParticles();
85  if (cloneOutParticles)
86  vertexClone->cloneOutParticles();
87  if (_debug)
88  printDebug << "cloned " << *this << "; " << this << " -> " << vertexClone << " "
89  << ((cloneInParticles ) ? "in" : "ex") << "cluding incoming particles, "
90  << ((cloneOutParticles) ? "in" : "ex") << "cluding outgoing particles" << std::endl;
91  return vertexClone;
92 }
93 
94 
95 void
97 {
98  _inParticles.clear();
99  _outParticles.clear();
100 }
101 
102 
103 bool
105 {
106  if ( (nmbInParticles () != vert.nmbInParticles ())
107  or (nmbOutParticles() != vert.nmbOutParticles()))
108  return false;
109  for (unsigned int i = 0; i < nmbInParticles(); ++i)
110  if (*(inParticles()[i]) != *(vert.inParticles()[i]))
111  return false;
112  for (unsigned int i = 0; i < nmbOutParticles(); ++i)
113  if (*(outParticles()[i]) != *(vert.outParticles()[i]))
114  return false;
115  return true;
116 }
117 
118 
119 bool
121 {
122  if (not part) {
123  printErr << "trying to add null pointer to incoming particles. aborting." << endl;
124  throw;
125  }
126  if (_debug)
127  printDebug << "adding incoming " << *part << endl;
128  _inParticles.push_back(part);
129  return true;
130 }
131 
132 
133 bool
135 {
136  if (not part) {
137  printErr << "trying to add null pointer to outgoing particles. aborting." << endl;
138  throw;
139  }
140  if (_debug)
141  printDebug << "adding outgoing " << *part << endl;
142  _outParticles.push_back(part);
143  return true;
144 }
145 
146 
147 void
149 {
150  for (unsigned int i = 0; i < nmbOutParticles(); ++i)
151  _outParticles[i]->transform(L);
152 }
153 
154 
155 ostream&
156 interactionVertex::print(ostream& out) const
157 {
158  out << name() << ": ";
159  for (unsigned int i = 0; i < _inParticles.size(); ++i) {
160  out << _inParticles[i]->qnSummary();
161  if (i < _inParticles.size() - 1)
162  out << " + ";
163  }
164  out << " ---> ";
165  for (unsigned int i = 0; i < _outParticles.size(); ++i) {
166  out << _outParticles[i]->qnSummary();
167  if (i < _outParticles.size() - 1)
168  out << " + ";
169  }
170  return out;
171 }
172 
173 
174 ostream&
175 interactionVertex::dump(ostream& out) const
176 {
177  out << name() << ":" << endl;
178  for (unsigned int i = 0; i < _inParticles.size(); ++i)
179  out << " incoming[" << i << "]: " << *_inParticles[i] << endl;
180  for (unsigned int i = 0; i < _outParticles.size(); ++i)
181  out << " outgoing[" << i << "]: " << *_outParticles[i] << endl;
182  return out;
183 }
184 
185 
186 ostream&
188 {
189  out << name() << " " << this << ": incoming particles: ";
190  for (unsigned int i = 0; i < _inParticles.size(); ++i) {
191  out << "[" << i << "] = " << _inParticles[i];
192  if (i < _inParticles.size() - 1)
193  out << ", ";
194  }
195  out << "; outgoing particles: ";
196  for (unsigned int i = 0; i < _outParticles.size(); ++i) {
197  out << "[" << i << "] = " << _outParticles[i];
198  if (i < _outParticles.size() - 1)
199  out << ", ";
200  }
201  out << endl;
202  return out;
203 }
204 
205 
206 void
208 {
209  for (unsigned int i = 0; i < nmbInParticles(); ++i) {
210  particlePtr newPart(inParticles()[i]->clone());
211  inParticles()[i] = newPart;
212  }
213 }
214 
215 
216 void
218 {
219  for (unsigned int i = 0; i < nmbOutParticles(); ++i) {
220  particlePtr newPart(outParticles()[i]->clone());
221  outParticles()[i] = newPart;
222  }
223 }