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