BOSS 7.0.8
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtOpenCharm.cc
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2//
3// Environment:
4// This software is part of models developed at BES collaboration
5// based on the EvtGen framework. If you use all or part
6// of it, please give an appropriate acknowledgement.
7//
8// Copyright Information: See CVS repository
9// Copyright (A) 2011 Ping Rong-Gang
10//
11// Module: EvtOpenCharm.cc
12//
13// Description: Routine to decay charmonium-> DD, DDpi according the
14// cross section measurement by CLEO PRD 80, 072001.
15//
16// Modification history:
17//
18// Ping R.-G. December, 2011 Module created
19//
20//------------------------------------------------------------------------
21//
22
28#include "EvtGenBase/EvtPDL.hh"
32#include <string>
33#include "EvtGenBase/EvtId.hh"
34#include <iostream>
35#include <iomanip>
36#include <fstream>
37#include <string.h>
38#include <stdlib.h>
39#include <unistd.h>
40#include <stdio.h>
41using std::endl;
42using std::fstream;
43using std::ios;
44using std::ofstream;
45using std::resetiosflags;
46using std::setiosflags;
47using std::setw;
48
49
50int EvtOpenCharm::nOpencharmdecays=0;
51EvtDecayBasePtr* EvtOpenCharm::Opencharmdecays=0;
52int EvtOpenCharm::ntable=0;
53
54int EvtOpenCharm::ncommand=0;
55int EvtOpenCharm::lcommand=0;
56std::string* EvtOpenCharm::commands=0;
57int EvtOpenCharm::nevt=0;
58
60std::vector<EvtId> EvtOpenCharm::mypar;
61std::vector<int> EvtOpenCharm::vmode;
62std::vector<double> EvtOpenCharm::Vcms;
63
64
66
68
69
70 int i;
71
72
73 //the deletion of commands is really uggly!
74
75 if (nOpencharmdecays==0) {
76 delete [] commands;
77 commands=0;
78 return;
79 }
80
81 for(i=0;i<nOpencharmdecays;i++){
82 if (Opencharmdecays[i]==this){
83 Opencharmdecays[i]=Opencharmdecays[nOpencharmdecays-1];
84 nOpencharmdecays--;
85 if (nOpencharmdecays==0) {
86 delete [] commands;
87 commands=0;
88 }
89 return;
90 }
91 }
92
93 report(ERROR,"EvtGen") << "Error in destroying OpenCharm model!"<<endl;
94
95}
96
97
98void EvtOpenCharm::getName(std::string& model_name){
99
100 model_name="OPENCHARM";
101
102}
103
105
106 return new EvtOpenCharm;
107
108}
109
110
112
113 noProbMax();
114
115}
116
117
119
120// checkNArg(1);
121
122
123 if (getParentId().isAlias()){
124
125 report(ERROR,"EvtGen") << "EvtOpenCharm finds that you are decaying the"<<endl
126 << " aliased particle "
127 << EvtPDL::name(getParentId()).c_str()
128 << " with the OpenCharm model"<<endl
129 << " this does not work, please modify decay table."
130 << endl;
131 report(ERROR,"EvtGen") << "Will terminate execution!"<<endl;
132 ::abort();
133
134 }
135
136 store(this);
137
138}
139
140
142
143 return std::string("OpenCharmPar");
144
145}
146
147void EvtOpenCharm::command(std::string cmd){
148
149 if (ncommand==lcommand){
150
151 lcommand=10+2*lcommand;
152
153 std::string* newcommands=new std::string[lcommand];
154
155 int i;
156
157 for(i=0;i<ncommand;i++){
158 newcommands[i]=commands[i];
159 }
160
161 delete [] commands;
162
163 commands=newcommands;
164
165 }
166
167 commands[ncommand]=cmd;
168
169 ncommand++;
170
171
172}
173
174
175
177
178 int istdheppar=EvtPDL::getStdHep(p->getId());
179
180 if(istdheppar != 9000443 && istdheppar != 9010443 && istdheppar != 9030443 &&istdheppar != 9020443 ){
181 std::cout<<"EvtGen: EvtOpenCharm cann't not decay the particle pid= "<<istdheppar<<endl;
182 ::abort();
183 }
184
185 double mp=p->mass();
186 float xmp=mp;
187 double totEn=0;
188
189 //debugging
190 // std::cout<<"parent "<<EvtPDL::name(p->getId())<<"float xmp="<<xmp<<" "<<p->getP4Lab()<<std::endl;
191
192 EvtVector4R p4[20];
193
194 int i,more;
195 int ip=EvtPDL::getStdHep(p->getId());
196 int ndaugjs;
197
198 static int myflag;
199 EvtPsi3Sdecay theIni;
200 EvtId pid = p->getId();
201
202 static int themode;
203 if(getNArg()==1){ themode = getArg(0); theIni.setMode(themode);}
204
205 int count=0;
206 do{
207
208 theIni.PHSPDecay(p);
209 std::vector<EvtVector4R> v_p4=theIni.getDaugP4();
210 std::vector<EvtId> Vid=theIni.getDaugId();
211 ndaugjs = Vid.size();
212
213 EvtId myId[3];
214
215 for(int i=0;i<ndaugjs;i++){myId[i]=Vid[i];}
216
217
218 if(p->getNDaug()!=0) p->resetNDaug();
219 p->makeDaughters(ndaugjs,myId);
220
221 for(int i=0;i<ndaugjs;i++){
222 // std::cout<<"Vid "<<EvtPDL::name(Vid[i])<<" p4: "<<v_p4[i]<<std::endl;
223 p->getDaug(i)->init(Vid[i],v_p4[i]);
224 }
225
226
227 theMode = theIni.getMode();
228 p->setGeneratorFlag(theMode);
229
230
231 totEn=0;
232 for(i=0;i<ndaugjs;i++){
233 totEn +=p->getDaug(i)->getP4().get(0);
234 if ( p->getDaug(i)->getId() ==EvtId(-1,-1)) {
235 report(ERROR,"EvtGen") << "OpenCharm returned particle:"<<EvtPDL::name( p->getDaug(i)->getId() )<<endl;
236 report(ERROR,"EvtGen") << "This can not be translated to evt number"<<endl;
237 report(ERROR,"EvtGen") << "and the decay will be rejected!"<<endl;
238 report(ERROR,"EvtGen") << "The decay was of particle:"<<ip<<endl;
239
240 }
241
242 }
243 int channel=EvtDecayTable::inChannelList(p->getId(),ndaugjs,myId);
244
245 // std::cout<<"channel= "<<channel<<std::endl;
246 more=(channel!=-1);
247 //if(more){std::cout<<"count= "<<count<<" inchannel= "<<channel<<std::endl;}
248
249 count++;
250
251 }while( more && (count<10000) );
252
253 if(fabs(xmp-totEn)>0.01){
254 std::cout<<"Warning:OPENCHARM generate incomplet final state, "<<mp<<" "<<totEn<<endl;
255 ::abort();
256 }
257
258 if (count>9999) {
259 report(INFO,"EvtGen") << "Too many loops in EvtOpenCharm!!!"<<endl;
260 report(INFO,"EvtGen") << "Parent:"<<EvtPDL::name(getParentId()).c_str()<<endl;
261 }
262
263 fixPolarizations(p);
264
265 return ;
266
267
268}
269
270void EvtOpenCharm::fixPolarizations(EvtParticle *p){
271
272 //special case for now to handle the J/psi polarization
273
274 int ndaug=p->getNDaug();
275
276 int i;
277
278 static EvtId Jpsi =EvtPDL::getId("J/psi");
279 static EvtId psip =EvtPDL::getId("psi(2S)");
280 static EvtId psipp =EvtPDL::getId("psi(3770)");
281 static EvtId psi_a =EvtPDL::getId("psi(4040)");
282 static EvtId psi_b =EvtPDL::getId("psi(4160)");
283 static EvtId psi_c =EvtPDL::getId("psi(4260)");
284
285 for(i=0;i<ndaug;i++){
286 EvtId idp = p->getDaug(i)->getId();
287 bool bflag=(idp==Jpsi || idp==psip || idp==psipp || idp==psi_a || idp==psi_b || idp ==psi_c);
288 if(bflag){
289
290 EvtSpinDensity rho;
291
292 rho.SetDim(3);
293 rho.Set(0,0,0.5);
294 rho.Set(0,1,0.0);
295 rho.Set(0,2,0.0);
296
297 rho.Set(1,0,0.0);
298 rho.Set(1,1,1.0);
299 rho.Set(1,2,0.0);
300
301 rho.Set(2,0,0.0);
302 rho.Set(2,1,0.0);
303 rho.Set(2,2,0.5);
304
305 EvtVector4R p4Psi=p->getDaug(i)->getP4();
306
307 double alpha=atan2(p4Psi.get(2),p4Psi.get(1));
308 double beta=acos(p4Psi.get(3)/p4Psi.d3mag());
309
310
313
314 }
315 }
316
317}
318
319void EvtOpenCharm::store(EvtDecayBase* jsdecay){
320
321 if (nOpencharmdecays==ntable){
322
323 EvtDecayBasePtr* newOpencharmdecays=new EvtDecayBasePtr[2*ntable+10];
324 int i;
325 for(i=0;i<ntable;i++){
326 newOpencharmdecays[i]=Opencharmdecays[i];
327 }
328 ntable=2*ntable+10;
329 delete [] Opencharmdecays;
330 Opencharmdecays=newOpencharmdecays;
331 }
332
333 Opencharmdecays[nOpencharmdecays++]=jsdecay;
334
335
336
337}
338
340}
341
342
344 for (int i=0;i<mypar.size();i++){
345 if(myid == mypar[i]) {_index = i; return true;}
346 }
347 return false;
348}
349
351 for (int i=0;i<mypar.size();i++){
352 if(myid == mypar[i]){
353 _index = i;
354 return i;
355 }
356 }
357 std::cout<<"EvtOpenCharm::which_mode() fails to find element"<<std::endl; abort();
358}
359
360
DOUBLE_PRECISION count[3]
ostream & report(Severity severity, const char *facility)
Definition: EvtReport.cc:36
@ ERROR
Definition: EvtReport.hh:49
@ INFO
Definition: EvtReport.hh:52
const double alpha
double getArg(int j)
void noProbMax()
EvtId getParentId()
Definition: EvtDecayBase.hh:60
void setDaughterSpinDensity(int daughter)
static int inChannelList(EvtId parent, int ndaug, EvtId *daugs)
Definition: EvtId.hh:27
int which_mode(EvtId myid)
std::string commandName()
static int myiter
Definition: EvtOpenCharm.hh:56
virtual ~EvtOpenCharm()
Definition: EvtOpenCharm.cc:67
void command(std::string cmd)
static void OpencrmInit(int f)
EvtDecayBase * clone()
void getName(std::string &name)
Definition: EvtOpenCharm.cc:98
void initProbMax()
bool isbelong(EvtId myid)
void decay(EvtParticle *p)
static int getStdHep(EvtId id)
Definition: EvtPDL.hh:56
static std::string name(EvtId i)
Definition: EvtPDL.hh:64
static EvtId getId(const std::string &name)
Definition: EvtPDL.cc:287
void setSpinDensityForwardHelicityBasis(const EvtSpinDensity &rho)
Definition: EvtParticle.cc:178
void makeDaughters(int ndaug, EvtId *id)
virtual void init(EvtId part_n, const EvtVector4R &p4)=0
void resetNDaug()
Definition: EvtParticle.hh:269
EvtId getId() const
Definition: EvtParticle.cc:113
void setGeneratorFlag(int flag)
Definition: EvtParticle.hh:141
const EvtVector4R & getP4() const
Definition: EvtParticle.cc:121
int getNDaug() const
Definition: EvtParticle.cc:125
EvtParticle * getDaug(int i)
Definition: EvtParticle.cc:85
double mass() const
Definition: EvtParticle.cc:127
void PHSPDecay(EvtParticle *par)
void setMode(int m)
std::vector< EvtVector4R > getDaugP4()
std::vector< EvtId > getDaugId()
void Set(int i, int j, const EvtComplex &rhoij)
void SetDim(int n)
double get(int i) const
Definition: EvtVector4R.hh:179
double d3mag() const
Definition: EvtVector4R.cc:186
const double mp
Definition: incllambda.cxx:45