Using starsim to simulate the BBbar->ee background

One of the residual backgrounds in the di-electron mass spectrum in Upsilon analyses are electron-positron pairs from semi-leptonic decays of B mesons.
To facilitate the Upsilon fitting, we use simulation to get a shape of the BBbar spectrum.
We are using the starsim framework: HF-tuned Pythia8 to generate the event and GEANT3 to simulate the detector response.

The settings for pythia8 are:

       pythia8->SetFrame("CMS", 200.0);

      pythia8->SetBlue("proton");
      pythia8->SetYell("proton");            
      //pythia8->Set("Main:numberOfEvents = 100000 ");
      pythia8->Set("Main:numberToList = 0 ");
      pythia8->Set("Main:timesToShow = 100 ");
      pythia8->Set("Main:timesAllowErrors = 100 ");
      pythia8->Set("Main:showChangedSettings = on ");
      pythia8->Set("Main:showAllSettings = on ");
      pythia8->Set("Main:showAllStatistics = on ");

      pythia8->Set( "HardQCD:all = off" );
      pythia8->Set( "HardQCD:gg2bbbar = on" );
      pythia8->Set( "HardQCD:qqbar2bbbar = on" );

      pythia8->Set( "SigmaProcess:Kfactor = 3 " );
      pythia8->Set( "SigmaProcess:renormScale2 = 3 " );
      pythia8->Set( "SigmaProcess:factorScale2 = 3 " );
      pythia8->Set( " SigmaProcess:renormMultFac = 2" );
      pythia8->Set( " SigmaProcess:factorMultFac = 2" );

      pythia8->Set( " Random:setSeed = on" );
      pythia8->Set( " Random:seed = 0" );

      pythia8->Set( " PDF:useLHAPDF = on" );
      pythia8->Set( " PDF:LHAPDFset = MRSTMCal.LHgrid" );
      pythia8->Set( " PDF:extrapolateLHAPDF = on" );

      pythia8->Set( " PartonLevel:MI = on" );
      pythia8->Set( " PartonLevel:ISR = on" );
      pythia8->Set( " BeamRemnants:primordialKT = on" );
      pythia8->Set( " PartonLevel:FSR = on" );
      pythia8->Set( " StringFlav:mesonCvector = 1.5" );
      pythia8->Set( " StringFlav:mesonBvector = 3.0" );
      pythia8->Set( " 4:m0 = 1.43" );
      pythia8->Set( " 5:m0 = 4.30" );

      pythia8->Set( " PhaseSpace:pTHatMin = 10.0" );
      pythia8->Set( " PhaseSpace:pTHatMax = 100.0" );

This tuning was done by T.Ulrich (http://www.star.bnl.gov/protected/heavy/ullrich/pythia8/) to reproduce the spectra of quarkonia and NPE.
For b->e, the description of data is not perfect at lower pt but is currently still the best we have.

For the vertex distributions we use:

       primary->SetVertex( 0., 0., 0. );
       primary->SetSigma( 0.1, 0.1, 14.0 );
The 14cm sigma on vz was chosen to describe the vz distribution seen in BHT2*VPDMB30 events of AuAu14.

We are interested in events which have at least one hard electron and one hard positron.
To save time on the computing, we set the pTHatMin to 10.0 . We also utilise a custom-built filter StDielectronFilter.
This filter is based on the StarParticleFilter introduced in SL16j. This filter also accepts only electrons/positrons with pT > 2GeV and |eta|<1.2 .

After the Pythia8 and Geant simulations are done and filtered, we call the BFC macro on the simulation's .fbz output to build the event files geant.root, event.root, and MuDst.root .
From this, we use a modified StMcAnalysisMaker to build nTuples with the event information and MC and primary kinematics of 1 electron and 1 positron.
In an event, there can be more than 1 electrons/positrons, coming from decays of other decay products of the B mesons. Thus, we select only the highest-momentum ones.
The entire simulation+reconstruction+ntuples takes about 1hour to complete at RCF, with 1000 processes with 100 events each.

Here is some basic QA; MC vs RC distribution on the electron momentum, phi, and eta:

Here are the invariant mass spectra with applied kinematics cuts as in the analysis (pLow > 3, pHigh > 4.5, |eta| < 1.0 ) in ranges (0,20), (0,5), and (5,15):

As you can see, besides the BBbar spectrum in the m>5 region, we can also see a lot of electrons coming from Jpsi's and other lighter resonances.
This occurs because sometimes in the simulated event, we don't have di-electrons coming from semi-leptonic decays of B's but from di-electron decays of B->Jpsi's etc.
This is unwanted, however other than reducing our statistics this shouldn't be a problem, because it is very clearly separated from the BBbar spectrum.
We probably also have a few B->D->e electrons but I don't see why they should be a problem either.

Currently, pol7 is used to describe the BBbar spectrum but it is insufficient/impractical so we will investigate other options.