00001 //-------------------------------------------------------------------------- 00002 // 00003 // Environment: 00004 // This software is part of models developed at BES collaboration 00005 // based on the EvtGen framework. If you use all or part 00006 // of it, please give an appropriate acknowledgement. 00007 // 00008 // Copyright Information: See EvtGen/BesCopyright 00009 // Copyright (A) 2006 Ping Rong-Gang @IHEP 00010 // 00011 // Module: EvtMassH1.cc 00012 // 00013 // Description: Routine to decay a particle using the invariant mass distribution of histogram 00014 // dimension one. 00015 // 00016 // Modification history: 00017 // 00018 // Ping R.-G. December, 2006 Module created 00019 // 00020 //------------------------------------------------------------------------ 00021 // 00022 #include "EvtGenBase/EvtPatches.hh" 00023 #include <stdlib.h> 00024 #include "EvtGenBase/EvtParticle.hh" 00025 #include "EvtGenBase/EvtGenKine.hh" 00026 #include "EvtGenBase/EvtPDL.hh" 00027 #include "EvtGenBase/EvtVector4C.hh" 00028 #include "EvtGenBase/EvtVector4R.hh" 00029 #include "EvtGenBase/EvtTensor4C.hh" 00030 #include "EvtGenBase/EvtDiracParticle.hh" 00031 #include "EvtGenBase/EvtScalarParticle.hh" 00032 #include "EvtGenBase/EvtVectorParticle.hh" 00033 #include "EvtGenBase/EvtTensorParticle.hh" 00034 #include "EvtGenBase/EvtPhotonParticle.hh" 00035 #include "EvtGenBase/EvtNeutrinoParticle.hh" 00036 #include "EvtGenBase/EvtStringParticle.hh" 00037 #include "EvtGenBase/EvtRaritaSchwingerParticle.hh" 00038 #include "EvtGenBase/EvtHighSpinParticle.hh" 00039 #include "EvtGenBase/EvtReport.hh" 00040 #include "EvtGenBase/EvtHelSys.hh" 00041 #include "EvtGenModels/EvtMassH1.hh" 00042 #include "EvtGenBase/EvtRandom.hh" 00043 #include <string> 00044 00045 #include "TH1.h" 00046 #include "TAxis.h" 00047 #include "TH2.h" 00048 #include "TFile.h" 00049 #include "TApplication.h" 00050 #include "TROOT.h" 00051 //#include "CLHEP/config/CLHEP.h" 00052 //#include "CLHEP/config/TemplateFunctions.h" 00053 00054 00055 using std::endl; 00056 00057 EvtMassH1::~EvtMassH1() {} 00058 00059 void EvtMassH1::getName(std::string& model_name){ 00060 00061 model_name="MassH1"; 00062 00063 } 00064 00065 EvtDecayBase* EvtMassH1::clone(){ 00066 00067 return new EvtMassH1; 00068 00069 } 00070 00071 00072 void EvtMassH1::init(){ 00073 00074 // check that there are 4 arguments: Invariant mass part. Index: i,j, histor. file name, Hid 00075 checkNArg(0); 00076 EvtSpinType::spintype parenttype = EvtPDL::getSpinType(getParentId()); 00077 } 00078 void EvtMassH1::initProbMax(){ 00079 00080 noProbMax(); 00081 00082 } 00083 00084 void EvtMassH1::decay( EvtParticle *p ){ 00085 00086 const char* fl=setFileName(); 00087 const char* hp=setHpoint(); 00088 int* dp; 00089 dp=setDaugPair(); 00090 int d1=dp[0]; 00091 int d2=dp[1]; 00092 00093 TFile f(fl); 00094 TH1F *hid = (TH1F*)f.Get(hp); 00095 TAxis* xaxis = hid->GetXaxis(); 00096 00097 double BLE =xaxis->GetBinLowEdge(1); 00098 int BINS =xaxis->GetLast(); 00099 // double yvalue[BINS+2],ymax=0.0; 00100 double yvalue[20000],ymax=0.0; 00101 int i; 00102 // double Ntotal=0,yc[BINS+2]; 00103 double Ntotal=0,yc[20000]; 00104 00105 for(i=1;i<BINS+1;i++){ 00106 yvalue[i]=hid->GetBinContent(i); 00107 if(yvalue[i]>ymax) ymax=yvalue[i]; 00108 } 00109 00110 00111 loop: 00112 p->initializePhaseSpace(getNDaug(),getDaugs()); 00113 00114 EvtParticle *v,*s1; 00115 EvtVector4R pv,ps; 00116 double ppr; 00117 00118 v =p->getDaug(d1); 00119 s1=p->getDaug(d2); 00120 pv=v->getP4Lab(); 00121 ps=s1->getP4Lab(); 00122 ppr=(pv+ps).mass(); 00123 00124 int xbin =hid->FindBin(ppr); 00125 double xratio=(hid->GetBinContent(xbin))/ymax; 00126 00127 double rd1=EvtRandom::Flat(0.0, 1.0); 00128 if(rd1>xratio) goto loop; 00129 return ; 00130 } 00131 00132