Newer
Older
// HeliDecAmps class definition file. -*- C++ -*-
// Copyright 2012 Bertram Kopf
#include <getopt.h>
#include <fstream>
#include <string>
#include "PwaUtils/HeliDecAmps.hh"
#include "qft++/relativistic-quantum-mechanics/Utils.hh"
#include "ErrLogger/ErrLogger.hh"
#include "PwaUtils/DataUtils.hh"
#include "PwaUtils/IsobarHeliDecay.hh"
//#include "PwaUtils/XdecAmpRegistry.hh"
#include "Particle/Particle.hh"
#ifdef _OPENMP
#include <omp.h>
#endif
HeliDecAmps::HeliDecAmps(boost::shared_ptr<IsobarHeliDecay> theDec) :
AbsXdecAmp(theDec)
,_JPClamlams(theDec->JPClamlamAmps())
,_factorMag(1.)
{
if(_JPClamlams.size()>0) _factorMag=1./sqrt(_JPClamlams.size());
Particle* daughter1=_decay->daughter1Part();
Particle* daughter2=_decay->daughter2Part();
_parityFactor=_JPCPtr->P*daughter1->theParity()*daughter2->theParity()*pow(-1,_JPCPtr->J-daughter1->J()-daughter2->J());
Info << "_parityFactor=\t" << _parityFactor << endmsg;
}
HeliDecAmps::HeliDecAmps(boost::shared_ptr<AbsDecay> theDec) :
AbsXdecAmp(theDec)
{
Particle* daughter1=_decay->daughter1Part();
Particle* daughter2=_decay->daughter2Part();
_parityFactor=_JPCPtr->P*daughter1->theParity()*daughter2->theParity()*pow(-1,_JPCPtr->J-daughter1->J()-daughter2->J());
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
Info << "_parityFactor=\t" << _parityFactor << endmsg;
}
HeliDecAmps::~HeliDecAmps()
{
}
complex<double> HeliDecAmps::XdecPartAmp(Spin lamX, Spin lamDec, short fixDaughterNr, EvtData* theData, Spin lamFs){
// Spin lam1Min=-_Jdaughter1;
// Spin lam1Max= _Jdaughter1;
// Spin lam2Min=-_Jdaughter2;
// Spin lam2Max=_Jdaughter2;
// if(fixDaughterNr == 1){
// lam1Min = lam1Max = lamDec;
// }
// else if(fixDaughterNr == 2){
// lam2Min = lam2Max = lamDec;
// }
// else{
// Alert << "Invalid fitDaughterNr in XdecPartAmp." << endmsg;
// }
// if( _daughter1IsStable && _Jdaughter1>0){
// lam1Min=lamFs;
// lam1Max=lamFs;
// }
// else if(_daughter2IsStable && _Jdaughter2>0){
// lam2Min=lamFs;
// lam2Max=lamFs;
// }
// complex<double> result(0.,0.);
// std::vector< boost::shared_ptr<const JPCLS> >::iterator it;
// for (it=_JPCLSs.begin(); it!=_JPCLSs.end(); ++it){
// if( fabs(lamX) > (*it)->J ) continue;
// double theMag=_currentParamMags[*it];
// double thePhi=_currentParamPhis[*it];
// complex<double> expi(cos(thePhi), sin(thePhi));
// for(Spin lambda1=lam1Min; lambda1<=lam1Max; lambda1++){
// for(Spin lambda2=lam2Min; lambda2<=lam2Max; lambda2++){
// Spin lambda = lambda1-lambda2;
// if( fabs(lambda)>(*it)->J || fabs(lambda)>(*it)->S) continue;
// complex<double> amp = theMag*expi*sqrt(2*(*it)->L+1)
// *Clebsch((*it)->L, 0, (*it)->S, lambda, (*it)->J, lambda)
// *Clebsch(_Jdaughter1, lambda1, _Jdaughter2, -lambda2, (*it)->S, lambda )
// *conj( theData->WignerDsString[_wignerDKey][(*it)->J][lamX][lambda]);
// result+=amp;
// }
// }
// }
complex<double> result(0.,0.);
return result;
}
complex<double> HeliDecAmps::XdecAmp(Spin lamX, EvtData* theData, Spin lamFs){
int evtNo=theData->evtNo;
if ( _cacheAmps && !_recalculate){
complex<double> result(0.,0.);
result= _cachedAmpMap[evtNo][lamX][lamFs];
return result;
}
bool lamFs_daughter1=false;
if( _daughter1IsStable && _Jdaughter1>0) lamFs_daughter1=true;
bool lamFs_daughter2=false;
if( _daughter2IsStable && _Jdaughter2>0) lamFs_daughter2=true;
complex<double> result(0.,0.);
std::vector< boost::shared_ptr<const JPClamlam> >::iterator it;
for (it=_JPClamlams.begin(); it!=_JPClamlams.end(); ++it){
if( fabs(lamX) > (*it)->J ) continue;
double theMag=_currentParamMagLamLams[*it];
double thePhi=_currentParamPhiLamLams[*it];
complex<double> expi(cos(thePhi), sin(thePhi));
double preFactor=1.;
Spin lambda1= (*it)->lam1;
if(lamFs_daughter1){
if( fabs(lamFs)!=fabs(lambda1) ) continue;
else if(lamFs = -lambda1){
preFactor=_parityFactor;
lambda1=-lambda1;
}
}
Spin lambda2= (*it)->lam2;
if(lamFs_daughter2){
if( fabs(lamFs)!=fabs(lambda2) ) continue;
else if(lamFs = -lambda2){
preFactor=_parityFactor;
lambda2=-lambda2;
}
}
Spin lambda = lambda1-lambda2;
// if( fabs(lambda)>(*it)->J || fabs(lambda)>(*it)->S) continue;
complex<double> amp = theMag*expi*conj( theData->WignerDsString[_wignerDKey][(*it)->J][lamX][lambda]);
if(!lamFs_daughter1 && !lamFs_daughter2){
result+=amp*daughterAmp(lambda1, lambda2, theData, lamFs);
if(lambda1 != lambda2) result+=_parityFactor*amp*daughterAmp(-lambda1, -lambda2, theData, lamFs);
}
else result+=amp*daughterAmp(lambda1, lambda2, theData, lamFs);
}
if(_withDyn){
Vector4<double> mass4Vec(0.,0.,0.,0.);
std::vector<Particle*> fsParticleVec=_decay->finalStateParticles();
std::vector<Particle*>::iterator itPartVec;
for (itPartVec=fsParticleVec.begin(); itPartVec!=fsParticleVec.end(); ++itPartVec){
mass4Vec+=theData->FourVecsString[(*itPartVec)->name()];
}
result*=BreitWigner(mass4Vec, _currentXMass, _currentXWidth);
}
result*=sqrt((2.*_JPCPtr->J+1.)/12.56637);
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
if ( _cacheAmps){
#ifdef _OPENMP
#pragma omp critical
{
#endif
_cachedAmpMap[evtNo][lamX][lamFs]=result;
#ifdef _OPENMP
}
#endif
}
return result;
}
void HeliDecAmps::getDefaultParams(fitParams& fitVal, fitParams& fitErr){
std::map< boost::shared_ptr<const JPClamlam>, double, pawian::Collection::SharedPtrLess > currentMagValMap;
std::map< boost::shared_ptr<const JPClamlam>, double, pawian::Collection::SharedPtrLess > currentPhiValMap;
std::map< boost::shared_ptr<const JPClamlam>, double, pawian::Collection::SharedPtrLess > currentMagErrMap;
std::map< boost::shared_ptr<const JPClamlam>, double, pawian::Collection::SharedPtrLess > currentPhiErrMap;
std::vector< boost::shared_ptr<const JPClamlam> >::const_iterator itlamlam;
for(itlamlam=_JPClamlams.begin(); itlamlam!=_JPClamlams.end(); ++itlamlam){
currentMagValMap[*itlamlam]=_factorMag;
currentPhiValMap[*itlamlam]=0.;
currentMagErrMap[*itlamlam]=0.5*_factorMag;
currentPhiErrMap[*itlamlam]=0.3;
}
fitVal.MagLamLams[_key]=currentMagValMap;
fitVal.PhiLamLams[_key]=currentPhiValMap;
fitErr.MagLamLams[_key]=currentMagErrMap;
fitErr.PhiLamLams[_key]=currentPhiErrMap;
if(_withDyn){
fitVal.Masses[_massKey]=_decay->motherPart()->mass();
fitErr.Masses[_massKey]=0.03;
fitVal.Widths[_massKey]=_decay->motherPart()->width();
fitErr.Widths[_massKey]=_decay->motherPart()->width();
}
if(!_daughter1IsStable) _decAmpDaughter1->getDefaultParams(fitVal, fitErr);
if(!_daughter2IsStable) _decAmpDaughter2->getDefaultParams(fitVal, fitErr);
}
void HeliDecAmps::print(std::ostream& os) const{
return; //dummy
}
bool HeliDecAmps::checkRecalculation(fitParams& theParamVal){
_recalculate=false;
std::map< boost::shared_ptr<const JPClamlam>, double, pawian::Collection::SharedPtrLess > magMap=theParamVal.MagLamLams[_key];
std::map< boost::shared_ptr<const JPClamlam>, double, pawian::Collection::SharedPtrLess > phiMap=theParamVal.PhiLamLams[_key];
std::vector< boost::shared_ptr<const JPClamlam> >::iterator it;
for (it=_JPClamlams.begin(); it!=_JPClamlams.end(); ++it){
double theMag=magMap[*it];
double thePhi=phiMap[*it];
if ( fabs(theMag - _currentParamMagLamLams[*it]) > 1.e-10 ){
_recalculate=true;
}
if ( fabs(thePhi - _currentParamPhiLamLams[*it]) > 1.e-10 ){
_recalculate=true;
}
}
if(_withDyn){
double mass=theParamVal.Masses[_massKey];
if ( fabs(mass-_currentXMass) > 1.e-10){
_recalculate=true;
}
double width=theParamVal.Widths[_massKey];
if ( fabs(width-_currentXWidth) > 1.e-10){
_recalculate=true;
}
}
if(!_daughter1IsStable) {
if(_decAmpDaughter1->checkRecalculation(theParamVal)) _recalculate=true;
}
if(!_daughter2IsStable){
if(_decAmpDaughter2->checkRecalculation(theParamVal)) _recalculate=true;
}
return _recalculate;
}
void HeliDecAmps::updateFitParams(fitParams& theParamVal){
std::map< boost::shared_ptr<const JPClamlam>, double, pawian::Collection::SharedPtrLess > magMap=theParamVal.MagLamLams[_key];
std::map< boost::shared_ptr<const JPClamlam>, double, pawian::Collection::SharedPtrLess > phiMap=theParamVal.PhiLamLams[_key];
std::vector< boost::shared_ptr<const JPClamlam> >::iterator it;
for (it=_JPClamlams.begin(); it!=_JPClamlams.end(); ++it){
double theMag=magMap[*it];
double thePhi=phiMap[*it];
_currentParamMagLamLams[*it]=theMag;
_currentParamPhiLamLams[*it]=thePhi;
}
if (_withDyn){
double xMass=theParamVal.Masses[_massKey];
_currentXMass= xMass;
double xWidth=theParamVal.Widths[_massKey];
_currentXWidth=xWidth;
}
if(!_daughter1IsStable) _decAmpDaughter1->updateFitParams(theParamVal);
if(!_daughter2IsStable) _decAmpDaughter2->updateFitParams(theParamVal);
}