BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtDecay Class Reference

#include <EvtDecay.h>

+ Inheritance diagram for EvtDecay:

Public Member Functions

 EvtDecay (const string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 
double ampsLenu (vector< double > Vexp, std::vector< double > vpars)
 
double ampsLbenu (vector< double > Vexp, std::vector< double > vpars)
 
double HV (double i, double j, vector< double > Vexp, std::vector< double > vpars)
 
double HA (double i, double j, vector< double > Vexp, std::vector< double > vpars)
 

Public Attributes

IDataInfoSvctmpInfoSvc
 
DataInfoSvcdataInfoSvc
 

Detailed Description

Definition at line 65 of file EvtDecay.h.

Constructor & Destructor Documentation

◆ EvtDecay()

EvtDecay::EvtDecay ( const string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 79 of file EvtDecay.cxx.

79 :Algorithm( name, pSvcLocator )
80{
81
82
83
84 // these can be used to specify alternative locations or filenames
85 // for the EvtGen particle and channel definition files.
86
87 declareProperty("DecayDecDir", m_DecayDec = "");
88 declareProperty("PdtTableDir", m_PdtTable = "");
89 declareProperty("userDecayTableName", userDecFileName = "NONE");
90 declareProperty("DecayTopology", m_DecayTop = ""); // output decay topology to a file specified by user
91 declareProperty("DecayRecord", m_DecayRec = ""); // output decay topology of one particle specified by user to a file
92 declareProperty("ParentParticle", m_ParentPart = "NONE");// Mothor particle name in pdt.table for only running BesEvtGen
93 declareProperty("Multiplicity", m_Ncharge = false); // output ncharge number of an event
94 declareProperty("NutupleFile",m_NtupleFile = false); // output Ntuple file
95 declareProperty("mDIY",_mDIY= false); // mDIY model
96 declareProperty("FDPdata",m_SB3File = ""); // Fit Dalitz Plot (FDP) data file name (*.root)
97 declareProperty("FDPHisT",m_SB3HT = ""); // histogram title of Dalitz plot in data file
98 declareProperty("FDPpart",m_FDPparticle =""); //to assign the FDP parent particle name (string)
99 declareProperty("TruthFile",m_truthFile ="");
100 declareProperty("TruthPart",m_truthPart ="");
101 declareProperty("Psi3SopenCharm",m_Psi4040OpenCharm=false);
102 declareProperty("Psi2openCharm", m_Psi2openCharm=false);
103 declareProperty("statDecays",m_statDecays=false);
104 declareProperty("TagLundCharmModel", m_tagLundModel=false);
105 m_mystring.clear();
106 declareProperty("FileForTrackGen", m_mystring);
107 //for polarized charmonium production
108 m_polarization.clear();//= diag{1+Pe, 0, 1-Pe} with electron polarization Pe
109 declareProperty("polarization", m_polarization);
110 declareProperty("eBeamPolarization", m_eBeamPolarization=-1);
111 m_cluster0.clear();m_wind0.clear();
112 m_cluster1.clear();m_wind1.clear();
113 m_cluster2.clear();m_wind2.clear();
114 declareProperty("cluster0",m_cluster0);
115 declareProperty("cluster1",m_cluster1);
116 declareProperty("cluster2",m_cluster2);
117 declareProperty("masswin0",m_wind0);
118 declareProperty("masswin1",m_wind1);
119 declareProperty("masswin2",m_wind2);
120 declareProperty("OutputP4",m_outputp4="");
121 declareProperty("ReadMeasuredEcms", m_RdMeasuredEcms = false);
122 m_ReadTruth.clear();
123 declareProperty("ReadTruth",m_ReadTruth);
124 //ReadTruth={{"ParentName"},{"i0","i1","i2"},{"j0","j1","j2","j3"}}, where the first part. is Parent->getDaug(i0)->getDaug(i1)->getDaug(i2),
125 //and second particle is Parent ->getDaug(j0)->getDaug(j1)->getDaug(j2)->getDaug(j3);
126}

Member Function Documentation

◆ ampsLbenu()

double EvtDecay::ampsLbenu ( vector< double >  Vexp,
std::vector< double >  vpars 
)

◆ ampsLenu()

double EvtDecay::ampsLenu ( vector< double >  Vexp,
std::vector< double >  vpars 
)

◆ execute()

StatusCode EvtDecay::execute ( )

Definition at line 322 of file EvtDecay.cxx.

323{
324
325 MsgStream log(messageService(), name());
326 // log << MSG::INFO << "EvtDecay executing" << endreq;
327 //------------------
328 string key = "GEN_EVENT";
329 // retrieve event from Transient Store (Storegate)
330 SmartDataPtr<McGenEventCol> McEvtColl(eventSvc(), "/Event/Gen");
331
332 m_numberEvent += 1;
333 writeFlag = 0;
334 //std::cout<<"EvtNumber= "<<m_numberEvent<<std::endl;
335 if ( McEvtColl == 0 )
336 {
337 HepMC::GenEvent* evt=new GenEvent();
338 evt->set_event_number(m_numberEvent);
339
340 //read Ecms from the database
341 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
342 int runNo=eventHeader->runNumber();
343 int event=eventHeader->eventNumber();
344 bool newRunFlag=0;
345 if(runNo != 0 && runNo != m_runNo){m_runNo=runNo;newRunFlag = true;}else{newRunFlag=false;}
346 if(m_RdMeasuredEcms&& newRunFlag){// using cms energy of beam read from database
347 runNo = std::abs(runNo);
348 ReadME theME(runNo);
349 if(theME.isRunNoValid()){
350 dbEcms=theME.getEcms();
351 std::cout<<"Read Ecms= "<<dbEcms<<std::endl;
352 if(dbEcms!=0){
353 std::cout<<"INFO: Read the MeasuredEcms"<<std::endl;
354 }
355 else{
356 std::cout<<"ERROR: Can not read the MeasuredEcms, try to turn off the ReadEcmsDB"<<std::endl;
357 return StatusCode::FAILURE;
358 }
359 }
360 }
361 //end of read Ecms
362
363 callBesEvtGen( evt );
364 if(!(m_DecayTop=="")) evt->print(outfile);
365
366 //create a Transient store
367 McGenEventCol *mcColl = new McGenEventCol;
368 McGenEvent* mcEvent = new McGenEvent(evt);
369 mcColl->push_back(mcEvent);
370 StatusCode sc = eventSvc()->registerObject("/Event/Gen",mcColl);
371 if(sc != SUCCESS) return StatusCode::FAILURE;
372
373 } else // (McEvtColl != 0)
374 {
375 McGenEventCol::iterator mcItr;
376 for( mcItr = McEvtColl->begin(); mcItr != McEvtColl->end(); mcItr++ )
377 {
378 HepMC::GenEvent* hEvt = (*mcItr)->getGenEvt();
379 // MeVToGeV( hEvt );
380
381 callEvtGen( hEvt );
382
383 if(!(m_DecayTop=="")) hEvt->print(outfile);
384 // GeVToMeV( hEvt );
385 // if(!(m_DecayRec=="")) outfile2<<std::endl;
386 if(!(m_DecayRec=="")) std::cout<<std::endl;
387 };
388 }
389 if( m_NtupleFile ){ m_tuple->write();}
390 return StatusCode::SUCCESS;
391}
int runNo
Definition: DQA_TO_DB.cxx:12
*************DOUBLE PRECISION m_pi *DOUBLE PRECISION m_HvecTau2 DOUBLE PRECISION m_HvClone2 DOUBLE PRECISION m_gamma1 DOUBLE PRECISION m_gamma2 DOUBLE PRECISION m_thet1 DOUBLE PRECISION m_thet2 INTEGER m_IFPHOT *COMMON c_Taupair $ !Spin Polarimeter vector first Tau $ !Spin Polarimeter vector second Tau $ !Clone Spin Polarimeter vector first Tau $ !Clone Spin Polarimeter vector second Tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !phi of HvecTau1 $ !theta of HvecTau1 $ !phi of HvecTau2 $ !theta of HvecTau2 $ !super key
Definition: Taupair.h:42

◆ finalize()

StatusCode EvtDecay::finalize ( )

Definition at line 944 of file EvtDecay.cxx.

945{
946
947 if(EvtCalHelAmp::nevt>0){
948 double H2=EvtCalHelAmp::_H2;
949 double H1=EvtCalHelAmp::_H1;
950 double H0=EvtCalHelAmp::_H0;
951 double H2err=EvtCalHelAmp::_H2err;
952 double H1err=EvtCalHelAmp::_H1err;
953 double H0err=EvtCalHelAmp::_H0err;
954 int nd = EvtCalHelAmp::nevt;
955 std::cout<<"Calculated helicity amplitude sqaured are:"<<std::endl;
956 std::cout<<"|H_{2}|^2=|H_{-2}|^2= "<<H2/nd<<" +/- "<<sqrt(H2err/nd)<<endl;
957 std::cout<<"|H_{1}|^2=|H_{-1}|^2= "<<H1/nd<<" +/- "<<sqrt(H1err/nd)<<endl;
958 //std::cout<<"|H_{0}|^2= "<<H0/nd <<" +/- "<<sqrt(H0err/nd)<<endl;
959 }
960 MsgStream log(messageService(), name());
961 truth.close();
962 log << MSG::INFO << "EvtDecay finalized" << endreq;
963 fstream Forfile;
964 Forfile.open("fort.16",ios::in);
965 char delcmd[300];
966 strcpy(delcmd,"rm -f ");
967 strcat(delcmd,"fort.16");
968 // if(Forfile)system(delcmd);
969
970 fstream Forfile2;
971 Forfile2.open("fort.22",ios::in);
972 strcpy(delcmd,"rm -f ");
973 strcat(delcmd,"fort.22");
974 // if(Forfile2)system(delcmd);
975
976 // To get the branching fraction of the specified mode in Lundcharm Model
977 /*
978 EvtLundCharm lundcharmEvt;
979 int nevt=lundcharmEvt.getTotalEvt();
980 std::cout<<"The total number of the specified mode is "<<nevt<<std::endl;
981 */
982 int totalEvt=0;
983 if(!(m_SB3File=="" || m_SB3HT=="")){
984 for(int i=0;i<500;i++){totalEvt=totalEvt+br[i];}
985 for(int i=0;i<500;i++){
986 double bi=1.0*br[i]/totalEvt;
987 std::cout<<"Branching fraction of channel "<<i<<" is: "<<bi<<std::endl;
988 if(br[i]==0) break;
989 }
990 }
991
992 if(m_statDecays){
993 int totalEvt=0;
994 for(int i=0;i<=totalChannels;i++){totalEvt=totalEvt+br[i];}
995 std::cout<<"==================Statistical first chain decay ==============================="<<std::endl;
996 std::cout<<"i-th channel Events Generated Branching fraction generated "<<std::endl;
997 for(int i=0;i<=totalChannels;i++){
998 std::cout<<"| "<<i<<" "<<br[i]<<" "<<br[i]*1.0/totalEvt<<std::endl;
999
1000 }
1001 std::cout<<"--------------------------------------------------------------------------------"<<std::endl;
1002 std::cout<<" sum: "<<totalEvt<<" "<<"1"<<std::endl;
1003 std::cout<<"================== End of statistical first chain decay ========================"<<std::endl;
1004 }
1005
1006 return StatusCode::SUCCESS;
1007}
static double _H0err
Definition: EvtCalHelAmp.hh:58
static double _H1err
Definition: EvtCalHelAmp.hh:58
static double _H0
Definition: EvtCalHelAmp.hh:58
static int nevt
Definition: EvtCalHelAmp.hh:59
static double _H1
Definition: EvtCalHelAmp.hh:58
static double _H2
Definition: EvtCalHelAmp.hh:58
static double _H2err
Definition: EvtCalHelAmp.hh:58

◆ HA()

double EvtDecay::HA ( double  i,
double  j,
vector< double >  Vexp,
std::vector< double >  vpars 
)

◆ HV()

double EvtDecay::HV ( double  i,
double  j,
vector< double >  Vexp,
std::vector< double >  vpars 
)

◆ initialize()

StatusCode EvtDecay::initialize ( )

Definition at line 129 of file EvtDecay.cxx.

129 {
130
131 MsgStream log(messageService(), name());
132 if(m_truthFile!=""){truth.open(m_truthFile.c_str());}
133 log << MSG::INFO << "EvtDecay initialize" << endreq;
134 static const bool CREATEIFNOTTHERE(true);
135 StatusCode RndmStatus = service("BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE);
136 if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
137 {
138 log << MSG::ERROR << " Could not initialize Random Number Service" << endreq;
139 return RndmStatus;
140 }
141
142 EvtGlobalSet::SV.clear();
143 for(int i=0;i<m_mystring.size();i++){EvtGlobalSet::SV.push_back(m_mystring[i]);}
144
145 EvtGlobalSet::iVV.clear();
146 EvtGlobalSet::dVV.clear();
147 std::vector<std::vector<int> >myivv;
148 std::vector<std::vector<double> >mydvv;
149
150 myivv.push_back(m_cluster0);
151 myivv.push_back(m_cluster1);
152 myivv.push_back(m_cluster2);
153
154 mydvv.push_back(m_wind0);
155 mydvv.push_back(m_wind1);
156 mydvv.push_back(m_wind2);
157
158 for(int i=0;i<myivv.size();i++){
159 std::vector<int> theivv;
160 for(int j=0;j<myivv[i].size();j++){
161 theivv.push_back(myivv[i][j]);
162 }
163 if(theivv.size()) EvtGlobalSet::iVV.push_back(theivv);
164 }
165
166 for(int i=0;i<mydvv.size();i++){
167 std::vector<double> thedvv;
168 for(int j=0;j<mydvv[i].size();j++){
169 thedvv.push_back(mydvv[i][j]);
170 }
171 if(thedvv.size()) EvtGlobalSet::dVV.push_back(thedvv);
172 }
173
174
175 if(m_eBeamPolarization>1) {std::cout<<"The e-beam polaziation should be in 0 to 1"<<std::endl;abort();}
176 m_numberEvent=0;
177 first = true;
178 m_ampscalflag = true;
179 // Save the random number seeds in the event
180 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->GetEngine("EVTGEN");
181 const long s = engine->getSeed();
182 p_BesRndmGenSvc->setGenseed(s+1);
183
184 m_seeds.clear();
185 m_seeds.push_back(s);
186 totalChannels = 0;
187
188 // open an interface to EvtGen
189
190 if ( m_DecayDec == "") { //use default DECAY.DEC and pdt.table if not defined by user
191 m_DecayDec=getenv("BESEVTGENROOT");
192 m_DecayDec +="/share/DECAY.DEC";
193 }
194
195 if ( m_PdtTable == "") {
196 m_PdtTable =getenv("BESEVTGENROOT");
197 m_PdtTable +="/share/pdt.table";
198 }
199
200 char catcmd[300]; //output user decay cards to log file
201 std::cout<<"===================== user decay card ========================"<<std::endl;
202 strcpy(catcmd, "cat ");
203 strcat(catcmd, userDecFileName.c_str());
204 system(catcmd);
205
208
209 // write decay cards to the root file: pingrg@2009-09-09
210 StatusCode status;
211 status = service("DataInfoSvc",tmpInfoSvc);
212 if (status.isSuccess()) {
213 log << MSG::INFO << "got the DataInfoSvc" << endreq;
214 dataInfoSvc=dynamic_cast<DataInfoSvc *>(tmpInfoSvc);
215 dataInfoSvc->setDecayCard(userDecFileName);
216 } else {
217 log << MSG::ERROR << "could not get the DataInfoSvc" << endreq;
218 return StatusCode::FAILURE;
219 }
220
221
222
223 m_RandomEngine = new EvtBesRandom(engine);
224 m_Gen = new EvtGen( m_DecayDec.c_str(), m_PdtTable.c_str(), m_RandomEngine );
225
226 if(userDecFileName =="NONE") log << MSG::INFO << "EvtDecay User did not define his Decay table EvtGen will use standart" << endreq;
227 if(!(userDecFileName =="NONE")) m_Gen->readUDecay(userDecFileName.c_str());
228
229 if(!(m_DecayTop==" ")) {
230 outfile.open(m_DecayTop.c_str());
231 }
232
233 //for output Ntuple file, pingrg-2009-09-07
234
235
236 if(m_NtupleFile) {
237 NTuplePtr nt1(ntupleSvc(),"MYROOTFILE/Trk");
238 if(nt1) {m_tuple=nt1;}
239 else {
240 m_tuple = ntupleSvc()->book ("MYROOTFILE/Trk", CLID_ColumnWiseTuple, "Generator-trk-Ntuple");
241 if(m_tuple){
242 status = m_tuple->addItem ("TotNumTrk", TotNumTrk, 0,100);
243 status = m_tuple->addIndexedItem ("Trk_index", TotNumTrk, m_Trk_index);
244 status = m_tuple->addIndexedItem ("m_px_trk", TotNumTrk, m_px_trk);
245 status = m_tuple->addIndexedItem ("m_py_trk", TotNumTrk, m_py_trk);
246 status = m_tuple->addIndexedItem ("m_pz_trk", TotNumTrk, m_pz_trk);
247 status = m_tuple->addIndexedItem ("m_en_trk", TotNumTrk, m_en_trk);
248 status = m_tuple->addIndexedItem ("FST", TotNumTrk, m_fst);
249
250 status = m_tuple->addItem ("nchr", m_nchr);
251 status = m_tuple->addItem ("nchr_e", m_nchr_e);
252 status = m_tuple->addItem ("nchr_mu", m_nchr_mu);
253 status = m_tuple->addItem ("nchr_pi", m_nchr_pi);
254 status = m_tuple->addItem ("nchr_k", m_nchr_k);
255 status = m_tuple->addItem ("nchr_p", m_nchr_p);
256 status = m_tuple->addItem ("N_gamma", m_gamma);
257 status = m_tuple->addItem ("N_gammaFSR", m_gammaFSR);
258 status = m_tuple->addItem ("Flag1", m_flag1);
259 } else {
260 log << MSG::ERROR << " Cannot book N-tuple:"<< long(m_tuple) << endmsg;
261 return StatusCode::FAILURE;
262 }
263 }
264
265 NTuplePtr nt2(ntupleSvc(),"MYROOTFILE/mass");
266 if(nt2) {mass_tuple=nt2;}
267 else {
268 mass_tuple = ntupleSvc()->book ("MYROOTFILE/mass", CLID_ColumnWiseTuple, "Generator-mass-Ntuple");
269 if(mass_tuple){
270 status = mass_tuple->addItem ("m12", m_m12);
271 status = mass_tuple->addItem ("m13", m_m13);
272 status = mass_tuple->addItem ("m23", m_m23);
273 status = mass_tuple->addItem ("m1", m_m1);
274 status = mass_tuple->addItem ("m2", m_m2);
275 status = mass_tuple->addItem ("m3", m_m3);
276 status = mass_tuple->addItem ("costheta1", m_cos1);
277 status = mass_tuple->addItem ("costheta2", m_cos2);
278 status = mass_tuple->addItem ("costheta3", m_cos3);
279 status = mass_tuple->addItem ("ichannel", m_ich);
280 } else {
281 log << MSG::ERROR << " Cannot book N-tuple:"<< long(m_tuple) << endmsg;
282 return StatusCode::FAILURE;
283 }
284 }
285
286 NTuplePtr nt3(ntupleSvc(),"MYROOTFILE/massGen");
287 if(nt3) {massgen_tuple=nt3;}
288 else {
289 massgen_tuple = ntupleSvc()->book ("MYROOTFILE/massGen", CLID_ColumnWiseTuple, "Generator-mass-Ntuple");
290 if(massgen_tuple){
291 status = massgen_tuple->addItem ("m12", _m12);
292 status = massgen_tuple->addItem ("m13", _m13);
293 status = massgen_tuple->addItem ("m23", _m23);
294 status = massgen_tuple->addItem ("m1", _m1);
295 status = massgen_tuple->addItem ("m2", _m2);
296 status = massgen_tuple->addItem ("m3", _m3);
297 status = massgen_tuple->addItem ("costheta1", _cos1);
298 status = massgen_tuple->addItem ("costheta2", _cos2);
299 status = massgen_tuple->addItem ("costheta3", _cos3);
300 status = massgen_tuple->addItem ("ichannel", _ich);
301 } else {
302 log << MSG::ERROR << " Cannot book N-tuple:"<< long(m_tuple) << endmsg;
303 return StatusCode::FAILURE;
304 }
305 }
306
307
308 }
309 for(int i=0;i<500;i++){br[i]=0;}
310 if(!(m_SB3File=="" && m_SB3HT=="")) {
311 const char *filename, *histitle;
312 filename=(char*)m_SB3File.c_str();
313 histitle=(char*)m_SB3HT.c_str();
314 SuperBody3decay.setFile(filename);
315 SuperBody3decay.setHTitle(histitle);
316 SuperBody3decay.init();
317 }
318
319 return StatusCode::SUCCESS;
320}
XmlRpcServer s
Definition: HelloServer.cpp:11
void setDecayCard(string card)
Definition: DataInfoSvc.cxx:50
DataInfoSvc * dataInfoSvc
Definition: EvtDecay.h:75
IDataInfoSvc * tmpInfoSvc
Definition: EvtDecay.h:74
Definition: EvtGen.hh:46
void readUDecay(const char *const udecay_name)
Definition: EvtGen.cc:126
static std::vector< std::string > SV
Definition: EvtGlobalSet.hh:19
static std::vector< std::vector< double > > dVV
Definition: EvtGlobalSet.hh:21
static std::vector< std::vector< int > > iVV
Definition: EvtGlobalSet.hh:22
void init()
Definition: EvtHis2F.cc:98
void setHTitle(const char *htitle)
Definition: EvtHis2F.cc:40
void setFile(const char *dtfile)
Definition: EvtHis2F.cc:35
virtual void setGenseed(long)=0
virtual CLHEP::HepRandomEngine * GetEngine(const std::string &StreamName)=0
Interface to the CLHEP engine.

Member Data Documentation

◆ dataInfoSvc

DataInfoSvc* EvtDecay::dataInfoSvc

Definition at line 75 of file EvtDecay.h.

Referenced by initialize().

◆ tmpInfoSvc

IDataInfoSvc* EvtDecay::tmpInfoSvc

Definition at line 74 of file EvtDecay.h.

Referenced by initialize().


The documentation for this class was generated from the following files: