38 #include <boost/timer/timer.hpp>
49 #include "reportingUtilsRoot.hpp"
59 using namespace boost;
60 using namespace boost::timer;
68 const double maxPt = 0.150,
69 const double maxEta = 1)
71 double pt = maxPt * random.Rndm();
72 double eta = 2 * maxEta * random.Rndm() - maxEta;
73 double phi = 2 *
pi * random.Rndm();
74 double tanhEta = tanh(eta);
75 TLorentzVector parent;
76 parent.SetPx(pt * cos(phi));
77 parent.SetPy(pt * sin(phi));
78 parent.SetPz(tanhEta * sqrt((mass * mass + pt * pt) / (1 - tanhEta * tanhEta)));
79 parent.SetVectM(parent.Vect(),
mass);
86 const unsigned int seed,
89 ::massDep* pwa2kMassDep,
91 const string& name =
"",
92 const double maxMass = 3)
94 vertex->setMassDependence(massDep);
95 pwa2kParent.setMassDep(pwa2kMassDep);
96 printInfo <<
"comparing '" << name <<
"' dynamic amplitudes" << endl
97 <<
" " << *(vertex->massDependence()) << endl
99 pwa2kMassDep->
print();
101 <<
" using decays" << endl
102 <<
" " << *vertex << endl;
108 const double daughterMasses[2] = {daughter1->mass(), daughter2->mass()};
109 const double massRange [2] = {daughterMasses[0] + daughterMasses[1], maxMass};
118 TRandom3 random(seed);
119 cpu_timer timer, timerPwa2k;
120 vector<complex<double> > newAmps (nmbEvents, 0);
121 vector<complex<double> > oldAmps (nmbEvents, 0);
122 vector<double> parentMass(nmbEvents, 0);
123 size_t countEvts = 0;
124 bool firstCall =
true;
125 while (countEvts < nmbEvents) {
126 const TLorentzVector parentLv
127 =
constructParent(random, massRange[0] + random.Rndm() * (massRange[1] - massRange[0]));
131 daughter1->setMomentum(psGen.
daughter(0).Vect());
132 daughter2->setMomentum(psGen.
daughter(1).Vect());
133 vertex->calcParentLzVec();
138 newAmps[countEvts] = vertex->massDepAmplitude();
140 parentMass[countEvts] = parentLv.M();
142 assert(pwa2kParent.Decay()->_children.size() == 2);
143 list< ::particle>::iterator child = pwa2kParent.Decay()->_children.begin();
148 pwa2kMom.
set(daughter1->lzVec().E(), daughter1->lzVec().X(),
149 daughter1->lzVec().Y(), daughter1->lzVec().Z());
151 pwa2kMom.
set(daughter2->lzVec().E(), daughter2->lzVec().X(),
152 daughter2->lzVec().Y(), daughter2->lzVec().Z());
154 pwa2kMom.
set(vertex->parent()->lzVec().E(), vertex->parent()->lzVec().X(),
155 vertex->parent()->lzVec().Y(), vertex->parent()->lzVec().Z());
156 pwa2kParent.set4P(pwa2kMom);
161 oldAmps[countEvts] = pwa2kMassDep->
val(pwa2kParent);
167 printInfo <<
"calculated mass dependence for " << nmbEvents <<
" events" << endl
168 <<
" this consumed: (new code) "
169 << timer.format(3,
"[%u sec user] + [%s sec sys] = [%t sec]")
170 <<
" vs. (PWA2000) " << timerPwa2k.format(3,
"[%t sec] = [%u sec user] + [%s sec sys]")
174 TH2D* hAmp =
new TH2D((
"h" + name +
"Amp" ).c_str(), (name +
" Amplitude" ).c_str(), 1000, -1, 1, 1000, -0.5, 1.5);
175 TH1D* hAmpReal =
new TH1D((
"h" + name +
"AmpReal" ).c_str(), (name +
" Amplitude (Real Part)" ).c_str(), 1000, -1.2, 1.2);
176 TH1D* hAmpImag =
new TH1D((
"h" + name +
"AmpImag" ).c_str(), (name +
" Amplitude (Imag Part)" ).c_str(), 1000, -1.2, 1.2);
177 TH2D* hInt =
new TH2D((
"h" + name +
"Int" ).c_str(), (name +
" Intensity" ).c_str(), 1000, massRange[0] - 0.2, massRange[1] + 0.2, 1000, 0, 1.2);
178 TH2D* hPhase =
new TH2D((
"h" + name +
"Phase" ).c_str(), (name +
" Phase" ).c_str(), 1000, massRange[0] - 0.2, massRange[1] + 0.2, 1000, -200, 200);
179 TH1D* hAbsDiffReal =
new TH1D((
"h" + name +
"AbsDiffReal").c_str(), (name +
" Absolute Diff. (Real Part)").c_str(), 100000, -1e-12, 1e-12);
180 TH1D* hAbsDiffImag =
new TH1D((
"h" + name +
"AbsDiffImag").c_str(), (name +
" Absolute Diff. (Imag Part)").c_str(), 100000, -1e-12, 1e-12);
181 TH1D* hRelDiffReal =
new TH1D((
"h" + name +
"RelDiffReal").c_str(), (name +
" Relative Diff. (Real Part)").c_str(), 100000, -1e-12, 1e-12);
182 TH1D* hRelDiffImag =
new TH1D((
"h" + name +
"RelDiffImag").c_str(), (name +
" Relative Diff. (Imag Part)").c_str(), 100000, -1e-12, 1e-12);
183 double maxAbsDiffReal = 0;
184 double maxRelDiffReal = 0;
185 double maxAbsDiffImag = 0;
186 double maxRelDiffImag = 0;
187 for (
unsigned int i = 0;
i < newAmps.size(); ++
i) {
188 const complex<double> absDiff = oldAmps[
i] - newAmps[
i];
189 const complex<double> relDiff = complex<double>(absDiff.real() / oldAmps[
i].real(),
190 absDiff.imag() / oldAmps[
i].imag());
191 hAmpReal->Fill(newAmps[
i].real());
192 hAmpImag->Fill(newAmps[
i].imag());
193 hAmp->Fill(newAmps[
i].real(), newAmps[
i].imag());
194 hInt->Fill(parentMass[
i], abs(newAmps[i]));
195 hPhase->Fill(parentMass[i], TMath::RadToDeg() * std::arg(newAmps[i]));
196 hAbsDiffReal->Fill(absDiff.real());
197 hAbsDiffImag->Fill(absDiff.imag());
198 hRelDiffReal->Fill(relDiff.real());
199 hRelDiffImag->Fill(relDiff.imag());
200 if (abs(absDiff.real()) > maxAbsDiffReal)
201 maxAbsDiffReal = abs(absDiff.real());
202 if (abs(absDiff.imag()) > maxAbsDiffImag)
203 maxAbsDiffImag = abs(absDiff.imag());
204 if ((oldAmps[i].real() != 0) and (abs(relDiff.real()) > maxRelDiffReal))
205 maxRelDiffReal = abs(relDiff.real());
206 if ((oldAmps[i].imag() != 0) and (abs(relDiff.imag()) > maxRelDiffImag))
207 maxRelDiffImag = abs(relDiff.imag());
210 <<
" real part: maximum absolute deviation is " << maxAbsDiffReal <<
"; "
211 <<
"maximum relative deviation is " << maxRelDiffReal << endl
212 <<
" imag part: maximum absolute deviation is " << maxAbsDiffImag <<
"; "
213 <<
"maximum relative deviation is " << maxRelDiffImag << endl;
225 const size_t nmbEvents = 1000000;
227 const unsigned int seed = 123456789;
231 PDGtable.initialize(
"../../keyfiles/key5pi/pdgTable.txt");
255 ::particle pwa2kDaughter1(PDGtable.get(
"a1(1260)"), +1);
257 ::particle pwa2kDaughter2(PDGtable.get(
"pi"), -1);
258 const unsigned int L = 0;
259 const unsigned int S = 2;
261 ::particle pwa2kParent(PDGtable.get(
"rho(1700)"), 0);
266 pwa2kDecay.
addChild(pwa2kDaughter1);
267 pwa2kDecay.
addChild(pwa2kDaughter2);
270 pwa2kParent.setDecay(pwa2kDecay);
273 TFile* outFile = TFile::Open(
"testMassDependence.root",
"RECREATE");
274 const size_t nmbMassDep = 2;
275 const string names[nmbMassDep] = {
299 for (
size_t i = 0;
i < nmbMassDep; ++
i) {
300 compareAmplitudes(nmbEvents, seed, massDep[
i], vertex, pwa2kMassDep[i], pwa2kParent, names[i]);