BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtmH2.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 EvtGen/BesCopyright
9// Copyright (A) 2006 Ping Rong-Gang @IHEP
10//
11// Module: EvtMassH1.cc
12//
13// Description: Routine to decay a particle using a scatter
14// plot forn n-body decays (n>3).
15//
16// Modification history:
17//
18// Ping R.-G. Oct. 2011 Module created
19//
20//------------------------------------------------------------------------
21//
22#include "EvtmH2.hh"
42#include <stdlib.h>
43#include <string>
44
45#include "TApplication.h"
46#include "TAxis.h"
47#include "TFile.h"
48#include "TH1.h"
49#include "TH2.h"
50#include "TROOT.h"
51// #include "CLHEP/config/CLHEP.h"
52// #include "CLHEP/config/TemplateFunctions.h"
53
54using std::endl;
55
57
58void EvtmH2::getName( std::string& model_name ) { model_name = "mH2"; }
59
61
63
64 // check that there are 4 arguments: Invariant mass part. Index: i,j, histor. file name, Hid
65 checkNArg( 2 );
67 nbx = getArg( 0 );
68 nby = getArg( 1 );
69}
71
73
74 const char* fl = setFileName();
75 const char* hp = setHpoint();
76
77 TFile f( fl );
78 TH2F* hid = (TH2F*)f.Get( "mH2" );
79 TAxis* xaxis = hid->GetXaxis();
80 TAxis* yaxis = hid->GetYaxis();
81
82 int BINSx = xaxis->GetLast();
83 int BINSy = yaxis->GetLast();
84 int BINS = BINSx * BINSy;
85 double yvalue, ymax = 0.0;
86 int i, j, binxy;
87
88 for ( i = 1; i < BINSx + 1; i++ )
89 {
90 for ( j = 1; j < BINSy + 1; j++ )
91 {
92 binxy = hid->GetBin( i, j );
93 yvalue = hid->GetBinContent( binxy );
94 // cout<<"binxy,yvalue = "<<binxy<<"; "<<yvalue<<endl;
95 if ( yvalue > ymax ) ymax = yvalue;
96 }
97 }
98
99loop:
101
102 if ( p->getNDaug() != nbx + nby )
103 {
104 std::cout
105 << "The number of specified particles is not equal the number of decay daughters "
106 << endl;
107 ::abort();
108 }
109
110 EvtVector4R pt, pt2;
111 double xmass, ymass;
112
113 pt = p->getDaug( 0 )->getP4Lab();
114 for ( int ii = 1; ii < nbx; ii++ ) { pt = pt + p->getDaug( ii )->getP4Lab(); }
115 xmass = pt.mass();
116
117 pt2 = p->getDaug( nbx )->getP4Lab();
118 for ( int jj = nbx + 1; jj < nbx + nby; jj++ ) pt2 = pt2 + p->getDaug( jj )->getP4Lab();
119 ymass = pt2.mass();
120
121 int xbin = hid->GetXaxis()->FindBin( xmass );
122 int ybin = hid->GetYaxis()->FindBin( ymass );
123 int xybin = hid->GetBin( xbin, ybin );
124 double zvalue = hid->GetBinContent( xybin );
125 double xratio = zvalue / ymax;
126 // cout<<"***************zvalue,ymax,xratio= "<<zvalue<<"; "<<ymax<<"; "<<xratio<<endl;
127 double rd1 = EvtRandom::Flat( 0.0, 1.0 );
128 if ( rd1 > xratio ) goto loop;
129 return;
130}
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
const double xmass[5]
Definition Gam4pikp.cxx:35
double getArg(int j)
EvtId getParentId()
EvtId * getDaugs()
void checkNArg(int a1, int a2=-1, int a3=-1, int a4=-1)
static EvtSpinType::spintype getSpinType(EvtId i)
Definition EvtPDL.hh:66
EvtVector4R getP4Lab()
int getNDaug() const
EvtParticle * getDaug(int i)
double initializePhaseSpace(int numdaughter, EvtId *daughters, double poleSize=-1., int whichTwo1=0, int whichTwo2=1)
static double Flat()
Definition EvtRandom.cc:69
double mass() const
void initProbMax()
Definition EvtmH2.cc:70
void init()
Definition EvtmH2.cc:62
EvtDecayBase * clone()
Definition EvtmH2.cc:60
const char * setFileName()
Definition UsermH2.cc:10
void getName(std::string &name)
Definition EvtmH2.cc:58
const char * setHpoint()
Definition UsermH2.cc:16
EvtmH2()
Definition EvtmH2.hh:31
void decay(EvtParticle *p)
Definition EvtmH2.cc:72
virtual ~EvtmH2()
Definition EvtmH2.cc:56