diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..57c4e14
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,113 @@
+stages:
+  - build
+  - test
+
+variables:
+  LCG_VERSION: "LCG_98python3"
+  GCC_VERSION: "10"
+  CLANG_VERSION: "10"
+  BUILD_TYPE: "Release"
+  BUILD_TESTS: "OFF"
+  BUILD_DOXYGEN: "OFF"
+  USE_HEPMC3: "ON"
+
+.production_image:
+  variables:
+    LCG_OS: x86_64-centos7
+  image: gitlab-registry.cern.ch/ci-tools/ci-worker:cc7
+  tags:
+    - cvmfs
+
+.lcg_setup:
+  before_script:
+    - set +e && source /cvmfs/sft.cern.ch/lcg/views/setupViews.sh $LCG_VERSION $LCG_OS-$LCG_COMPILER; set -e
+
+.build_template:
+  stage: build
+  extends:
+    - .lcg_setup
+  script:
+    - mkdir install
+    - mkdir build && cd build
+    - cmake -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX:PATH=$CI_PROJECT_DIR/install -DEVTGEN_HEPMC3:BOOL=$USE_HEPMC3 -DEVTGEN_PYTHIA:BOOL=ON -DEVTGEN_PHOTOS:BOOL=ON -DEVTGEN_TAUOLA:BOOL=ON -DEVTGEN_BUILD_TESTS:BOOL=$BUILD_TESTS -DEVTGEN_BUILD_VALIDATIONS:BOOL=$BUILD_TESTS -DEVTGEN_BUILD_DOXYGEN:BOOL=$BUILD_DOXYGEN $CI_PROJECT_DIR
+    - cmake --build .
+    - cmake --build . --target install
+
+build_clang_opt:
+  variables:
+    LCG_COMPILER: "clang$CLANG_VERSION-opt"
+  extends:
+    - .production_image
+    - .build_template
+
+build_gcc_opt:
+  variables:
+    LCG_COMPILER: "gcc$GCC_VERSION-opt"
+  extends:
+    - .production_image
+    - .build_template
+
+build_hepmc2_gcc_opt:
+  variables:
+    LCG_COMPILER: "gcc$GCC_VERSION-opt"
+    USE_HEPMC3: "OFF"
+  extends:
+    - .production_image
+    - .build_template
+
+build_gcc_dbg:
+  variables:
+    LCG_COMPILER: "gcc$GCC_VERSION-dbg"
+    BUILD_TYPE: "Debug"
+    BUILD_TESTS: "ON"
+    BUILD_DOXYGEN: "ON"
+  extends:
+    - .production_image
+    - .build_template
+  after_script:
+    - cd install/share/EvtGen/test
+    - ./makeModelsJson $CI_PROJECT_DIR > Models.json
+    - ./makeSrcDepsJson $CI_PROJECT_DIR $CI_PROJECT_DIR/build > SrcDeps.json
+  artifacts:
+    paths:
+      - install
+    expire_in: 1 day
+    when: always
+
+.test_template:
+  stage: test
+  variables:
+    LCG_COMPILER: "gcc$GCC_VERSION-dbg"
+  extends:
+    - .production_image
+    - .lcg_setup
+  dependencies:
+    - build_gcc_dbg
+  artifacts:
+    paths:
+      - install/share/EvtGen/test
+    expire_in: 1 day
+    when: always
+
+# TODO - need to copy in the appropriate files to act as references for this run
+#        and save the resulting files for possible future use as references
+#      - where to store the reference files? CI cache? EOS?
+#      - need to add a test case for merge requests
+
+test_on_push:
+  extends:
+    - .test_template
+  rules:
+    - if: '$CI_PIPELINE_SOURCE == "push"'
+  script:
+    - cd install/share/EvtGen/test
+    - git diff --numstat $CI_COMMIT_BEFORE_SHA $CI_COMMIT_SHA | awk '{print $NF}' | xargs ./runTests.py Models.json SrcDeps.json
+
+test_on_schedule:
+  extends:
+    - .test_template
+  rules:
+    - if: '$CI_PIPELINE_SOURCE == "schedule" && $CI_COMMIT_BRANCH == "master"'
+  script:
+    - cd install/share/EvtGen/test
+    - git diff --numstat `git tag --list 'R*' | tail -n 1` $CI_COMMIT_SHA | awk '{print $NF}' | xargs ./runTests.py Models.json SrcDeps.json
diff --git a/EvtGenBase/EvtParticle.hh b/EvtGenBase/EvtParticle.hh
index ecaa341..953613a 100644
--- a/EvtGenBase/EvtParticle.hh
+++ b/EvtGenBase/EvtParticle.hh
@@ -1,499 +1,502 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #ifndef EVTPARTICLE_HH
 #define EVTPARTICLE_HH
 
-//#include <iostream.h>
 #include "EvtGenBase/EvtId.hh"
 #include "EvtGenBase/EvtSpinDensity.hh"
 #include "EvtGenBase/EvtSpinType.hh"
 #include "EvtGenBase/EvtVector4R.hh"
 
 #include <assert.h>
 #include <map>
 #include <string>
 #include <vector>
 
 class EvtDiracSpinor;
 class EvtVector4C;
 class EvtTensor4C;
 class EvtStdHep;
 class EvtSecondary;
 class EvtRaritaSchwinger;
 
 const int MAX_DAUG = 100;
 const int MAX_LEVEL = 10;
 const int MAX_TRIES = 10000;
 
 class EvtParticle {
   public:
     /**
   * Default constructor.
   */
     EvtParticle();
 
     /**
   * Destructor.
   */
     virtual ~EvtParticle();
 
     /**
   * Returns polarization vector in the parents restframe.
   */
     virtual EvtVector4C epsParent( int i ) const;
 
     /**
   * Returns polarization vector in the particles own restframe.
   */
     virtual EvtVector4C eps( int i ) const;
 
     /**
   * Returns polarization vector in the parents restframe for a photon.
   */
     virtual EvtVector4C epsParentPhoton( int i );
 
     /**
   * Returns polarization vector in the particles own restframe for a photon.
   */
     virtual EvtVector4C epsPhoton( int i );
 
     /**
   * Returns Dirac spinor in the parents restframe for a Dirac particle.
   */
     virtual EvtDiracSpinor spParent( int ) const;
 
     /**
   * Returns Dirac spinor in the particles own restframe for a Dirac particle.
   */
     virtual EvtDiracSpinor sp( int ) const;
 
     /**
   * Returns Dirac spinor in the parents restframe for a Neutrino particle.
   */
     virtual EvtDiracSpinor spParentNeutrino() const;
 
     /**
   * Returns Dirac spinor in the particles own restframe for a
   * Neutrino particle.
   */
     virtual EvtDiracSpinor spNeutrino() const;
 
     /**
   * Returns tensor in the parents restframe for a spin 2 particle.
   */
     virtual EvtTensor4C epsTensorParent( int i ) const;
 
     /**
   * Returns tensor in the particles own restframe for a spin 2 particle.
   */
     virtual EvtTensor4C epsTensor( int i ) const;
 
     /**
    * Returns Rarita-Schwinger spinor in the parents restframe for a 
    * Rarita-Schwinger particle.
    */
     virtual EvtRaritaSchwinger spRSParent( int ) const;
 
     /**
    * Returns Rarita-Schwinger spinor in the particles own restframe for a 
    * Rarita-Schwinger particle.
    */
     virtual EvtRaritaSchwinger spRS( int ) const;
 
     /**
   * Initialiaze particle with id and 4momentum.
   */
     virtual void init( EvtId part_n, const EvtVector4R& p4 ) = 0;
 
     /**
   * Add another daughter to the particle
   */
     void addDaug( EvtParticle* node );
 
     /**
   * Decay particle
   */
     void decay();
 
     /** 
   * Delete a decay chain
   */
     void deleteTree();
     void deleteDaughters( bool keepChannel = false );
 
     /**
   * Should only be used internally.
   */
     void setChannel( int i );
 
     /**
   * Creates the daughters in the list of ids and 
   * adds them to the parent. Note that momentum
   * is left uninitialized, this is _only_ creation.
   */
     void makeDaughters( unsigned int ndaug, EvtId* id );
 
     /**
   * Creates the daughters in the list of ids and 
   * adds them to the parent. Note that momentum
   * is left uninitialized, this is _only_ creation.
   */
     void makeDaughters( unsigned int ndaug, std::vector<EvtId> idVector );
 
     /**
   * Similar to the routine above except that here 
   * momentum is generated according to phase space 
   * daughters are filled with this momentum.
   */
     double initializePhaseSpace( unsigned int numdaughter, EvtId* daughters,
                                  bool forceResetMasses = false,
                                  double poleSize = -1., int whichTwo1 = 0,
                                  int whichTwo2 = 1 );
 
     /**
   * Get pointer the the i:th daugther.
   */
-    const EvtParticle* getDaug( const int i ) const { return _daug[i]; }
     EvtParticle* getDaug( const int i ) { return _daug[i]; }
 
     /**
+  * Get const pointer the the i:th daugther.
+  */
+    const EvtParticle* getDaug( const int i ) const { return _daug[i]; }
+
+    /**
   * Iterates over the particles in a decay chain.
   */
     EvtParticle* nextIter( EvtParticle* rootOfTree = 0 );
 
     /**
   * Makes stdhep list
   */
     void makeStdHep( EvtStdHep& stdhep, EvtSecondary& secondary,
                      EvtId* stable_parent_ihep );
     void makeStdHep( EvtStdHep& stdhep );
 
     /**
   * Gets 4vector in the labframe, i.e., the frame in which the root
   * particles momentum is measured.
   */
     EvtVector4R getP4Lab() const;
 
     /**
   * Gets 4vector in the labframe for the 4-momentum before FSR was 
   * generated in the parents decay. The lab frame is where the root
   * particles momentum is measured.
   */
     EvtVector4R getP4LabBeforeFSR();
 
     /**
   * Gets 4vector in the particles restframe, i.e. this functiont will
   * return (m,0,0,0)
   */
     EvtVector4R getP4Restframe() const;
 
     /**
   * Returns the 4position of the particle in the lab frame.
   */
     EvtVector4R get4Pos() const;
 
     /**
   * Returns pointer to parent particle.
   */
     EvtParticle* getParent() const;
 
     /**
   * Makes partptr the idaug:th daugther.
   */
     void insertDaugPtr( int idaug, EvtParticle* partptr )
     {
         _daug[idaug] = partptr;
         partptr->_parent = this;
     }
     /**
   * Returns mass of particle.
   */
     double mass() const;
 
     /**
   * Used internally to decide if first time particle is decayed.
   */
     int firstornot() const;
     void setFirstOrNot();
     void resetFirstOrNot();
 
     /**
   * Returns Id of particle.
   */
     EvtId getId() const;
 
     /**
   * Returns the PDG id of the particle
   */
 
     int getPDGId() const;
 
     /** 
   * Returns particle type.
   */
 
     EvtSpinType::spintype getSpinType() const;
 
     /**
   * Returns number of spin states of the particle.
   */
     int getSpinStates() const;
 
     /**
   * Returns 4momentum in parents restframe.
   */
     const EvtVector4R& getP4() const;
 
     /**
   * Sets the 4momentum in the parents restframe.
   */
     void setP4( const EvtVector4R& p4 )
     {
         _p = p4;
         _pBeforeFSR = p4;
     }
 
     void setP4WithFSR( const EvtVector4R& p4 ) { _p = p4; }
 
     void setFSRP4toZero() { _pBeforeFSR.set( 0.0, 0.0, 0.0, 0.0 ); }
 
     /**
   * Retunrs the decay channel.
   */
     int getChannel() const;
 
     /**
   * Returns number of daugthers.
   */
     size_t getNDaug() const;
     void resetNDaug()
     {
         _ndaug = 0;
         return;
     }
 
     /**
   * Prints out the particle "tree" of a given particle.  The
   * tree consists of all daughters (and their daughters, etc)
   * and their properties.
   */
     void printTree() const;
 
     void printTreeRec( unsigned int level ) const;
 
     std::string treeStr() const;
     std::string treeStrRec( unsigned int level ) const;
 
     /**
   * Prints information for the particle.
   */
     void printParticle() const;
 
     /**
   * Set lifetime of the particle in parents restframe.
   */
     void setLifetime( double tau );
 
     /**
   * Generate lifetime according to pure exponential.
   */
     void setLifetime();
 
     /**
   * Returns the lifetime.
   */
-    double getLifetime();
+    double getLifetime() const;
 
     /** 
   * Set diagonal spindensity matrix.
   */
     void setDiagonalSpinDensity();
 
     /** 
   * Set spindensity matrix for e+e- -> V
   */
     void setVectorSpinDensity();
 
     /**
   * Set forward spin density matrix.
   */
     void setSpinDensityForward( const EvtSpinDensity& rho )
     {
         _rhoForward = rho;
     }
 
     /**
   * Set forward spin density matrix according to the density matrix
   * rho in the helicity amplitude basis.
   */
     void setSpinDensityForwardHelicityBasis( const EvtSpinDensity& rho );
     void setSpinDensityForwardHelicityBasis( const EvtSpinDensity& rho,
                                              double alpha, double beta,
                                              double gamma );
 
     /**
   * Returns a rotation matrix need to rotate the basis state
   * to the helicity basis. The EvtSpinDensity matrix is just use
   * as a matrix here. This function is to be implemented in each
   * derived class.
   */
     virtual EvtSpinDensity rotateToHelicityBasis() const = 0;
     virtual EvtSpinDensity rotateToHelicityBasis( double alpha, double beta,
                                                   double gamma ) const = 0;
 
     /**
   * Get forward spin density matrix.
   */
     EvtSpinDensity getSpinDensityForward() { return _rhoForward; }
 
     /**
   * Set backward spin density matrix.
   */
     void setSpinDensityBackward( const EvtSpinDensity& rho )
     {
         _rhoBackward = rho;
     }
 
     /**
   * Get backward spin density matrix.
   */
     EvtSpinDensity getSpinDensityBackward() { return _rhoBackward; }
 
     //Hacks will be removed when better solutions are thought of!
     //This is used to suppress use of random numbers when doing initialization
     //of some models.
     void noLifeTime() { _genlifetime = 0; }
 
     //lange - April 29, 2002
     void setId( EvtId id ) { _id = id; }
     void initDecay( bool useMinMass = false );
     bool generateMassTree();
 
     double compMassProb();
 
     //setMass will blow away any existing 4vector
     void setMass( double m ) { _p = EvtVector4R( m, 0.0, 0.0, 0.0 ); }
 
     //void setMixed() {_mix=true;}
     //void setUnMixed() {_mix=false;}
     //bool getMixed() {return _mix;}
 
     //void takeCConj() {EvtGenReport(EVTGEN_INFO,"EvtGen") << "should take conj\n";}
 
     //this means that the particle has gone through initDecay
     // and thus has a mass
     bool isInitialized() { return _isInit; }
     bool hasValidP4() { return _validP4; }
     bool isDecayed() { return _isDecayed; }
 
     // decay prob - only relevent if already decayed
     // and is a scalar particle
     // returned is a double* that should be prob/probMax
     double* decayProb() { return _decayProb; }
     void setDecayProb( double p );
 
     // Return the name of the particle (from the EvtId number)
-    std::string getName();
+    std::string getName() const;
 
     // Specify whether the particle has a special named attribute with
     // a set value. By default, nothing is set, but derived classes
     // can set this to mean something specific, e.g. if a photon is FSR
     void setAttribute( std::string attName, int attValue )
     {
         _intAttributes[attName] = attValue;
     }
 
     // Retrieve the integer value for the given attribute name
     int getAttribute( std::string attName );
 
     // Specify if the particle has a double attribute value, e.g. amplitude weight.
     // By default, nothing is set, but derived classes can set this to mean something specific
     void setAttributeDouble( std::string attName, double attValue )
     {
         _dblAttributes[attName] = attValue;
     }
 
     // Retrieve the double value for the given attribute name
     double getAttributeDouble( std::string attName );
 
   protected:
     void setp( double e, double px, double py, double pz )
     {
         _p.set( e, px, py, pz );
         _pBeforeFSR = _p;
     }
 
     void setp( const EvtVector4R& p4 )
     {
         _p = p4;
         _pBeforeFSR = _p;
     }
 
     void setpart_num( EvtId particle_number )
     {
         assert( _channel == -10 || _id.getId() == particle_number.getId() ||
                 _id.getId() == -1 );
         _id = particle_number;
     }
     bool _validP4;
 
     // A typedef to define the attribute (name, integer) map
     typedef std::map<std::string, int> EvtAttIntMap;
     EvtAttIntMap _intAttributes;
 
     // A typedef to define the attribute (name, double) map
     typedef std::map<std::string, double> EvtAttDblMap;
     EvtAttDblMap _dblAttributes;
 
   private:
     EvtParticle* _daug[MAX_DAUG];
     size_t _ndaug;
     EvtParticle* _parent;
     int _channel;
     int _first;
     EvtId _id;
     EvtVector4R _p;
     EvtVector4R _pBeforeFSR;
     double _t;
     bool _isInit;
     bool _isDecayed;
 
     //bool _mix;
 
     EvtSpinDensity _rhoForward;
     EvtSpinDensity _rhoBackward;
 
     void makeStdHepRec( int firstparent, int lastparent, EvtStdHep& stdhep,
                         EvtSecondary& secondary, EvtId* stable_parent_ihep );
     void makeStdHepRec( int firstparent, int lastparent, EvtStdHep& stdhep );
 
     //This is a hack until things gets straightened out. (Ryd)
     int _genlifetime;
 
     //should never be used, therefor is private.
     //these does _not_ have an implementation
     EvtParticle& operator=( const EvtParticle& p );
     EvtParticle( const EvtParticle& p );
 
     double* _decayProb;
 };
 
 #endif
diff --git a/EvtGenModels/EvtBTo4piCP.hh b/EvtGenModels/EvtBTo4piCP.hh
index dc12d4b..a034d8e 100644
--- a/EvtGenModels/EvtBTo4piCP.hh
+++ b/EvtGenModels/EvtBTo4piCP.hh
@@ -1,37 +1,38 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #ifndef EVTBTO4PICP_HH
 #define EVTBTO4PICP_HH
 
 #include "EvtGenBase/EvtDecayAmp.hh"
 
 class EvtParticle;
 
 class EvtBTo4piCP : public EvtDecayAmp {
   public:
     std::string getName() override;
     EvtBTo4piCP* clone() override;
 
     void init() override;
+    void initProbMax() override;
     void decay( EvtParticle* p ) override;
 };
 
 #endif
diff --git a/EvtGenModels/EvtBToKpipiCP.hh b/EvtGenModels/EvtBToKpipiCP.hh
index c397a72..520b78b 100644
--- a/EvtGenModels/EvtBToKpipiCP.hh
+++ b/EvtGenModels/EvtBToKpipiCP.hh
@@ -1,56 +1,57 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #ifndef EVTBTOKPIPICP_HH
 #define EVTBTOKPIPICP_HH
 
 #include "EvtGenBase/EvtDecayAmp.hh"
 #include "EvtGenBase/EvtVector4R.hh"
 
 #include "EvtGenModels/EvtBTo3hCP.hh"
 
 class EvtParticle;
 
 // Description: Routine to decay B->K pi pi
 //              and has CP violation.
 //       --- This is the routine to be called by the Main generator
 //          to get the decay of B0    -->-- K+ pi- pi0
 //          The decay proceeeds through three channels:
 //          a) B0 -->-- K*+ pi-  ; K*+    -->-- K+ pi0
 //          b)          K*0 pi0  ; K*0bar -->-- K+ pi-
 //          c)          K-  rho+ ; rho+   -->-- pi+ pi0
 //         It provides at the same time the CP conjugate decay
 //                              B0bar -->-- K- pi+ pi0
 
 class EvtBToKpipiCP : public EvtDecayAmp {
   public:
     EvtBToKpipiCP() {}
 
     std::string getName() override;
     EvtBToKpipiCP* clone() override;
 
     void init() override;
+    void initProbMax() override;
     void decay( EvtParticle* p ) override;
 
   private:
     EvtBTo3hCP generator;
 };
 
 #endif
diff --git a/EvtGenModels/EvtISGW.hh b/EvtGenModels/EvtISGW.hh
index ebe44b4..3d1bbc2 100644
--- a/EvtGenModels/EvtISGW.hh
+++ b/EvtGenModels/EvtISGW.hh
@@ -1,44 +1,45 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #ifndef EVTISGW_HH
 #define EVTISGW_HH
 
 #include "EvtGenBase/EvtDecayAmp.hh"
 #include "EvtGenBase/EvtSemiLeptonicAmp.hh"
 #include "EvtGenBase/EvtSemiLeptonicFF.hh"
 
 #include <memory>
 class EvtParticle;
 
 class EvtISGW : public EvtDecayAmp {
   public:
     std::string getName() override;
     EvtDecayBase* clone() override;
 
     void decay( EvtParticle* p ) override;
     void init() override;
+    void initProbMax() override;
 
   private:
     std::unique_ptr<EvtSemiLeptonicFF> isgwffmodel;
     std::unique_ptr<EvtSemiLeptonicAmp> calcamp;
 };
 
 #endif
diff --git a/EvtGenModels/EvtKstarnunu.hh b/EvtGenModels/EvtKstarnunu.hh
index 20dab04..637de19 100644
--- a/EvtGenModels/EvtKstarnunu.hh
+++ b/EvtGenModels/EvtKstarnunu.hh
@@ -1,38 +1,39 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #ifndef EVTKSTARNUNU_HH
 #define EVTKSTARNUNU_HH
 
 #include "EvtGenBase/EvtDecayAmp.hh"
 
 class EvtParticle;
 
 class EvtKstarnunu : public EvtDecayAmp {
   public:
     std::string getName() override;
     EvtDecayBase* clone() override;
 
     void init() override;
+    void initProbMax() override;
 
     void decay( EvtParticle* p ) override;
 };
 
 #endif
diff --git a/EvtGenModels/EvtLambdaB2LambdaV.hh b/EvtGenModels/EvtLambdaB2LambdaV.hh
index 81c83d3..3b2044f 100644
--- a/EvtGenModels/EvtLambdaB2LambdaV.hh
+++ b/EvtGenModels/EvtLambdaB2LambdaV.hh
@@ -1,182 +1,180 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #ifndef EVTLAMBDAB2LAMBDAV_HH
 #define EVTLAMBDAB2LAMBDAV_HH
 
 #include "EvtGenBase/EvtDecayProb.hh"
-#include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
-#include "EvtGenBase/EvtReport.hh"
 
 #include <stdlib.h>
 #include <string>
 
 namespace VID {
     enum VectorMesonType
     {
         JPSI,
         OMEGA,
         RHO,
         RHO_OMEGA_MIXING
     };
 }
 
 // Description:
 //   Class to generate LambdaB -> Lambda(p pi) V(Vp Vm) decays
 //   with V a vector meson such as J/psi (mu+mu-)
 //                                 Rho (pi+pi-)
 //                                 Omega (pi+pi-)
 //                                 Rho-omega mixing (pi+pi-)
 //
 // DECAY : LambdaB -> Lambda + vector meson
 //
 // d(Sigma)
 // -------- = 1 + A*B*cos(theta) + 2*A*Re(C*exp(i*phi))*sin(theta)
 // d(Omega)
 //
 // with A (real)    : lambdaB  helicity asymmetry parameter
 //      B (real)    : lambdaB polarisation
 //      C (complex) : lambdaB density matrix element rho+-
 //
 // cf : O. Leitner, Z.J Ajaltouni, E. Conte,
 //      PCCF RI 0601, ECT-05-15, LPNHE/2006-01, hep-ph/0602043
 
 class EvtLambdaB2LambdaV : public EvtDecayProb {
   public:
     EvtLambdaB2LambdaV();
 
     EvtDecayBase* clone() override;
 
     std::string getName() override;
     void init() override;
     void initProbMax() override;
     void decay( EvtParticle* lambdab ) override;
 
   private:
     //class name for report method
     std::string fname;
 
     //meson vector identity
     VID::VectorMesonType Vtype;
 
     //decay dynamics parameters
     double A;
     double B;
     EvtComplex C;
 
     //V mass generator method
     double getVMass( double MASS_LAMBDAB, double MASS_LAMBDA );
 
     //PDF generator method
     double BreitWignerRelPDF( double m, double _m0, double _g0 );
     double RhoOmegaMixingPDF( double m, double _mr, double _gr, double _mo,
                               double _go );
 };
 
 //*******************************************************************
 //*                                                                 *
 //*             Class EvtLambda2PPiForLambdaB2LambdaV               *
 //*                                                                 *
 //*******************************************************************
 //
 // DECAY : Lambda -> p + pi-
 //
 // d(Sigma)
 // -------- = 1 + A*B*cos(theta) + 2*A*Re(D*exp(i*phi))*sin(theta)
 // d(Omega)
 //
 // with A (real)    : lambda asymmetry parameter
 //      B (real)    : lambda polarisation
 //      C (real)    : lambdaB polarisation
 //      D (complex) : lambda density matrix element rho+-
 //
 // cf : O. Leitner, Z.J Ajaltouni, E. Conte
 //      PCCF RI 0601, ECT-05-15, LPNHE/2006-01, hep-ph/0602043
 
 class EvtLambda2PPiForLambdaB2LambdaV : public EvtDecayProb {
   public:
     EvtLambda2PPiForLambdaB2LambdaV();
     EvtDecayBase* clone() override;
 
     std::string getName() override;
     void init() override;
     void initProbMax() override;
     void decay( EvtParticle* lambda ) override;
 
   private:
     //class name for report method
     std::string fname;
 
     //meson vector identity
     VID::VectorMesonType Vtype;
 
     //decay dynamics parameters
     double A;
     double B;
     double C;
     EvtComplex D;
 };
 
 //*******************************************************************
 //*                                                                 *
 //*               Class EvtV2VpVmForLambdaB2LambdaV                 *
 //*                                                                 *
 //*******************************************************************
 //
 // DECAY : vector meson V -> Vp + Vm
 //
 // d(Sigma)
 // -------- = (1-3A)*cos(theta)^2 + (1+A)   //leptonic decays
 // d(Omega)
 //
 // d(Sigma)
 // -------- = (3A-1)*cos(theta)^2 + (1-A)   //hadronic decays
 // d(Omega)
 //
 // with A (real)    : V density matrix element indicating the
 //                    probability to be longitudinally polarized
 //
 // cf : O. Leitner, Z.J Ajaltouni, E. Conte
 //      PCCF RI 0601, ECT-05-15, LPNHE/2006-01, hep-ph/0602043
 
 class EvtV2VpVmForLambdaB2LambdaV : public EvtDecayProb {
   public:
     EvtV2VpVmForLambdaB2LambdaV();
 
     EvtDecayBase* clone() override;
 
     std::string getName() override;
     void init() override;
     void initProbMax() override;
     void decay( EvtParticle* V ) override;
 
   private:
     //class name for report method
     std::string fname;
 
     //meson vector identity
     VID::VectorMesonType Vtype;
     //decay dynamics parameters
     double A;
 };
 
 #endif
diff --git a/EvtGenModels/EvtMelikhov.hh b/EvtGenModels/EvtMelikhov.hh
index da9b7ad..261d34c 100644
--- a/EvtGenModels/EvtMelikhov.hh
+++ b/EvtGenModels/EvtMelikhov.hh
@@ -1,47 +1,48 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #ifndef EVTMELIKHOV_HH
 #define EVTMELIKHOV_HH
 
 #include "EvtGenBase/EvtDecayAmp.hh"
 #include "EvtGenBase/EvtSemiLeptonicAmp.hh"
 #include "EvtGenBase/EvtSemiLeptonicFF.hh"
 
 #include <memory>
 
 class EvtParticle;
 
 // Description:Implementation of the Melikhov semileptonic model
 
 class EvtMelikhov : public EvtDecayAmp {
   public:
     std::string getName() override;
     EvtDecayBase* clone() override;
 
     void decay( EvtParticle* p ) override;
     void init() override;
+    void initProbMax() override;
 
   private:
     std::unique_ptr<EvtSemiLeptonicFF> Melikhovffmodel;
     std::unique_ptr<EvtSemiLeptonicAmp> calcamp;
 };
 
 #endif
diff --git a/EvtGenModels/EvtPhiDalitz.hh b/EvtGenModels/EvtPhiDalitz.hh
index dec0c51..ada0306 100644
--- a/EvtGenModels/EvtPhiDalitz.hh
+++ b/EvtGenModels/EvtPhiDalitz.hh
@@ -1,49 +1,49 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #ifndef EVTPHIDALITZ_HH
 #define EVTPHIDALITZ_HH
 
 #include "EvtGenBase/EvtDecayAmp.hh"
 
 class EvtParticle;
 
 class EvtPhiDalitz : public EvtDecayAmp {
   public:
     std::string getName() override;
     EvtDecayBase* clone() override;
 
     void init() override;
-
+    void initProbMax() override;
     void decay( EvtParticle* p ) override;
 
   private:
     double _mRho;
     double _gRho;
     double _aD;
     double _phiD;
     double _aOmega;
     double _phiOmega;
     int _locPip;
     int _locPim;
     int _locPi0;
 };
 
 #endif
diff --git a/EvtGenModels/EvtSSSCPT.hh b/EvtGenModels/EvtSSSCPT.hh
index 79ff801..33ebbea 100644
--- a/EvtGenModels/EvtSSSCPT.hh
+++ b/EvtGenModels/EvtSSSCPT.hh
@@ -1,37 +1,45 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #ifndef EVTSSSCPT_HH
 #define EVTSSSCPT_HH
 
 #include "EvtGenBase/EvtDecayAmp.hh"
 
 class EvtParticle;
 
 class EvtSSSCPT : public EvtDecayAmp {
   public:
     std::string getName() override;
     EvtDecayBase* clone() override;
 
     void init() override;
+    void initProbMax() override;
     void decay( EvtParticle* p ) override;
+
+  private:
+    // Amplitude coeffs
+    EvtComplex A, Abar;
+    EvtComplex P, Q, D, Im;
+    // Set amplitude coeffs from decay model params
+    void setAmpCoeffs();
 };
 
 #endif
diff --git a/EvtGenModels/EvtSVSCPiso.hh b/EvtGenModels/EvtSVSCPiso.hh
index f683251..84aca33 100644
--- a/EvtGenModels/EvtSVSCPiso.hh
+++ b/EvtGenModels/EvtSVSCPiso.hh
@@ -1,44 +1,63 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #ifndef EVTSVSCPISO_HH
 #define EVTSVSCPISO_HH
 
+#include "EvtGenBase/EvtComplex.hh"
 #include "EvtGenBase/EvtDecayAmp.hh"
 
 class EvtParticle;
 
 // Description: Routine to decay scalar -> vectors scalar
 //              with CP violation and isospin amplitudes.
 //              More specifically, it is indended to handle
 //              decays like B->rho pi and B->a1 pi.
 
 class EvtSVSCPiso : public EvtDecayAmp {
   public:
     std::string getName() override;
     EvtDecayBase* clone() override;
 
     void init() override;
     void initProbMax() override;
 
     void decay( EvtParticle* p ) override;
+
+  private:
+    // Amplitude coefficients
+    EvtComplex Tp0, Tp0_bar, T0p, T0p_bar;
+    EvtComplex Tpm, Tpm_bar, Tmp, Tmp_bar;
+    EvtComplex P1, P1_bar, P0, P0_bar;
+
+    // Amplitudes
+    EvtComplex A_f, Abar_f;
+    EvtComplex A_fbar, Abar_fbar;
+    EvtComplex Apm, Apm_bar, Amp, Amp_bar;
+    // Charged mode flag
+    int charged{ 0 };
+
+    // Set amplitude coeffs from decay model pars
+    void setAmpCoeffs();
+    // Calculate amplitude terms
+    void calcAmpTerms();
 };
 
 #endif
diff --git a/EvtGenModels/EvtSingleParticle.hh b/EvtGenModels/EvtSingleParticle.hh
index d527769..793a687 100644
--- a/EvtGenModels/EvtSingleParticle.hh
+++ b/EvtGenModels/EvtSingleParticle.hh
@@ -1,46 +1,47 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #ifndef EVTSINGLEPARTICLE_HH
 #define EVTSINGLEPARTICLE_HH
 
 #include "EvtGenBase/EvtDecayIncoherent.hh"
 class EvtParticle;
 
 // Description:
 //This is a special decay model to generate single particles.
 
 class EvtSingleParticle : public EvtDecayIncoherent {
   public:
     std::string getName() override;
 
     EvtDecayBase* clone() override;
 
     void decay( EvtParticle* p ) override;
 
     void init() override;
+    void initProbMax() override;
 
   private:
     double pmin, pmax;
     double cthetamin, cthetamax;
     double phimin, phimax;
 };
 
 #endif
diff --git a/EvtGenModels/EvtSll.hh b/EvtGenModels/EvtSll.hh
index 9920516..b86551e 100644
--- a/EvtGenModels/EvtSll.hh
+++ b/EvtGenModels/EvtSll.hh
@@ -1,40 +1,41 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #ifndef EVTSLL_HH
 #define EVTSLL_HH
 
 #include "EvtGenBase/EvtDecayAmp.hh"
 
 class EvtParticle;
 
 //Class to handle decays of the form SCALAR -> DIRAC DIRAC.
 
 class EvtSll : public EvtDecayAmp {
   public:
     std::string getName() override;
     EvtDecayBase* clone() override;
 
     void init() override;
+    void initProbMax() override;
 
     void decay( EvtParticle* p ) override;
 };
 
 #endif
diff --git a/src/EvtGenBase/EvtMTree.cpp b/src/EvtGenBase/EvtMTree.cpp
index 506ebbb..9ddc973 100644
--- a/src/EvtGenBase/EvtMTree.cpp
+++ b/src/EvtGenBase/EvtMTree.cpp
@@ -1,464 +1,471 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenBase/EvtMTree.hh"
 
 #include "EvtGenBase/EvtConst.hh"
 #include "EvtGenBase/EvtKine.hh"
 #include "EvtGenBase/EvtMBreitWigner.hh"
 #include "EvtGenBase/EvtMHelAmp.hh"
 #include "EvtGenBase/EvtMTrivialLS.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtReport.hh"
 
 #include <algorithm>
 #include <stdio.h>
 #include <stdlib.h>
 
 using std::endl;
 
 EvtMTree::EvtMTree( const EvtId* idtbl, unsigned int ndaug )
 {
     for ( size_t i = 0; i < ndaug; ++i ) {
         _lbltbl.push_back( EvtPDL::name( idtbl[i] ) );
     }
 }
 
 EvtMTree::~EvtMTree()
 {
     for ( size_t i = 0; i < _root.size(); ++i )
         delete _root[i];
 }
 
 bool EvtMTree::parsecheck( char arg, const string& chars )
 {
     bool ret = false;
 
     for ( size_t i = 0; i < chars.size(); ++i ) {
         ret = ret || ( chars[i] == arg );
     }
 
     return ret;
 }
 
 vector<EvtMNode*> EvtMTree::makeparticles( const string& strid )
 {
     vector<EvtMNode*> particles;
     vector<int> labels;
 
     for ( size_t i = 0; i < _lbltbl.size(); ++i ) {
         if ( _lbltbl[i] == strid )
             labels.push_back( i );
     }
 
     if ( labels.size() == 0 ) {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "Error unknown particle label " << strid << endl;
         ::abort();
     }
 
     for ( size_t i = 0; i < labels.size(); ++i )
         particles.push_back(
             new EvtMParticle( labels[i], EvtPDL::getId( strid ) ) );
 
     return particles;
 }
 
 EvtMRes* EvtMTree::makeresonance( const EvtId& id, const string& ls,
                                   const vector<string>& lsarg, const string& type,
                                   const vector<EvtComplex>& amps,
                                   const vector<EvtMNode*>& children )
 {
     EvtMRes* resonance = NULL;
     EvtMLineShape* lineshape = NULL;
 
     if ( ls == "BREITWIGNER" ) {
         lineshape = new EvtMBreitWigner( id, lsarg );
     } else if ( ls == "TRIVIAL" ) {
         lineshape = new EvtMTrivialLS( id, lsarg );
     } else {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "Lineshape " << lineshape << " not recognized." << endl;
         ::abort();
     }
 
     if ( type == "HELAMP" ) {
         resonance = new EvtMHelAmp( id, lineshape, children, amps );
     } else {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "Model " << type << " not recognized." << endl;
         ::abort();
     }
 
     lineshape->setres( resonance );
 
     return resonance;
 }
 
 void EvtMTree::parseerror( bool flag, ptype& c_iter, ptype& c_begin, ptype& c_end )
 {
     if ( !flag )
         return;
 
     string error;
 
     while ( c_begin != c_end ) {
         if ( c_begin == c_iter ) {
             error += '_';
             error += *c_begin;
             error += '_';
         } else
             error += *c_begin;
 
         ++c_begin;
     }
 
     EvtGenReport( EVTGEN_ERROR, "EvtGen" ) << "Parse error at: " << error << endl;
     ::abort();
 }
 
 string EvtMTree::parseId( ptype& c_iter, ptype& c_begin, ptype& c_end )
 {
     string strid;
 
     while ( c_iter != c_end ) {
         parseerror( parsecheck( *c_iter, ")[]," ), c_iter, c_begin, c_end );
         if ( *c_iter == '(' ) {
             ++c_iter;
             return strid;
         }
 
         strid += *c_iter;
         ++c_iter;
     }
 
     return strid;
 }
 
 string EvtMTree::parseKey( ptype& c_iter, ptype& c_begin, ptype& c_end )
 {
     string key;
 
     while ( *c_iter != ',' ) {
         parseerror( c_iter == c_end || parsecheck( *c_iter, "()[]" ), c_iter,
                     c_begin, c_end );
         key += *c_iter;
         ++c_iter;
     }
 
     ++c_iter;
 
     parseerror( c_iter == c_end, c_iter, c_begin, c_end );
 
     return key;
 }
 
 vector<string> EvtMTree::parseArg( ptype& c_iter, ptype& c_begin, ptype& c_end )
 {
     vector<string> arg;
 
     if ( *c_iter != '[' )
         return arg;
     ++c_iter;
 
     string temp;
     while ( true ) {
         parseerror( c_iter == c_end || parsecheck( *c_iter, "[()" ), c_iter,
                     c_begin, c_end );
 
         if ( *c_iter == ']' ) {
             ++c_iter;
             if ( temp.size() > 0 )
                 arg.push_back( temp );
             break;
         }
 
         if ( *c_iter == ',' ) {
             arg.push_back( temp );
             temp.clear();
             ++c_iter;
             continue;
         }
 
         temp += *c_iter;
         ++c_iter;
     }
     parseerror( c_iter == c_end || *c_iter != ',', c_iter, c_begin, c_end );
     ++c_iter;
 
     return arg;
 }
 
 vector<EvtComplex> EvtMTree::parseAmps( ptype& c_iter, ptype& c_begin,
                                         ptype& c_end )
 {
     vector<string> parg = parseArg( c_iter, c_begin, c_end );
     parseerror( parg.size() == 0, c_iter, c_begin, c_end );
 
     // Get parametrization amplitudes
     vector<string>::iterator amp_iter = parg.begin();
     vector<string>::iterator amp_end = parg.end();
     vector<EvtComplex> amps;
 
     while ( amp_iter != amp_end ) {
         const char* nptr;
         char* endptr = NULL;
         double amp = 0.0, phase = 0.0;
 
         nptr = ( *amp_iter ).c_str();
         amp = strtod( nptr, &endptr );
         parseerror( nptr == endptr, c_iter, c_begin, c_end );
 
         ++amp_iter;
         parseerror( amp_iter == amp_end, c_iter, c_begin, c_end );
 
         nptr = ( *amp_iter ).c_str();
         phase = strtod( nptr, &endptr );
         parseerror( nptr == endptr, c_iter, c_begin, c_end );
 
         amps.push_back( amp * exp( EvtComplex( 0.0, phase ) ) );
 
         ++amp_iter;
     }
 
     return amps;
 }
 
 vector<EvtMNode*> EvtMTree::duplicate( const vector<EvtMNode*>& list ) const
 {
     vector<EvtMNode*> newlist;
 
     for ( size_t i = 0; i < list.size(); ++i )
         newlist.push_back( list[i]->duplicate() );
 
     return newlist;
 }
 
 // XXX Warning it is unsafe to use cl1 after a call to this function XXX
 vector<vector<EvtMNode*>> EvtMTree::unionChildren( const string& nodestr,
                                                    vector<vector<EvtMNode*>>& cl1 )
 {
     vector<EvtMNode*> cl2 = parsenode( nodestr, false );
     vector<vector<EvtMNode*>> cl;
 
     if ( cl1.size() == 0 ) {
         for ( size_t i = 0; i < cl2.size(); ++i ) {
             vector<EvtMNode*> temp( 1, cl2[i] );
             cl.push_back( temp );
         }
 
         return cl;
     }
 
     for ( size_t i = 0; i < cl1.size(); ++i ) {
         for ( size_t j = 0; j < cl2.size(); ++j ) {
             vector<EvtMNode*> temp;
             temp = duplicate( cl1[i] );
             temp.push_back( cl2[j]->duplicate() );
 
             cl.push_back( temp );
         }
     }
 
     for ( size_t i = 0; i < cl1.size(); ++i )
         for ( size_t j = 0; j < cl1[i].size(); ++j )
             delete cl1[i][j];
     for ( size_t i = 0; i < cl2.size(); ++i )
         delete ( cl2[i] );
 
     return cl;
 }
 
 vector<vector<EvtMNode*>> EvtMTree::parseChildren( ptype& c_iter,
                                                    ptype& c_begin, ptype& c_end )
 {
     bool test = true;
     int pcount = 0;
     string nodestr;
     vector<vector<EvtMNode*>> children;
 
     parseerror( c_iter == c_end || *c_iter != '[', c_iter, c_begin, c_end );
     ++c_iter;
 
     while ( test ) {
         parseerror( c_iter == c_end || pcount < 0, c_iter, c_begin, c_end );
 
         switch ( *c_iter ) {
             case ')':
                 --pcount;
                 nodestr += *c_iter;
                 break;
             case '(':
                 ++pcount;
                 nodestr += *c_iter;
                 break;
             case ']':
                 if ( pcount == 0 ) {
                     children = unionChildren( nodestr, children );
                     test = false;
                 } else {
                     nodestr += *c_iter;
                 }
                 break;
             case ',':
                 if ( pcount == 0 ) {
                     children = unionChildren( nodestr, children );
                     nodestr.clear();
                 } else {
                     nodestr += *c_iter;
                 }
                 break;
             default:
                 nodestr += *c_iter;
                 break;
         }
 
         ++c_iter;
     }
 
     return children;
 }
 
 vector<EvtMNode*> EvtMTree::parsenode( const string& args, bool rootnode )
 {
     ptype c_iter, c_begin, c_end;
 
     c_iter = c_begin = args.begin();
     c_end = args.end();
 
     string strid = parseId( c_iter, c_begin, c_end );
 
     // Case 1: Particle
     if ( c_iter == c_end )
         return makeparticles( strid );
 
     // Case 2: Resonance - parse further
     EvtId id = EvtPDL::getId( strid );
     parseerror( EvtId( -1, -1 ) == id, c_iter, c_begin, c_end );
 
     string ls;
     vector<string> lsarg;
 
     if ( rootnode ) {
         ls = "TRIVIAL";
     } else {
         // Get lineshape (e.g. BREITWIGNER)
         ls = parseKey( c_iter, c_begin, c_end );
         lsarg = parseArg( c_iter, c_begin, c_end );
     }
 
     // Get resonance parametrization type (e.g. HELAMP)
     string type = parseKey( c_iter, c_begin, c_end );
     vector<EvtComplex> amps = parseAmps( c_iter, c_begin, c_end );
 
     // Children
     vector<vector<EvtMNode*>> children = parseChildren( c_iter, c_begin, c_end );
 
     EvtGenReport( EVTGEN_ERROR, "EvtGen" ) << children.size() << endl;
     vector<EvtMNode*> resonances;
     for ( size_t i = 0; i < children.size(); ++i ) {
         resonances.push_back(
             makeresonance( id, ls, lsarg, type, amps, children[i] ) );
     }
 
     parseerror( c_iter == c_end || *c_iter != ')', c_iter, c_begin, c_end );
 
     return resonances;
 }
 
 bool EvtMTree::validTree( const EvtMNode* root ) const
 {
     vector<int> res = root->getresonance();
     vector<bool> check( res.size(), false );
 
     for ( size_t i = 0; i < res.size(); ++i ) {
         check[res[i]] = true;
     }
 
     bool ret = true;
 
     for ( size_t i = 0; i < check.size(); ++i ) {
         ret = ret && check[i];
     }
 
+    // Function appears to check child integer indices, but this fails if they are
+    // not always the first and second ones, so just return true for all cases
+    ret = true;
+
     return ret;
+
 }
 
 void EvtMTree::addtree( const string& str )
 {
-    vector<EvtMNode*> roots = parsenode( str, true );
+    // vector<EvtMNode*> roots = parsenode( str, true );
+    // Edit previous line to allow the creation of node resonances:
+    vector<EvtMNode*> roots = parsenode( str, false );
     _norm = 0;
 
     for ( size_t i = 0; i < roots.size(); ++i ) {
         if ( validTree( roots[i] ) ) {
             _root.push_back( roots[i] );
             _norm = _norm + 1;
         } else
             delete roots[i];
     }
 
     _norm = 1.0 / sqrt( _norm );
 }
 EvtSpinAmp EvtMTree::getrotation( EvtParticle* p ) const
 {
     // Set up the rotation matrix for the root particle (for now)
     EvtSpinDensity sd = p->rotateToHelicityBasis();
     EvtSpinType::spintype type = EvtPDL::getSpinType( _root[0]->getid() );
     int twospin = EvtSpinType::getSpin2( type );
 
     vector<EvtSpinType::spintype> types( 2, type );
     EvtSpinAmp rot( types, EvtComplex( 0.0, 0.0 ) );
     vector<int> index = rot.iterallowedinit();
     do {
         rot( index ) = sd.get( ( index[0] + twospin ) / 2,
                                ( index[1] + twospin ) / 2 );
     } while ( rot.iterateallowed( index ) );
 
     return rot;
 }
 
 EvtSpinAmp EvtMTree::amplitude( EvtParticle* p ) const
 {
     vector<EvtVector4R> product;
     for ( size_t i = 0; i < p->getNDaug(); ++i )
         product.push_back( p->getDaug( i )->getP4Lab() );
 
     if ( _root.size() == 0 ) {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "No decay tree present." << endl;
         ::abort();
     }
 
     EvtSpinAmp amp = _root[0]->amplitude( product );
     for ( size_t i = 1; i < _root.size(); ++i ) {
         // Assume that helicity amplitude is returned
         amp += _root[i]->amplitude( product );
     }
     amp = _norm * amp;
 
     //ryd
     return amp;
 
     // Do Rotation to Proper Frame
     EvtSpinAmp newamp = getrotation( p );
     newamp.extcont( amp, 1, 0 );
 
     return newamp;
 }
diff --git a/src/EvtGenBase/EvtParticle.cpp b/src/EvtGenBase/EvtParticle.cpp
index 2184fb5..c405294 100644
--- a/src/EvtGenBase/EvtParticle.cpp
+++ b/src/EvtGenBase/EvtParticle.cpp
@@ -1,1314 +1,1314 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenBase/EvtParticle.hh"
 
 #include "EvtGenBase/EvtCPUtil.hh"
 #include "EvtGenBase/EvtDecayTable.hh"
 #include "EvtGenBase/EvtDiracParticle.hh"
 #include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtId.hh"
 #include "EvtGenBase/EvtIdSet.hh"
 #include "EvtGenBase/EvtNeutrinoParticle.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticleFactory.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtPhotonParticle.hh"
 #include "EvtGenBase/EvtRadCorr.hh"
 #include "EvtGenBase/EvtRandom.hh"
 #include "EvtGenBase/EvtRaritaSchwingerParticle.hh"
 #include "EvtGenBase/EvtReport.hh"
 #include "EvtGenBase/EvtScalarParticle.hh"
 #include "EvtGenBase/EvtSecondary.hh"
 #include "EvtGenBase/EvtStatus.hh"
 #include "EvtGenBase/EvtStdHep.hh"
 #include "EvtGenBase/EvtStringParticle.hh"
 #include "EvtGenBase/EvtTensorParticle.hh"
 #include "EvtGenBase/EvtVectorParticle.hh"
 
 #include <sys/stat.h>
 
 #include <iostream>
 #include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
 
 using std::endl;
 
 EvtParticle::~EvtParticle()
 {
     delete _decayProb;
 }
 
 EvtParticle::EvtParticle()
 {
     _ndaug = 0;
     _parent = 0;
     _channel = -10;
     _t = 0.0;
     _genlifetime = 1;
     _first = 1;
     _isInit = false;
     _validP4 = false;
     _isDecayed = false;
     _decayProb = 0;
     _intAttributes.clear();
     _dblAttributes.clear();
     //   _mix=false;
 }
 
 void EvtParticle::setFirstOrNot()
 {
     _first = 0;
 }
 void EvtParticle::resetFirstOrNot()
 {
     _first = 1;
 }
 
 void EvtParticle::setChannel( int i )
 {
     _channel = i;
 }
 
 EvtParticle* EvtParticle::getParent() const
 {
     return _parent;
 }
 
 void EvtParticle::setLifetime( double tau )
 {
     _t = tau;
 }
 
 void EvtParticle::setLifetime()
 {
     if ( _genlifetime ) {
         _t = -log( EvtRandom::Flat() ) * EvtPDL::getctau( getId() );
     }
 }
 
-double EvtParticle::getLifetime()
+double EvtParticle::getLifetime() const
 {
     return _t;
 }
 
 void EvtParticle::addDaug( EvtParticle* node )
 {
     node->_daug[node->_ndaug++] = this;
     _ndaug = 0;
     _parent = node;
 }
 
 int EvtParticle::firstornot() const
 {
     return _first;
 }
 
 EvtId EvtParticle::getId() const
 {
     return _id;
 }
 
 int EvtParticle::getPDGId() const
 {
     return EvtPDL::getStdHep( _id );
 }
 
 EvtSpinType::spintype EvtParticle::getSpinType() const
 {
     return EvtPDL::getSpinType( _id );
 }
 
 int EvtParticle::getSpinStates() const
 {
     return EvtSpinType::getSpinStates( EvtPDL::getSpinType( _id ) );
 }
 
 const EvtVector4R& EvtParticle::getP4() const
 {
     return _p;
 }
 
 int EvtParticle::getChannel() const
 {
     return _channel;
 }
 
 size_t EvtParticle::getNDaug() const
 {
     return _ndaug;
 }
 
 double EvtParticle::mass() const
 {
     return _p.mass();
 }
 
 void EvtParticle::setDiagonalSpinDensity()
 {
     _rhoForward.setDiag( getSpinStates() );
 }
 
 void EvtParticle::setVectorSpinDensity()
 {
     if ( getSpinStates() != 3 ) {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "Error in EvtParticle::setVectorSpinDensity" << endl;
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "spin_states:" << getSpinStates() << endl;
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "particle:" << EvtPDL::name( _id ).c_str() << endl;
         ::abort();
     }
 
     EvtSpinDensity rho;
 
     //Set helicity +1 and -1 to 1.
     rho.setDiag( getSpinStates() );
     rho.set( 1, 1, EvtComplex( 0.0, 0.0 ) );
 
     setSpinDensityForwardHelicityBasis( rho );
 }
 
 void EvtParticle::setSpinDensityForwardHelicityBasis( const EvtSpinDensity& rho )
 {
     EvtSpinDensity R = rotateToHelicityBasis();
 
     assert( R.getDim() == rho.getDim() );
 
     int n = rho.getDim();
 
     _rhoForward.setDim( n );
 
     int i, j, k, l;
 
     for ( i = 0; i < n; i++ ) {
         for ( j = 0; j < n; j++ ) {
             EvtComplex tmp = 0.0;
             for ( k = 0; k < n; k++ ) {
                 for ( l = 0; l < n; l++ ) {
                     tmp += R.get( l, i ) * rho.get( l, k ) *
                            conj( R.get( k, j ) );
                 }
             }
             _rhoForward.set( i, j, tmp );
         }
     }
 }
 
 void EvtParticle::setSpinDensityForwardHelicityBasis( const EvtSpinDensity& rho,
                                                       double alpha, double beta,
                                                       double gamma )
 {
     EvtSpinDensity R = rotateToHelicityBasis( alpha, beta, gamma );
 
     assert( R.getDim() == rho.getDim() );
 
     int n = rho.getDim();
 
     _rhoForward.setDim( n );
 
     int i, j, k, l;
 
     for ( i = 0; i < n; i++ ) {
         for ( j = 0; j < n; j++ ) {
             EvtComplex tmp = 0.0;
             for ( k = 0; k < n; k++ ) {
                 for ( l = 0; l < n; l++ ) {
                     tmp += R.get( l, i ) * rho.get( l, k ) *
                            conj( R.get( k, j ) );
                 }
             }
             _rhoForward.set( i, j, tmp );
         }
     }
 }
 
 void EvtParticle::initDecay( bool useMinMass )
 {
     EvtParticle* p = this;
     // carefull - the parent mass might be fixed in stone..
     EvtParticle* par = p->getParent();
     double parMass = -1.;
     if ( par != 0 ) {
         if ( par->hasValidP4() )
             parMass = par->mass();
         for ( size_t i = 0; i < par->getNDaug(); i++ ) {
             EvtParticle* tDaug = par->getDaug( i );
             if ( p != tDaug )
                 parMass -= EvtPDL::getMinMass( tDaug->getId() );
         }
     }
 
     if ( _isInit ) {
         //we have already been here - just reroll the masses!
         if ( _ndaug > 0 ) {
             for ( size_t ii = 0; ii < _ndaug; ii++ ) {
                 if ( _ndaug == 1 ||
                      EvtPDL::getWidth( p->getDaug( ii )->getId() ) > 0.0000001 )
                     p->getDaug( ii )->initDecay( useMinMass );
                 else
                     p->getDaug( ii )->setMass(
                         EvtPDL::getMeanMass( p->getDaug( ii )->getId() ) );
             }
         }
 
         EvtId* dauId = 0;
         double* dauMasses = 0;
         if ( _ndaug > 0 ) {
             dauId = new EvtId[_ndaug];
             dauMasses = new double[_ndaug];
             for ( size_t j = 0; j < _ndaug; j++ ) {
                 dauId[j] = p->getDaug( j )->getId();
                 dauMasses[j] = p->getDaug( j )->mass();
             }
         }
         EvtId* parId = 0;
         EvtId* othDauId = 0;
         EvtParticle* tempPar = p->getParent();
         if ( tempPar ) {
             parId = new EvtId( tempPar->getId() );
             if ( tempPar->getNDaug() == 2 ) {
                 if ( tempPar->getDaug( 0 ) == this )
                     othDauId = new EvtId( tempPar->getDaug( 1 )->getId() );
                 else
                     othDauId = new EvtId( tempPar->getDaug( 0 )->getId() );
             }
         }
         if ( p->getParent() && _validP4 == false ) {
             if ( !useMinMass ) {
                 p->setMass( EvtPDL::getRandMass( p->getId(), parId, _ndaug, dauId,
                                                  othDauId, parMass, dauMasses ) );
             } else
                 p->setMass( EvtPDL::getMinMass( p->getId() ) );
         }
         if ( parId )
             delete parId;
         if ( othDauId )
             delete othDauId;
         if ( dauId )
             delete[] dauId;
         if ( dauMasses )
             delete[] dauMasses;
         return;
     }
 
     //Will include effects of mixing here
     //added by Lange Jan4,2000
     static EvtId BS0 = EvtPDL::getId( "B_s0" );
     static EvtId BSB = EvtPDL::getId( "anti-B_s0" );
     static EvtId BD0 = EvtPDL::getId( "B0" );
     static EvtId BDB = EvtPDL::getId( "anti-B0" );
     static EvtId D0 = EvtPDL::getId( "D0" );
     static EvtId D0B = EvtPDL::getId( "anti-D0" );
     static EvtId U4S = EvtPDL::getId( "Upsilon(4S)" );
     static EvtIdSet borUps( BS0, BSB, BD0, BDB, U4S );
 
     //only makes sense if there is no parent particle which is a B or an Upsilon
     bool hasBorUps = false;
     if ( getParent() && borUps.contains( getParent()->getId() ) )
         hasBorUps = true;
     //    if ( (getNDaug()==0)&&(getParent()==0) && (getId()==BS0||getId()==BSB||getId()==BD0||getId()==BDB)){
     EvtId thisId = getId();
     // remove D0 mixing for now.
     //  if ( (getNDaug()==0 && !hasBorUps) && (thisId==BS0||thisId==BSB||thisId==BD0||thisId==BDB||thisId==D0||thisId==D0B)){
     if ( ( getNDaug() == 0 && !hasBorUps ) &&
          ( thisId == BS0 || thisId == BSB || thisId == BD0 || thisId == BDB ) ) {
         double t;
         int mix;
         EvtCPUtil::getInstance()->incoherentMix( getId(), t, mix );
         setLifetime( t );
 
         if ( mix ) {
             EvtScalarParticle* scalar_part;
 
             scalar_part = new EvtScalarParticle;
             if ( getId() == BS0 ) {
                 EvtVector4R p_init( EvtPDL::getMass( BSB ), 0.0, 0.0, 0.0 );
                 scalar_part->init( EvtPDL::chargeConj( getId() ), p_init );
             } else if ( getId() == BSB ) {
                 EvtVector4R p_init( EvtPDL::getMass( BS0 ), 0.0, 0.0, 0.0 );
                 scalar_part->init( EvtPDL::chargeConj( getId() ), p_init );
             } else if ( getId() == BD0 ) {
                 EvtVector4R p_init( EvtPDL::getMass( BDB ), 0.0, 0.0, 0.0 );
                 scalar_part->init( EvtPDL::chargeConj( getId() ), p_init );
             } else if ( getId() == BDB ) {
                 EvtVector4R p_init( EvtPDL::getMass( BD0 ), 0.0, 0.0, 0.0 );
                 scalar_part->init( EvtPDL::chargeConj( getId() ), p_init );
             } else if ( getId() == D0 ) {
                 EvtVector4R p_init( EvtPDL::getMass( D0B ), 0.0, 0.0, 0.0 );
                 scalar_part->init( EvtPDL::chargeConj( getId() ), p_init );
             } else if ( getId() == D0B ) {
                 EvtVector4R p_init( EvtPDL::getMass( D0 ), 0.0, 0.0, 0.0 );
                 scalar_part->init( EvtPDL::chargeConj( getId() ), p_init );
             }
 
             scalar_part->setLifetime( 0 );
             scalar_part->setDiagonalSpinDensity();
 
             insertDaugPtr( 0, scalar_part );
 
             _ndaug = 1;
             _isInit = true;
             p = scalar_part;
             p->initDecay( useMinMass );
             return;
         }
     }
 
     EvtDecayBase* decayer;
     decayer = EvtDecayTable::getInstance()->getDecayFunc( p );
 
     if ( decayer ) {
         p->makeDaughters( decayer->nRealDaughters(), decayer->getDaugs() );
         //then loop over the daughters and init their decay
         for ( size_t i = 0; i < p->getNDaug(); i++ ) {
             //      std::cout << EvtPDL::name(p->getDaug(i)->getId()) << " " << i << " " << p->getDaug(i)->getSpinType() << " " << EvtPDL::name(p->getId()) << std::endl;
             if ( EvtPDL::getWidth( p->getDaug( i )->getId() ) > 0.0000001 )
                 p->getDaug( i )->initDecay( useMinMass );
             else
                 p->getDaug( i )->setMass(
                     EvtPDL::getMeanMass( p->getDaug( i )->getId() ) );
         }
     }
 
     int j;
     EvtId* dauId = 0;
     double* dauMasses = 0;
     int nDaugT = p->getNDaug();
     if ( nDaugT > 0 ) {
         dauId = new EvtId[nDaugT];
         dauMasses = new double[nDaugT];
         for ( j = 0; j < nDaugT; j++ ) {
             dauId[j] = p->getDaug( j )->getId();
             dauMasses[j] = p->getDaug( j )->mass();
         }
     }
 
     EvtId* parId = 0;
     EvtId* othDauId = 0;
     EvtParticle* tempPar = p->getParent();
     if ( tempPar ) {
         parId = new EvtId( tempPar->getId() );
         if ( tempPar->getNDaug() == 2 ) {
             if ( tempPar->getDaug( 0 ) == this )
                 othDauId = new EvtId( tempPar->getDaug( 1 )->getId() );
             else
                 othDauId = new EvtId( tempPar->getDaug( 0 )->getId() );
         }
     }
     if ( p->getParent() && p->hasValidP4() == false ) {
         if ( !useMinMass ) {
             p->setMass( EvtPDL::getRandMass( p->getId(), parId, p->getNDaug(),
                                              dauId, othDauId, parMass,
                                              dauMasses ) );
         } else {
             p->setMass( EvtPDL::getMinMass( p->getId() ) );
         }
     }
     if ( parId )
         delete parId;
     if ( othDauId )
         delete othDauId;
     if ( dauId )
         delete[] dauId;
     if ( dauMasses )
         delete[] dauMasses;
     _isInit = true;
 }
 
 void EvtParticle::decay()
 {
     //P is particle to decay, typically 'this' but sometime
     //modified by mixing
     EvtParticle* p = this;
     //Did it mix?
     //if ( p->getMixed() ) {
     //should take C(p) - this should only
     //happen the first time we call decay for this
     //particle
     //p->takeCConj();
     // p->setUnMixed();
     //}
 
     EvtDecayBase* decayer;
     decayer = EvtDecayTable::getInstance()->getDecayFunc( p );
     //  if ( decayer ) {
     //    EvtGenReport(EVTGEN_INFO,"EvtGen") << "calling decay for " << EvtPDL::name(p->getId()) << " " << p->mass() << " " << p->getP4() << " " << p->getNDaug() << " " << p << endl;
     //    EvtGenReport(EVTGEN_INFO,"EvtGen") << "NDaug= " << decayer->getNDaug() << endl;
     //    int ti;
     //    for ( ti=0; ti<decayer->getNDaug(); ti++)
     //      EvtGenReport(EVTGEN_INFO,"EvtGen") << "Daug " << ti << " " << EvtPDL::name(decayer->getDaug(ti)) << endl;
     //  }
     //if (p->_ndaug>0) {
     //      EvtGenReport(EVTGEN_INFO,"EvtGen") <<"Is decaying particle with daughters!!!!!"<<endl;
     //     ::abort();
     //return;
     //call initdecay first - April 29,2002 - Lange
     //}
 
     //if there are already daughters, then this step is already done!
     // figure out the masses
     bool massTreeOK( true );
     if ( _ndaug == 0 ) {
         massTreeOK = generateMassTree();
     }
 
     if ( massTreeOK == false ) {
         EvtGenReport( EVTGEN_INFO, "EvtGen" )
             << "Could not decay " << EvtPDL::name( p->getId() ) << " with mass "
             << p->mass() << " to decay channel number " << _channel << endl;
         _isDecayed = false;
         return;
     }
 
     static EvtId BS0 = EvtPDL::getId( "B_s0" );
     static EvtId BSB = EvtPDL::getId( "anti-B_s0" );
     static EvtId BD0 = EvtPDL::getId( "B0" );
     static EvtId BDB = EvtPDL::getId( "anti-B0" );
     // static EvtId D0=EvtPDL::getId("D0");
     // static EvtId D0B=EvtPDL::getId("anti-D0");
 
     EvtId thisId = getId();
     // remove D0 mixing for now..
     //  if ( _ndaug==1 &&  (thisId==BS0||thisId==BSB||thisId==BD0||thisId==BDB||thisId==D0||thisId==D0B) ) {
     if ( _ndaug == 1 &&
          ( thisId == BS0 || thisId == BSB || thisId == BD0 || thisId == BDB ) ) {
         p = p->getDaug( 0 );
         decayer = EvtDecayTable::getInstance()->getDecayFunc( p );
     }
     //now we have accepted a set of masses - time
     if ( decayer != 0 ) {
         decayer->makeDecay( p );
     } else {
         p->_rhoBackward.setDiag( p->getSpinStates() );
     }
 
     _isDecayed = true;
     return;
 }
 
 bool EvtParticle::generateMassTree()
 {
     bool isOK( true );
 
     double massProb = 1.;
     double ranNum = 2.;
     int counter = 0;
     EvtParticle* p = this;
     while ( massProb < ranNum ) {
         //check it out the first time.
         p->initDecay();
         massProb = p->compMassProb();
         ranNum = EvtRandom::Flat();
         counter++;
 
         if ( counter > 10000 ) {
             if ( counter == 10001 ) {
                 EvtGenReport( EVTGEN_INFO, "EvtGen" )
                     << "Too many iterations to determine the mass tree. Parent mass= "
                     << p->mass() << " " << massProb << endl;
                 p->printTree();
                 EvtGenReport( EVTGEN_INFO, "EvtGen" )
                     << "will take next combo with non-zero likelihood\n";
             }
             if ( massProb > 0. )
                 massProb = 2.0;
             if ( counter > 20000 ) {
                 // one last try - take the minimum masses
                 p->initDecay( true );
                 p->printTree();
                 massProb = p->compMassProb();
                 if ( massProb > 0. ) {
                     massProb = 2.0;
                     EvtGenReport( EVTGEN_INFO, "EvtGen" )
                         << "Taking the minimum mass of all particles in the chain\n";
                 } else {
                     EvtGenReport( EVTGEN_INFO, "EvtGen" )
                         << "Sorry, no luck finding a valid set of masses.  This may be a pathological combo\n";
                     isOK = false;
                     break;
                 }
             }
         }
     }
 
     return isOK;
 }
 
 double EvtParticle::compMassProb()
 {
     EvtParticle* p = this;
     double mass = p->mass();
     double parMass = 0.;
     if ( p->getParent() ) {
         parMass = p->getParent()->mass();
     }
 
     int nDaug = p->getNDaug();
     double* dMasses = 0;
 
     int i;
     if ( nDaug > 0 ) {
         dMasses = new double[nDaug];
         for ( i = 0; i < nDaug; i++ )
             dMasses[i] = p->getDaug( i )->mass();
     }
 
     double temp = 1.0;
     temp = EvtPDL::getMassProb( p->getId(), mass, parMass, nDaug, dMasses );
 
     //If the particle already has a mass, we dont need to include
     //it in the probability calculation
     if ( ( !p->getParent() || _validP4 ) && temp > 0.0 )
         temp = 1.;
 
     delete[] dMasses;
     for ( i = 0; i < nDaug; i++ ) {
         temp *= p->getDaug( i )->compMassProb();
     }
     return temp;
 }
 
 void EvtParticle::deleteDaughters( bool keepChannel )
 {
     for ( size_t i = 0; i < _ndaug; i++ ) {
         _daug[i]->deleteTree();
     }
 
     _ndaug = 0;
     if ( !keepChannel )
         _channel = -10;
     _first = 1;
     _isInit = false;
 }
 
 void EvtParticle::deleteTree()
 {
     this->deleteDaughters();
 
     delete this;
 }
 
 EvtVector4C EvtParticle::epsParent( int i ) const
 {
     EvtVector4C temp;
     printParticle();
     EvtGenReport( EVTGEN_ERROR, "EvtGen" )
         << "and you have asked for the:" << i << "th polarization vector."
         << " I.e. you thought it was a"
         << " vector particle!" << endl;
     ::abort();
     return temp;
 }
 
 EvtVector4C EvtParticle::eps( int i ) const
 {
     EvtVector4C temp;
     printParticle();
     EvtGenReport( EVTGEN_ERROR, "EvtGen" )
         << "and you have asked for the:" << i << "th polarization vector."
         << " I.e. you thought it was a"
         << " vector particle!" << endl;
     ::abort();
     return temp;
 }
 
 EvtVector4C EvtParticle::epsParentPhoton( int i )
 {
     EvtVector4C temp;
     printParticle();
     EvtGenReport( EVTGEN_ERROR, "EvtGen" ) << "and you have asked for the:" << i
                                            << "th polarization vector of photon."
                                            << " I.e. you thought it was a"
                                            << " photon particle!" << endl;
     ::abort();
     return temp;
 }
 
 EvtVector4C EvtParticle::epsPhoton( int i )
 {
     EvtVector4C temp;
     printParticle();
     EvtGenReport( EVTGEN_ERROR, "EvtGen" )
         << "and you have asked for the:" << i
         << "th polarization vector of a photon."
         << " I.e. you thought it was a"
         << " photon particle!" << endl;
     ::abort();
     return temp;
 }
 
 EvtDiracSpinor EvtParticle::spParent( int i ) const
 {
     EvtDiracSpinor tempD;
     printParticle();
     EvtGenReport( EVTGEN_ERROR, "EvtGen" )
         << "and you have asked for the:" << i << "th dirac spinor."
         << " I.e. you thought it was a"
         << " Dirac particle!" << endl;
     ::abort();
     return tempD;
 }
 
 EvtDiracSpinor EvtParticle::sp( int i ) const
 {
     EvtDiracSpinor tempD;
     printParticle();
     EvtGenReport( EVTGEN_ERROR, "EvtGen" )
         << "and you have asked for the:" << i << "th dirac spinor."
         << " I.e. you thought it was a"
         << " Dirac particle!" << endl;
     ::abort();
     return tempD;
 }
 
 EvtDiracSpinor EvtParticle::spParentNeutrino() const
 {
     EvtDiracSpinor tempD;
     printParticle();
     EvtGenReport( EVTGEN_ERROR, "EvtGen" ) << "and you have asked for the "
                                            << "dirac spinor."
                                            << " I.e. you thought it was a"
                                            << " neutrino particle!" << endl;
     ::abort();
     return tempD;
 }
 
 EvtDiracSpinor EvtParticle::spNeutrino() const
 {
     EvtDiracSpinor tempD;
     printParticle();
     EvtGenReport( EVTGEN_ERROR, "EvtGen" ) << "and you have asked for the "
                                            << "dirac spinor."
                                            << " I.e. you thought it was a"
                                            << " neutrino particle!" << endl;
     ::abort();
     return tempD;
 }
 
 EvtTensor4C EvtParticle::epsTensorParent( int i ) const
 {
     EvtTensor4C tempC;
     printParticle();
     EvtGenReport( EVTGEN_ERROR, "EvtGen" )
         << "and you have asked for the:" << i << "th tensor."
         << " I.e. you thought it was a"
         << " Tensor particle!" << endl;
     ::abort();
     return tempC;
 }
 
 EvtTensor4C EvtParticle::epsTensor( int i ) const
 {
     EvtTensor4C tempC;
     printParticle();
     EvtGenReport( EVTGEN_ERROR, "EvtGen" )
         << "and you have asked for the:" << i << "th tensor."
         << " I.e. you thought it was a"
         << " Tensor particle!" << endl;
     ::abort();
     return tempC;
 }
 
 EvtRaritaSchwinger EvtParticle::spRSParent( int i ) const
 {
     EvtRaritaSchwinger tempD;
     printParticle();
     EvtGenReport( EVTGEN_ERROR, "EvtGen" )
         << "and you have asked for the:" << i << "th Rarita-Schwinger spinor."
         << " I.e. you thought it was a"
         << " RaritaSchwinger particle!" << std::endl;
     ::abort();
     return tempD;
 }
 
 EvtRaritaSchwinger EvtParticle::spRS( int i ) const
 {
     EvtRaritaSchwinger tempD;
     printParticle();
     EvtGenReport( EVTGEN_ERROR, "EvtGen" )
         << "and you have asked for the:" << i << "th Rarita-Schwinger spinor."
         << " I.e. you thought it was a"
         << " RaritaSchwinger particle!" << std::endl;
     ::abort();
     return tempD;
 }
 
 EvtVector4R EvtParticle::getP4Lab() const
 {
     EvtVector4R temp, mom;
     const EvtParticle* ptemp;
 
     temp = this->getP4();
     ptemp = this;
 
     while ( ptemp->getParent() != 0 ) {
         ptemp = ptemp->getParent();
         mom = ptemp->getP4();
         temp = boostTo( temp, mom );
     }
     return temp;
 }
 
 EvtVector4R EvtParticle::getP4LabBeforeFSR()
 {
     EvtVector4R temp, mom;
     EvtParticle* ptemp;
 
     temp = this->_pBeforeFSR;
     ptemp = this;
 
     while ( ptemp->getParent() != 0 ) {
         ptemp = ptemp->getParent();
         mom = ptemp->getP4();
         temp = boostTo( temp, mom );
     }
     return temp;
 }
 
 EvtVector4R EvtParticle::getP4Restframe() const
 {
     return EvtVector4R( mass(), 0.0, 0.0, 0.0 );
 }
 
 EvtVector4R EvtParticle::get4Pos() const
 {
     EvtVector4R temp, mom;
     EvtParticle* ptemp;
 
     temp.set( 0.0, 0.0, 0.0, 0.0 );
     ptemp = getParent();
 
     if ( ptemp == 0 )
         return temp;
 
     temp = ( ptemp->_t / ptemp->mass() ) * ( ptemp->getP4() );
 
     while ( ptemp->getParent() != 0 ) {
         ptemp = ptemp->getParent();
         mom = ptemp->getP4();
         temp = boostTo( temp, mom );
         temp = temp + ( ptemp->_t / ptemp->mass() ) * ( ptemp->getP4() );
     }
 
     return temp;
 }
 
 EvtParticle* EvtParticle::nextIter( EvtParticle* rootOfTree )
 {
     EvtParticle* bpart;
     EvtParticle* current;
 
     current = this;
     size_t i;
 
     if ( _ndaug != 0 )
         return _daug[0];
 
     do {
         bpart = current->_parent;
         if ( bpart == 0 )
             return 0;
         i = 0;
         while ( bpart->_daug[i] != current ) {
             i++;
         }
 
         if ( bpart == rootOfTree ) {
             if ( i + 1 == bpart->_ndaug )
                 return 0;
         }
 
         i++;
         current = bpart;
 
     } while ( i >= bpart->_ndaug );
 
     return bpart->_daug[i];
 }
 
 void EvtParticle::makeStdHep( EvtStdHep& stdhep, EvtSecondary& secondary,
                               EvtId* list_of_stable )
 {
     //first add particle to the stdhep list;
     stdhep.createParticle( getP4Lab(), get4Pos(), -1, -1,
                            EvtPDL::getStdHep( getId() ) );
 
     int ii = 0;
 
     //lets see if this is a longlived particle and terminate the
     //list building!
 
     while ( list_of_stable[ii] != EvtId( -1, -1 ) ) {
         if ( getId() == list_of_stable[ii] ) {
             secondary.createSecondary( 0, this );
             return;
         }
         ii++;
     }
 
     for ( size_t i = 0; i < _ndaug; i++ ) {
         stdhep.createParticle( _daug[i]->getP4Lab(), _daug[i]->get4Pos(), 0, 0,
                                EvtPDL::getStdHep( _daug[i]->getId() ) );
     }
 
     for ( size_t i = 0; i < _ndaug; i++ ) {
         _daug[i]->makeStdHepRec( 1 + i, 1 + i, stdhep, secondary, list_of_stable );
     }
     return;
 }
 
 void EvtParticle::makeStdHep( EvtStdHep& stdhep )
 {
     //first add particle to the stdhep list;
     stdhep.createParticle( getP4Lab(), get4Pos(), -1, -1,
                            EvtPDL::getStdHep( getId() ) );
 
     for ( size_t i = 0; i < _ndaug; i++ ) {
         stdhep.createParticle( _daug[i]->getP4Lab(), _daug[i]->get4Pos(), 0, 0,
                                EvtPDL::getStdHep( _daug[i]->getId() ) );
     }
 
     for ( size_t i = 0; i < _ndaug; i++ ) {
         _daug[i]->makeStdHepRec( 1 + i, 1 + i, stdhep );
     }
     return;
 }
 
 void EvtParticle::makeStdHepRec( int firstparent, int lastparent,
                                  EvtStdHep& stdhep, EvtSecondary& secondary,
                                  EvtId* list_of_stable )
 {
     int ii = 0;
 
     //lets see if this is a longlived particle and terminate the
     //list building!
 
     while ( list_of_stable[ii] != EvtId( -1, -1 ) ) {
         if ( getId() == list_of_stable[ii] ) {
             secondary.createSecondary( firstparent, this );
             return;
         }
         ii++;
     }
 
     int parent_num = stdhep.getNPart();
     for ( size_t i = 0; i < _ndaug; i++ ) {
         stdhep.createParticle( _daug[i]->getP4Lab(), _daug[i]->get4Pos(),
                                firstparent, lastparent,
                                EvtPDL::getStdHep( _daug[i]->getId() ) );
     }
 
     for ( size_t i = 0; i < _ndaug; i++ ) {
         _daug[i]->makeStdHepRec( parent_num + i, parent_num + i, stdhep,
                                  secondary, list_of_stable );
     }
     return;
 }
 
 void EvtParticle::makeStdHepRec( int firstparent, int lastparent,
                                  EvtStdHep& stdhep )
 {
     int parent_num = stdhep.getNPart();
     for ( size_t i = 0; i < _ndaug; i++ ) {
         stdhep.createParticle( _daug[i]->getP4Lab(), _daug[i]->get4Pos(),
                                firstparent, lastparent,
                                EvtPDL::getStdHep( _daug[i]->getId() ) );
     }
 
     for ( size_t i = 0; i < _ndaug; i++ ) {
         _daug[i]->makeStdHepRec( parent_num + i, parent_num + i, stdhep );
     }
     return;
 }
 
 void EvtParticle::printTreeRec( unsigned int level ) const
 {
     size_t newlevel, i;
     newlevel = level + 1;
 
     if ( _ndaug != 0 ) {
         if ( level > 0 ) {
             for ( i = 0; i < ( 5 * level ); i++ ) {
                 EvtGenReport( EVTGEN_INFO, "" ) << " ";
             }
         }
         EvtGenReport( EVTGEN_INFO, "" ) << EvtPDL::name( _id ).c_str();
         EvtGenReport( EVTGEN_INFO, "" ) << " -> ";
         for ( i = 0; i < _ndaug; i++ ) {
             EvtGenReport( EVTGEN_INFO, "" )
                 << EvtPDL::name( _daug[i]->getId() ).c_str() << " ";
         }
         for ( i = 0; i < _ndaug; i++ ) {
             EvtGenReport( EVTGEN_INFO, "" )
                 << _daug[i]->mass() << " " << _daug[i]->getP4() << " "
                 << _daug[i]->getSpinStates() << "; ";
         }
         EvtGenReport( EVTGEN_INFO, "" ) << endl;
         for ( i = 0; i < _ndaug; i++ ) {
             _daug[i]->printTreeRec( newlevel );
         }
     }
 }
 
 void EvtParticle::printTree() const
 {
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "This is the current decay chain" << endl;
     EvtGenReport( EVTGEN_INFO, "" )
         << "This top particle is " << EvtPDL::name( _id ).c_str() << " "
         << this->mass() << " " << this->getP4() << endl;
 
     this->printTreeRec( 0 );
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "End of decay chain." << endl;
 }
 
 std::string EvtParticle::treeStrRec( unsigned int level ) const
 {
     size_t newlevel, i;
     newlevel = level + 1;
 
     std::string retval = "";
 
     for ( i = 0; i < _ndaug; i++ ) {
         retval += EvtPDL::name( _daug[i]->getId() );
         if ( _daug[i]->getNDaug() > 0 ) {
             retval += " (";
             retval += _daug[i]->treeStrRec( newlevel );
             retval += ") ";
         } else {
             if ( i + 1 != _ndaug )
                 retval += " ";
         }
     }
 
     return retval;
 }
 
 std::string EvtParticle::treeStr() const
 {
     std::string retval = EvtPDL::name( _id );
     retval += " -> ";
 
     retval += treeStrRec( 0 );
 
     return retval;
 }
 
 void EvtParticle::printParticle() const
 {
     switch ( EvtPDL::getSpinType( _id ) ) {
         case EvtSpinType::SCALAR:
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << "This is a scalar particle:" << EvtPDL::name( _id ).c_str()
                 << "\n";
             break;
         case EvtSpinType::VECTOR:
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << "This is a vector particle:" << EvtPDL::name( _id ).c_str()
                 << "\n";
             break;
         case EvtSpinType::TENSOR:
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << "This is a tensor particle:" << EvtPDL::name( _id ).c_str()
                 << "\n";
             break;
         case EvtSpinType::DIRAC:
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << "This is a dirac particle:" << EvtPDL::name( _id ).c_str()
                 << "\n";
             break;
         case EvtSpinType::PHOTON:
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << "This is a photon:" << EvtPDL::name( _id ).c_str() << "\n";
             break;
         case EvtSpinType::NEUTRINO:
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << "This is a neutrino:" << EvtPDL::name( _id ).c_str() << "\n";
             break;
         case EvtSpinType::STRING:
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << "This is a string:" << EvtPDL::name( _id ).c_str() << "\n";
             break;
         default:
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << "Unknown particle type in EvtParticle::printParticle()"
                 << endl;
             break;
     }
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "Number of daughters:" << _ndaug << "\n";
 }
 
 void init_vector( EvtParticle** part )
 {
     *part = new EvtVectorParticle;
 }
 
 void init_scalar( EvtParticle** part )
 {
     *part = new EvtScalarParticle;
 }
 
 void init_tensor( EvtParticle** part )
 {
     *part = new EvtTensorParticle;
 }
 
 void init_dirac( EvtParticle** part )
 {
     *part = new EvtDiracParticle;
 }
 
 void init_photon( EvtParticle** part )
 {
     *part = new EvtPhotonParticle;
 }
 
 void init_neutrino( EvtParticle** part )
 {
     *part = new EvtNeutrinoParticle;
 }
 
 void init_string( EvtParticle** part )
 {
     *part = new EvtStringParticle;
 }
 
 double EvtParticle::initializePhaseSpace( unsigned int numdaughter,
                                           EvtId* daughters,
                                           bool forceDaugMassReset,
                                           double poleSize, int whichTwo1,
                                           int whichTwo2 )
 {
     double m_b;
     unsigned int i;
     //lange
     //  this->makeDaughters(numdaughter,daughters);
 
     static EvtVector4R p4[100];
     static double mass[100];
 
     m_b = this->mass();
 
     //lange - Jan2,2002 - Need to check to see if the daughters of the parent
     // have changed. If so, delete them and start over.
     //EvtGenReport(EVTGEN_INFO,"EvtGen") << "the parent is\n";
     //if ( this->getParent() ) {
     //  if ( this->getParent()->getParent() ) this->getParent()->getParent()->printTree();
     //    this->getParent()->printTree();
     //}
     //EvtGenReport(EVTGEN_INFO,"EvtGen") << "and this is\n";
     //if ( this) this->printTree();
     bool resetDaughters = false;
 
     if ( numdaughter != this->getNDaug() && this->getNDaug() > 0 )
         resetDaughters = true;
     if ( numdaughter == this->getNDaug() )
         for ( i = 0; i < numdaughter; i++ ) {
             if ( this->getDaug( i )->getId() != daughters[i] )
                 resetDaughters = true;
             //EvtGenReport(EVTGEN_INFO,"EvtGen") << EvtPDL::name(this->getDaug(i)->getId())
             //		    << " " << EvtPDL::name(daughters[i]) << endl;
         }
 
     if ( resetDaughters || forceDaugMassReset ) {
         bool t1 = true;
         //but keep the decay channel of the parent.
         this->deleteDaughters( t1 );
         this->makeDaughters( numdaughter, daughters );
         bool massTreeOK = this->generateMassTree();
         if ( massTreeOK == false ) {
             return 0.0;
         }
     }
 
     double weight = 0.;
     for ( i = 0; i < numdaughter; i++ ) {
         mass[i] = this->getDaug( i )->mass();
     }
 
     if ( poleSize < -0.1 ) {
         //special case to enforce 4-momentum conservation in 1->1 decays
         if ( numdaughter == 1 ) {
             this->getDaug( 0 )->init( daughters[0],
                                       EvtVector4R( m_b, 0.0, 0.0, 0.0 ) );
         } else {
             EvtGenKine::PhaseSpace( numdaughter, mass, p4, m_b );
             for ( i = 0; i < numdaughter; i++ ) {
                 this->getDaug( i )->init( daughters[i], p4[i] );
             }
         }
     } else {
         if ( numdaughter != 3 ) {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << "Only can generate pole phase space "
                 << "distributions for 3 body final states" << endl
                 << "Will terminate." << endl;
             ::abort();
         }
         bool ok = false;
         if ( ( whichTwo1 == 1 && whichTwo2 == 0 ) ||
              ( whichTwo1 == 0 && whichTwo2 == 1 ) ) {
             weight = EvtGenKine::PhaseSpacePole( m_b, mass[0], mass[1], mass[2],
                                                  poleSize, p4 );
             this->getDaug( 0 )->init( daughters[0], p4[0] );
             this->getDaug( 1 )->init( daughters[1], p4[1] );
             this->getDaug( 2 )->init( daughters[2], p4[2] );
             ok = true;
         }
         if ( ( whichTwo1 == 1 && whichTwo2 == 2 ) ||
              ( whichTwo1 == 2 && whichTwo2 == 1 ) ) {
             weight = EvtGenKine::PhaseSpacePole( m_b, mass[2], mass[1], mass[0],
                                                  poleSize, p4 );
             this->getDaug( 0 )->init( daughters[0], p4[2] );
             this->getDaug( 1 )->init( daughters[1], p4[1] );
             this->getDaug( 2 )->init( daughters[2], p4[0] );
             ok = true;
         }
         if ( ( whichTwo1 == 0 && whichTwo2 == 2 ) ||
              ( whichTwo1 == 2 && whichTwo2 == 0 ) ) {
             weight = EvtGenKine::PhaseSpacePole( m_b, mass[1], mass[0], mass[2],
                                                  poleSize, p4 );
             this->getDaug( 0 )->init( daughters[0], p4[1] );
             this->getDaug( 1 )->init( daughters[1], p4[0] );
             this->getDaug( 2 )->init( daughters[2], p4[2] );
             ok = true;
         }
         if ( !ok ) {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << "Invalid pair of particle to generate a pole dist "
                 << whichTwo1 << " " << whichTwo2 << endl
                 << "Will terminate." << endl;
             ::abort();
         }
     }
 
     return weight;
 }
 
 void EvtParticle::makeDaughters( unsigned int ndaugstore,
                                  std::vector<EvtId> idVector )
 {
     // Convert the STL vector method to use the array method for now, since the
     // array method pervades most of the EvtGen code...
 
     unsigned int nVector = idVector.size();
     if ( nVector < ndaugstore ) {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "Asking to make " << ndaugstore << " daughters when there "
             << "are only " << nVector << " EvtId values available" << endl;
         return;
     }
 
     EvtId* idArray = new EvtId[ndaugstore];
     unsigned int i;
     for ( i = 0; i < ndaugstore; i++ ) {
         idArray[i] = idVector[i];
     }
 
     this->makeDaughters( ndaugstore, idArray );
 
     delete[] idArray;
 }
 
 void EvtParticle::makeDaughters( unsigned int ndaugstore, EvtId* id )
 {
     unsigned int i;
     if ( _channel < 0 ) {
         setChannel( 0 );
     }
     EvtParticle* pdaug;
     if ( _ndaug != 0 ) {
         if ( _ndaug != ndaugstore ) {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << "Asking to make a different number of "
                 << "daughters than what was previously created." << endl;
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << "Original parent:" << EvtPDL::name( _id ) << endl;
             for ( size_t i = 0; i < _ndaug; i++ ) {
                 EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                     << "Original daugther:"
                     << EvtPDL::name( getDaug( i )->getId() ) << endl;
             }
             for ( size_t i = 0; i < ndaugstore; i++ ) {
                 EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                     << "New Daug:" << EvtPDL::name( id[i] ) << endl;
             }
             EvtGenReport( EVTGEN_ERROR, "EvtGen" ) << "Will terminate." << endl;
             ::abort();
         }
     } else {
         for ( i = 0; i < ndaugstore; i++ ) {
             pdaug = EvtParticleFactory::particleFactory(
                 EvtPDL::getSpinType( id[i] ) );
             pdaug->setId( id[i] );
             pdaug->addDaug( this );
         }
 
     }    //else
 }    //makeDaughters
 
 void EvtParticle::setDecayProb( double prob )
 {
     if ( _decayProb == 0 )
         _decayProb = new double;
     *_decayProb = prob;
 }
 
-std::string EvtParticle::getName()
+std::string EvtParticle::getName() const
 {
     std::string theName = _id.getName();
     return theName;
 }
 
 int EvtParticle::getAttribute( std::string attName )
 {
     // Retrieve the attribute integer if the name exists.
     // Otherwise, simply return 0
 
     int attValue = 0;
 
     EvtAttIntMap::iterator mapIter;
 
     if ( ( mapIter = _intAttributes.find( attName ) ) != _intAttributes.end() ) {
         attValue = mapIter->second;
     }
 
     return attValue;
 }
 
 double EvtParticle::getAttributeDouble( std::string attName )
 {
     // Retrieve the attribute double if the name exists.
     // Otherwise, simply return 0.0
 
     double attValue = 0.0;
 
     EvtAttDblMap::iterator mapIter;
 
     if ( ( mapIter = _dblAttributes.find( attName ) ) != _dblAttributes.end() ) {
         attValue = mapIter->second;
     }
 
     return attValue;
 }
diff --git a/src/EvtGenBase/EvtPto3PAmpFactory.cpp b/src/EvtGenBase/EvtPto3PAmpFactory.cpp
index b6a7cbb..94f4e9b 100644
--- a/src/EvtGenBase/EvtPto3PAmpFactory.cpp
+++ b/src/EvtGenBase/EvtPto3PAmpFactory.cpp
@@ -1,371 +1,371 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenBase/EvtPto3PAmpFactory.hh"
 
 #include "EvtGenBase/EvtComplex.hh"
 #include "EvtGenBase/EvtConst.hh"
 #include "EvtGenBase/EvtCyclic3.hh"
 #include "EvtGenBase/EvtDalitzFlatPdf.hh"
 #include "EvtGenBase/EvtDalitzResPdf.hh"
 #include "EvtGenBase/EvtFlatAmp.hh"
 #include "EvtGenBase/EvtId.hh"
 #include "EvtGenBase/EvtLASSAmp.hh"
 #include "EvtGenBase/EvtNonresonantAmp.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtPropBreitWigner.hh"
 #include "EvtGenBase/EvtPropBreitWignerRel.hh"
 #include "EvtGenBase/EvtPropFlatte.hh"
 #include "EvtGenBase/EvtPto3PAmp.hh"
 #include "EvtGenBase/EvtSpinType.hh"
 
 #include <assert.h>
 #include <math.h>
 #include <memory>
 #include <stdio.h>
 #include <stdlib.h>
 
 using namespace EvtCyclic3;
 #include <iostream>
 
 void EvtPto3PAmpFactory::processAmp( EvtComplex c, std::vector<std::string> vv,
                                      bool conj )
 {
     if ( _verbose ) {
         printf( "Make %samplitude\n", conj ? "CP conjugate" : "" );
         unsigned i;
         for ( i = 0; i < vv.size(); i++ )
             printf( "%s\n", vv[i].c_str() );
         printf( "\n" );
     }
 
     std::unique_ptr<EvtAmplitude<EvtDalitzPoint>> amp;
     std::unique_ptr<EvtPdf<EvtDalitzPoint>> pdf;
     std::string name;
     Pair pairRes = AB;
 
     size_t i;
     /*
          Experimental amplitudes
   */
     if ( vv[0] == "PHASESPACE" ) {
         pdf = std::make_unique<EvtDalitzFlatPdf>( _dp );
         amp = std::make_unique<EvtFlatAmp<EvtDalitzPoint>>();
         name = "NR";
     } else if ( !vv[0].find( "NONRES" ) ) {
         double alpha = 0;
         EvtPto3PAmp::NumType typeNRes = EvtPto3PAmp::NONRES;
         if ( vv[0] == "NONRES_LIN" ) {
             typeNRes = EvtPto3PAmp::NONRES_LIN;
             pairRes = strToPair( vv[1].c_str() );
         } else if ( vv[0] == "NONRES_EXP" ) {
             typeNRes = EvtPto3PAmp::NONRES_EXP;
             pairRes = strToPair( vv[1].c_str() );
             alpha = strtod( vv[2].c_str(), 0 );
         } else
             assert( 0 );
         pdf = std::make_unique<EvtDalitzFlatPdf>( _dp );
         amp = std::make_unique<EvtNonresonantAmp>( &_dp, typeNRes, pairRes,
                                                    alpha );
     } else if ( vv[0] == "LASS" || vv[0] == "LASS_ELASTIC" ||
                 vv[0] == "LASS_RESONANT" ) {
         pairRes = strToPair( vv[1].c_str() );
         double m0 = strtod( vv[2].c_str(), 0 );
         double g0 = strtod( vv[3].c_str(), 0 );
         double a = strtod( vv[4].c_str(), 0 );
         double r = strtod( vv[5].c_str(), 0 );
         double cutoff = strtod( vv[6].c_str(), 0 );
         pdf = std::make_unique<EvtDalitzResPdf>( _dp, m0, g0, pairRes );
         amp = std::make_unique<EvtLASSAmp>( &_dp, pairRes, m0, g0, a, r, cutoff,
                                             vv[0] );
     }
 
     /*
       Resonant amplitudes
   */
     else if ( vv[0] == "RESONANCE" ) {
         std::unique_ptr<EvtPto3PAmp> partAmp;
 
         // RESONANCE stanza
 
         pairRes = strToPair( vv[1].c_str() );
         EvtSpinType::spintype spinR = EvtSpinType::SCALAR;
         double mR, gR;
         name = vv[2];
         EvtId resId = EvtPDL::getId( vv[2] );
         if ( _verbose )
             printf( "Particles %s form %sresonance %s\n", vv[1].c_str(),
                     vv[2].c_str(), conj ? "(conj) " : "" );
 
         // If no valid particle name is given, assume that
         // it is the spin, the mass and the width of the particle.
 
         if ( resId.getId() == -1 ) {
             switch ( atoi( vv[2].c_str() ) ) {
                 case 0: {
                     spinR = EvtSpinType::SCALAR;
                     break;
                 }
                 case 1: {
                     spinR = EvtSpinType::VECTOR;
                     break;
                 }
                 case 2: {
                     spinR = EvtSpinType::TENSOR;
                     break;
                 }
                 case 3: {
                     spinR = EvtSpinType::SPIN3;
                     break;
                 }
                 case 4: {
                     spinR = EvtSpinType::SPIN4;
                     break;
                 }
                 default: {
                     assert( 0 );
                     break;
                 }
             }
 
             mR = strtod( vv[3].c_str(), 0 );
             gR = strtod( vv[4].c_str(), 0 );
             i = 4;
         } else {
             // For a valid particle get spin, mass and width
 
             spinR = EvtPDL::getSpinType( resId );
             mR = EvtPDL::getMeanMass( resId );
             gR = EvtPDL::getWidth( resId );
             i = 2;
 
             // It's possible to specify mass and width of a particle
             // explicitly
 
             if ( vv[3] != "ANGULAR" ) {
                 if ( _verbose )
                     printf( "Setting m(%s)=%s g(%s)=%s\n", vv[2].c_str(),
                             vv[3].c_str(), vv[2].c_str(), vv[4].c_str() );
 
                 mR = strtod( vv[3].c_str(), 0 );
                 gR = strtod( vv[4].c_str(), 0 );
                 i = 4;
             }
         }
 
         // ANGULAR stanza
 
         if ( vv[++i] != "ANGULAR" ) {
             printf( "%s instead of ANGULAR\n", vv[i].c_str() );
             exit( 0 );
         }
         Pair pairAng = strToPair( vv[++i].c_str() );
         if ( _verbose )
             printf( "Angle is measured between particles %s\n", vv[i].c_str() );
 
         // TYPE stanza
 
         std::string typeName = vv[++i];
         assert( typeName == "TYPE" );
         std::string type = vv[++i];
         if ( _verbose )
             printf( "Propagator type %s\n", vv[i].c_str() );
 
         if ( type == "NBW" ) {
             EvtPropBreitWigner prop( mR, gR );
             partAmp = std::make_unique<EvtPto3PAmp>( _dp, pairAng, pairRes, spinR,
                                                      prop, EvtPto3PAmp::NBW );
         } else if ( type == "RBW_ZEMACH" ) {
             EvtPropBreitWignerRel prop( mR, gR );
             partAmp = std::make_unique<EvtPto3PAmp>( _dp, pairAng, pairRes,
                                                      spinR, prop,
                                                      EvtPto3PAmp::RBW_ZEMACH );
         } else if ( type == "RBW_KUEHN" ) {
             EvtPropBreitWignerRel prop( mR, gR );
             partAmp = std::make_unique<EvtPto3PAmp>( _dp, pairAng, pairRes,
                                                      spinR, prop,
                                                      EvtPto3PAmp::RBW_KUEHN );
         } else if ( type == "RBW_CLEO" ) {
             EvtPropBreitWignerRel prop( mR, gR );
             partAmp = std::make_unique<EvtPto3PAmp>( _dp, pairAng, pairRes,
                                                      spinR, prop,
                                                      EvtPto3PAmp::RBW_CLEO );
         } else if ( type == "FLATTE" ) {
             double m1a = _dp.m( first( pairRes ) );
             double m1b = _dp.m( second( pairRes ) );
             // 2nd channel
             double g2 = strtod( vv[++i].c_str(), 0 );
             double m2a = strtod( vv[++i].c_str(), 0 );
             double m2b = strtod( vv[++i].c_str(), 0 );
             EvtPropFlatte prop( mR, gR, m1a, m1b, g2, m2a, m2b );
             partAmp = std::make_unique<EvtPto3PAmp>( _dp, pairAng, pairRes, spinR,
                                                      prop, EvtPto3PAmp::FLATTE );
         } else
             assert( 0 );
 
         // Optional DVFF, BVFF stanzas
 
         if ( i < vv.size() - 1 ) {
             if ( vv[i + 1] == "DVFF" ) {
                 i++;
                 if ( vv[++i] == "BLATTWEISSKOPF" ) {
                     double R = strtod( vv[++i].c_str(), 0 );
                     partAmp->set_fd( R );
                 } else
                     assert( 0 );
             }
         }
 
         if ( i < vv.size() - 1 ) {
             if ( vv[i + 1] == "BVFF" ) {
                 i++;
                 if ( vv[++i] == "BLATTWEISSKOPF" ) {
                     if ( _verbose )
                         printf( "BVFF=%s\n", vv[i].c_str() );
                     double R = strtod( vv[++i].c_str(), 0 );
                     partAmp->set_fb( R );
                 } else
                     assert( 0 );
             }
         }
 
         const int minwidths = 5;
         //Optional resonance minimum and maximum
         if ( i < vv.size() - 1 ) {
             if ( vv[i + 1] == "CUTOFF" ) {
                 i++;
                 if ( vv[i + 1] == "MIN" ) {
                     i++;
                     double min = strtod( vv[++i].c_str(), 0 );
                     if ( _verbose )
                         std::cout << "CUTOFF MIN = " << min << " " << minwidths
                                   << std::endl;
                     //ensure against cutting off too close to the resonance
                     assert( min < ( mR - minwidths * gR ) );
                     partAmp->setmin( min );
                 } else if ( vv[i + 1] == "MAX" ) {
                     i++;
                     double max = strtod( vv[++i].c_str(), 0 );
                     if ( _verbose )
                         std::cout << "CUTOFF MAX = " << max << " " << minwidths
                                   << std::endl;
                     //ensure against cutting off too close to the resonance
                     assert( max > ( mR + minwidths * gR ) );
                     partAmp->setmax( max );
                 } else
                     assert( 0 );
             }
         }
 
         //2nd iteration in case min and max are both specified
         if ( i < vv.size() - 1 ) {
             if ( vv[i + 1] == "CUTOFF" ) {
                 i++;
                 if ( vv[i + 1] == "MIN" ) {
                     i++;
                     double min = strtod( vv[++i].c_str(), 0 );
                     if ( _verbose )
                         std::cout << "CUTOFF MIN = " << min << std::endl;
                     //ensure against cutting off too close to the resonance
                     assert( min < ( mR - minwidths * gR ) );
                     partAmp->setmin( min );
                 } else if ( vv[i + 1] == "MAX" ) {
                     i++;
                     double max = strtod( vv[++i].c_str(), 0 );
                     if ( _verbose )
                         std::cout << "CUTOFF MAX = " << max << std::endl;
                     //ensure against cutting off too close to the resonance
                     assert( max > ( mR + minwidths * gR ) );
                     partAmp->setmax( max );
                 } else
                     assert( 0 );
             }
         }
 
         i++;
 
         pdf = std::make_unique<EvtDalitzResPdf>( _dp, mR, gR, pairRes );
         amp = std::move( partAmp );
     }
 
     assert( amp );
     assert( pdf );
 
-    double scale = matchIsobarCoef( *_amp, *pdf, pairRes );
+    double scale = matchIsobarCoef( *amp, *pdf, pairRes );
 
     if ( !conj ) {
         _amp->addOwnedTerm( c, std::move( amp ) );
     } else {
         _ampConj->addOwnedTerm( c, std::move( amp ) );
     }
     _pc->addOwnedTerm( abs2( c ) * scale, std::move( pdf ) );
 
     _names.push_back( name );
 }
 
 double EvtPto3PAmpFactory::matchIsobarCoef( EvtAmplitude<EvtDalitzPoint>& amp,
                                             EvtPdf<EvtDalitzPoint>& pdf,
                                             EvtCyclic3::Pair ipair )
 {
     // account for differences in the definition of amplitudes by matching
     //        Integral( c'*pdf ) = Integral( c*|A|^2 )
     // to improve generation efficiency ...
 
     double Ipdf = pdf.compute_integral( 10000 ).value();
     double Iamp2 = 0;
 
     EvtCyclic3::Pair jpair = EvtCyclic3::next( ipair );
     EvtCyclic3::Pair kpair = EvtCyclic3::next( jpair );
 
     // Trapezoidal integral
     int N = 10000;
 
     double di = ( _dp.qAbsMax( ipair ) - _dp.qAbsMin( ipair ) ) / ( (double)N );
 
     double siMin = _dp.qAbsMin( ipair );
 
     double s[3];    // playing with fire
     for ( int i = 1; i < N; i++ ) {
         s[ipair] = siMin + di * i;
         s[jpair] = _dp.q( jpair, 0.9999, ipair, s[ipair] );
         s[kpair] = _dp.bigM() * _dp.bigM() - s[ipair] - s[jpair] +
                    _dp.mA() * _dp.mA() + _dp.mB() * _dp.mB() +
                    _dp.mC() * _dp.mC();
 
         EvtDalitzPoint point( _dp.mA(), _dp.mB(), _dp.mC(), s[EvtCyclic3::AB],
                               s[EvtCyclic3::BC], s[EvtCyclic3::CA] );
 
         if ( !point.isValid() )
             continue;
 
         double p = point.p( other( ipair ), ipair );
         double q = point.p( first( ipair ), ipair );
 
         double itg = abs2( amp.evaluate( point ) ) * di * 4 * q * p;
         Iamp2 += itg;
     }
     if ( _verbose )
         std::cout << "integral = " << Iamp2 << "  pdf=" << Ipdf << std::endl;
 
     assert( Ipdf > 0 && Iamp2 > 0 );
 
     return Iamp2 / Ipdf;
 }
diff --git a/src/EvtGenBase/EvtSemiLeptonicBaryonAmp.cpp b/src/EvtGenBase/EvtSemiLeptonicBaryonAmp.cpp
index e283221..b8c5220 100644
--- a/src/EvtGenBase/EvtSemiLeptonicBaryonAmp.cpp
+++ b/src/EvtGenBase/EvtSemiLeptonicBaryonAmp.cpp
@@ -1,788 +1,788 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenBase/EvtSemiLeptonicBaryonAmp.hh"
 
 #include "EvtGenBase/EvtAmp.hh"
 #include "EvtGenBase/EvtDiracParticle.hh"
 #include "EvtGenBase/EvtDiracSpinor.hh"
 #include "EvtGenBase/EvtGammaMatrix.hh"
 #include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtId.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtRaritaSchwinger.hh"
 #include "EvtGenBase/EvtReport.hh"
 #include "EvtGenBase/EvtSemiLeptonicFF.hh"
 #include "EvtGenBase/EvtTensor4C.hh"
 #include "EvtGenBase/EvtVector4C.hh"
 
 #include <stdlib.h>
 
 using std::endl;
 
 void EvtSemiLeptonicBaryonAmp::CalcAmp( EvtParticle* parent, EvtAmp& amp,
                                         EvtSemiLeptonicFF* FormFactors )
 {
     static EvtId EM = EvtPDL::getId( "e-" );
     static EvtId MUM = EvtPDL::getId( "mu-" );
     static EvtId TAUM = EvtPDL::getId( "tau-" );
     static EvtId EP = EvtPDL::getId( "e+" );
     static EvtId MUP = EvtPDL::getId( "mu+" );
     static EvtId TAUP = EvtPDL::getId( "tau+" );
 
     //Add the lepton and neutrino 4 momenta to find q2
 
     EvtVector4R q = parent->getDaug( 1 )->getP4() + parent->getDaug( 2 )->getP4();
     double q2 = ( q.mass2() );
 
     double f1v, f1a, f2v, f2a;
     double m_meson = parent->getDaug( 0 )->mass();
 
     FormFactors->getbaryonff( parent->getId(), parent->getDaug( 0 )->getId(),
                               q2, m_meson, &f1v, &f1a, &f2v, &f2a );
 
     EvtVector4R p4b;
     p4b.set( parent->mass(), 0.0, 0.0, 0.0 );
 
     EvtVector4C temp_00_term1;
     EvtVector4C temp_00_term2;
 
     EvtVector4C temp_01_term1;
     EvtVector4C temp_01_term2;
 
     EvtVector4C temp_10_term1;
     EvtVector4C temp_10_term2;
 
     EvtVector4C temp_11_term1;
     EvtVector4C temp_11_term2;
 
     EvtDiracSpinor p0 = parent->sp( 0 );
     EvtDiracSpinor p1 = parent->sp( 1 );
 
     EvtDiracSpinor d0 = parent->getDaug( 0 )->spParent( 0 );
     EvtDiracSpinor d1 = parent->getDaug( 0 )->spParent( 1 );
 
     temp_00_term1.set( 0, f1v * ( d0 * ( EvtGammaMatrix::g0() * p0 ) ) );
     temp_00_term2.set(
         0,
         f1a * ( d0 * ( ( EvtGammaMatrix::g0() * EvtGammaMatrix::g5() ) * p0 ) ) );
     temp_01_term1.set( 0, f1v * ( d0 * ( EvtGammaMatrix::g0() * p1 ) ) );
     temp_01_term2.set(
         0,
         f1a * ( d0 * ( ( EvtGammaMatrix::g0() * EvtGammaMatrix::g5() ) * p1 ) ) );
     temp_10_term1.set( 0, f1v * ( d1 * ( EvtGammaMatrix::g0() * p0 ) ) );
     temp_10_term2.set(
         0,
         f1a * ( d1 * ( ( EvtGammaMatrix::g0() * EvtGammaMatrix::g5() ) * p0 ) ) );
     temp_11_term1.set( 0, f1v * ( d1 * ( EvtGammaMatrix::g0() * p1 ) ) );
     temp_11_term2.set(
         0,
         f1a * ( d1 * ( ( EvtGammaMatrix::g0() * EvtGammaMatrix::g5() ) * p1 ) ) );
 
     temp_00_term1.set( 1, f1v * ( d0 * ( EvtGammaMatrix::g1() * p0 ) ) );
     temp_00_term2.set(
         1,
         f1a * ( d0 * ( ( EvtGammaMatrix::g1() * EvtGammaMatrix::g5() ) * p0 ) ) );
     temp_01_term1.set( 1, f1v * ( d0 * ( EvtGammaMatrix::g1() * p1 ) ) );
     temp_01_term2.set(
         1,
         f1a * ( d0 * ( ( EvtGammaMatrix::g1() * EvtGammaMatrix::g5() ) * p1 ) ) );
     temp_10_term1.set( 1, f1v * ( d1 * ( EvtGammaMatrix::g1() * p0 ) ) );
     temp_10_term2.set(
         1,
         f1a * ( d1 * ( ( EvtGammaMatrix::g1() * EvtGammaMatrix::g5() ) * p0 ) ) );
     temp_11_term1.set( 1, f1v * ( d1 * ( EvtGammaMatrix::g1() * p1 ) ) );
     temp_11_term2.set(
         1,
         f1a * ( d1 * ( ( EvtGammaMatrix::g1() * EvtGammaMatrix::g5() ) * p1 ) ) );
 
     temp_00_term1.set( 2, f1v * ( d0 * ( EvtGammaMatrix::g2() * p0 ) ) );
     temp_00_term2.set(
         2,
         f1a * ( d0 * ( ( EvtGammaMatrix::g2() * EvtGammaMatrix::g5() ) * p0 ) ) );
     temp_01_term1.set( 2, f1v * ( d0 * ( EvtGammaMatrix::g2() * p1 ) ) );
     temp_01_term2.set(
         2,
         f1a * ( d0 * ( ( EvtGammaMatrix::g2() * EvtGammaMatrix::g5() ) * p1 ) ) );
     temp_10_term1.set( 2, f1v * ( d1 * ( EvtGammaMatrix::g2() * p0 ) ) );
     temp_10_term2.set(
         2,
         f1a * ( d1 * ( ( EvtGammaMatrix::g2() * EvtGammaMatrix::g5() ) * p0 ) ) );
     temp_11_term1.set( 2, f1v * ( d1 * ( EvtGammaMatrix::g2() * p1 ) ) );
     temp_11_term2.set(
         2,
         f1a * ( d1 * ( ( EvtGammaMatrix::g2() * EvtGammaMatrix::g5() ) * p1 ) ) );
 
     temp_00_term1.set( 3, f1v * ( d0 * ( EvtGammaMatrix::g3() * p0 ) ) );
     temp_00_term2.set(
         3,
         f1a * ( d0 * ( ( EvtGammaMatrix::g3() * EvtGammaMatrix::g5() ) * p0 ) ) );
     temp_01_term1.set( 3, f1v * ( d0 * ( EvtGammaMatrix::g3() * p1 ) ) );
     temp_01_term2.set(
         3,
         f1a * ( d0 * ( ( EvtGammaMatrix::g3() * EvtGammaMatrix::g5() ) * p1 ) ) );
     temp_10_term1.set( 3, f1v * ( d1 * ( EvtGammaMatrix::g3() * p0 ) ) );
     temp_10_term2.set(
         3,
         f1a * ( d1 * ( ( EvtGammaMatrix::g3() * EvtGammaMatrix::g5() ) * p0 ) ) );
     temp_11_term1.set( 3, f1v * ( d1 * ( EvtGammaMatrix::g3() * p1 ) ) );
     temp_11_term2.set(
         3,
         f1a * ( d1 * ( ( EvtGammaMatrix::g3() * EvtGammaMatrix::g5() ) * p1 ) ) );
 
     EvtVector4C l1, l2;
 
     EvtId l_num = parent->getDaug( 1 )->getId();
     if ( l_num == EM || l_num == MUM || l_num == TAUM ) {
         l1 = EvtLeptonVACurrent( parent->getDaug( 1 )->spParent( 0 ),
                                  parent->getDaug( 2 )->spParentNeutrino() );
         l2 = EvtLeptonVACurrent( parent->getDaug( 1 )->spParent( 1 ),
                                  parent->getDaug( 2 )->spParentNeutrino() );
     } else {
         if ( l_num == EP || l_num == MUP || l_num == TAUP ) {
             l1 = EvtLeptonVACurrent( parent->getDaug( 2 )->spParentNeutrino(),
                                      parent->getDaug( 1 )->spParent( 0 ) );
             l2 = EvtLeptonVACurrent( parent->getDaug( 2 )->spParentNeutrino(),
                                      parent->getDaug( 1 )->spParent( 1 ) );
         } else {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << "Wrong lepton number" << endl;
         }
     }
 
     amp.vertex( 0, 0, 0, l1.cont( temp_00_term1 + temp_00_term2 ) );
     amp.vertex( 0, 0, 1, l2.cont( temp_00_term1 + temp_00_term2 ) );
 
     amp.vertex( 0, 1, 0, l1.cont( temp_01_term1 + temp_01_term2 ) );
     amp.vertex( 0, 1, 1, l2.cont( temp_01_term1 + temp_01_term2 ) );
 
     amp.vertex( 1, 0, 0, l1.cont( temp_10_term1 + temp_10_term2 ) );
     amp.vertex( 1, 0, 1, l2.cont( temp_10_term1 + temp_10_term2 ) );
 
     amp.vertex( 1, 1, 0, l1.cont( temp_11_term1 + temp_11_term2 ) );
     amp.vertex( 1, 1, 1, l2.cont( temp_11_term1 + temp_11_term2 ) );
 
     return;
 }
 
 double EvtSemiLeptonicBaryonAmp::CalcMaxProb( EvtId parent, EvtId baryon,
                                               EvtId lepton, EvtId nudaug,
                                               EvtSemiLeptonicFF* FormFactors,
                                               EvtComplex r00, EvtComplex r01,
                                               EvtComplex r10, EvtComplex r11 )
 {
     //This routine takes the arguements parent, baryon, and lepton
     //number, and a form factor model, and returns a maximum
     //probability for this semileptonic form factor model.  A
     //brute force method is used.  The 2D cos theta lepton and
     //q2 phase space is probed.
 
     //Start by declaring a particle at rest.
 
     //It only makes sense to have a scalar parent.  For now.
     //This should be generalized later.
 
     //  EvtScalarParticle *scalar_part;
     //  scalar_part=new EvtScalarParticle;
 
     EvtDiracParticle* dirac_part;
     EvtParticle* root_part;
     dirac_part = new EvtDiracParticle;
 
     //cludge to avoid generating random numbers!
     //  scalar_part->noLifeTime();
     dirac_part->noLifeTime();
 
     EvtVector4R p_init;
 
     p_init.set( EvtPDL::getMass( parent ), 0.0, 0.0, 0.0 );
     //  scalar_part->init(parent,p_init);
     //  root_part=(EvtParticle *)scalar_part;
     //  root_part->set_type(EvtSpinType::SCALAR);
 
     dirac_part->init( parent, p_init );
     root_part = (EvtParticle*)dirac_part;
     root_part->setDiagonalSpinDensity();
 
     EvtParticle *daughter, *lep, *trino;
 
     EvtAmp amp;
 
     EvtId listdaug[3];
     listdaug[0] = baryon;
     listdaug[1] = lepton;
     listdaug[2] = nudaug;
 
     amp.init( parent, 3, listdaug );
 
     root_part->makeDaughters( 3, listdaug );
     daughter = root_part->getDaug( 0 );
     lep = root_part->getDaug( 1 );
     trino = root_part->getDaug( 2 );
 
     //cludge to avoid generating random numbers!
     daughter->noLifeTime();
     lep->noLifeTime();
     trino->noLifeTime();
 
     //Initial particle is unpolarized, well it is a scalar so it is
     //trivial
     EvtSpinDensity rho;
     rho.setDiag( root_part->getSpinStates() );
 
     double mass[3];
 
     double m = root_part->mass();
 
     EvtVector4R p4baryon, p4lepton, p4nu, p4w;
     double q2max;
 
     double q2, elepton, plepton;
     int i, j;
     double erho, prho, costl;
 
     double maxfoundprob = 0.0;
     double prob = -10.0;
     int massiter;
 
     for ( massiter = 0; massiter < 3; massiter++ ) {
         mass[0] = EvtPDL::getMass( baryon );
         mass[1] = EvtPDL::getMass( lepton );
         mass[2] = EvtPDL::getMass( nudaug );
         if ( massiter == 1 ) {
             mass[0] = EvtPDL::getMinMass( baryon );
         }
         if ( massiter == 2 ) {
             mass[0] = EvtPDL::getMaxMass( baryon );
         }
 
         q2max = ( m - mass[0] ) * ( m - mass[0] );
 
         //loop over q2
 
         for ( i = 0; i < 25; i++ ) {
             q2 = ( ( i + 0.5 ) * q2max ) / 25.0;
 
             erho = ( m * m + mass[0] * mass[0] - q2 ) / ( 2.0 * m );
 
             prho = sqrt( erho * erho - mass[0] * mass[0] );
 
             p4baryon.set( erho, 0.0, 0.0, -1.0 * prho );
             p4w.set( m - erho, 0.0, 0.0, prho );
 
             //This is in the W rest frame
             elepton = ( q2 + mass[1] * mass[1] ) / ( 2.0 * sqrt( q2 ) );
             plepton = sqrt( elepton * elepton - mass[1] * mass[1] );
 
             double probctl[3];
 
             for ( j = 0; j < 3; j++ ) {
                 costl = 0.99 * ( j - 1.0 );
 
                 //These are in the W rest frame. Need to boost out into
                 //the B frame.
                 p4lepton.set( elepton, 0.0, plepton * sqrt( 1.0 - costl * costl ),
                               plepton * costl );
                 p4nu.set( plepton, 0.0,
                           -1.0 * plepton * sqrt( 1.0 - costl * costl ),
                           -1.0 * plepton * costl );
 
                 EvtVector4R boost( ( m - erho ), 0.0, 0.0, 1.0 * prho );
                 p4lepton = boostTo( p4lepton, boost );
                 p4nu = boostTo( p4nu, boost );
 
                 //Now initialize the daughters...
 
                 daughter->init( baryon, p4baryon );
                 lep->init( lepton, p4lepton );
                 trino->init( nudaug, p4nu );
 
                 CalcAmp( root_part, amp, FormFactors, r00, r01, r10, r11 );
 
                 //Now find the probability at this q2 and cos theta lepton point
                 //and compare to maxfoundprob.
 
                 //Do a little magic to get the probability!!
                 prob = rho.normalizedProb( amp.getSpinDensity() );
 
                 probctl[j] = prob;
             }
 
             //probclt contains prob at ctl=-1,0,1.
             //prob=a+b*ctl+c*ctl^2
 
             double a = probctl[1];
             double b = 0.5 * ( probctl[2] - probctl[0] );
             double c = 0.5 * ( probctl[2] + probctl[0] ) - probctl[1];
 
             prob = probctl[0];
             if ( probctl[1] > prob )
                 prob = probctl[1];
             if ( probctl[2] > prob )
                 prob = probctl[2];
 
             if ( fabs( c ) > 1e-20 ) {
                 double ctlx = -0.5 * b / c;
                 if ( fabs( ctlx ) < 1.0 ) {
                     double probtmp = a + b * ctlx + c * ctlx * ctlx;
                     if ( probtmp > prob )
                         prob = probtmp;
                 }
             }
 
             //EvtGenReport(EVTGEN_DEBUG,"EvtGen") << "prob,probctl:"<<prob<<" "
             //			    << probctl[0]<<" "
             //			    << probctl[1]<<" "
             //			    << probctl[2]<<std::endl;
 
             if ( prob > maxfoundprob ) {
                 maxfoundprob = prob;
             }
         }
         if ( EvtPDL::getWidth( baryon ) <= 0.0 ) {
             //if the particle is narrow dont bother with changing the mass.
             massiter = 4;
         }
     }
     root_part->deleteTree();
 
     maxfoundprob *= 1.1;
     return maxfoundprob;
 }
 void EvtSemiLeptonicBaryonAmp::CalcAmp( EvtParticle* parent, EvtAmp& amp,
                                         EvtSemiLeptonicFF* FormFactors,
                                         EvtComplex r00, EvtComplex r01,
                                         EvtComplex r10, EvtComplex r11 )
 {
     //  Leptons
     static EvtId EM = EvtPDL::getId( "e-" );
     static EvtId MUM = EvtPDL::getId( "mu-" );
     static EvtId TAUM = EvtPDL::getId( "tau-" );
     //  Anti-Leptons
     static EvtId EP = EvtPDL::getId( "e+" );
     static EvtId MUP = EvtPDL::getId( "mu+" );
     static EvtId TAUP = EvtPDL::getId( "tau+" );
 
     //  Baryons
     static EvtId LAMCP = EvtPDL::getId( "Lambda_c+" );
     static EvtId LAMC1P = EvtPDL::getId( "Lambda_c(2593)+" );
     static EvtId LAMC2P = EvtPDL::getId( "Lambda_c(2625)+" );
     static EvtId LAMB = EvtPDL::getId( "Lambda_b0" );
 
     // Anti-Baryons
     static EvtId LAMCM = EvtPDL::getId( "anti-Lambda_c-" );
     static EvtId LAMC1M = EvtPDL::getId( "anti-Lambda_c(2593)-" );
     static EvtId LAMC2M = EvtPDL::getId( "anti-Lambda_c(2625)-" );
     static EvtId LAMBB = EvtPDL::getId( "anti-Lambda_b0" );
 
     // Set the spin density matrix of the parent baryon
     EvtSpinDensity rho;
     rho.setDim( 2 );
     rho.set( 0, 0, r00 );
     rho.set( 0, 1, r01 );
 
     rho.set( 1, 0, r10 );
     rho.set( 1, 1, r11 );
 
     EvtVector4R vector4P = parent->getP4Lab();
     double pmag = vector4P.d3mag();
-    double cosTheta = vector4P.get( 3 ) / pmag;
+    double cosTheta = pmag > 0.0 ? vector4P.get( 3 ) / pmag : 0.0;
 
     double theta = acos( cosTheta );
     double phi = atan2( vector4P.get( 2 ), vector4P.get( 1 ) );
 
     parent->setSpinDensityForwardHelicityBasis( rho, phi, theta, 0.0 );
     //parent->setSpinDensityForward(rho);
 
     // Set the four momentum of the parent baryon in it's rest frame
     EvtVector4R p4b;
     p4b.set( parent->mass(), 0.0, 0.0, 0.0 );
 
     // Get the four momentum of the daughter baryon in the parent's rest frame
     EvtVector4R p4daught = parent->getDaug( 0 )->getP4();
 
     // Add the lepton and neutrino 4 momenta to find q (q^2)
     EvtVector4R q = parent->getDaug( 1 )->getP4() + parent->getDaug( 2 )->getP4();
 
     double q2 = q.mass2();
 
     EvtId l_num = parent->getDaug( 1 )->getId();
     EvtId bar_num = parent->getDaug( 0 )->getId();
     EvtId par_num = parent->getId();
 
     double baryonmass = parent->getDaug( 0 )->mass();
 
     // Handle spin-1/2 daughter baryon Dirac spinor cases
     if ( EvtPDL::getSpinType( parent->getDaug( 0 )->getId() ) ==
          EvtSpinType::DIRAC ) {
         // Set the form factors
         double f1, f2, f3, g1, g2, g3;
         FormFactors->getdiracff( par_num, bar_num, q2, baryonmass, &f1, &f2,
                                  &f3, &g1, &g2, &g3 );
 
         const double form_fact[6] = {f1, f2, f3, g1, g2, g3};
 
         EvtVector4C b11, b12, b21, b22, l1, l2;
 
         //  Lepton Current
         if ( l_num == EM || l_num == MUM || l_num == TAUM ) {
             l1 = EvtLeptonVACurrent( parent->getDaug( 1 )->spParent( 0 ),
                                      parent->getDaug( 2 )->spParentNeutrino() );
             l2 = EvtLeptonVACurrent( parent->getDaug( 1 )->spParent( 1 ),
                                      parent->getDaug( 2 )->spParentNeutrino() );
 
         } else if ( l_num == EP || l_num == MUP || l_num == TAUP ) {
             l1 = EvtLeptonVACurrent( parent->getDaug( 2 )->spParentNeutrino(),
                                      parent->getDaug( 1 )->spParent( 0 ) );
             l2 = EvtLeptonVACurrent( parent->getDaug( 2 )->spParentNeutrino(),
                                      parent->getDaug( 1 )->spParent( 1 ) );
 
         } else {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" ) << "Wrong lepton number \n";
             ::abort();
         }
 
         // Baryon current
 
         // Flag for particle/anti-particle parent, daughter with same/opp. parity
         // pflag = 0 => particle, same parity parent, daughter
         // pflag = 1 => particle, opp. parity parent, daughter
         // pflag = 2 => anti-particle, same parity parent, daughter
         // pflag = 3 => anti-particle, opp. parity parent, daughter
 
         int pflag = 0;
 
         // Handle 1/2+ -> 1/2+ first
         if ( ( par_num == LAMB && bar_num == LAMCP ) ||
              ( par_num == LAMBB && bar_num == LAMCM ) ) {
             // Set particle/anti-particle flag
             if ( bar_num == LAMCP )
                 pflag = 0;
             else if ( bar_num == LAMCM )
                 pflag = 2;
 
             b11 = EvtBaryonVACurrent( parent->getDaug( 0 )->spParent( 0 ),
                                       parent->sp( 0 ), p4b, p4daught, form_fact,
                                       pflag );
             b21 = EvtBaryonVACurrent( parent->getDaug( 0 )->spParent( 0 ),
                                       parent->sp( 1 ), p4b, p4daught, form_fact,
                                       pflag );
             b12 = EvtBaryonVACurrent( parent->getDaug( 0 )->spParent( 1 ),
                                       parent->sp( 0 ), p4b, p4daught, form_fact,
                                       pflag );
             b22 = EvtBaryonVACurrent( parent->getDaug( 0 )->spParent( 1 ),
                                       parent->sp( 1 ), p4b, p4daught, form_fact,
                                       pflag );
         }
 
         // Handle 1/2+ -> 1/2- second
         else if ( ( par_num == LAMB && bar_num == LAMC1P ) ||
                   ( par_num == LAMBB && bar_num == LAMC1M ) ) {
             // Set particle/anti-particle flag
             if ( bar_num == LAMC1P )
                 pflag = 1;
             else if ( bar_num == LAMC1M )
                 pflag = 3;
 
             b11 = EvtBaryonVACurrent( ( parent->getDaug( 0 )->spParent( 0 ) ),
                                       ( EvtGammaMatrix::g5() * parent->sp( 0 ) ),
                                       p4b, p4daught, form_fact, pflag );
             b21 = EvtBaryonVACurrent( ( parent->getDaug( 0 )->spParent( 0 ) ),
                                       ( EvtGammaMatrix::g5() * parent->sp( 1 ) ),
                                       p4b, p4daught, form_fact, pflag );
             b12 = EvtBaryonVACurrent( ( parent->getDaug( 0 )->spParent( 1 ) ),
                                       ( EvtGammaMatrix::g5() * parent->sp( 0 ) ),
                                       p4b, p4daught, form_fact, pflag );
             b22 = EvtBaryonVACurrent( ( parent->getDaug( 0 )->spParent( 1 ) ),
                                       ( EvtGammaMatrix::g5() * parent->sp( 1 ) ),
                                       p4b, p4daught, form_fact, pflag );
 
         }
 
         else {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << "Dirac semilep. baryon current "
                 << "not implemented for this decay sequence." << std::endl;
             ::abort();
         }
 
         amp.vertex( 0, 0, 0, l1 * b11 );
         amp.vertex( 0, 0, 1, l2 * b11 );
 
         amp.vertex( 1, 0, 0, l1 * b21 );
         amp.vertex( 1, 0, 1, l2 * b21 );
 
         amp.vertex( 0, 1, 0, l1 * b12 );
         amp.vertex( 0, 1, 1, l2 * b12 );
 
         amp.vertex( 1, 1, 0, l1 * b22 );
         amp.vertex( 1, 1, 1, l2 * b22 );
 
     }
 
     // Need special handling for the spin-3/2 daughter baryon
     // Rarita-Schwinger spinor cases
     else if ( EvtPDL::getSpinType( parent->getDaug( 0 )->getId() ) ==
               EvtSpinType::RARITASCHWINGER ) {
         // Set the form factors
         double f1, f2, f3, f4, g1, g2, g3, g4;
         FormFactors->getraritaff( par_num, bar_num, q2, baryonmass, &f1, &f2,
                                   &f3, &f4, &g1, &g2, &g3, &g4 );
 
         const double form_fact[8] = {f1, f2, f3, f4, g1, g2, g3, g4};
 
         EvtId l_num = parent->getDaug( 1 )->getId();
 
         EvtVector4C b11, b12, b21, b22, b13, b23, b14, b24, l1, l2;
 
         //  Lepton Current
         if ( l_num == EM || l_num == MUM || l_num == TAUM ) {
             //  Lepton Current
             l1 = EvtLeptonVACurrent( parent->getDaug( 1 )->spParent( 0 ),
                                      parent->getDaug( 2 )->spParentNeutrino() );
             l2 = EvtLeptonVACurrent( parent->getDaug( 1 )->spParent( 1 ),
                                      parent->getDaug( 2 )->spParentNeutrino() );
         } else if ( l_num == EP || l_num == MUP || l_num == TAUP ) {
             l1 = EvtLeptonVACurrent( parent->getDaug( 2 )->spParentNeutrino(),
                                      parent->getDaug( 1 )->spParent( 0 ) );
             l2 = EvtLeptonVACurrent( parent->getDaug( 2 )->spParentNeutrino(),
                                      parent->getDaug( 1 )->spParent( 1 ) );
 
         } else {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" ) << "Wrong lepton number \n";
         }
 
         //  Baryon Current
         // Declare particle, anti-particle flag, same/opp. parity
         // pflag = 0 => particle
         // pflag = 1 => anti-particle
         int pflag = 0;
 
         // Handle cases of 1/2+ -> 3/2-
         if ( par_num == LAMB && bar_num == LAMC2P ) {
             // Set flag for particle case
             pflag = 0;
         } else if ( par_num == LAMBB && bar_num == LAMC2M ) {
             // Set flag for anti-particle case
             pflag = 1;
         } else {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << "Rarita-Schwinger semilep. baryon current "
                 << "not implemented for this decay sequence." << std::endl;
             ::abort();
         }
 
         // Baryon current
         b11 = EvtBaryonVARaritaCurrent( parent->getDaug( 0 )->spRSParent( 0 ),
                                         parent->sp( 0 ), p4b, p4daught,
                                         form_fact, pflag );
         b21 = EvtBaryonVARaritaCurrent( parent->getDaug( 0 )->spRSParent( 0 ),
                                         parent->sp( 1 ), p4b, p4daught,
                                         form_fact, pflag );
 
         b12 = EvtBaryonVARaritaCurrent( parent->getDaug( 0 )->spRSParent( 1 ),
                                         parent->sp( 0 ), p4b, p4daught,
                                         form_fact, pflag );
         b22 = EvtBaryonVARaritaCurrent( parent->getDaug( 0 )->spRSParent( 1 ),
                                         parent->sp( 1 ), p4b, p4daught,
                                         form_fact, pflag );
 
         b13 = EvtBaryonVARaritaCurrent( parent->getDaug( 0 )->spRSParent( 2 ),
                                         parent->sp( 0 ), p4b, p4daught,
                                         form_fact, pflag );
         b23 = EvtBaryonVARaritaCurrent( parent->getDaug( 0 )->spRSParent( 2 ),
                                         parent->sp( 1 ), p4b, p4daught,
                                         form_fact, pflag );
 
         b14 = EvtBaryonVARaritaCurrent( parent->getDaug( 0 )->spRSParent( 3 ),
                                         parent->sp( 0 ), p4b, p4daught,
                                         form_fact, pflag );
         b24 = EvtBaryonVARaritaCurrent( parent->getDaug( 0 )->spRSParent( 3 ),
                                         parent->sp( 1 ), p4b, p4daught,
                                         form_fact, pflag );
 
         amp.vertex( 0, 0, 0, l1 * b11 );
         amp.vertex( 0, 0, 1, l2 * b11 );
 
         amp.vertex( 1, 0, 0, l1 * b21 );
         amp.vertex( 1, 0, 1, l2 * b21 );
 
         amp.vertex( 0, 1, 0, l1 * b12 );
         amp.vertex( 0, 1, 1, l2 * b12 );
 
         amp.vertex( 1, 1, 0, l1 * b22 );
         amp.vertex( 1, 1, 1, l2 * b22 );
 
         amp.vertex( 0, 2, 0, l1 * b13 );
         amp.vertex( 0, 2, 1, l2 * b13 );
 
         amp.vertex( 1, 2, 0, l1 * b23 );
         amp.vertex( 1, 2, 1, l2 * b23 );
 
         amp.vertex( 0, 3, 0, l1 * b14 );
         amp.vertex( 0, 3, 1, l2 * b14 );
 
         amp.vertex( 1, 3, 0, l1 * b24 );
         amp.vertex( 1, 3, 1, l2 * b24 );
     }
 }
 
 EvtVector4C EvtSemiLeptonicBaryonAmp::EvtBaryonVACurrent(
     const EvtDiracSpinor& Bf, const EvtDiracSpinor& Bi, EvtVector4R parent,
     EvtVector4R daught, const double* ff, int pflag )
 {
     // flag == 0 => particle, same parity
     // flag == 1 => particle, opposite parity
     // flag == 2 => anti-particle, same parity
     // flag == 3 => anti-particle, opposite parity
 
     // particle
     EvtComplex cv = EvtComplex( 1.0, 0. );
     EvtComplex ca = EvtComplex( 1.0, 0. );
 
     EvtComplex cg0 = EvtComplex( 1.0, 0. );
     EvtComplex cg5 = EvtComplex( 1.0, 0. );
 
     // antiparticle- same parity parent & daughter
     if ( pflag == 2 ) {
         cv = EvtComplex( -1.0, 0. );
         ca = EvtComplex( 1.0, 0. );
 
         cg0 = EvtComplex( 1.0, 0.0 );
         cg5 = EvtComplex( 0.0, -1.0 );
     }
     // antiparticle- opposite parity parent & daughter
     else if ( pflag == 3 ) {
         cv = EvtComplex( 1.0, 0. );
         ca = EvtComplex( -1.0, 0. );
 
         cg0 = EvtComplex( 0.0, -1.0 );
         cg5 = EvtComplex( 1.0, 0.0 );
     }
 
     EvtVector4C t[6];
 
     // Term 1 = \bar{u}(p',s')*(F_1(q^2)*\gamma_{mu})*u(p,s)
     t[0] = cv * EvtLeptonVCurrent( Bf, Bi );
 
     // Term 2 = \bar{u}(p',s')*(F_2(q^2)*(p_{mu}/m_{\Lambda_Q}))*u(p,s)
     t[1] = cg0 * EvtLeptonSCurrent( Bf, Bi ) * ( parent / parent.mass() );
 
     // Term 3 = \bar{u}(p',s')*(F_3(q^2)*(p'_{mu}/m_{\Lambda_q}))*u(p,s)
     t[2] = cg0 * EvtLeptonSCurrent( Bf, Bi ) * ( daught / daught.mass() );
 
     // Term 4 = \bar{u}(p',s')*(G_1(q^2)*\gamma_{mu}*\gamma_5)*u(p,s)
     t[3] = ca * EvtLeptonACurrent( Bf, Bi );
 
     // Term 5 =  \bar{u}(p',s')*(G_2(q^2)*(p_{mu}/m_{\Lambda_Q})*\gamma_5)*u(p,s)
     t[4] = cg5 * EvtLeptonPCurrent( Bf, Bi ) * ( parent / parent.mass() );
 
     // Term 6 = \bar{u}(p',s')*(G_3(q^2)*(p'_{mu}/m_{\Lambda_q})*\gamma_5)*u(p,s)
     t[5] = cg5 * EvtLeptonPCurrent( Bf, Bi ) * ( daught / daught.mass() );
 
     // Sum the individual terms
     EvtVector4C current = ( ff[0] * t[0] + ff[1] * t[1] + ff[2] * t[2] -
                             ff[3] * t[3] - ff[4] * t[4] - ff[5] * t[5] );
 
     return current;
 }
 
 EvtVector4C EvtSemiLeptonicBaryonAmp::EvtBaryonVARaritaCurrent(
     const EvtRaritaSchwinger& Bf, const EvtDiracSpinor& Bi, EvtVector4R parent,
     EvtVector4R daught, const double* ff, int pflag )
 {
     // flag == 0 => particle
     // flag == 1 => anti-particle
 
     // particle
     EvtComplex cv = EvtComplex( 1.0, 0. );
     EvtComplex ca = EvtComplex( 1.0, 0. );
 
     EvtComplex cg0 = EvtComplex( 1.0, 0. );
     EvtComplex cg5 = EvtComplex( 1.0, 0. );
 
     // antiparticle
     if ( pflag == 1 ) {
         cv = EvtComplex( -1.0, 0. );
         ca = EvtComplex( 1.0, 0. );
 
         cg0 = EvtComplex( 1.0, 0.0 );
         cg5 = EvtComplex( 0.0, -1.0 );
     }
 
     EvtVector4C t[8];
     EvtTensor4C id;
     id.setdiag( 1.0, 1.0, 1.0, 1.0 );
 
     EvtDiracSpinor tmp;
     for ( int i = 0; i < 4; i++ ) {
         tmp.set_spinor( i, Bf.getVector( i ) * parent );
     }
 
     EvtVector4C v1, v2;
     for ( int i = 0; i < 4; i++ ) {
         v1.set( i, EvtLeptonSCurrent( Bf.getSpinor( i ), Bi ) );
         v2.set( i, EvtLeptonPCurrent( Bf.getSpinor( i ), Bi ) );
     }
 
     // Term 1 = \bar{u}^{\alpha}(p',s')*(p_{\alpha}/m_{\Lambda_Q})*(F_1(q^2)*\gamma_{mu})*u(p,s)
     t[0] = ( cv / parent.mass() ) * EvtLeptonVCurrent( tmp, Bi );
 
     // Term 2
     // = \bar{u}^{\alpha}(p',s')*(p_{\alpha}/m_{\Lambda_Q})*(F_2(q^2)*(p_{mu}/m_{\Lambda_Q}))*u(p,s)
     t[1] = ( ( cg0 / parent.mass() ) * EvtLeptonSCurrent( tmp, Bi ) ) *
            ( parent / parent.mass() );
 
     // Term 3
     // = \bar{u}^{\alpha}(p',s')*(p_{\alpha}/m_{\Lambda_Q})*(F_3(q^2)*(p'_{mu}/m_{\Lambda_q}))*u(p,s)
     t[2] = ( ( cg0 / parent.mass() ) * EvtLeptonSCurrent( tmp, Bi ) ) *
            ( daught / daught.mass() );
 
     // Term 4 = \bar{u}^{\alpha}(p',s')*(F_4(q^2)*g_{\alpha,\mu})*u(p,s)
     t[3] = cg0 * ( id.cont2( v1 ) );
 
     // Term 5
     // = \bar{u}^{\alpha}(p',s')*(p_{\alpha}/m_{\Lambda_Q})*(G_1(q^2)*\gamma_{mu}*\gamma_5)*u(p,s)
     t[4] = ( ca / parent.mass() ) * EvtLeptonACurrent( tmp, Bi );
 
     // Term 6
     // = \bar{u}^{\alpha}(p',s')*(p_{\alpha}/m_{\Lambda_Q})
     //      *(G_2(q^2)*(p_{mu}/m_{\Lambda_Q})*\gamma_5)*u(p,s)
     t[5] = ( ( cg5 / parent.mass() ) * EvtLeptonPCurrent( tmp, Bi ) ) *
            ( parent / parent.mass() );
 
     // Term 7
     // = \bar{u}^{\alpha}(p',s')*(p_{\alpha}/m_{\Lambda_Q})
     //      *(G_3(q^2)*(p'_{mu}/m_{\Lambda_q})*\gamma_5)*u(p,s)
     t[6] = ( ( cg5 / parent.mass() ) * EvtLeptonPCurrent( tmp, Bi ) ) *
            ( daught / daught.mass() );
 
     // Term 8 = \bar{u}^{\alpha}(p',s')*(G_4(q^2)*g_{\alpha,\mu}*\gamma_5))*u(p,s)
     t[7] = cg5 * ( id.cont2( v2 ) );
 
     // Sum the individual terms
     EvtVector4C current = ( ff[0] * t[0] + ff[1] * t[1] + ff[2] * t[2] +
                             ff[3] * t[3] - ff[4] * t[4] - ff[5] * t[5] -
                             ff[6] * t[6] - ff[7] * t[7] );
 
     return current;
 }
diff --git a/src/EvtGenModels/EvtBTo4piCP.cpp b/src/EvtGenModels/EvtBTo4piCP.cpp
index 46d9310..1bb6819 100644
--- a/src/EvtGenModels/EvtBTo4piCP.cpp
+++ b/src/EvtGenModels/EvtBTo4piCP.cpp
@@ -1,261 +1,266 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtBTo4piCP.hh"
 
 #include "EvtGenBase/EvtCPUtil.hh"
 #include "EvtGenBase/EvtConst.hh"
 #include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtId.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtReport.hh"
 #include "EvtGenBase/EvtVector4R.hh"
 
 #include <stdlib.h>
 #include <string>
 
 EvtComplex EvtAmpA2( const EvtVector4R& p4pi1, const EvtVector4R& p4pi2,
                      const EvtVector4R& p4pi3, const EvtVector4R& p4pi4 )
 {
     //added by Lange Jan4,2000
     static EvtId A2M = EvtPDL::getId( "a_2-" );
     static EvtId RHO0 = EvtPDL::getId( "rho0" );
 
     EvtVector4R p4a2, p4rho, p4b;
 
     p4rho = p4pi1 + p4pi2;
 
     p4a2 = p4rho + p4pi3;
 
     p4b = p4a2 + p4pi4;
 
     EvtVector4R p4b_a2, p4rho_a2, p4pi1_a2, p4a2_a2;
 
     p4b_a2 = boostTo( p4b, p4a2 );
     p4rho_a2 = boostTo( p4rho, p4a2 );
     p4pi1_a2 = boostTo( p4pi1, p4a2 );
     p4a2_a2 = boostTo( p4a2, p4a2 );
 
     EvtVector4R p4pi1_rho;
 
     p4pi1_rho = boostTo( p4pi1_a2, p4rho_a2 );
 
     EvtVector4R vb, vrho, vpi, t;
 
     vb = p4b_a2 / p4b_a2.d3mag();
     vrho = p4rho_a2 / p4rho_a2.d3mag();
     vpi = p4pi1_rho / p4pi1_rho.d3mag();
 
     t.set( 1.0, 0.0, 0.0, 0.0 );
 
     //  EvtComplex amp_a1,amp_a2;
     EvtComplex amp_a2;
 
     //  double bwm_a1=EvtPDL::getMeanMass(A1M);
     //  double gamma_a1=EvtPDL::getWidth(A1M);
     double bwm_a2 = EvtPDL::getMeanMass( A2M );
     double gamma_a2 = EvtPDL::getWidth( A2M );
     double bwm_rho = EvtPDL::getMeanMass( RHO0 );
     double gamma_rho = EvtPDL::getWidth( RHO0 );
 
     amp_a2 =
         ( sqrt( gamma_a2 / EvtConst::twoPi ) /
           ( ( p4a2 ).mass() - bwm_a2 - EvtComplex( 0.0, 0.5 * gamma_a2 ) ) ) *
         ( sqrt( gamma_rho / EvtConst::twoPi ) /
           ( ( p4rho ).mass() - bwm_rho - EvtComplex( 0.0, 0.5 * gamma_rho ) ) );
 
     return amp_a2 *
            ( vb.get( 1 ) * vrho.get( 1 ) + vb.get( 2 ) * vrho.get( 2 ) +
              vb.get( 3 ) * vrho.get( 3 ) ) *
            ( vpi.get( 1 ) *
                  ( vb.get( 2 ) * vrho.get( 3 ) - vb.get( 3 ) * vrho.get( 2 ) ) +
              vpi.get( 2 ) *
                  ( vb.get( 3 ) * vrho.get( 1 ) - vb.get( 1 ) * vrho.get( 3 ) ) +
              vpi.get( 3 ) *
                  ( vb.get( 1 ) * vrho.get( 2 ) - vb.get( 2 ) * vrho.get( 1 ) ) );
 }
 
 EvtComplex EvtAmpA1( const EvtVector4R& p4pi1, const EvtVector4R& p4pi2,
                      const EvtVector4R& p4pi3, const EvtVector4R& p4pi4 )
 {
     //added by Lange Jan4,2000
     static EvtId A1M = EvtPDL::getId( "a_1-" );
     static EvtId RHO0 = EvtPDL::getId( "rho0" );
 
     EvtVector4R p4a1, p4rho, p4b;
 
     p4rho = p4pi1 + p4pi2;
 
     p4a1 = p4rho + p4pi3;
 
     p4b = p4a1 + p4pi4;
 
     EvtVector4R p4b_a1, p4rho_a1, p4pi1_a1, p4a1_a1;
 
     p4b_a1 = boostTo( p4b, p4a1 );
     p4rho_a1 = boostTo( p4rho, p4a1 );
     p4pi1_a1 = boostTo( p4pi1, p4a1 );
     p4a1_a1 = boostTo( p4a1, p4a1 );
 
     EvtVector4R p4pi1_rho;
 
     p4pi1_rho = boostTo( p4pi1_a1, p4rho_a1 );
 
     EvtVector4R vb, vrho, vpi, t;
 
     vb = p4b_a1 / p4b_a1.d3mag();
     vrho = p4rho_a1 / p4rho_a1.d3mag();
     vpi = p4pi1_rho / p4pi1_rho.d3mag();
 
     t.set( 1.0, 0.0, 0.0, 0.0 );
 
     EvtComplex amp_a1;
 
     double bwm_a1 = EvtPDL::getMeanMass( A1M );
     double gamma_a1 = EvtPDL::getWidth( A1M );
     //  double bwm_a2=EvtPDL::getMeanMass(A2M);
     //  double gamma_a2=EvtPDL::getWidth(A2M);
     double bwm_rho = EvtPDL::getMeanMass( RHO0 );
     double gamma_rho = EvtPDL::getWidth( RHO0 );
 
     amp_a1 =
         ( sqrt( gamma_a1 / EvtConst::twoPi ) /
           ( ( p4a1 ).mass() - bwm_a1 - EvtComplex( 0.0, 0.5 * gamma_a1 ) ) ) *
         ( sqrt( gamma_rho / EvtConst::twoPi ) /
           ( ( p4rho ).mass() - bwm_rho - EvtComplex( 0.0, 0.5 * gamma_rho ) ) );
 
     return amp_a1 * ( vb.get( 1 ) * vpi.get( 1 ) + vb.get( 2 ) * vpi.get( 2 ) +
                       vb.get( 3 ) * vpi.get( 3 ) );
 }
 
 std::string EvtBTo4piCP::getName()
 {
     return "BTO4PI_CP";
 }
 
 EvtBTo4piCP* EvtBTo4piCP::clone()
 {
     return new EvtBTo4piCP;
 }
 
+void EvtBTo4piCP::initProbMax()
+{
+    setProbMax( 50.0 );
+}
+
 void EvtBTo4piCP::init()
 {
     // check that there are 18 arguments
     checkNArg( 18 );
     checkNDaug( 4 );
 
     checkSpinParent( EvtSpinType::SCALAR );
 
     checkSpinDaughter( 0, EvtSpinType::SCALAR );
     checkSpinDaughter( 1, EvtSpinType::SCALAR );
     checkSpinDaughter( 2, EvtSpinType::SCALAR );
     checkSpinDaughter( 3, EvtSpinType::SCALAR );
 }
 
 void EvtBTo4piCP::decay( EvtParticle* p )
 {
     //added by Lange Jan4,2000
     static EvtId B0 = EvtPDL::getId( "B0" );
     static EvtId B0B = EvtPDL::getId( "anti-B0" );
 
     double t;
     EvtId other_b;
 
     EvtCPUtil::getInstance()->OtherB( p, t, other_b, 0.5 );
 
     p->initializePhaseSpace( getNDaug(), getDaugs() );
     EvtVector4R mom1 = p->getDaug( 0 )->getP4();
     EvtVector4R mom2 = p->getDaug( 1 )->getP4();
     EvtVector4R mom3 = p->getDaug( 2 )->getP4();
     EvtVector4R mom4 = p->getDaug( 3 )->getP4();
 
     //  double alpha=getArg(0);
     //double dm=getArg(1);
 
     EvtComplex amp;
 
     EvtComplex A, Abar;
 
     EvtComplex A_a1p, Abar_a1p, A_a2p, Abar_a2p;
     EvtComplex A_a1m, Abar_a1m, A_a2m, Abar_a2m;
 
     A_a1p = EvtComplex( getArg( 2 ) * cos( getArg( 3 ) ),
                         getArg( 2 ) * sin( getArg( 3 ) ) );
     Abar_a1p = EvtComplex( getArg( 4 ) * cos( getArg( 5 ) ),
                            getArg( 4 ) * sin( getArg( 5 ) ) );
 
     A_a2p = EvtComplex( getArg( 6 ) * cos( getArg( 7 ) ),
                         getArg( 6 ) * sin( getArg( 7 ) ) );
     Abar_a2p = EvtComplex( getArg( 8 ) * cos( getArg( 9 ) ),
                            getArg( 8 ) * sin( getArg( 9 ) ) );
 
     A_a1m = EvtComplex( getArg( 10 ) * cos( getArg( 11 ) ),
                         getArg( 10 ) * sin( getArg( 11 ) ) );
     Abar_a1m = EvtComplex( getArg( 12 ) * cos( getArg( 13 ) ),
                            getArg( 12 ) * sin( getArg( 13 ) ) );
 
     A_a2m = EvtComplex( getArg( 14 ) * cos( getArg( 15 ) ),
                         getArg( 14 ) * sin( getArg( 15 ) ) );
     Abar_a2m = EvtComplex( getArg( 16 ) * cos( getArg( 17 ) ),
                            getArg( 16 ) * sin( getArg( 17 ) ) );
 
     EvtComplex a2p_amp = EvtAmpA2( mom1, mom2, mom3, mom4 ) +
                          EvtAmpA2( mom1, mom4, mom3, mom2 ) +
                          EvtAmpA2( mom3, mom2, mom1, mom4 ) +
                          EvtAmpA2( mom3, mom4, mom1, mom2 );
 
     EvtComplex a2m_amp = EvtAmpA2( mom2, mom3, mom4, mom1 ) +
                          EvtAmpA2( mom2, mom1, mom4, mom3 ) +
                          EvtAmpA2( mom4, mom3, mom2, mom1 ) +
                          EvtAmpA2( mom4, mom1, mom2, mom3 );
 
     EvtComplex a1p_amp = EvtAmpA1( mom1, mom2, mom3, mom4 ) +
                          EvtAmpA1( mom1, mom4, mom3, mom2 ) +
                          EvtAmpA1( mom3, mom2, mom1, mom4 ) +
                          EvtAmpA1( mom3, mom4, mom1, mom2 );
 
     EvtComplex a1m_amp = EvtAmpA1( mom2, mom3, mom4, mom1 ) +
                          EvtAmpA1( mom2, mom1, mom4, mom3 ) +
                          EvtAmpA1( mom4, mom3, mom2, mom1 ) +
                          EvtAmpA1( mom4, mom1, mom2, mom3 );
 
     A = A_a2p * a2p_amp + A_a1p * a1p_amp + A_a2m * a2m_amp + A_a1m * a1m_amp;
     Abar = Abar_a2p * a2p_amp + Abar_a1p * a1p_amp + Abar_a2m * a2m_amp +
            Abar_a1m * a1m_amp;
 
     if ( other_b == B0B ) {
         amp = A * cos( getArg( 1 ) * t / ( 2 * EvtConst::c ) ) +
               EvtComplex( cos( -2.0 * getArg( 0 ) ), sin( -2.0 * getArg( 0 ) ) ) *
                   getArg( 2 ) * EvtComplex( 0.0, 1.0 ) * Abar *
                   sin( getArg( 1 ) * t / ( 2 * EvtConst::c ) );
     }
     if ( other_b == B0 ) {
         amp = A * EvtComplex( cos( 2.0 * getArg( 0 ) ), sin( 2.0 * getArg( 0 ) ) ) *
                   EvtComplex( 0.0, 1.0 ) *
                   sin( getArg( 1 ) * t / ( 2 * EvtConst::c ) ) +
               getArg( 2 ) * Abar * cos( getArg( 1 ) * t / ( 2 * EvtConst::c ) );
     }
 
     vertex( amp );
 
     return;
 }
diff --git a/src/EvtGenModels/EvtBToKpipiCP.cpp b/src/EvtGenModels/EvtBToKpipiCP.cpp
index d4b961d..c9c7bbe 100644
--- a/src/EvtGenModels/EvtBToKpipiCP.cpp
+++ b/src/EvtGenModels/EvtBToKpipiCP.cpp
@@ -1,125 +1,130 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtBToKpipiCP.hh"
 
 #include "EvtGenBase/EvtCPUtil.hh"
 #include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtId.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtReport.hh"
 #include "EvtGenBase/EvtVector4R.hh"
 
 #include <stdlib.h>
 #include <string>
 
 std::string EvtBToKpipiCP::getName()
 {
     return "BTOKPIPI_CP";
 }
 
 EvtBToKpipiCP* EvtBToKpipiCP::clone()
 {
     return new EvtBToKpipiCP;
 }
 
 void EvtBToKpipiCP::init()
 {
     // check that there are 3 arguments
     checkNArg( 3 );
     checkNDaug( 3 );
 
     checkSpinParent( EvtSpinType::SCALAR );
 
     checkSpinDaughter( 0, EvtSpinType::SCALAR );
     checkSpinDaughter( 1, EvtSpinType::SCALAR );
     checkSpinDaughter( 2, EvtSpinType::SCALAR );
 
     double alpha = getArg( 1 );
     double beta = getArg( 2 );
     int iset;
     iset = 10000;
 
     EvtVector4R p4Kplus, p4piminus, p4gamm1, p4gamm2;
 
     double realA, imgA, realbarA, imgbarA;
 
     generator.EvtKpipi( alpha, beta, iset, p4Kplus, p4piminus, p4gamm1, p4gamm2,
                         realA, imgA, realbarA, imgbarA );
 }
 
+void EvtBToKpipiCP::initProbMax()
+{
+    setProbMax( 1.2 );
+}
+
 void EvtBToKpipiCP::decay( EvtParticle* p )
 {
     //added by Lange Jan4,2000
     static EvtId B0 = EvtPDL::getId( "B0" );
     static EvtId B0B = EvtPDL::getId( "anti-B0" );
 
     double t;
     EvtId other_b;
 
     EvtCPUtil::getInstance()->OtherB( p, t, other_b, 0.5 );
 
     EvtParticle *Kp, *pim, *pi0;
 
     p->makeDaughters( getNDaug(), getDaugs() );
     Kp = p->getDaug( 0 );
     pim = p->getDaug( 1 );
     pi0 = p->getDaug( 2 );
 
     EvtVector4R p4[3];
 
     //double dm=getArg(0);
     double alpha = getArg( 1 );
     double beta = getArg( 2 );
     int iset;
 
     iset = 0;
 
     EvtVector4R p4Kplus, p4piminus, p4gamm1, p4gamm2;
 
     double realA, imgA, realbarA, imgbarA;
 
     generator.EvtKpipi( alpha, beta, iset, p4[0], p4[1], p4gamm1, p4gamm2,
                         realA, imgA, realbarA, imgbarA );
 
     p4[2] = p4gamm1 + p4gamm2;
 
     Kp->init( getDaug( 0 ), p4[0] );
     pim->init( getDaug( 1 ), p4[1] );
     pi0->init( getDaug( 2 ), p4[2] );
 
     EvtComplex amp;
 
     EvtComplex A( realA, imgA );
     EvtComplex Abar( realbarA, imgbarA );
 
     if ( other_b == B0B ) {
         amp = Abar;
     }
     if ( other_b == B0 ) {
         amp = A;
     }
 
     vertex( amp );
 
     return;
 }
diff --git a/src/EvtGenModels/EvtBsquark.cpp b/src/EvtGenModels/EvtBsquark.cpp
index 46c5530..65c61a9 100644
--- a/src/EvtGenModels/EvtBsquark.cpp
+++ b/src/EvtGenModels/EvtBsquark.cpp
@@ -1,206 +1,204 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtBsquark.hh"
 
 #include "EvtGenBase/EvtDiracParticle.hh"
 #include "EvtGenBase/EvtDiracSpinor.hh"
 #include "EvtGenBase/EvtGammaMatrix.hh"
 #include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtIdSet.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtReport.hh"
 
 #include <iostream>
 #include <string>
 
 std::string EvtBsquark::getName()
 {
     return "BSQUARK";
 }
 
 EvtDecayBase* EvtBsquark::clone()
 {
     return new EvtBsquark;
 }
 
 void EvtBsquark::init()
 {
     // check that there are 5 arguments
     checkNArg( 5 );
 }
 
 void EvtBsquark::initProbMax()
 {
-    //For now do not set a maximum.
-
-    //SetProbMax(0.000000000005);
+    setProbMax( 1e-6 );
 }
 
 void EvtBsquark::decay( EvtParticle* p )
 {
     static EvtId cquark = EvtPDL::getId( "c" );
     static EvtId anticquark = EvtPDL::getId( "anti-c" );
 
     static EvtIdSet leptons( "e-", "mu-", "tau-" );
 
     p->initializePhaseSpace( getNDaug(), getDaugs() );
 
     int charge = 1;
 
     EvtParticle* lepton;
     lepton = p->getDaug( 1 );
     if ( leptons.contains( lepton->getId() ) ) {
         charge = -1;
     }
 
     EvtDiracParticle charmquark;
 
     //this is a very crude approximation...
     if ( charge == -1 ) {
         charmquark.init( cquark, p->getDaug( 0 )->getP4() );
     } else {
         charmquark.init( anticquark, p->getDaug( 0 )->getP4() );
     }
 
     EvtVector4R p4c = p->getDaug( 0 )->getP4();
 
     EvtVector4R p4sn = p->getDaug( 2 )->getP4();
 
     EvtVector4R p4b( p->mass(), 0.0, 0.0, 0.0 );
 
     EvtComplex M[2][2];
 
     int il, ic;
 
     //project out the right handed current
     EvtGammaMatrix PR = 0.5 * ( EvtGammaMatrix::id() + EvtGammaMatrix::g5() );
 
     double tanbeta = getArg( 1 );
     double cosbeta = cos( atan( tanbeta ) );
     double sinbeta = sin( atan( tanbeta ) );
 
     double mb = 4.9;
     double mc = 1.3;
     double mw = 80.4;
 
     double Mass = getArg( 2 );
     double mu = getArg( 3 );
     double mchargino = getArg( 4 );
 
     double tan2phim = 2 * sqrt( 2.0 ) * mw * ( mu * cosbeta + Mass * sinbeta ) /
                       ( Mass * Mass - mu * mu +
                         2 * mw * mw * cos( 2 * atan( tanbeta ) ) );
 
     double phim = 0.5 * atan( tan2phim );
 
     EvtComplex U11 = cos( phim );
     EvtComplex U12 = sin( phim );
     EvtComplex U21 = -sin( phim );
     EvtComplex U22 = cos( phim );
 
     double tan2phip = 2 * sqrt( 2.0 ) * mw * ( mu * cosbeta + Mass * sinbeta ) /
                       ( Mass * Mass - mu * mu -
                         2 * mw * mw * cos( 2 * atan( tanbeta ) ) );
 
     double phip = 0.5 * atan( tan2phip );
 
     EvtComplex V11 = cos( phip );
     EvtComplex V12 = sin( phip );
     EvtComplex V21 = -sin( phip );
     EvtComplex V22 = cos( phip );
 
     double theta = getArg( 0 );
     double ctheta = cos( theta );
     double stheta = sin( theta );
 
     double vcsb = 0.08;
     double mchi1 = mchargino;
     double mchi2 = mchargino;
 
     //overall scale factor
     double g = 1.0;
 
     EvtComplex a1 = mchi1 * ( U11 * ctheta - mb * U12 * stheta /
                                                  ( sqrt( 2.0 ) * mw * cosbeta ) );
     EvtComplex a2 = mchi2 * ( U21 * ctheta - mb * U22 * stheta /
                                                  ( sqrt( 2.0 ) * mw * cosbeta ) );
 
     EvtComplex b1 = mc * conj( V12 ) * ctheta / ( sqrt( 2.0 ) * mw * sinbeta );
     EvtComplex b2 = mc * conj( V22 ) * ctheta / ( sqrt( 2.0 ) * mw * sinbeta );
 
     EvtComplex f1 = -( g * g * V11 * vcsb ) /
                     ( ( p4b - p4c ).mass2() - mchi1 * mchi1 );
     EvtComplex f2 = -( g * g * V21 * vcsb ) /
                     ( ( p4b - p4c ).mass2() - mchi1 * mchi2 );
 
     //EvtGenReport(EVTGEN_INFO,"EvtGen") <<g<<" "<<V11<<" "<<FL<<" "<<vcsb<<" "<<mchi1<<endl;
     //EvtGenReport(EVTGEN_INFO,"EvtGen") << "f1:"<<f1<<" "<<(p4b-p4c).mass2()<<endl;
     //EvtGenReport(EVTGEN_INFO,"EvtGen") << "f2:"<<f2<<" "<<(p4b-p4c).mass2()<<endl;
 
     //EvtGenReport(EVTGEN_INFO,"EvtGen") << "p4sn:"<<p4sn<<endl;
 
     EvtGammaMatrix pslash = p4sn.get( 0 ) * EvtGammaMatrix::g0() -
                             p4sn.get( 1 ) * EvtGammaMatrix::g1() -
                             p4sn.get( 2 ) * EvtGammaMatrix::g2() -
                             p4sn.get( 3 ) * EvtGammaMatrix::g3();
 
     //EvtGenReport(EVTGEN_INFO,"EvtGen") << "pslash:"<<pslash<<endl;
 
     for ( il = 0; il < 2; il++ ) {
         for ( ic = 0; ic < 2; ic++ ) {
             EvtComplex a = 0.0;
             EvtComplex b = 0.0;
 
             if ( charge == -1 ) {
                 a = charmquark.spParent( ic ) * ( PR * lepton->spParent( il ) );
                 b = charmquark.spParent( ic ) *
                     ( ( pslash * PR ) * lepton->spParent( il ) );
             } else {
                 a = lepton->spParent( il ) * ( PR * charmquark.spParent( ic ) );
                 b = lepton->spParent( il ) *
                     ( ( pslash * PR ) * charmquark.spParent( ic ) );
             }
 
             //EvtGenReport(EVTGEN_INFO,"EvtGen") <<"pslash*PR:"<<pslash*PR<<endl;
             //EvtGenReport(EVTGEN_INFO,"EvtGen") <<"sp charm:"<<charmquark.spParent(ic)<<endl;
             //EvtGenReport(EVTGEN_INFO,"EvtGen") <<"sp lepton:"<<lepton->spParent(il)<<endl;
 
             M[ic][il] = f1 * ( a1 * a + b1 * b ) + f2 * ( a2 * a + b2 * b );
 
             //EvtGenReport(EVTGEN_INFO,"EvtGen") << "Contr1:"<<a1<<" "<<a<<" "<<b1<<" "<<b<<endl;
             //EvtGenReport(EVTGEN_INFO,"EvtGen") << "Contr2:"<<a2<<" "<<a<<" "<<b2<<" "<<b<<endl;
 
             //EvtGenReport(EVTGEN_INFO,"EvtGen") <<"case1:"<<f1<<" "<<a1<<" "<<b1<<" "<<a<<" "<<b<<endl;
             //EvtGenReport(EVTGEN_INFO,"EvtGen") <<"case2:"<<f2<<" "<<a2<<" "<<b2<<" "<<a<<" "<<b<<endl;
         }
     }
 
     double prob = real( M[0][0] * conj( M[0][0] ) + M[1][0] * conj( M[1][0] ) +
                         M[0][1] * conj( M[0][1] ) + M[1][1] * conj( M[1][1] ) );
 
     //EvtGenReport(EVTGEN_INFO,"EvtGen") <<"prob:"<<prob<<endl;
 
     setProb( prob );
 
     return;
 }
diff --git a/src/EvtGenModels/EvtBtoKD3P.cpp b/src/EvtGenModels/EvtBtoKD3P.cpp
index 1c4b624..2c42907 100644
--- a/src/EvtGenModels/EvtBtoKD3P.cpp
+++ b/src/EvtGenModels/EvtBtoKD3P.cpp
@@ -1,222 +1,228 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtBtoKD3P.hh"
 
 #include "EvtGenBase/EvtCyclic3.hh"
 #include "EvtGenBase/EvtDalitzPoint.hh"
 #include "EvtGenBase/EvtDecayTable.hh"
 #include "EvtGenBase/EvtId.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtRandom.hh"
 #include "EvtGenBase/EvtReport.hh"
 
 #include "EvtGenModels/EvtPto3P.hh"
 
 #include <assert.h>
 using std::endl;
 
 //------------------------------------------------------------------
 EvtDecayBase* EvtBtoKD3P::clone()
 {
     return new EvtBtoKD3P();
 }
 
 //------------------------------------------------------------------
 std::string EvtBtoKD3P::getName()
 {
     return "BTOKD3P";
 }
 
 //------------------------------------------------------------------
 void EvtBtoKD3P::init()
 {
     checkNArg( 2 );     // r, phase
     checkNDaug( 3 );    // K, D0(allowed), D0(suppressed).
                         // The last two daughters are really one particle
 
     // check that the mother and all daughters are scalars:
     checkSpinParent( EvtSpinType::SCALAR );
     checkSpinDaughter( 0, EvtSpinType::SCALAR );
     checkSpinDaughter( 1, EvtSpinType::SCALAR );
     checkSpinDaughter( 2, EvtSpinType::SCALAR );
 
     // Check that the B dtr types are K D D:
 
     // get the parameters:
     _r = getArg( 0 );
     double phase = getArg( 1 );
     _exp = EvtComplex( cos( phase ), sin( phase ) );
 }
 
 //------------------------------------------------------------------
 void EvtBtoKD3P::initProbMax()
 {
     setProbMax( 1 );    // this is later changed in decay()
 }
 
 //------------------------------------------------------------------
 void EvtBtoKD3P::decay( EvtParticle* p )
 {
     // tell the subclass that we decay the daughter:
     _daugsDecayedByParentModel = true;
 
     // the K is the 1st daughter of the B EvtParticle.
     // The decay mode of the allowed D (the one produced in b->c decay) is 2nd
     // The decay mode of the suppressed D (the one produced in b->u decay) is 3rd
     const int KIND = 0;
     const int D1IND = 1;
     const int D2IND = 2;
 
     // generate kinematics of daughters (K and D):
     EvtId tempDaug[2] = {getDaug( KIND ), getDaug( D1IND )};
     p->initializePhaseSpace( 2, tempDaug );
 
     // Get the D daughter particle and the decay models of the allowed
     // and suppressed D modes:
     EvtParticle* theD = p->getDaug( D1IND );
     EvtPto3P* model1 =
         (EvtPto3P*)( EvtDecayTable::getInstance()->getDecayFunc( theD ) );
 
-    // for the suppressed mode, re-initialize theD as the suppressed D alias:
+    // For the suppressed mode, re-initialize theD as the suppressed D alias.
+    // First set the id, then re-initialize (since it matches the expected id)
+    theD->setId( getDaug( D2IND ) );
     theD->init( getDaug( D2IND ), theD->getP4() );
     EvtPto3P* model2 =
         (EvtPto3P*)( EvtDecayTable::getInstance()->getDecayFunc( theD ) );
 
     // on the first call:
     if ( false == _decayedOnce ) {
         _decayedOnce = true;
 
         // store the D decay model pointers:
         _model1 = model1;
         _model2 = model2;
 
         // check the decay models of the first 2 daughters and that they
         // have the same final states:
         std::string name1 = model1->getName();
         std::string name2 = model2->getName();
 
         if ( name1 != "PTO3P" ) {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << "D daughters of EvtBtoKD3P decay must decay via the \"PTO3P\" model"
                 << endl
                 << "    but found to decay via " << name1.c_str() << " or "
                 << name2.c_str() << ". Will terminate execution!" << endl;
             assert( 0 );
         }
 
         EvtId* daugs1 = model1->getDaugs();
         EvtId* daugs2 = model2->getDaugs();
 
         bool idMatch = true;
         int d;
         for ( d = 0; d < 2; ++d ) {
             if ( daugs1[d] != daugs2[d] ) {
                 idMatch = false;
             }
         }
         if ( false == idMatch ) {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << "D daughters of EvtBtoKD3P decay must decay to the same final state"
                 << endl
                 << "   particles in the same order (not CP-conjugate order),"
                 << endl
                 << "   but they were found to decay to" << endl;
             for ( d = 0; d < model1->getNDaug(); ++d ) {
                 EvtGenReport( EVTGEN_ERROR, "" )
                     << "   " << EvtPDL::name( daugs1[d] ).c_str() << " ";
             }
             EvtGenReport( EVTGEN_ERROR, "" ) << endl;
             for ( d = 0; d < model1->getNDaug(); ++d ) {
                 EvtGenReport( EVTGEN_ERROR, "" )
                     << "   " << EvtPDL::name( daugs2[d] ).c_str() << " ";
             }
             EvtGenReport( EVTGEN_ERROR, "" )
                 << endl
                 << ". Will terminate execution!" << endl;
             assert( 0 );
         }
 
         // estimate the probmax. Need to know the probmax's of the 2
         // models for this:
         setProbMax(
             model1->getProbMax( 0 ) + _r * _r * model2->getProbMax( 0 ) +
             2 * _r * sqrt( model1->getProbMax( 0 ) * model2->getProbMax( 0 ) ) );
 
     }    // end of things to do on the first call
 
     // make sure the models haven't changed since the first call:
     if ( _model1 != model1 || _model2 != model2 ) {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "D daughters of EvtBtoKD3P decay should have only 1 decay modes, "
             << endl
             << "    but a new decay mode was found after the first call" << endl
             << "    Will terminate execution!" << endl;
         assert( 0 );
     }
 
+    // Reset the D id to the 1st D
+    theD->setId( getDaug( D1IND ) );
+    theD->init( getDaug( D1IND ), theD->getP4() );
+
     // get the cover function for each of the models and add them up.
     // They are summed with coefficients 1 because we are willing to
     // take a small inefficiency (~50%) in order to ensure that the
     // cover function is large enough without getting into complications
     // associated with the smallness of _r:
     EvtPdfSum<EvtDalitzPoint>* pc1 = model1->getPC();
     EvtPdfSum<EvtDalitzPoint>* pc2 = model2->getPC();
     EvtPdfSum<EvtDalitzPoint> pc;
     pc.addTerm( 1.0, *pc1 );
     pc.addTerm( 1.0, *pc2 );
 
     // from this combined cover function, generate the Dalitz point:
     EvtDalitzPoint x = pc.randomPoint();
 
     // get the aptitude for each of the models on this point and add them up:
     EvtComplex amp1 = model1->amplNonCP( x );
     EvtComplex amp2 = model2->amplNonCP( x );
     EvtComplex amp = amp1 + amp2 * _r * _exp;
 
     // get the value of the cover function for this point and set the
     // relative amplitude for this decay:
 
     double comp = sqrt( pc.evaluate( x ) );
     vertex( amp / comp );
 
     // Make the daughters of theD:
     bool massTreeOK = theD->generateMassTree();
     if ( massTreeOK == false ) {
         return;
     }
 
     // Now generate the p4's of the daughters of theD:
     std::vector<EvtVector4R> v = model2->initDaughters( x );
 
     if ( v.size() != theD->getNDaug() ) {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "Number of daughters " << theD->getNDaug() << " != "
             << "Momentum vector size " << v.size() << endl
             << "     Terminating execution." << endl;
         assert( 0 );
     }
 
     // Apply the new p4's to the daughters:
     for ( unsigned int i = 0; i < theD->getNDaug(); ++i ) {
         theD->getDaug( i )->init( model2->getDaugs()[i], v[i] );
     }
 }
diff --git a/src/EvtGenModels/EvtBtoKpiCPiso.cpp b/src/EvtGenModels/EvtBtoKpiCPiso.cpp
index 8f27a96..b8c8401 100644
--- a/src/EvtGenModels/EvtBtoKpiCPiso.cpp
+++ b/src/EvtGenModels/EvtBtoKpiCPiso.cpp
@@ -1,201 +1,201 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtBtoKpiCPiso.hh"
 
 #include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtReport.hh"
 
 #include <stdlib.h>
 #include <string>
 
 std::string EvtBtoKpiCPiso::getName()
 {
     return "BTOKPI_CP_ISO";
 }
 
 EvtDecayBase* EvtBtoKpiCPiso::clone()
 {
     return new EvtBtoKpiCPiso;
 }
 
 void EvtBtoKpiCPiso::init()
 {
-    // check that there are 15 arguments
-    checkNArg( 15 );
+    // check that there are 14 arguments
+    checkNArg( 14 );
     checkNDaug( 2 );
 
     checkSpinParent( EvtSpinType::SCALAR );
 
     checkSpinDaughter( 0, EvtSpinType::SCALAR );
     checkSpinDaughter( 1, EvtSpinType::SCALAR );
 }
 
 void EvtBtoKpiCPiso::initProbMax()
 {
     //this might need to be revised
 
     //added by Lange Jan4,2000
     static EvtId PI0 = EvtPDL::getId( "pi0" );
     static EvtId PIP = EvtPDL::getId( "pi+" );
-    static EvtId PIM = EvtPDL::getId( "pi+" );
+    static EvtId PIM = EvtPDL::getId( "pi-" );
     static EvtId K0 = EvtPDL::getId( "K0" );
     static EvtId KB = EvtPDL::getId( "anti-K0" );
     static EvtId KP = EvtPDL::getId( "K+" );
     static EvtId KM = EvtPDL::getId( "K-" );
 
     if ( ( ( getDaug( 0 ) == PI0 ) && ( getDaug( 1 ) == KP ) ) ||
          ( ( getDaug( 0 ) == KP ) && ( getDaug( 1 ) == PI0 ) ) ) {
         setProbMax(
             2.0 * ( getArg( 2 ) * getArg( 2 ) + getArg( 10 ) * getArg( 10 ) ) );
     }
 
     if ( ( ( getDaug( 0 ) == PI0 ) && ( getDaug( 1 ) == KM ) ) ||
          ( ( getDaug( 0 ) == KM ) && ( getDaug( 1 ) == PI0 ) ) ) {
         setProbMax(
             2.0 * ( getArg( 4 ) * getArg( 4 ) + getArg( 12 ) * getArg( 12 ) ) );
     }
 
     if ( ( ( getDaug( 0 ) == PIP ) && ( getDaug( 1 ) == K0 ) ) ||
          ( ( getDaug( 0 ) == K0 ) && ( getDaug( 1 ) == PIP ) ) ) {
         setProbMax(
             4.0 * ( getArg( 6 ) * getArg( 6 ) + getArg( 10 ) * getArg( 10 ) ) );
     }
 
     if ( ( ( getDaug( 0 ) == PIM ) && ( getDaug( 1 ) == KB ) ) ||
          ( ( getDaug( 0 ) == KB ) && ( getDaug( 1 ) == PIM ) ) ) {
         setProbMax(
             4.0 * ( getArg( 8 ) * getArg( 8 ) + getArg( 12 ) * getArg( 12 ) ) );
     }
 
     if ( ( ( getDaug( 0 ) == PI0 ) && ( getDaug( 1 ) == K0 ) ) ||
          ( ( getDaug( 0 ) == K0 ) && ( getDaug( 1 ) == PI0 ) ) ) {
         setProbMax(
             2.0 * ( getArg( 2 ) * getArg( 2 ) + getArg( 10 ) * getArg( 10 ) ) );
     }
 
     if ( ( ( getDaug( 0 ) == PI0 ) && ( getDaug( 1 ) == KB ) ) ||
          ( ( getDaug( 0 ) == KB ) && ( getDaug( 1 ) == PI0 ) ) ) {
         setProbMax(
             2.0 * ( getArg( 4 ) * getArg( 4 ) + getArg( 12 ) * getArg( 12 ) ) );
     }
 
     if ( ( ( getDaug( 0 ) == PIM ) && ( getDaug( 1 ) == KP ) ) ||
          ( ( getDaug( 0 ) == KP ) && ( getDaug( 1 ) == PIM ) ) ) {
         setProbMax(
             4.0 * ( getArg( 6 ) * getArg( 6 ) + getArg( 10 ) * getArg( 10 ) ) );
     }
 
     if ( ( ( getDaug( 0 ) == PIP ) && ( getDaug( 1 ) == KM ) ) ||
          ( ( getDaug( 0 ) == KM ) && ( getDaug( 1 ) == PIP ) ) ) {
         setProbMax(
             4.0 * ( getArg( 8 ) * getArg( 8 ) + getArg( 12 ) * getArg( 12 ) ) );
     }
 }
 
 void EvtBtoKpiCPiso::decay( EvtParticle* p )
 {
     p->initializePhaseSpace( getNDaug(), getDaugs() );
     //added by Lange Jan4,2000
     static EvtId PI0 = EvtPDL::getId( "pi0" );
     static EvtId PIP = EvtPDL::getId( "pi+" );
-    static EvtId PIM = EvtPDL::getId( "pi+" );
+    static EvtId PIM = EvtPDL::getId( "pi-" );
     static EvtId K0 = EvtPDL::getId( "K0" );
     static EvtId KB = EvtPDL::getId( "anti-K0" );
     static EvtId KP = EvtPDL::getId( "K+" );
     static EvtId KM = EvtPDL::getId( "K-" );
 
     EvtComplex A;
     EvtComplex U, Ubar, V, Vbar, W, Wbar;
 
     U = EvtComplex( getArg( 2 ) * cos( getArg( 3 ) ),
                     getArg( 2 ) * sin( getArg( 3 ) ) );
     Ubar = EvtComplex( getArg( 4 ) * cos( getArg( 5 ) ),
                        getArg( 4 ) * sin( getArg( 5 ) ) );
     V = EvtComplex( getArg( 6 ) * cos( getArg( 7 ) ),
                     getArg( 6 ) * sin( getArg( 7 ) ) );
     Vbar = EvtComplex( getArg( 8 ) * cos( getArg( 9 ) ),
                        getArg( 8 ) * sin( getArg( 9 ) ) );
     W = EvtComplex( getArg( 10 ) * cos( getArg( 11 ) ),
                     getArg( 10 ) * sin( getArg( 11 ) ) );
     Wbar = EvtComplex( getArg( 12 ) * cos( getArg( 13 ) ),
                        getArg( 12 ) * sin( getArg( 13 ) ) );
 
     //depending on what combination of K pi we have, there will be different
     //A and Abar (only A given in comments!)
 
     if ( ( ( getDaug( 0 ) == PI0 ) && ( getDaug( 1 ) == KP ) ) ||
          ( ( getDaug( 0 ) == KP ) && ( getDaug( 1 ) == PI0 ) ) ) {
         //pi0 K+, so U - W
 
         A = U - W;
     }
 
     if ( ( ( getDaug( 0 ) == PI0 ) && ( getDaug( 1 ) == KM ) ) ||
          ( ( getDaug( 0 ) == KM ) && ( getDaug( 1 ) == PI0 ) ) ) {
         //pi0 K-, so Ubar - Wbar
 
         A = Ubar - Wbar;
     }
 
     if ( ( ( getDaug( 0 ) == PIP ) && ( getDaug( 1 ) == K0 ) ) ||
          ( ( getDaug( 0 ) == K0 ) && ( getDaug( 1 ) == PIP ) ) ) {
         //pi+ K0, so V + W
 
         A = sqrt( 2.0 ) * ( V + W );
     }
 
     if ( ( ( getDaug( 0 ) == PIM ) && ( getDaug( 1 ) == KB ) ) ||
          ( ( getDaug( 0 ) == KB ) && ( getDaug( 1 ) == PIM ) ) ) {
         //pi- K0bar, so Vbar + Wbar
         A = sqrt( 2.0 ) * ( Vbar + Wbar );
     }
 
     if ( ( ( getDaug( 0 ) == PI0 ) && ( getDaug( 1 ) == K0 ) ) ||
          ( ( getDaug( 0 ) == K0 ) && ( getDaug( 1 ) == PI0 ) ) ) {
         //pi0 K0, so U + W
 
         A = U + W;
     }
 
     if ( ( ( getDaug( 0 ) == PI0 ) && ( getDaug( 1 ) == KB ) ) ||
          ( ( getDaug( 0 ) == KB ) && ( getDaug( 1 ) == PI0 ) ) ) {
         A = Ubar + Wbar;
     }
 
     if ( ( ( getDaug( 0 ) == PIM ) && ( getDaug( 1 ) == KP ) ) ||
          ( ( getDaug( 0 ) == KP ) && ( getDaug( 1 ) == PIM ) ) ) {
         //pi- K+, so V - W
 
         A = sqrt( 2.0 ) * ( V - W );
     }
 
     if ( ( ( getDaug( 0 ) == PIP ) && ( getDaug( 1 ) == KM ) ) ||
          ( ( getDaug( 0 ) == KM ) && ( getDaug( 1 ) == PIP ) ) ) {
         A = sqrt( 2.0 ) * ( Vbar - Wbar );
     }
 
     vertex( A );
 
     return;
 }
diff --git a/src/EvtGenModels/EvtDMix.cpp b/src/EvtGenModels/EvtDMix.cpp
index 142bc3c..07026fd 100644
--- a/src/EvtGenModels/EvtDMix.cpp
+++ b/src/EvtGenModels/EvtDMix.cpp
@@ -1,96 +1,96 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtDMix.hh"
 
 #include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtRandom.hh"
 #include "EvtGenBase/EvtReport.hh"
 
 #include <stdlib.h>
 #include <string>
 
 std::string EvtDMix::getName()
 {
     return "DMIX";
 }
 
 EvtDecayBase* EvtDMix::clone()
 {
     return new EvtDMix;
 }
 
 void EvtDMix::init()
 {
-    // check that there are 0 arguments
+    // check arguments
     checkNArg( 3 );
     _rd = getArg( 0 );
     _xpr = getArg( 1 );
     _ypr = getArg( 2 );
 }
 
 void EvtDMix::initProbMax()
 {
     noProbMax();
 }
 
 void EvtDMix::decay( EvtParticle* p )
 {
     //unneeded - lange - may13-02
     //if ( p->getNDaug() != 0 ) {
     //Will end up here because maxrate multiplies by 1.2
     //  EvtGenReport(EVTGEN_DEBUG,"EvtGen") << "In EvtDMix: has "
     //			   <<" daugthers should not be here!"<<endl;
     //  return;
     //}
 
     p->initializePhaseSpace( getNDaug(), getDaugs() );
 
     double ctau = EvtPDL::getctau( p->getId() );
     if ( ctau == 0. )
         return;
 
     double pdf, random, gt, weight;
 
     double maxPdf = _rd + sqrt( _rd ) * _ypr * 50. +
                     2500.0 * ( _xpr * _xpr + _ypr * _ypr ) / 4.0;
     bool keepGoing = true;
     while ( keepGoing ) {
         random = EvtRandom::Flat();
         gt = -log( random );
         weight = random;
         pdf = _rd + sqrt( _rd ) * _ypr * gt +
               gt * gt * ( _xpr * _xpr + _ypr * _ypr ) / 4.0;
         pdf *= exp( -1.0 * gt );
         pdf /= weight;
         if ( pdf > maxPdf )
             std::cout << pdf << " " << weight << " " << maxPdf << " " << gt
                       << std::endl;
         if ( pdf > maxPdf * EvtRandom::Flat() )
             keepGoing = false;
     }
 
     p->setLifetime( gt * ctau );
 
     return;
 }
diff --git a/src/EvtGenModels/EvtISGW.cpp b/src/EvtGenModels/EvtISGW.cpp
index 0f2507c..6c738fe 100644
--- a/src/EvtGenModels/EvtISGW.cpp
+++ b/src/EvtGenModels/EvtISGW.cpp
@@ -1,82 +1,87 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtISGW.hh"
 
 #include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtReport.hh"
 #include "EvtGenBase/EvtSemiLeptonicScalarAmp.hh"
 #include "EvtGenBase/EvtSemiLeptonicTensorAmp.hh"
 #include "EvtGenBase/EvtSemiLeptonicVectorAmp.hh"
 
 #include "EvtGenModels/EvtISGWFF.hh"
 
 #include <stdlib.h>
 #include <string>
 
 std::string EvtISGW::getName()
 {
     return "ISGW";
 }
 
 EvtDecayBase* EvtISGW::clone()
 {
     return new EvtISGW;
 }
 
 void EvtISGW::decay( EvtParticle* p )
 {
     p->initializePhaseSpace( getNDaug(), getDaugs() );
 
     calcamp->CalcAmp( p, _amp2, isgwffmodel.get() );
 }
 
 void EvtISGW::init()
 {
     checkNArg( 0 );
     checkNDaug( 3 );
 
     //We expect the parent to be a scalar
     //and the daughters to be X lepton neutrino
 
     EvtSpinType::spintype mesontype = EvtPDL::getSpinType( getDaug( 0 ) );
 
     checkSpinParent( EvtSpinType::SCALAR );
     checkSpinDaughter( 1, EvtSpinType::DIRAC );
     checkSpinDaughter( 2, EvtSpinType::NEUTRINO );
 
     isgwffmodel = std::make_unique<EvtISGWFF>();
 
     switch ( mesontype ) {
         case EvtSpinType::SCALAR:
             calcamp = std::make_unique<EvtSemiLeptonicScalarAmp>();
             break;
         case EvtSpinType::VECTOR:
             calcamp = std::make_unique<EvtSemiLeptonicVectorAmp>();
             break;
         case EvtSpinType::TENSOR:
             calcamp = std::make_unique<EvtSemiLeptonicTensorAmp>();
             break;
         default:;
     }
 }
+
+void EvtISGW::initProbMax()
+{
+    setProbMax( 10000.0 );
+}
diff --git a/src/EvtGenModels/EvtKKLambdaC.cpp b/src/EvtGenModels/EvtKKLambdaC.cpp
index 9aebafc..562ef40 100644
--- a/src/EvtGenModels/EvtKKLambdaC.cpp
+++ b/src/EvtGenModels/EvtKKLambdaC.cpp
@@ -1,82 +1,82 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtKKLambdaC.hh"
 
 #include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtReport.hh"
 #include "EvtGenBase/EvtSemiLeptonicBaryonAmp.hh"
 
 #include "EvtGenModels/EvtKKLambdaCFF.hh"
 
 #include <stdlib.h>
 #include <string>
 
 std::string EvtKKLambdaC::getName()
 {
     return "KK_LAMBDAC_SL";
 }
 
 EvtDecayBase* EvtKKLambdaC::clone()
 {
     return new EvtKKLambdaC;
 }
 
 void EvtKKLambdaC::decay( EvtParticle* p )
 {
     p->initializePhaseSpace( getNDaug(), getDaugs() );
 
     _calcamp->CalcAmp( p, _amp2, _ffmodel.get() );
 }
 
 void EvtKKLambdaC::initProbMax()
 {
     EvtId parnum, mesnum, lnum, nunum;
 
     parnum = getParentId();
     mesnum = getDaug( 0 );
     lnum = getDaug( 1 );
     nunum = getDaug( 2 );
 
     //double mymaxprob = _calcamp->CalcMaxProb(parnum,mesnum,
     //                           lnum,nunum,_ffmodel);
-    double mymaxprob = 100.;
+    double mymaxprob = 1e3;
     setProbMax( mymaxprob );
 }
 
 void EvtKKLambdaC::init()
 {
     checkNDaug( 3 );
 
     //We expect the parent to be a dirac
     //and the daughters to be dirac lepton neutrino
 
     checkSpinParent( EvtSpinType::DIRAC );
     checkSpinDaughter( 0, EvtSpinType::DIRAC );
     checkSpinDaughter( 1, EvtSpinType::DIRAC );
     checkSpinDaughter( 2, EvtSpinType::NEUTRINO );
 
     _ffmodel = std::make_unique<EvtKKLambdaCFF>( getNArg(), getArgs() );
 
     _calcamp = std::make_unique<EvtSemiLeptonicBaryonAmp>();
 }
diff --git a/src/EvtGenModels/EvtKstarnunu.cpp b/src/EvtGenModels/EvtKstarnunu.cpp
index fb9b86d..b1744ba 100644
--- a/src/EvtGenModels/EvtKstarnunu.cpp
+++ b/src/EvtGenModels/EvtKstarnunu.cpp
@@ -1,134 +1,139 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtKstarnunu.hh"
 
 #include "EvtGenBase/EvtDiracSpinor.hh"
 #include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtReport.hh"
 #include "EvtGenBase/EvtTensor4C.hh"
 #include "EvtGenBase/EvtVector4C.hh"
 
 #include <iostream>
 #include <stdlib.h>
 #include <string>
 
 std::string EvtKstarnunu::getName()
 {
     return "KSTARNUNU";
 }
 
 EvtDecayBase* EvtKstarnunu::clone()
 {
     return new EvtKstarnunu;
 }
 
 void EvtKstarnunu::init()
 {
     // check that there are 0 arguments
     checkNArg( 0 );
     checkNDaug( 3 );
 
     //We expect the parent to be a scalar
     //and the daughters to be K neutrino netrino
 
     checkSpinParent( EvtSpinType::SCALAR );
 
     checkSpinDaughter( 0, EvtSpinType::VECTOR );
     checkSpinDaughter( 1, EvtSpinType::NEUTRINO );
     checkSpinDaughter( 2, EvtSpinType::NEUTRINO );
 }
 
+void EvtKstarnunu::initProbMax()
+{
+    setProbMax( 7000.0 );
+}
+
 void EvtKstarnunu::decay( EvtParticle* p )
 {
     static EvtId NUE = EvtPDL::getId( "nu_e" );
     static EvtId NUM = EvtPDL::getId( "nu_mu" );
     static EvtId NUT = EvtPDL::getId( "nu_tau" );
     static EvtId NUEB = EvtPDL::getId( "anti-nu_e" );
     static EvtId NUMB = EvtPDL::getId( "anti-nu_mu" );
     static EvtId NUTB = EvtPDL::getId( "anti-nu_tau" );
 
     p->initializePhaseSpace( getNDaug(), getDaugs() );
 
     double m_b = p->mass();
 
     EvtParticle *meson, *neutrino1, *neutrino2;
     meson = p->getDaug( 0 );
     neutrino1 = p->getDaug( 1 );
     neutrino2 = p->getDaug( 2 );
     EvtVector4R momnu1 = neutrino1->getP4();
     EvtVector4R momnu2 = neutrino2->getP4();
     EvtVector4R momkstar = meson->getP4();
 
     double v0_0, a1_0, a2_0;
     double m2v0, a1_b, a2_b;
     v0_0 = 0.47;
     a1_0 = 0.37;
     a2_0 = 0.40;
     m2v0 = 5. * 5.;
     a1_b = -0.023;
     a2_b = 0.034;
 
     EvtVector4R q = momnu1 + momnu2;
     double q2 = q.mass2();
 
     double v0, a1, a2;
     v0 = v0_0 / ( 1 - q2 / m2v0 );
     a1 = a1_0 * ( 1 + a1_b * q2 );
     a2 = a2_0 * ( 1 + a2_b * q2 );
 
     EvtVector4R p4b;
     p4b.set( m_b, 0., 0., 0. );    // Do calcs in mother rest frame
 
     double m_k = meson->mass();
 
     EvtTensor4C tds = ( -2 * v0 / ( m_b + m_k ) ) *
                           dual( EvtGenFunctions::directProd( p4b, momkstar ) ) -
                       EvtComplex( 0.0, 1.0 ) *
                           ( ( m_b + m_k ) * a1 * EvtTensor4C::g() -
                             ( a2 / ( m_b + m_k ) ) *
                                 EvtGenFunctions::directProd( p4b - momkstar,
                                                              p4b + momkstar ) );
 
     EvtVector4C l;
 
     if ( getDaug( 1 ) == NUE || getDaug( 1 ) == NUM || getDaug( 1 ) == NUT ) {
         l = EvtLeptonVACurrent( neutrino1->spParentNeutrino(),
                                 neutrino2->spParentNeutrino() );
     }
     if ( getDaug( 1 ) == NUEB || getDaug( 1 ) == NUMB || getDaug( 1 ) == NUTB ) {
         l = EvtLeptonVACurrent( neutrino2->spParentNeutrino(),
                                 neutrino1->spParentNeutrino() );
     }
 
     EvtVector4C et0, et1, et2;
     et0 = tds.cont1( meson->epsParent( 0 ).conj() );
     et1 = tds.cont1( meson->epsParent( 1 ).conj() );
     et2 = tds.cont1( meson->epsParent( 2 ).conj() );
 
     vertex( 0, l * et0 );
     vertex( 1, l * et1 );
     vertex( 2, l * et2 );
 
     return;
 }
diff --git a/src/EvtGenModels/EvtLambdaB2LambdaV.cpp b/src/EvtGenModels/EvtLambdaB2LambdaV.cpp
index d7f1cc8..f541960 100644
--- a/src/EvtGenModels/EvtLambdaB2LambdaV.cpp
+++ b/src/EvtGenModels/EvtLambdaB2LambdaV.cpp
@@ -1,1488 +1,1409 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtLambdaB2LambdaV.hh"
 
 #include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtRandom.hh"
 #include "EvtGenBase/EvtReport.hh"
 
 #include <fstream>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string>
 
 using std::fstream;
 //************************************************************************
 //*                                                                      *
 //*                      Class EvtLambdaB2LambdaV                        *
 //*                                                                      *
 //************************************************************************
 //DECLARE_COMPONENT( EvtLambdaB2LambdaV );
 
 EvtLambdaB2LambdaV::EvtLambdaB2LambdaV()
 {
     //set facility name
     fname = "EvtGen.EvtLambdaB2LambdaV";
 }
 
 //------------------------------------------------------------------------
 // Method 'getName'
 //------------------------------------------------------------------------
 std::string EvtLambdaB2LambdaV::getName()
 {
     return "LAMBDAB2LAMBDAV";
 }
 
 //------------------------------------------------------------------------
 // Method 'clone'
 //------------------------------------------------------------------------
 EvtDecayBase* EvtLambdaB2LambdaV::clone()
 {
     return new EvtLambdaB2LambdaV;
 }
 
 //------------------------------------------------------------------------
 // Method 'initProbMax'
 //------------------------------------------------------------------------
 void EvtLambdaB2LambdaV::initProbMax()
 {
     //maximum (case where C=0)
-    double Max = 1 + fabs( A * B );
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << " PDF max value : " << Max << std::endl;
+    double Max = 1.0 + fabs( A * B ) + 2.0 * fabs( A * abs( C ) );
+    if ( verbose() ) {
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << " PDF max value : " << Max << std::endl;
+    }
     setProbMax( Max );
 }
 
 //------------------------------------------------------------------------
 // Method 'init'
 //------------------------------------------------------------------------
 void EvtLambdaB2LambdaV::init()
 {
     bool antiparticle = false;
 
     //introduction
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << "*************************************************" << std::endl;
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << "*    Event Model Class : EvtLambdaB2LambdaV     *" << std::endl;
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << "*************************************************" << std::endl;
+    if ( verbose() ) {
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << "*************************************************" << std::endl;
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << "*    Event Model Class : EvtLambdaB2LambdaV     *" << std::endl;
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << "*************************************************" << std::endl;
+    }
 
     //check the number of arguments
     checkNArg( 2 );
 
     //check the number of daughters
     checkNDaug( 2 );
 
     const EvtId Id_mother = getParentId();
     const EvtId Id_daug1 = getDaug( 0 );
     const EvtId Id_daug2 = getDaug( 1 );
 
     //lambdab identification
     if ( Id_mother == EvtPDL::getId( "Lambda_b0" ) ) {
         antiparticle = false;
     } else if ( Id_mother == EvtPDL::getId( "anti-Lambda_b0" ) ) {
         antiparticle = true;
     } else {
         EvtGenReport( EVTGEN_ERROR, fname.c_str() )
             << " Mother is not a Lambda_b0 or an anti-Lambda_b0, but a "
             << EvtPDL::name( Id_mother ) << std::endl;
         abort();
     }
 
     //lambda
     if ( !( Id_daug1 == EvtPDL::getId( "Lambda0" ) && !antiparticle ) &&
          !( Id_daug1 == EvtPDL::getId( "anti-Lambda0" ) && antiparticle ) ) {
         if ( !antiparticle ) {
             EvtGenReport( EVTGEN_ERROR, fname.c_str() )
                 << " Daughter1 is not a Lambda0, but a "
                 << EvtPDL::name( Id_daug1 ) << std::endl;
         } else {
             EvtGenReport( EVTGEN_ERROR, fname.c_str() )
                 << " Daughter1 is not an anti-Lambda0, but a "
                 << EvtPDL::name( Id_daug1 ) << std::endl;
         }
         abort();
     }
 
     //identification meson V
     if ( getArg( 1 ) == 1 )
         Vtype = VID::JPSI;
     else if ( getArg( 1 ) == 2 )
         Vtype = VID::RHO;
     else if ( getArg( 1 ) == 3 )
         Vtype = VID::OMEGA;
     else if ( getArg( 1 ) == 4 )
         Vtype = VID::RHO_OMEGA_MIXING;
     else {
         EvtGenReport( EVTGEN_ERROR, fname.c_str() )
             << " Vtype " << getArg( 1 ) << " is unknown" << std::endl;
         abort();
     }
 
     //check vector meson V
     if ( Id_daug2 == EvtPDL::getId( "J/psi" ) && Vtype == VID::JPSI ) {
         if ( !antiparticle )
             EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
                 << " Decay mode successfully initialized : Lambda_b0 -> Lambda J/psi"
                 << std::endl;
         else
             EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
                 << " Decay mode successfully initialized : anti-Lambda_b0 -> anti-Lambda J/psi"
                 << std::endl;
     } else if ( Id_daug2 == EvtPDL::getId( "rho0" ) && Vtype == VID::RHO ) {
         if ( !antiparticle )
             EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
                 << " Decay mode successfully initialized : Lambda_b0 -> Lambda rho0"
                 << std::endl;
         else
             EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
                 << " Decay mode successfully initialized : anti-Lambda_b0 -> anti-Lambda rho0"
                 << std::endl;
     } else if ( Id_daug2 == EvtPDL::getId( "omega" ) && Vtype == VID::OMEGA ) {
         if ( !antiparticle )
             EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
                 << " Decay mode successfully initialized : Lambda_b0 -> Lambda omega"
                 << std::endl;
         else
             EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
                 << " Decay mode successfully initialized : anti-Lambda_b0 -> anti-Lambda omega"
                 << std::endl;
     } else if ( ( Id_daug2 == EvtPDL::getId( "omega" ) ||
                   Id_daug2 == EvtPDL::getId( "rho0" ) ) &&
                 Vtype == VID::RHO_OMEGA_MIXING ) {
         if ( !antiparticle )
             EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
                 << " Decay mode successfully initialized : "
                 << "Lambda_b0 -> Lambda rho-omega-mixing" << std::endl;
         else
             EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
                 << " Decay mode successfully initialized : "
                 << "anti-Lambda_b0 -> anti-Lambda rho-omega-mixing" << std::endl;
     }
 
     else {
         EvtGenReport( EVTGEN_ERROR, fname.c_str() )
             << " Daughter2 is not a J/psi, phi or rho0 but a "
             << EvtPDL::name( Id_daug2 ) << std::endl;
         abort();
     }
 
     //fix dynamics parameters
     B = (double)getArg( 0 );
     C = EvtComplex( ( sqrt( 2. ) / 2. ), ( sqrt( 2. ) / 2. ) );
     switch ( Vtype ) {
         case VID::JPSI:
             A = 0.490;
             break;
         case VID::RHO:
         case VID::OMEGA:
         case VID::RHO_OMEGA_MIXING:
             A = 0.194;
             break;
         default:
             A = 0;
             break;
     }
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << " LambdaB decay parameters : " << std::endl;
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << "   - lambda asymmetry A = " << A << std::endl;
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << "   - lambdab polarisation B = " << B << std::endl;
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << "   - lambdab density matrix rho+- C = " << C << std::endl;
+
+    if ( verbose() ) {
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << " LambdaB decay parameters : " << std::endl;
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << "   - lambda asymmetry A = " << A << std::endl;
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << "   - lambdab polarisation B = " << B << std::endl;
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << "   - lambdab density matrix rho+- C = " << C << std::endl;
+    }
 }
 
 //------------------------------------------------------------------------
 // Method 'decay'
 //------------------------------------------------------------------------
 void EvtLambdaB2LambdaV::decay( EvtParticle* lambdab )
 {
+    // Using formulae from hep-ph/0602043
+
     lambdab->makeDaughters( getNDaug(), getDaugs() );
 
     //get lambda and V particles
     EvtParticle* lambda = lambdab->getDaug( 0 );
     EvtParticle* V = lambdab->getDaug( 1 );
 
     //get resonance masses
     // - LAMBDAB          -> mass given by the preceding class
     // - LAMBDA           -> nominal mass
     // - V                -> getVmass method
     double MASS_LAMBDAB = lambdab->mass();
     double MASS_LAMBDA = EvtPDL::getMeanMass( EvtPDL::getId( "Lambda0" ) );
     double MASS_V = getVMass( MASS_LAMBDAB, MASS_LAMBDA );
 
     //generate random angles
     double phi = EvtRandom::Flat( 0, 2 * EvtConst::pi );
     double theta = acos( EvtRandom::Flat( -1, +1 ) );
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << " Angular angles  : theta = " << theta << " ; phi = " << phi
-        << std::endl;
-    //computate resonance quadrivectors
+
+    // Get 4-vectors
     double E_lambda = ( MASS_LAMBDAB * MASS_LAMBDAB +
                         MASS_LAMBDA * MASS_LAMBDA - MASS_V * MASS_V ) /
                       ( 2 * MASS_LAMBDAB );
     double E_V = ( MASS_LAMBDAB * MASS_LAMBDAB + MASS_V * MASS_V -
                    MASS_LAMBDA * MASS_LAMBDA ) /
                  ( 2 * MASS_LAMBDAB );
     double P = sqrt( E_lambda * E_lambda - lambda->mass() * lambda->mass() );
 
     EvtVector4R P_lambdab = lambdab->getP4();
 
     double px = P_lambdab.get( 1 );
     double py = P_lambdab.get( 2 );
     double pz = P_lambdab.get( 3 );
     double E = P_lambdab.get( 0 );
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << "E of lambdab:  " << P_lambdab.get( 0 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << "E of lambdab:  " << E << std::endl;
-
-    EvtVector4R q_lambdab2( E,
-                            ( ( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) ) *
-                              ( ( px * ( px ) ) + ( py * ( py ) ) ) ),
-                            ( ( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) ) *
-                              ( -( ( py ) * ( px ) ) + ( px * ( py ) ) ) ),
-                            ( pz ) );
+
+    const double pxSq = px * px;
+    const double pySq = py * py;
+    const double pT = sqrt( pxSq + pySq );
+    const double invPT = pT > 0.0 ? 1.0 / pT : 0.0;
+    EvtVector4R q_lambdab2( E, pT, 0.0, pz );
 
     EvtVector4R q_lambdab3( E, q_lambdab2.get( 3 ), q_lambdab2.get( 1 ),
                             q_lambdab2.get( 2 ) );
 
     EvtVector4R q_lambda0( E_lambda, P * sin( theta ) * cos( phi ),
                            P * sin( theta ) * sin( phi ), P * cos( theta ) );
 
     EvtVector4R q_V0( E_V, -P * sin( theta ) * cos( phi ),
                       -P * sin( theta ) * sin( phi ), -P * cos( theta ) );
 
     EvtVector4R q_lambda1( E_lambda, q_lambda0.get( 2 ), q_lambda0.get( 3 ),
                            q_lambda0.get( 1 ) );
 
     EvtVector4R q_V1( E_V, q_V0.get( 2 ), q_V0.get( 3 ), q_V0.get( 1 ) );
 
     EvtVector4R q_lambda(
-        E_lambda,
-        ( ( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) ) *
-          ( ( px * ( q_lambda1.get( 1 ) ) ) - ( py * ( q_lambda1.get( 2 ) ) ) ) ),
-        ( ( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) ) *
-          ( ( py * ( q_lambda1.get( 1 ) ) ) + ( px * ( q_lambda1.get( 2 ) ) ) ) ),
-        ( q_lambda1.get( 3 ) ) );
-
-    EvtVector4R q_V(
-        E_V,
-        ( ( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) ) *
-          ( ( px * ( q_V1.get( 1 ) ) ) - ( py * ( q_V1.get( 2 ) ) ) ) ),
-        ( ( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) ) *
-          ( ( py * ( q_V1.get( 1 ) ) ) + ( px * ( q_V1.get( 2 ) ) ) ) ),
-        ( q_V1.get( 3 ) ) );
-
-    lambda->getP4();
-    V->getP4();
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " LambdaB  px: " << px << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " LambdaB  py: " << py << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " LambdaB  pz: " << pz << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " LambdaB  E: " << E << std::endl;
-
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambdab3  E:  " << q_lambdab3.get( 0 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda 0 px:  " << q_lambda0.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda 0 py:  " << q_lambda0.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda 0 pz:  " << q_lambda0.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda 0 E:  " << q_lambda0.get( 0 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda 1 px:  " << q_lambda1.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda 1 py:  " << q_lambda1.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda 1 pz:  " << q_lambda1.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda 1 E:  " << q_lambda1.get( 0 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda  px:  " << q_lambda.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda  py:  " << q_lambda.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda  pz:  " << q_lambda.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda  E:  " << q_lambda0.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " V 0 px:  " << q_V0.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " V 0 py:  " << q_V0.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " V 0 pz:  " << q_V0.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " V 0 E:  " << q_V0.get( 0 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " V 1 px:  " << q_V1.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " V 1 py:  " << q_V1.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " V 1 pz:  " << q_V1.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " V 1 E:  " << q_V1.get( 0 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " V  px:  " << q_V.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " V  py:  " << q_V.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " V  pz:  " << q_V.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " V  E:  " << q_V0.get( 3 ) << std::endl;
-    //set quadrivectors to particles
+        E_lambda, invPT * ( px * q_lambda1.get( 1 ) - py * q_lambda1.get( 2 ) ),
+        invPT * ( py * q_lambda1.get( 1 ) + px * q_lambda1.get( 2 ) ),
+        q_lambda1.get( 3 ) );
+
+    EvtVector4R q_V( E_V, invPT * ( px * q_V1.get( 1 ) - py * q_V1.get( 2 ) ),
+                     invPT * ( py * q_V1.get( 1 ) + px * q_V1.get( 2 ) ),
+                     q_V1.get( 3 ) );
+
+    // Set particle 4-vectors
     lambda->init( getDaugs()[0], q_lambda );
     V->init( getDaugs()[1], q_V );
 
-    //computate pdf
-    double pdf = 1 + A * B * cos( theta ) +
-                 2 * A * real( C * EvtComplex( cos( phi ), sin( phi ) ) ) *
+    // Find pdf (eq 11 in paper)
+    double pdf = 1.0 + A * B * cos( theta ) +
+                 2.0 * A * real( C * EvtComplex( cos( phi ), sin( phi ) ) ) *
                      sin( theta );
 
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << " LambdaB decay pdf value : " << pdf << std::endl;
     //set probability
     setProb( pdf );
 
-    return;
+    if ( verbose() ) {
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Angular angles  : theta = " << theta << " ; phi = " << phi
+            << std::endl;
+
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << "E of lambdab:  " << P_lambdab.get( 0 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << "E of lambdab:  " << E << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " LambdaB  px: " << px << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " LambdaB  py: " << py << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " LambdaB  pz: " << pz << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " LambdaB  E: " << E << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambdab3  E:  " << q_lambdab3.get( 0 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda 0 px:  " << q_lambda0.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda 0 py:  " << q_lambda0.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda 0 pz:  " << q_lambda0.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda 0 E:  " << q_lambda0.get( 0 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda 1 px:  " << q_lambda1.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda 1 py:  " << q_lambda1.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda 1 pz:  " << q_lambda1.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda 1 E:  " << q_lambda1.get( 0 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda  px:  " << q_lambda.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda  py:  " << q_lambda.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda  pz:  " << q_lambda.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda  E:  " << q_lambda0.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V 0 px:  " << q_V0.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V 0 py:  " << q_V0.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V 0 pz:  " << q_V0.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V 0 E:  " << q_V0.get( 0 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V 1 px:  " << q_V1.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V 1 py:  " << q_V1.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V 1 pz:  " << q_V1.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V 1 E:  " << q_V1.get( 0 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V  px:  " << q_V.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V  py:  " << q_V.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V  pz:  " << q_V.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V  E:  " << q_V0.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << " LambdaB decay pdf value : " << pdf << std::endl;
+    }
 }
 
 //------------------------------------------------------------------------
 // Method 'BreitWignerRelPDF'
 //------------------------------------------------------------------------
 double EvtLambdaB2LambdaV::BreitWignerRelPDF( double m, double _m0, double _g0 )
 {
     double a = ( _m0 * _g0 ) * ( _m0 * _g0 );
     double b = ( m * m - _m0 * _m0 ) * ( m * m - _m0 * _m0 );
     return a / ( b + a );
 }
 
 //------------------------------------------------------------------------
 // Method 'RhoOmegaMixingPDF'
 //------------------------------------------------------------------------
 double EvtLambdaB2LambdaV::RhoOmegaMixingPDF( double m, double _mr, double _gr,
                                               double _mo, double _go )
 {
     double a = m * m - _mr * _mr;
     double b = m * m - _mo * _mo;
     double c = _gr * _mr;
     double d = _go * _mo;
     double re_pi = -3500e-6;    //GeV^2
     double im_pi = -300e-6;     //GeV^2
     double va_pi = re_pi + im_pi;
 
-    //computate pdf value
+    //compute pdf value
     double f = 1 / ( a * a + c * c ) *
                ( 1 + ( va_pi * va_pi + 2 * b * re_pi + 2 * d * im_pi ) /
                          ( b * b + d * d ) );
 
-    //computate pdf max value
+    //compute pdf max value
     a = 0;
     b = _mr * _mr - _mo * _mo;
 
     double maxi = 1 / ( a * a + c * c ) *
                   ( 1 + ( va_pi * va_pi + 2 * b * re_pi + 2 * d * im_pi ) /
                             ( b * b + d * d ) );
 
     return f / maxi;
 }
 
 //------------------------------------------------------------------------
 // Method 'getVMass'
 //------------------------------------------------------------------------
 double EvtLambdaB2LambdaV::getVMass( double MASS_LAMBDAB, double MASS_LAMBDA )
 {
     //JPSI case
     if ( Vtype == VID::JPSI ) {
         return EvtPDL::getMass( EvtPDL::getId( "J/psi" ) );
     }
 
     //RHO,OMEGA,MIXING case
     else {
         //parameters
         double MASS_RHO = EvtPDL::getMeanMass( EvtPDL::getId( "rho0" ) );
         double MASS_OMEGA = EvtPDL::getMeanMass( EvtPDL::getId( "omega" ) );
         double WIDTH_RHO = EvtPDL::getWidth( EvtPDL::getId( "rho0" ) );
         double WIDTH_OMEGA = EvtPDL::getWidth( EvtPDL::getId( "omega" ) );
         double MASS_PION = EvtPDL::getMeanMass( EvtPDL::getId( "pi-" ) );
         double _max = MASS_LAMBDAB - MASS_LAMBDA;
         double _min = 2 * MASS_PION;
 
         double mass = 0;
         bool test = false;
         int ntimes = 10000;
         do {
             double y = EvtRandom::Flat( 0, 1 );
 
             //generate mass
             mass = ( _max - _min ) * EvtRandom::Flat( 0, 1 ) + _min;
 
             //pdf calculate
             double f = 0;
             switch ( Vtype ) {
                 case VID::RHO:
                     f = BreitWignerRelPDF( mass, MASS_RHO, WIDTH_RHO );
                     break;
                 case VID::OMEGA:
                     f = BreitWignerRelPDF( mass, MASS_OMEGA, WIDTH_OMEGA );
                     break;
                 case VID::RHO_OMEGA_MIXING:
                     f = RhoOmegaMixingPDF( mass, MASS_RHO, WIDTH_RHO,
                                            MASS_OMEGA, WIDTH_OMEGA );
                     break;
                 default:
                     f = 1;
                     break;
             }
 
             ntimes--;
             if ( y < f )
                 test = true;
         } while ( ntimes && !test );
 
         //looping 10000 times
         if ( ntimes == 0 ) {
             EvtGenReport( EVTGEN_INFO, fname.c_str() )
                 << "Tried accept/reject:10000"
                 << " times, and rejected all the times!" << std::endl;
             EvtGenReport( EVTGEN_INFO, fname.c_str() )
                 << "Is therefore accepting the last event!" << std::endl;
         }
 
         //return V particle mass
         return mass;
     }
 }
 
 //************************************************************************
 //*                                                                      *
 //*                Class EvtLambda2PPiForLambdaB2LambdaV                 *
 //*                                                                      *
 //************************************************************************
 
 //------------------------------------------------------------------------
 // Constructor
 //------------------------------------------------------------------------
 EvtLambda2PPiForLambdaB2LambdaV::EvtLambda2PPiForLambdaB2LambdaV()
 {
     //set facility name
     fname = "EvtGen.EvtLambda2PPiForLambdaB2LambdaV";
 }
 
 //------------------------------------------------------------------------
 // Method 'getName'
 //------------------------------------------------------------------------
 std::string EvtLambda2PPiForLambdaB2LambdaV::getName()
 {
     return "LAMBDA2PPIFORLAMBDAB2LAMBDAV";
 }
 
 //------------------------------------------------------------------------
 // Method 'clone'
 //------------------------------------------------------------------------
 EvtDecayBase* EvtLambda2PPiForLambdaB2LambdaV::clone()
 {
     return new EvtLambda2PPiForLambdaB2LambdaV;
 }
 
 //------------------------------------------------------------------------
 // Method 'initProbMax'
 //------------------------------------------------------------------------
 void EvtLambda2PPiForLambdaB2LambdaV::initProbMax()
 {
-    //maximum (case where D is real)
-    double Max = 0;
-    if ( A == 0 )
-        Max = 1;
-    else if ( C == 0 || real( D ) == 0 )
-        Max = 1 + fabs( A * B );
-    else if ( B == 0 )
-        Max = 1 + EvtConst::pi / 2.0 * fabs( C * A * real( D ) );
-    else {
-        double theta_max = atan( -EvtConst::pi / 2.0 * C * real( D ) / B );
-        double max1 = 1 + fabs( A * B * cos( theta_max ) -
-                                EvtConst::pi / 2.0 * C * A * real( D ) *
-                                    sin( theta_max ) );
-        double max2 = 1 + fabs( A * B );
-        if ( max1 > max2 )
-            Max = max1;
-        else
-            Max = max2;
+    double Max = 1.0 + fabs( A * B ) + 2.0 * fabs( A * abs( D ) );
+    if ( verbose() ) {
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << " PDF max value : " << Max << std::endl;
     }
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << " PDF max value : " << Max << std::endl;
     setProbMax( Max );
 }
 
 //------------------------------------------------------------------------
 // Method 'init'
 //------------------------------------------------------------------------
 void EvtLambda2PPiForLambdaB2LambdaV::init()
 {
     bool antiparticle = false;
 
-    //introduction
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << " ***********************************************************"
-        << std::endl;
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << " *   Event Model Class : EvtLambda2PPiForLambdaB2LambdaV   *"
-        << std::endl;
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << " ***********************************************************"
-        << std::endl;
+    if ( verbose() ) {
+        //introduction
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << " ***********************************************************"
+            << std::endl;
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << " *   Event Model Class : EvtLambda2PPiForLambdaB2LambdaV   *"
+            << std::endl;
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << " ***********************************************************"
+            << std::endl;
+    }
 
     //check the number of arguments
     checkNArg( 2 );
 
     //check the number of daughters
     checkNDaug( 2 );
 
     const EvtId Id_mother = getParentId();
     const EvtId Id_daug1 = getDaug( 0 );
     const EvtId Id_daug2 = getDaug( 1 );
 
     //lambda  identification
     if ( Id_mother == EvtPDL::getId( "Lambda0" ) ) {
         antiparticle = false;
     } else if ( Id_mother == EvtPDL::getId( "anti-Lambda0" ) ) {
         antiparticle = true;
     } else {
         EvtGenReport( EVTGEN_ERROR, fname.c_str() )
             << " Mother is not a Lambda0 or an anti-Lambda0, but a "
             << EvtPDL::name( Id_mother ) << std::endl;
         abort();
     }
 
     //proton identification
     if ( !( Id_daug1 == EvtPDL::getId( "p+" ) && !antiparticle ) &&
          !( Id_daug1 == EvtPDL::getId( "anti-p-" ) && antiparticle ) ) {
         if ( !antiparticle ) {
             EvtGenReport( EVTGEN_ERROR, fname.c_str() )
                 << " Daughter1 is not a p+, but a " << EvtPDL::name( Id_daug1 )
                 << std::endl;
         } else {
             EvtGenReport( EVTGEN_ERROR, fname.c_str() )
                 << " Daughter1 is not an anti-p-, but a "
                 << EvtPDL::name( Id_daug1 ) << std::endl;
         }
         abort();
     }
 
     //pion identification
     if ( !( Id_daug2 == EvtPDL::getId( "pi-" ) && !antiparticle ) &&
          !( Id_daug2 == EvtPDL::getId( "pi+" ) && antiparticle ) ) {
         if ( !antiparticle ) {
             EvtGenReport( EVTGEN_ERROR, fname.c_str() )
                 << " Daughter2 is not a p-, but a " << EvtPDL::name( Id_daug1 )
                 << std::endl;
         } else {
             EvtGenReport( EVTGEN_ERROR, fname.c_str() )
                 << " Daughter2 is not an p+, but a " << EvtPDL::name( Id_daug1 )
                 << std::endl;
         }
         abort();
     }
     if ( !antiparticle )
         EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
             << " Decay mode successfully initialized : Lambda0 -> p+ pi-"
             << std::endl;
     else
         EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
             << " Decay mode successfully initialized : Anti-Lambda0 -> anti-p- pi+"
             << std::endl;
 
     //identification meson V
     if ( getArg( 1 ) == 1 ) {
         Vtype = VID::JPSI;
         if ( !antiparticle )
             EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
                 << " From : Lambda_b0 -> Lambda J/psi" << std::endl;
         else
             EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
                 << " From : anti-Lambda_b0 -> anti-Lambda J/psi" << std::endl;
     } else if ( getArg( 1 ) == 2 ) {
         Vtype = VID::RHO;
         if ( !antiparticle )
             EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
                 << " From : Lambda_b0 -> Lambda rho0" << std::endl;
         else
             EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
                 << " From : anti-Lambda_b0 -> anti-Lambda rho0" << std::endl;
     } else if ( getArg( 1 ) == 3 ) {
         Vtype = VID::OMEGA;
         if ( !antiparticle )
             EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
                 << " From : Lambda_b0 -> Lambda omega" << std::endl;
         else
             EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
                 << " From : anti-Lambda_b0 -> anti-Lambda omega" << std::endl;
     } else if ( getArg( 1 ) == 4 ) {
         Vtype = VID::RHO_OMEGA_MIXING;
     } else {
         EvtGenReport( EVTGEN_ERROR, fname.c_str() )
             << " Vtype " << getArg( 1 ) << " is unknown" << std::endl;
         if ( !antiparticle ) {
             EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
                 << " From : Lambda_b0 -> Lambda rho-omega-mixing" << std::endl;
         } else {
             EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
                 << " From : anti-Lambda_b0 -> anti-Lambda rho-omega-mixing"
                 << std::endl;
         }
         abort();
     }
 
     //constants
     A = 0.642;
     C = (double)getArg( 0 );
     switch ( Vtype ) {
         case VID::JPSI:
             B = -0.167;
             D = EvtComplex( 0.25, 0.0 );
             break;
         case VID::RHO:
         case VID::OMEGA:
         case VID::RHO_OMEGA_MIXING:
             B = -0.21;
             D = EvtComplex( 0.31, 0.0 );
             break;
         default:
             B = 0;
             D = EvtComplex( 0, 0 );
             break;
     }
 
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << " Lambda decay parameters : " << std::endl;
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << "   - proton asymmetry A = " << A << std::endl;
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << "   - lambda polarisation B = " << B << std::endl;
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << "   - lambdaB polarisation C = " << C << std::endl;
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << "   - lambda density matrix rho+- D = " << D << std::endl;
+    if ( verbose() ) {
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << " Lambda decay parameters : " << std::endl;
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << "   - proton asymmetry A = " << A << std::endl;
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << "   - lambda polarisation B = " << B << std::endl;
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << "   - lambdaB polarisation C = " << C << std::endl;
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << "   - lambda density matrix rho+- D = " << D << std::endl;
+    }
+
+    // Update max prob
+    initProbMax();
 }
 
 //------------------------------------------------------------------------
 // Method 'decay'
 //------------------------------------------------------------------------
 void EvtLambda2PPiForLambdaB2LambdaV::decay( EvtParticle* lambda )
 {
     lambda->makeDaughters( getNDaug(), getDaugs() );
 
     //get proton and pion particles
     EvtParticle* proton = lambda->getDaug( 0 );
     EvtParticle* pion = lambda->getDaug( 1 );
 
     //get resonance masses
     // - LAMBDA        -> mass given by EvtLambdaB2LambdaV class
     // - PROTON & PION -> nominal mass
     double MASS_LAMBDA = lambda->mass();
     double MASS_PROTON = EvtPDL::getMeanMass( EvtPDL::getId( "p+" ) );
     double MASS_PION = EvtPDL::getMeanMass( EvtPDL::getId( "pi-" ) );
 
     //generate random angles
-    double phi = EvtRandom::Flat( 0, 2 * EvtConst::pi );
-    double theta = acos( EvtRandom::Flat( -1, +1 ) );
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << " Angular angles  : theta = " << theta << " ; phi = " << phi
-        << std::endl;
+    double phi = EvtRandom::Flat( 0.0, 2.0 * EvtConst::pi );
+    double theta = acos( EvtRandom::Flat( -1.0, 1.0 ) );
 
-    //computate resonance quadrivectors
+    // Find 4-vectors
     double E_proton = ( MASS_LAMBDA * MASS_LAMBDA + MASS_PROTON * MASS_PROTON -
                         MASS_PION * MASS_PION ) /
                       ( 2 * MASS_LAMBDA );
     double E_pion = ( MASS_LAMBDA * MASS_LAMBDA + MASS_PION * MASS_PION -
                       MASS_PROTON * MASS_PROTON ) /
                     ( 2 * MASS_LAMBDA );
     double P = sqrt( E_proton * E_proton - proton->mass() * proton->mass() );
 
     EvtVector4R P_lambda = lambda->getP4();
     EvtParticle* Mother_lambda = lambda->getParent();
     EvtVector4R lambdab = Mother_lambda->getP4();
 
     double E_lambda = P_lambda.get( 0 );
     double px_M = lambdab.get( 1 );
     double py_M = lambdab.get( 2 );
     double pz_M = lambdab.get( 3 );
     double E_M = lambdab.get( 0 );
 
-    EvtVector4R q_lambdab2(
-        E_M,
-        ( ( 1 / ( sqrt( pow( px_M, 2 ) + pow( py_M, 2 ) ) ) ) *
-          ( ( px_M * ( px_M ) ) + ( py_M * ( py_M ) ) ) ),
-        ( ( 1 / ( sqrt( pow( px_M, 2 ) + pow( py_M, 2 ) ) ) ) *
-          ( -( ( py_M ) * ( px_M ) ) + ( px_M * ( py_M ) ) ) ),
-        ( pz_M ) );
+    const double px_MSq = px_M * px_M;
+    const double py_MSq = py_M * py_M;
+    const double pT_M = sqrt( px_MSq + py_MSq );
+    const double invPT_M = pT_M > 0.0 ? 1.0 / pT_M : 0.0;
+
+    EvtVector4R q_lambdab2( E_M, pT_M, 0.0, pz_M );
 
     EvtVector4R q_lambdab3( E_M, q_lambdab2.get( 3 ), q_lambdab2.get( 1 ),
                             q_lambdab2.get( 2 ) );
 
-    EvtVector4R q_lambda1( E_lambda,
-                           ( ( 1 / ( sqrt( pow( px_M, 2 ) + pow( py_M, 2 ) ) ) ) *
-                             ( ( px_M * ( P_lambda.get( 1 ) ) ) +
-                               ( py_M * ( P_lambda.get( 2 ) ) ) ) ),
-                           ( ( 1 / ( sqrt( pow( px_M, 2 ) + pow( py_M, 2 ) ) ) ) *
-                             ( -( py_M * ( P_lambda.get( 1 ) ) ) +
-                               ( px_M * ( P_lambda.get( 2 ) ) ) ) ),
-                           P_lambda.get( 3 ) );
+    EvtVector4R q_lambda1(
+        E_lambda,
+        invPT_M * ( px_M * P_lambda.get( 1 ) + py_M * P_lambda.get( 2 ) ),
+        invPT_M * ( -py_M * P_lambda.get( 1 ) + px_M * P_lambda.get( 2 ) ),
+        P_lambda.get( 3 ) );
 
     EvtVector4R q_lambda2( E_lambda, q_lambda1.get( 3 ), q_lambda1.get( 1 ),
                            q_lambda1.get( 2 ) );
 
-    double px = q_lambda2.get( 1 );
-    double py = q_lambda2.get( 2 );
-    double pz = q_lambda2.get( 3 );
-
-    EvtVector4R q_lambda4(
-        q_lambda2.get( 0 ),
-        ( ( 1 / ( sqrt( pow( q_lambda2.get( 1 ), 2 ) + pow( q_lambda2.get( 2 ), 2 ) +
-                        pow( q_lambda2.get( 3 ), 2 ) ) ) ) *
-          ( 1 / ( sqrt( pow( q_lambda2.get( 1 ), 2 ) +
-                        pow( q_lambda2.get( 2 ), 2 ) ) ) ) *
-          ( ( q_lambda2.get( 1 ) ) * ( q_lambda2.get( 1 ) ) *
-                ( q_lambda2.get( 3 ) ) +
-            ( ( q_lambda2.get( 2 ) ) * ( q_lambda2.get( 2 ) ) *
-              ( q_lambda2.get( 3 ) ) ) -
-            ( ( q_lambda2.get( 3 ) ) * ( pow( q_lambda2.get( 1 ), 2 ) +
-                                         pow( q_lambda2.get( 2 ), 2 ) ) ) ) ),
-        ( ( ( ( q_lambda2.get( 2 ) ) * ( q_lambda2.get( 1 ) ) ) -
-            ( ( q_lambda2.get( 1 ) ) * ( q_lambda2.get( 2 ) ) ) ) /
-          ( sqrt( pow( q_lambda2.get( 1 ), 2 ) + pow( q_lambda2.get( 2 ), 2 ) ) ) ),
-        ( ( ( 1 / sqrt( pow( q_lambda2.get( 1 ), 2 ) + pow( q_lambda2.get( 2 ), 2 ) +
-                        pow( q_lambda2.get( 3 ), 2 ) ) ) *
-            ( ( ( q_lambda2.get( 1 ) ) * ( q_lambda2.get( 1 ) ) ) +
-              ( ( q_lambda2.get( 2 ) ) * ( q_lambda2.get( 2 ) ) ) +
-              ( ( q_lambda2.get( 3 ) ) * ( q_lambda2.get( 3 ) ) ) ) ) ) );
+    const double E = q_lambda2.get( 0 );
+    const double px = q_lambda2.get( 1 );
+    const double py = q_lambda2.get( 2 );
+    const double pz = q_lambda2.get( 3 );
+    const double pxSq = px * px;
+    const double pySq = py * py;
+    const double pzSq = pz * pz;
+    const double pTSq = pxSq + pySq;
+    const double p = sqrt( pTSq + pzSq );
+    const double invP = p > 0.0 ? 1.0 / p : 0.0;
+    const double invPSq = invP * invP;
+    const double pT = sqrt( pTSq );
+
+    //EvtVector4R q_lambda4( E, 0.0, 0.0, p );
+    EvtVector4R q_lambda4( E, pT, 0.0, pz );
 
     EvtVector4R q_proton1( E_proton, P * sin( theta ) * cos( phi ),
                            P * sin( theta ) * sin( phi ), P * cos( theta ) );
     EvtVector4R q_pion1( E_pion, -P * sin( theta ) * cos( phi ),
                          -P * sin( theta ) * sin( phi ), -P * cos( theta ) );
 
-    EvtVector4R q_proton3(
-        E_proton,
-        ( ( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) + pow( pz, 2 ) ) ) ) *
-          ( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) ) *
-          ( ( q_proton1.get( 1 ) ) * ( px ) * ( pz ) -
-            ( ( q_proton1.get( 2 ) ) * ( py ) *
-              ( ( sqrt( pow( px, 2 ) + pow( py, 2 ) + pow( pz, 2 ) ) ) ) ) +
-            ( ( ( q_proton1.get( 3 ) ) ) *
-              ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) * ( px ) ) ) ),
-        ( ( ( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) + pow( pz, 2 ) ) ) ) ) *
-          ( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) ) *
-          ( ( ( q_proton1.get( 1 ) ) ) * ( py ) * ( pz ) +
-            ( ( q_proton1.get( 2 ) ) * ( px ) *
-              ( ( sqrt( pow( px, 2 ) + pow( py, 2 ) + pow( pz, 2 ) ) ) ) ) +
-            ( ( ( q_proton1.get( 3 ) ) ) *
-              ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) * ( py ) ) ) ),
-        ( ( ( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) + pow( pz, 2 ) ) ) ) ) *
-          ( ( -( q_proton1.get( 1 ) ) ) *
-                ( ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) ) +
-            ( ( q_proton1.get( 3 ) ) * ( pz ) ) ) ) );
+    const double qx_proton1 = q_proton1.get( 1 );
+    const double qy_proton1 = q_proton1.get( 2 );
+    const double qz_proton1 = q_proton1.get( 3 );
+
+    EvtVector4R q_proton3( E_proton,
+                           invPSq * ( qx_proton1 * px * pz - qy_proton1 * py * p +
+                                      qz_proton1 * pT * px ),
+                           invPSq * ( qx_proton1 * py * pz + qy_proton1 * px * p +
+                                      qz_proton1 * pT * py ),
+                           invP * ( -qx_proton1 * pT + qz_proton1 * pz ) );
+
+    const double qx_pion1 = q_pion1.get( 1 );
+    const double qy_pion1 = q_pion1.get( 2 );
+    const double qz_pion1 = q_pion1.get( 3 );
 
     EvtVector4R q_pion3(
         E_pion,
-        ( ( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) + pow( pz, 2 ) ) ) ) *
-          ( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) ) *
-          ( ( q_pion1.get( 1 ) ) * ( px ) * ( pz ) -
-            ( ( q_pion1.get( 2 ) ) * ( py ) *
-              ( ( sqrt( pow( px, 2 ) + pow( py, 2 ) + pow( pz, 2 ) ) ) ) ) +
-            ( ( ( q_pion1.get( 3 ) ) ) *
-              ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) * ( px ) ) ) ),
-        ( ( ( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) + pow( pz, 2 ) ) ) ) ) *
-          ( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) ) *
-          ( ( q_pion1.get( 1 ) ) * ( py ) * ( pz ) +
-            ( ( q_pion1.get( 2 ) ) * ( px ) *
-              ( ( sqrt( pow( px, 2 ) + pow( py, 2 ) + pow( pz, 2 ) ) ) ) ) +
-            ( ( ( q_pion1.get( 3 ) ) ) *
-              ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) * ( py ) ) ) ),
-        ( ( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) + pow( pz, 2 ) ) ) ) *
-          ( ( -( q_pion1.get( 1 ) ) ) * ( ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) ) +
-            ( ( q_pion1.get( 3 ) ) * ( pz ) ) ) ) );
-
-    EvtVector4R q_proton5( q_proton3.get( 0 ), ( q_proton3.get( 2 ) ),
-                           ( q_proton3.get( 3 ) ), ( q_proton3.get( 1 ) ) );
-
-    EvtVector4R q_pion5( q_pion3.get( 0 ), ( q_pion3.get( 2 ) ),
-                         ( q_pion3.get( 3 ) ), ( q_pion3.get( 1 ) ) );
-
-    EvtVector4R q_proton( q_proton5.get( 0 ),
-                          ( ( 1 / ( sqrt( pow( px_M, 2 ) + pow( py_M, 2 ) ) ) ) *
-                            ( ( px_M * ( q_proton5.get( 1 ) ) ) -
-                              ( py_M * ( q_proton5.get( 2 ) ) ) ) ),
-                          ( ( 1 / ( sqrt( pow( px_M, 2 ) + pow( py_M, 2 ) ) ) ) *
-                            ( ( py_M * ( q_proton5.get( 1 ) ) ) +
-                              ( px_M * ( q_proton5.get( 2 ) ) ) ) ),
-                          ( q_proton5.get( 3 ) ) );
+        invPSq * ( qx_pion1 * px * pz - qy_pion1 * py * p + qz_pion1 * pT * px ),
+        invPSq * ( qx_pion1 * py * pz + qy_pion1 * px * p + qz_pion1 * pT * py ),
+        invP * ( -qx_pion1 * pT + qz_pion1 * pz ) );
+
+    EvtVector4R q_proton5( q_proton3.get( 0 ), q_proton3.get( 2 ),
+                           q_proton3.get( 3 ), q_proton3.get( 1 ) );
+
+    EvtVector4R q_pion5( q_pion3.get( 0 ), q_pion3.get( 2 ), q_pion3.get( 3 ),
+                         q_pion3.get( 1 ) );
+
+    EvtVector4R q_proton(
+        q_proton5.get( 0 ),
+        invPT_M * ( px_M * q_proton5.get( 1 ) - py_M * q_proton5.get( 2 ) ),
+        invPT_M * ( py_M * q_proton5.get( 1 ) + px_M * q_proton5.get( 2 ) ),
+        q_proton5.get( 3 ) );
 
     EvtVector4R q_pion(
         q_pion5.get( 0 ),
-        ( ( 1 / ( sqrt( pow( px_M, 2 ) + pow( py_M, 2 ) ) ) ) *
-          ( ( px_M * ( q_pion5.get( 1 ) ) ) - ( py_M * ( q_pion5.get( 2 ) ) ) ) ),
-        ( ( 1 / ( sqrt( pow( px_M, 2 ) + pow( py_M, 2 ) ) ) ) *
-          ( ( py_M * ( q_pion5.get( 1 ) ) ) + ( px_M * ( q_pion5.get( 2 ) ) ) ) ),
-        ( q_pion5.get( 3 ) ) );
-
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambdab  px: " << px_M << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambdab  py: " << py_M << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambdab  pz: " << pz_M << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambdab  E: " << E_M << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambdab2  px:  " << q_lambdab2.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambdab2  py:  " << q_lambdab2.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambdab2  pz:  " << q_lambdab2.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambdab2  E:   " << q_lambdab2.get( 0 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambdab3  px:  " << q_lambdab3.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambdab3  py:  " << q_lambdab3.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambdab3  pz:  " << q_lambdab3.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambdab3  E:   " << q_lambdab3.get( 0 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda 0  px:  " << P_lambda.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda 0  py:  " << P_lambda.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda 0  pz:  " << P_lambda.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda 0  E:   " << P_lambda.get( 0 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda 1  px:  " << q_lambda1.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda 1  py:  " << q_lambda1.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda 1  pz:  " << q_lambda1.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda 1  E:   " << q_lambda1.get( 0 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda 2  px:  " << q_lambda2.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda 2  py:  " << q_lambda2.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda 2  pz:  " << q_lambda2.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda 2  E:   " << q_lambda2.get( 0 ) << std::endl;
-
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda  px: " << px << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda  py: " << py << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambda  pz: " << pz << std::endl;
-
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " pion 1 px:  " << q_pion1.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " pion 1 py:  " << q_pion1.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " pion 1 pz:  " << q_pion1.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " pion 1 E:   " << q_pion1.get( 0 ) << std::endl;
-
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " pion 3 px:  " << q_pion3.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " pion 3 px:  " << q_pion3.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " pion 3 py:  " << q_pion3.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " pion 3 pz:  " << q_pion3.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " pion 3 E:   " << q_pion3.get( 0 ) << std::endl;
-
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " pion 5 px:  " << q_pion5.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " pion 5 py:  " << q_pion5.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " pion 5 pz:  " << q_pion5.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " pion 5 E:   " << q_pion5.get( 0 ) << std::endl;
-
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " proton 1  px:  " << q_proton1.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " proton 1  py:  " << q_proton1.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " proton 1  pz:  " << q_proton1.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " proton 1  E:   " << q_proton1.get( 0 ) << std::endl;
-
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " proton 3  px:  " << q_proton3.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " proton 3  py:  " << q_proton3.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " proton 3  pz:  " << q_proton3.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " proton 3  E:   " << q_proton3.get( 0 ) << std::endl;
-
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " proton 5  px:  " << q_proton5.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " proton 5  py:  " << q_proton5.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " proton 5  pz:  " << q_proton5.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " proton 5  E:   " << q_proton5.get( 0 ) << std::endl;
-
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " proton  px:  " << q_proton.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " proton  py:  " << q_proton.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << "proton  pz:  " << q_proton.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " pion px:  " << q_pion.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " pion py:  " << q_pion.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " pion pz:  " << q_pion.get( 3 ) << std::endl;
-
-    ;
-
-    ///////////*******NEW********//////////////////////
-
-    //set quadrivectors to particles
+        invPT_M * ( px_M * q_pion5.get( 1 ) - py_M * q_pion5.get( 2 ) ),
+        invPT_M * ( py_M * q_pion5.get( 1 ) + px_M * q_pion5.get( 2 ) ),
+        q_pion5.get( 3 ) );
+
+    // Set particle 4 vectors
     proton->init( getDaugs()[0], q_proton );
     pion->init( getDaugs()[1], q_pion );
 
-    //computate pdf
-    //double pdf = 1 + A*B*cos(theta) - EvtConst::pi/2.0*C*A*real(D*EvtComplex(cos(phi),sin(phi)))*sin(theta);
-    double pdf = 1 + A * B * cos( theta ) +
-                 2 * A * real( D * EvtComplex( cos( phi ), sin( phi ) ) ) *
+    //compute pdf
+    double pdf = 1.0 + A * B * cos( theta ) +
+                 2.0 * A * real( D * EvtComplex( cos( phi ), sin( phi ) ) ) *
                      sin( theta );
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << " Lambda decay pdf value : " << pdf << std::endl;
     //set probability
     setProb( pdf );
 
-    return;
+    if ( verbose() ) {
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << " Angular angles  : theta = " << theta << " ; phi = " << phi
+            << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambdab  px: " << px_M << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambdab  py: " << py_M << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambdab  pz: " << pz_M << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambdab  E: " << E_M << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambdab2  px:  " << q_lambdab2.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambdab2  py:  " << q_lambdab2.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambdab2  pz:  " << q_lambdab2.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambdab2  E:   " << q_lambdab2.get( 0 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambdab3  px:  " << q_lambdab3.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambdab3  py:  " << q_lambdab3.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambdab3  pz:  " << q_lambdab3.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambdab3  E:   " << q_lambdab3.get( 0 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda 0  px:  " << P_lambda.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda 0  py:  " << P_lambda.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda 0  pz:  " << P_lambda.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda 0  E:   " << P_lambda.get( 0 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda 1  px:  " << q_lambda1.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda 1  py:  " << q_lambda1.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda 1  pz:  " << q_lambda1.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda 1  E:   " << q_lambda1.get( 0 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda 2  px:  " << q_lambda2.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda 2  py:  " << q_lambda2.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda 2  pz:  " << q_lambda2.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda 2  E:   " << q_lambda2.get( 0 ) << std::endl;
+
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda  px: " << px << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda  py: " << py << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambda  pz: " << pz << std::endl;
+
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " pion 1 px:  " << q_pion1.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " pion 1 py:  " << q_pion1.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " pion 1 pz:  " << q_pion1.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " pion 1 E:   " << q_pion1.get( 0 ) << std::endl;
+
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " pion 3 px:  " << q_pion3.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " pion 3 px:  " << q_pion3.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " pion 3 py:  " << q_pion3.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " pion 3 pz:  " << q_pion3.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " pion 3 E:   " << q_pion3.get( 0 ) << std::endl;
+
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " pion 5 px:  " << q_pion5.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " pion 5 py:  " << q_pion5.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " pion 5 pz:  " << q_pion5.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " pion 5 E:   " << q_pion5.get( 0 ) << std::endl;
+
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " proton 1  px:  " << q_proton1.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " proton 1  py:  " << q_proton1.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " proton 1  pz:  " << q_proton1.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " proton 1  E:   " << q_proton1.get( 0 ) << std::endl;
+
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " proton 3  px:  " << q_proton3.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " proton 3  py:  " << q_proton3.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " proton 3  pz:  " << q_proton3.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " proton 3  E:   " << q_proton3.get( 0 ) << std::endl;
+
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " proton 5  px:  " << q_proton5.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " proton 5  py:  " << q_proton5.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " proton 5  pz:  " << q_proton5.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " proton 5  E:   " << q_proton5.get( 0 ) << std::endl;
+
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " proton  px:  " << q_proton.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " proton  py:  " << q_proton.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << "proton  pz:  " << q_proton.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " pion px:  " << q_pion.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " pion py:  " << q_pion.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " pion pz:  " << q_pion.get( 3 ) << std::endl;
+
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << " Lambda decay pdf value : " << pdf << std::endl;
+    }
 }
 
 //************************************************************************
 //*                                                                      *
-//*                Class EvtLambda2PPiForLambdaB2LambdaV                 *
+//*                Class EvtV2VpVmForLambdaB2LambdaV                     *
 //*                                                                      *
 //************************************************************************
 
 //------------------------------------------------------------------------
 // Constructor
 //------------------------------------------------------------------------
 EvtV2VpVmForLambdaB2LambdaV::EvtV2VpVmForLambdaB2LambdaV()
 {
     //set facility name
     fname = "EvtGen.EvtV2VpVmForLambdaB2LambdaV";
 }
 
 //------------------------------------------------------------------------
 // Method 'getName'
 //------------------------------------------------------------------------
 std::string EvtV2VpVmForLambdaB2LambdaV::getName()
 {
     return "V2VPVMFORLAMBDAB2LAMBDAV";
 }
 
 //------------------------------------------------------------------------
 // Method 'clone'
 //------------------------------------------------------------------------
 EvtDecayBase* EvtV2VpVmForLambdaB2LambdaV::clone()
 {
     return new EvtV2VpVmForLambdaB2LambdaV;
 }
 
 //------------------------------------------------------------------------
 // Method 'initProbMax'
 //------------------------------------------------------------------------
 void EvtV2VpVmForLambdaB2LambdaV::initProbMax()
 {
     //maximum
-    double Max = 0;
+    double Max = 0.0;
     if ( Vtype == VID::JPSI ) {
-        if ( ( 1 - 3 * A ) > 0 )
-            Max = 2 * ( 1 - A );
+        if ( ( 1.0 - 3.0 * A ) > 0.0 )
+            Max = 2.0 * ( 1.0 - A );
         else
-            Max = 1 + A;
+            Max = 1.0 + A;
     } else {
-        if ( ( 3 * A - 1 ) >= 0 )
-            Max = 2 * A;
+        if ( ( 3.0 * A - 1.0 ) >= 0.0 )
+            Max = 2.0 * A;
         else
-            Max = 1 - A;
+            Max = 1.0 - A;
     }
 
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << " PDF max value : " << Max << std::endl;
+    if ( verbose() ) {
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << " PDF max value : " << Max << std::endl;
+    }
     setProbMax( Max );
 }
 
 //------------------------------------------------------------------------
 // Method 'init'
 //------------------------------------------------------------------------
 void EvtV2VpVmForLambdaB2LambdaV::init()
 {
-    //introduction
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << " ***********************************************************"
-        << std::endl;
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << " *     Event Model Class : EvtV2VpVmForLambdaB2LambdaV     *"
-        << std::endl;
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << " ***********************************************************"
-        << std::endl;
+    if ( verbose() ) {
+        //introduction
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << " ***********************************************************"
+            << std::endl;
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << " *     Event Model Class : EvtV2VpVmForLambdaB2LambdaV     *"
+            << std::endl;
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << " ***********************************************************"
+            << std::endl;
+    }
 
     //check the number of arguments
     checkNArg( 2 );
 
     //check the number of daughters
     checkNDaug( 2 );
 
     const EvtId Id_mother = getParentId();
     const EvtId Id_daug1 = getDaug( 0 );
     const EvtId Id_daug2 = getDaug( 1 );
 
     //identification meson V
     if ( getArg( 1 ) == 1 )
         Vtype = VID::JPSI;
     else if ( getArg( 1 ) == 2 )
         Vtype = VID::RHO;
     else if ( getArg( 1 ) == 3 )
         Vtype = VID::OMEGA;
     else if ( getArg( 1 ) == 4 )
         Vtype = VID::RHO_OMEGA_MIXING;
     else {
         EvtGenReport( EVTGEN_ERROR, fname.c_str() )
             << " Vtype " << getArg( 1 ) << " is unknown" << std::endl;
         abort();
     }
 
     //vector meson V
     if ( Id_mother == EvtPDL::getId( "J/psi" ) && Vtype == VID::JPSI ) {
     } else if ( Id_mother == EvtPDL::getId( "omega" ) && Vtype == VID::OMEGA ) {
     } else if ( Id_mother == EvtPDL::getId( "rho0" ) && Vtype == VID::RHO ) {
     } else if ( ( Id_mother == EvtPDL::getId( "rho0" ) ||
                   Id_mother == EvtPDL::getId( "omega" ) ) &&
                 Vtype == VID::RHO_OMEGA_MIXING ) {
     } else {
         EvtGenReport( EVTGEN_ERROR, fname.c_str() )
             << " Mother is not a J/psi, phi or rho0 but a "
             << EvtPDL::name( Id_mother ) << std::endl;
         abort();
     }
 
     //daughters for each V possibility
     switch ( Vtype ) {
         case VID::JPSI:
             if ( Id_daug1 != EvtPDL::getId( "mu+" ) ) {
                 EvtGenReport( EVTGEN_ERROR, fname.c_str() )
                     << " Daughter1 is not a mu+, but a "
                     << EvtPDL::name( Id_daug1 ) << std::endl;
                 abort();
             }
             if ( Id_daug2 != EvtPDL::getId( "mu-" ) ) {
                 EvtGenReport( EVTGEN_ERROR, fname.c_str() )
                     << " Daughter2 is not a mu-, but a "
                     << EvtPDL::name( Id_daug2 ) << std::endl;
                 abort();
             }
             EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
                 << " Decay mode successfully initialized : J/psi -> mu+ mu-"
                 << std::endl;
             break;
 
         case VID::RHO:
         case VID::OMEGA:
         case VID::RHO_OMEGA_MIXING:
             if ( Id_daug1 != EvtPDL::getId( "pi+" ) ) {
                 EvtGenReport( EVTGEN_ERROR, fname.c_str() )
                     << " Daughter1 is not a pi+, but a "
                     << EvtPDL::name( Id_daug1 ) << std::endl;
                 abort();
             }
             if ( Id_daug2 != EvtPDL::getId( "pi-" ) ) {
                 EvtGenReport( EVTGEN_ERROR, fname.c_str() )
                     << " Daughter2 is not a pi-, but a "
                     << EvtPDL::name( Id_daug2 ) << std::endl;
                 abort();
             }
             if ( Vtype == VID::RHO )
                 EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
                     << " Decay mode successfully initialized : rho0 -> pi+ pi-"
                     << std::endl;
             if ( Vtype == VID::OMEGA )
                 EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
                     << " Decay mode successfully initialized : omega -> pi+ pi-"
                     << std::endl;
             if ( Vtype == VID::RHO_OMEGA_MIXING )
                 EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
                     << " Decay mode successfully initialized : rho-omega mixing -> pi+ pi-"
                     << std::endl;
             break;
 
         default:
             EvtGenReport( EVTGEN_ERROR, fname.c_str() )
                 << "No decay mode chosen ! " << std::endl;
             abort();
             break;
     }
 
     //fix dynamics parameters
     switch ( Vtype ) {
         case VID::JPSI:
             A = 0.66;
             break;
         case VID::RHO:
         case VID::OMEGA:
         case VID::RHO_OMEGA_MIXING:
             A = 0.79;
             break;
         default:
             A = 0;
             break;
     }
 
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << " V decay parameters : " << std::endl;
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << "   - V density matrix rho00 A = " << A << std::endl;
+    if ( verbose() ) {
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << " V decay parameters : " << std::endl;
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << "   - V density matrix rho00 A = " << A << std::endl;
+    }
 }
 
 //------------------------------------------------------------------------
 // Method 'decay'
 //------------------------------------------------------------------------
 void EvtV2VpVmForLambdaB2LambdaV::decay( EvtParticle* V )
 {
     V->makeDaughters( getNDaug(), getDaugs() );
 
     //get Vp and Vm particles
     EvtParticle* Vp = V->getDaug( 0 );
     EvtParticle* Vm = V->getDaug( 1 );
 
     //get resonance masses
     // - V         -> mass given by EvtLambdaB2LambdaV class
     // - Vp & Vm   -> nominal mass
     double MASS_V = V->mass();
     double MASS_VM = 0;
     switch ( Vtype ) {
         case VID::JPSI:
             MASS_VM = EvtPDL::getMeanMass( EvtPDL::getId( "mu-" ) );
             break;
         case VID::RHO:
         case VID::OMEGA:
         case VID::RHO_OMEGA_MIXING:
             MASS_VM = EvtPDL::getMeanMass( EvtPDL::getId( "pi-" ) );
             break;
         default:
             MASS_VM = 0;
             break;
     }
     double MASS_VP = MASS_VM;
 
     //generate random angles
     double phi = EvtRandom::Flat( 0, 2 * EvtConst::pi );
     double theta = acos( EvtRandom::Flat( -1, +1 ) );
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << " Angular angles  : theta = " << theta << " ; phi = " << phi
-        << std::endl;
 
-    //computate resonance quadrivectors
+    // Get resonance 4-vectors
     double E_Vp = ( MASS_V * MASS_V + MASS_VP * MASS_VP - MASS_VM * MASS_VM ) /
                   ( 2 * MASS_V );
     double E_Vm = ( MASS_V * MASS_V + MASS_VM * MASS_VM - MASS_VP * MASS_VP ) /
                   ( 2 * MASS_V );
     double P = sqrt( E_Vp * E_Vp - Vp->mass() * Vp->mass() );
 
     EvtVector4R P_V = V->getP4();
     EvtParticle* Mother_V = V->getParent();
     EvtVector4R lambdab = Mother_V->getP4();
 
-    double E_V = ( P_V.get( 0 ) );
-    double px_M = lambdab.get( 1 );
-    double py_M = lambdab.get( 2 );
-    double pz_M = lambdab.get( 3 );
-    double E_M = lambdab.get( 0 );
+    const double E_V = ( P_V.get( 0 ) );
+    const double px_M = lambdab.get( 1 );
+    const double py_M = lambdab.get( 2 );
+    const double pz_M = lambdab.get( 3 );
+    const double E_M = lambdab.get( 0 );
+    const double px_MSq = px_M * px_M;
+    const double py_MSq = py_M * py_M;
+    const double pT_MSq = px_MSq + py_MSq;
+    const double pT_M = sqrt( pT_MSq );
+    const double invPT_M = pT_M > 0.0 ? 1.0 / pT_M : 0.0;
 
-    EvtVector4R q_lambdab2(
-        E_M,
-        ( ( 1 / ( sqrt( pow( px_M, 2 ) + pow( py_M, 2 ) ) ) ) *
-          ( ( px_M * ( px_M ) ) + ( py_M * ( py_M ) ) ) ),
-        ( ( 1 / ( sqrt( pow( px_M, 2 ) + pow( py_M, 2 ) ) ) ) *
-          ( -( ( py_M ) * ( px_M ) ) + ( px_M * ( py_M ) ) ) ),
-        ( pz_M ) );
+    EvtVector4R q_lambdab2( E_M, pT_M, 0.0, pz_M );
 
     EvtVector4R q_lambdab3( E_M, q_lambdab2.get( 3 ), q_lambdab2.get( 1 ),
                             q_lambdab2.get( 2 ) );
 
-    EvtVector4R q_V1(
-        E_V,
-        ( ( 1 / ( sqrt( pow( px_M, 2 ) + pow( py_M, 2 ) ) ) ) *
-          ( ( px_M * ( P_V.get( 1 ) ) ) + ( py_M * ( P_V.get( 2 ) ) ) ) ),
-        ( ( 1 / ( sqrt( pow( px_M, 2 ) + pow( py_M, 2 ) ) ) ) *
-          ( -( py_M * ( P_V.get( 1 ) ) ) + ( px_M * ( P_V.get( 2 ) ) ) ) ),
-        P_V.get( 3 ) );
+    EvtVector4R q_V1( E_V,
+                      invPT_M * ( px_M * P_V.get( 1 ) + py_M * P_V.get( 2 ) ),
+                      invPT_M * ( -py_M * P_V.get( 1 ) + px_M * P_V.get( 2 ) ),
+                      P_V.get( 3 ) );
 
     EvtVector4R q_V2( E_V, q_V1.get( 3 ), q_V1.get( 1 ), q_V1.get( 2 ) );
 
-    double px = -( q_V2.get( 1 ) );
-    double py = -( q_V2.get( 2 ) );
-    double pz = -( q_V2.get( 3 ) );
-
-    EvtVector4R q_V4(
-        q_V2.get( 0 ),
-        ( ( 1 / ( sqrt( pow( q_V2.get( 1 ), 2 ) + pow( q_V2.get( 2 ), 2 ) +
-                        pow( q_V2.get( 3 ), 2 ) ) ) ) *
-          ( 1 / ( sqrt( pow( q_V2.get( 1 ), 2 ) + pow( q_V2.get( 2 ), 2 ) ) ) ) *
-          ( ( q_V2.get( 1 ) ) * ( q_V2.get( 1 ) ) * ( q_V2.get( 3 ) ) +
-            ( ( q_V2.get( 2 ) ) * ( q_V2.get( 2 ) ) * ( q_V2.get( 3 ) ) ) -
-            ( ( q_V2.get( 3 ) ) *
-              ( pow( q_V2.get( 1 ), 2 ) + pow( q_V2.get( 2 ), 2 ) ) ) ) ),
-        ( ( ( ( q_V2.get( 2 ) ) * ( q_V2.get( 1 ) ) ) -
-            ( ( q_V2.get( 1 ) ) * ( q_V2.get( 2 ) ) ) ) /
-          ( sqrt( pow( q_V2.get( 1 ), 2 ) + pow( q_V2.get( 2 ), 2 ) ) ) ),
-        ( ( ( 1 / sqrt( pow( q_V2.get( 1 ), 2 ) + pow( q_V2.get( 2 ), 2 ) +
-                        pow( q_V2.get( 3 ), 2 ) ) ) *
-            ( ( ( q_V2.get( 1 ) ) * ( q_V2.get( 1 ) ) ) +
-              ( ( q_V2.get( 2 ) ) * ( q_V2.get( 2 ) ) ) +
-              ( ( q_V2.get( 3 ) ) * ( q_V2.get( 3 ) ) ) ) ) ) );
+    const double px = -q_V2.get( 1 );
+    const double py = -q_V2.get( 2 );
+    const double pz = -q_V2.get( 3 );
+    const double pxSq = px * px;
+    const double pySq = py * py;
+    const double pzSq = pz * pz;
+    const double pTSq = pxSq + pySq;
+    const double pSq = pTSq + pzSq;
+    const double p = sqrt( pSq );
+    const double invP = p > 0.0 ? 1.0 / p : 0.0;
+    const double pT = sqrt( pTSq );
+    const double invPT = pT > 0.0 ? 1.0 / pT : 0.0;
+
+    EvtVector4R q_V4( q_V2.get( 0 ), 0.0, pT, p );
 
     EvtVector4R q_Vp1( E_Vp, P * sin( theta ) * cos( phi ),
                        P * sin( theta ) * sin( phi ), P * cos( theta ) );
     EvtVector4R q_Vm1( E_Vm, -P * sin( theta ) * cos( phi ),
                        -P * sin( theta ) * sin( phi ), -P * cos( theta ) );
 
-    EvtVector4R q_Vp3(
-        q_Vp1.get( 0 ),
-        ( ( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) + pow( pz, 2 ) ) ) ) *
-          ( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) ) *
-          ( ( q_Vp1.get( 1 ) ) * ( px ) * ( pz ) +
-            ( ( q_Vp1.get( 2 ) ) * ( py ) *
-              ( ( sqrt( pow( px, 2 ) + pow( py, 2 ) + pow( pz, 2 ) ) ) ) ) -
-            ( ( ( q_Vp1.get( 3 ) ) ) * ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) *
-              ( px ) ) ) ),
-        ( ( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) + pow( pz, 2 ) ) ) ) *
-          ( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) ) *
-          ( ( ( q_Vp1.get( 1 ) ) ) * ( py ) * ( pz ) -
-            ( ( q_Vp1.get( 2 ) ) * ( px ) *
-              ( ( sqrt( pow( px, 2 ) + pow( py, 2 ) + pow( pz, 2 ) ) ) ) ) -
-            ( ( ( q_Vp1.get( 3 ) ) ) * ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) *
-              ( py ) ) ) ),
-        ( ( -( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) + pow( pz, 2 ) ) ) ) ) *
-          ( ( q_Vp1.get( 1 ) ) * ( ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) ) +
-            ( ( q_Vp1.get( 3 ) ) * ( pz ) ) ) ) );
-
-    EvtVector4R q_Vm3(
-        q_Vm1.get( 0 ),
-        ( ( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) + pow( pz, 2 ) ) ) ) *
-          ( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) ) *
-          ( ( q_Vm1.get( 1 ) ) * ( px ) * ( pz ) +
-            ( ( q_Vm1.get( 2 ) ) * ( py ) *
-              ( ( sqrt( pow( px, 2 ) + pow( py, 2 ) + pow( pz, 2 ) ) ) ) ) -
-            ( ( ( q_Vm1.get( 3 ) ) ) * ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) *
-              ( px ) ) ) ),
-        ( ( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) + pow( pz, 2 ) ) ) ) *
-          ( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) ) *
-          ( ( ( q_Vm1.get( 1 ) ) ) * ( py ) * ( pz ) -
-            ( ( q_Vm1.get( 2 ) ) * ( px ) *
-              ( ( sqrt( pow( px, 2 ) + pow( py, 2 ) + pow( pz, 2 ) ) ) ) ) -
-            ( ( ( q_Vm1.get( 3 ) ) ) * ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) *
-              ( py ) ) ) ),
-        ( ( -( 1 / ( sqrt( pow( px, 2 ) + pow( py, 2 ) + pow( pz, 2 ) ) ) ) ) *
-          ( ( q_Vm1.get( 1 ) ) * ( ( sqrt( pow( px, 2 ) + pow( py, 2 ) ) ) ) +
-            ( ( q_Vm1.get( 3 ) ) * ( pz ) ) ) ) );
-
-    EvtVector4R q_Vp5( q_Vp3.get( 0 ), ( q_Vp3.get( 2 ) ), ( q_Vp3.get( 3 ) ),
-                       ( q_Vp3.get( 1 ) ) );
-
-    EvtVector4R q_Vm5( q_Vm3.get( 0 ), ( q_Vm3.get( 2 ) ), ( q_Vm3.get( 3 ) ),
-                       ( q_Vm3.get( 1 ) ) );
-
-    EvtVector4R q_Vp(
-        q_Vp5.get( 0 ),
-        ( ( 1 / ( sqrt( pow( px_M, 2 ) + pow( py_M, 2 ) ) ) ) *
-          ( ( px_M * ( q_Vp5.get( 1 ) ) ) - ( py_M * ( q_Vp5.get( 2 ) ) ) ) ),
-        ( ( 1 / ( sqrt( pow( px_M, 2 ) + pow( py_M, 2 ) ) ) ) *
-          ( ( py_M * ( q_Vp5.get( 1 ) ) ) + ( px_M * ( q_Vp5.get( 2 ) ) ) ) ),
-        ( q_Vp5.get( 3 ) ) );
-
-    EvtVector4R q_Vm(
-        q_Vm5.get( 0 ),
-        ( ( 1 / ( sqrt( pow( px_M, 2 ) + pow( py_M, 2 ) ) ) ) *
-          ( ( px_M * ( q_Vm5.get( 1 ) ) ) - ( py_M * ( q_Vm5.get( 2 ) ) ) ) ),
-        ( ( 1 / ( sqrt( pow( px_M, 2 ) + pow( py_M, 2 ) ) ) ) *
-          ( ( py_M * ( q_Vm5.get( 1 ) ) ) + ( px_M * ( q_Vm5.get( 2 ) ) ) ) ),
-        ( q_Vm5.get( 3 ) ) );
-
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambdab  px: " << px_M << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambdab  py: " << py_M << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambdab  pz: " << pz_M << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambdab  E: " << E_M << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambdab2  px:  " << q_lambdab2.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambdab2  py:  " << q_lambdab2.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambdab2  pz:  " << q_lambdab2.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambdab2  E:   " << q_lambdab2.get( 0 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambdab3  px:  " << q_lambdab3.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambdab3  py:  " << q_lambdab3.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambdab3  pz:  " << q_lambdab3.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Lambdab3  E:   " << q_lambdab3.get( 0 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " V 0  px:  " << P_V.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " V 0  py:  " << P_V.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " V 0  pz:  " << P_V.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " V 0  E:   " << P_V.get( 0 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " V 1  px:  " << q_V1.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " V 1  py:  " << q_V1.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " V 1  pz:  " << q_V1.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " V 1  E:   " << q_V1.get( 0 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " V 2  px:  " << q_V2.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " V 2  py:  " << q_V2.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " V 2  pz:  " << q_V2.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " V 2  E:   " << q_V2.get( 0 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() ) << " V  px: " << px << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() ) << " V  py: " << py << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() ) << " V  pz: " << pz << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vm 1 px:  " << q_Vm1.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vm 1 py:  " << q_Vm1.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vm 1 pz:  " << q_Vm1.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vm 1 E:   " << q_Vm1.get( 0 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vm 3 px:  " << q_Vm3.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vm 3 px:  " << q_Vm3.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vm 3 py:  " << q_Vm3.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vm 3 pz:  " << q_Vm3.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vm 3 E:   " << q_Vm3.get( 0 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vm 5 px:  " << q_Vm5.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vm 5 py:  " << q_Vm5.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vm 5 pz:  " << q_Vm5.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vm 5 E:   " << q_Vm5.get( 0 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vp 1  px:  " << q_Vp1.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vp 1  py:  " << q_Vp1.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vp 1  pz:  " << q_Vp1.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vp 1  E:   " << q_Vp1.get( 0 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vp 3  px:  " << q_Vp3.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vp 3  py:  " << q_Vp3.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vp 3  pz:  " << q_Vp3.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vp 3  E:   " << q_Vp3.get( 0 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vp 5  px:  " << q_Vp5.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vp 5  py:  " << q_Vp5.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vp 5  pz:  " << q_Vp5.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vp 5  E:   " << q_Vp5.get( 0 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vp  px:  " << q_Vp.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vp  py:  " << q_Vp.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << "Vp  pz:  " << q_Vp.get( 3 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vm px:  " << q_Vm.get( 1 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vm py:  " << q_Vm.get( 2 ) << std::endl;
-    EvtGenReport( EVTGEN_INFO, fname.c_str() )
-        << " Vm pz:  " << q_Vm.get( 3 ) << std::endl;
-
-    //set quadrivectors to particles
+    EvtVector4R q_Vp3( q_Vp1.get( 0 ),
+                       invP * invPT *
+                           ( q_Vp1.get( 1 ) * px * pz + q_Vp1.get( 2 ) * py * p -
+                             q_Vp1.get( 3 ) * pT * px ),
+                       invP * invPT *
+                           ( q_Vp1.get( 1 ) * py * pz - q_Vp1.get( 2 ) * px * p -
+                             q_Vp1.get( 3 ) * pT * py ),
+                       -invP * ( q_Vp1.get( 1 ) * pT + q_Vp1.get( 3 ) * pz ) );
+
+    EvtVector4R q_Vm3( q_Vm1.get( 0 ),
+                       invP * invPT *
+                           ( q_Vm1.get( 1 ) * px * pz + q_Vm1.get( 2 ) * py * p -
+                             q_Vm1.get( 3 ) * pT * px ),
+                       invP * invPT *
+                           ( q_Vm1.get( 1 ) * py * pz - q_Vm1.get( 2 ) * px * p -
+                             q_Vm1.get( 3 ) * pT * py ),
+                       -invP * ( q_Vm1.get( 1 ) * pT + q_Vm1.get( 3 ) * pz ) );
+
+    EvtVector4R q_Vp5( q_Vp3.get( 0 ), q_Vp3.get( 2 ), q_Vp3.get( 3 ),
+                       q_Vp3.get( 1 ) );
+
+    EvtVector4R q_Vm5( q_Vm3.get( 0 ), q_Vm3.get( 2 ), q_Vm3.get( 3 ),
+                       q_Vm3.get( 1 ) );
+
+    EvtVector4R q_Vp( q_Vp5.get( 0 ),
+                      invPT_M * ( px_M * q_Vp5.get( 1 ) - py_M * q_Vp5.get( 2 ) ),
+                      invPT_M * ( py_M * q_Vp5.get( 1 ) + px_M * q_Vp5.get( 2 ) ),
+                      q_Vp5.get( 3 ) );
+
+    EvtVector4R q_Vm( q_Vm5.get( 0 ),
+                      invPT_M * ( px_M * q_Vm5.get( 1 ) - py_M * q_Vm5.get( 2 ) ),
+                      invPT_M * ( py_M * q_Vm5.get( 1 ) + px_M * q_Vm5.get( 2 ) ),
+                      q_Vm5.get( 3 ) );
+
+    // Set particle 4-momenta
     Vp->init( getDaugs()[0], q_Vp );
     Vm->init( getDaugs()[1], q_Vm );
 
-    //computate pdf
-    double pdf = 0;
+    //compute pdf
+    double pdf = 0.0;
     if ( Vtype == VID::JPSI ) {
         //leptonic case
-        pdf = ( 1 - 3 * A ) * cos( theta ) * cos( theta ) + ( 1 + A );
+        pdf = ( 1.0 - 3.0 * A ) * cos( theta ) * cos( theta ) + ( 1.0 + A );
     } else {
         //hadronic case
-        pdf = ( 3 * A - 1 ) * cos( theta ) * cos( theta ) + ( 1 - A );
+        pdf = ( 3.0 * A - 1.0 ) * cos( theta ) * cos( theta ) + ( 1.0 - A );
     }
-    EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
-        << " V decay pdf value : " << pdf << std::endl;
 
     //set probability
     setProb( pdf );
-    return;
+
+    if ( verbose() ) {
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << " Angular angles  : theta = " << theta << " ; phi = " << phi
+            << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambdab  px: " << px_M << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambdab  py: " << py_M << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambdab  pz: " << pz_M << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambdab  E: " << E_M << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambdab2  px:  " << q_lambdab2.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambdab2  py:  " << q_lambdab2.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambdab2  pz:  " << q_lambdab2.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambdab2  E:   " << q_lambdab2.get( 0 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambdab3  px:  " << q_lambdab3.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambdab3  py:  " << q_lambdab3.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambdab3  pz:  " << q_lambdab3.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Lambdab3  E:   " << q_lambdab3.get( 0 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V 0  px:  " << P_V.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V 0  py:  " << P_V.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V 0  pz:  " << P_V.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V 0  E:   " << P_V.get( 0 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V 1  px:  " << q_V1.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V 1  py:  " << q_V1.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V 1  pz:  " << q_V1.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V 1  E:   " << q_V1.get( 0 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V 2  px:  " << q_V2.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V 2  py:  " << q_V2.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V 2  pz:  " << q_V2.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V 2  E:   " << q_V2.get( 0 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V  px: " << px << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V  py: " << py << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " V  pz: " << pz << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vm 1 px:  " << q_Vm1.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vm 1 py:  " << q_Vm1.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vm 1 pz:  " << q_Vm1.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vm 1 E:   " << q_Vm1.get( 0 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vm 3 px:  " << q_Vm3.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vm 3 px:  " << q_Vm3.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vm 3 py:  " << q_Vm3.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vm 3 pz:  " << q_Vm3.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vm 3 E:   " << q_Vm3.get( 0 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vm 5 px:  " << q_Vm5.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vm 5 py:  " << q_Vm5.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vm 5 pz:  " << q_Vm5.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vm 5 E:   " << q_Vm5.get( 0 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vp 1  px:  " << q_Vp1.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vp 1  py:  " << q_Vp1.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vp 1  pz:  " << q_Vp1.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vp 1  E:   " << q_Vp1.get( 0 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vp 3  px:  " << q_Vp3.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vp 3  py:  " << q_Vp3.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vp 3  pz:  " << q_Vp3.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vp 3  E:   " << q_Vp3.get( 0 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vp 5  px:  " << q_Vp5.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vp 5  py:  " << q_Vp5.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vp 5  pz:  " << q_Vp5.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vp 5  E:   " << q_Vp5.get( 0 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vp  px:  " << q_Vp.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vp  py:  " << q_Vp.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << "Vp  pz:  " << q_Vp.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vm px:  " << q_Vm.get( 1 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vm py:  " << q_Vm.get( 2 ) << std::endl;
+        EvtGenReport( EVTGEN_INFO, fname.c_str() )
+            << " Vm pz:  " << q_Vm.get( 3 ) << std::endl;
+        EvtGenReport( EVTGEN_DEBUG, fname.c_str() )
+            << " V decay pdf value : " << pdf << std::endl;
+    }
 }
diff --git a/src/EvtGenModels/EvtLb2Lll.cpp b/src/EvtGenModels/EvtLb2Lll.cpp
index 5c4a2c7..058ba4c 100644
--- a/src/EvtGenModels/EvtLb2Lll.cpp
+++ b/src/EvtGenModels/EvtLb2Lll.cpp
@@ -1,903 +1,909 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtLb2Lll.hh"
 
 #include "EvtGenBase/EvtComplex.hh"
 #include "EvtGenBase/EvtDiracParticle.hh"
 #include "EvtGenBase/EvtDiracSpinor.hh"
 #include "EvtGenBase/EvtGammaMatrix.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtTensor4C.hh"
 #include "EvtGenBase/EvtVector4C.hh"
 #include "EvtGenBase/EvtVector4R.hh"
 
 #include <stdio.h>
 #include <string.h>
 
 EvtDecayBase* EvtLb2Lll::clone()
 {
     return new EvtLb2Lll;
 }
 
 std::string EvtLb2Lll::getName()
 {
     return "Lb2Lll";
 }
 
 void EvtLb2Lll::init()
 {
     if ( getNArg() > 8 ) {    // Decay parameters
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << " ERROR: EvtLb2Lll generator expected max. 8 arguments but found: "
             << getNArg() << std::endl;
         EvtGenReport( EVTGEN_INFO, "EvtGen" )
             << "  1. Lambda_b0 polarization - zero is default" << std::endl;
         EvtGenReport( EVTGEN_INFO, "EvtGen" )
             << "  2. Model type - \"SM\" for Standard Model is default"
             << std::endl;
         EvtGenReport( EVTGEN_INFO, "EvtGen" )
             << "  3. Form-Factors - \"HQET\" is used by default" << std::endl;
         EvtGenReport( EVTGEN_INFO, "EvtGen" )
             << "  4. How to set polarization - \"ModifiedSpinors\" is default"
             << std::endl;
         EvtGenReport( EVTGEN_INFO, "EvtGen" )
             << "  5. Include long distance (LD) effects - \"SD\" (no) is default"
             << std::endl;
         EvtGenReport( EVTGEN_INFO, "EvtGen" )
             << "  6. NonFactorizable contribution (omega) to b->sg decay at q2=0 "
             << std::endl;
         EvtGenReport( EVTGEN_INFO, "EvtGen" )
             << "  7. Note on every x-th decay" << std::endl;
         EvtGenReport( EVTGEN_INFO, "EvtGen" )
             << "  8. Maximum probability - automatic by default" << std::endl;
         ::abort();
     }
 
     if ( getNDaug() != 3 ) {    // Check that there are 3 daughters only
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << " ERROR: EvtLb2Lll generator expected 3 daughters but found: "
             << getNDaug() << std::endl;
         ::abort();
     }
 
     EvtId LbID = EvtPDL::getId( std::string( "Lambda_b0" ) );
     EvtId aLbID = EvtPDL::getId( std::string( "anti-Lambda_b0" ) );
     EvtId eID = EvtPDL::getId( std::string( "e-" ) );
     EvtId aeID = EvtPDL::getId( std::string( "e+" ) );
     EvtId muID = EvtPDL::getId( std::string( "mu-" ) );
     EvtId amuID = EvtPDL::getId( std::string( "mu+" ) );
     EvtId tauID = EvtPDL::getId( std::string( "tau-" ) );
     EvtId atauID = EvtPDL::getId( std::string( "tau+" ) );
 
     // TODO: better check based on spin and falvour is needed to allow usage of aliases !
     if ( getParentId() == LbID ) {    // Check daughters of Lambda_b0
         EvtGenReport( EVTGEN_INFO, "EvtGen" )
             << " EvtLb2Lll generator found Lambda_b0" << std::endl;
         //if(EvtPDL::name(getDaug(0))!="Lambda0"){
         //  EvtGenReport(EVTGEN_ERROR,"EvtGen") << " ERROR: EvtLb2Lll generator expected Lambda0 daughter but found: " << EvtPDL::name(getDaug(0)) << std::endl;
         //  ::abort();
         //}
         if ( getDaug( 1 ) == eID && getDaug( 2 ) == aeID ) {
             m_decayName = "Lambda_b0 -> Lambda0 e- e+";
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << " EvtLb2Lll generator found decay:  Lambda_b0 -> Lambda0 e- e+"
                 << std::endl;
         } else if ( getDaug( 1 ) == muID && getDaug( 2 ) == amuID ) {
             m_decayName = "Lambda_b0 -> Lambda0 mu- mu+";
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << " EvtLb2Lll generator found decay:  Lambda_b0 -> Lambda0 mu- mu+"
                 << std::endl;
         } else if ( getDaug( 1 ) == tauID && getDaug( 2 ) == atauID ) {
             m_decayName = "Lambda_b0 -> Lambda0 tau- tau+";
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << " EvtLb2Lll generator found decay:  Lambda_b0 -> Lambda0 tau- tau+"
                 << std::endl;
         } else {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << " ERROR: EvtLb2Lll generator expected lepton pair daughters but found:  "
                 << EvtPDL::name( getDaug( 1 ) ) << " "
                 << EvtPDL::name( getDaug( 2 ) ) << std::endl;
             ::abort();
         }
         //TODO: The model is known not to work correctly for anti-Lambda_b0 (A_FB does not change its sign)
     } else if ( getParentId() == aLbID ) {    // Check daughters of anti-Lambda_b0
         EvtGenReport( EVTGEN_INFO, "EvtGen" )
             << " EvtLb2Lll generator found anti-Lambda_b0" << std::endl;
         //if(EvtPDL::name(getDaug(0))!="anti-Lambda0"){
         //  EvtGenReport(EVTGEN_ERROR,"EvtGen") << " ERROR: EvtLb2Lll generator expected anti-Lambda0 daughter but found: " << EvtPDL::name(getDaug(0)) << std::endl;
         //  ::abort();
         //}
         if ( getDaug( 1 ) == aeID && getDaug( 2 ) == eID ) {
             m_decayName = "anti-Lambda_b0 -> anti-Lambda0 e+ e-";
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << " EvtLb2Lll generator found decay:  anti-Lambda_b0 -> anti-Lambda0 e+ e-"
                 << std::endl;
         } else if ( getDaug( 1 ) == amuID && getDaug( 2 ) == muID ) {
             m_decayName = "anti-Lambda_b0 -> anti-Lambda0 mu+ mu-";
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << " EvtLb2Lll generator found decay:  anti-Lambda_b0 -> anti-Lambda0 mu+ mu-"
                 << std::endl;
         } else if ( getDaug( 1 ) == atauID && getDaug( 2 ) == tauID ) {
             m_decayName = "anti-Lambda_b0 -> anti-Lambda0 tau+ tau-";
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << " EvtLb2Lll generator found decay:  anti-Lambda_b0 -> anti-Lambda0 tau+ tau-"
                 << std::endl;
         } else {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << " ERROR: EvtLb2Lll generator expected lepton pair daughters but found:  "
                 << EvtPDL::name( getDaug( 1 ) ) << " "
                 << EvtPDL::name( getDaug( 2 ) ) << std::endl;
             ::abort();
         }
     } else {    // This model is not intended for decay of anything else than (anti-)Lambda_b0
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << " ERROR: EvtLb2Lll generator expected (anti-)Lambda_b0 parent but found:  "
             << EvtPDL::name( getParentId() ) << std::endl;
         ::abort();
     }
 
     // Read and check all parameters
     if ( getNArg() > 0 ) {
         if ( getArg( 0 ) > 1. || getArg( 0 ) < -1. ) {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << " ERROR: EvtLb2Lll expects polarization to be in interval <-1,1>, not "
                 << getArg( 0 ) << std::endl;
             ::abort();
         }
         m_polarizationLambdab0 = getArg( 0 );
     } else {
         m_polarizationLambdab0 = 0;
     }
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << " EvtLb2Lll set Lambda_b0 polarization to " << m_polarizationLambdab0
         << std::endl;
 
     if ( getNArg() > 1 ) {
         if ( getArgStr( 1 ).substr( 1, getArgStr( 1 ).size() - 2 ) != "SM" &&
              getArgStr( 1 ).substr( 1, getArgStr( 1 ).size() - 2 ) != "-C7_SM" &&
              getArgStr( 1 ).substr( 1, getArgStr( 1 ).size() - 2 ) !=
                  "SUSY-ChenGeng" ) {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << " ERROR: EvtLb2Lll doesn't know this physics model: "
                 << getArgStr( 1 ) << std::endl;
             ::abort();
         }
         m_HEPmodel = getArgStr( 1 ).substr( 1, getArgStr( 1 ).size() - 2 );
     } else {
         m_HEPmodel = "SM";
     }
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << " EvtLb2Lll will use this physics model: " << m_HEPmodel << std::endl;
 
     if ( getNArg() > 2 ) {
         if ( getArgStr( 2 ).substr( 1, getArgStr( 2 ).size() - 2 ) != "HQET" &&
              getArgStr( 2 ).substr( 1, getArgStr( 2 ).size() - 2 ) != "HQET-noF2" &&
              getArgStr( 2 ).substr( 1, 11 ) != "HQET-delta=" ) {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << " ERROR: EvtLb2Lll doesn't know this Form-Factors model: "
                 << getArgStr( 2 ) << std::endl;
             ::abort();
         }
         m_FFtype = getArgStr( 2 ).substr( 1, getArgStr( 2 ).size() - 2 );
     } else {
         m_FFtype = "HQET";
     }
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << " EvtLb2Lll will use this Form-Factors model: " << m_FFtype
         << std::endl;
 
     if ( getNArg() > 3 ) {
         if ( getArgStr( 3 ).substr( 1, getArgStr( 3 ).size() - 2 ) !=
              "Unpolarized" ) {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << " ERROR: EvtLb2Lll doesn't know kind of introducing polarization: "
                 << getArgStr( 3 ) << std::endl;
             ::abort();
         }
         m_polarizationIntroduction =
             getArgStr( 3 ).substr( 1, getArgStr( 3 ).size() - 2 );
     } else {
         m_polarizationIntroduction = "Unpolarized";
     }
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << " EvtLb2Lll will use this kind of introducing polarization: "
         << m_polarizationIntroduction << std::endl;
 
     if ( getNArg() > 4 ) {
         if ( getArgStr( 4 ).substr( 1, getArgStr( 4 ).size() - 2 ) != "SD" &&
              getArgStr( 4 ).substr( 1, getArgStr( 4 ).size() - 2 ) != "LD" ) {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << " ERROR: EvtLb2Lll didn't find SD or LD parameter: "
                 << getArgStr( 4 ) << std::endl;
             ::abort();
         }
         m_effectContribution = getArgStr( 5 ).substr( 1, getArgStr( 4 ).size() -
                                                              2 );
     } else {
         m_effectContribution = "SD";
     }
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << " EvtLb2Lll will include contribution from these effects: "
         << m_effectContribution << std::endl;
 
     if ( getNArg() > 5 ) {
         if ( fabs( getArg( 5 ) ) > 0.15 ) {
             EvtGenReport( EVTGEN_WARNING, "EvtGen" )
                 << " WARNING: EvtLb2Lll found very high contribution to b->sg decay at q2=0: "
                 << getArg( 5 ) << std::endl;
         }
         m_omega = getArg( 5 );
     } else {
         m_omega = 0;
     }
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << " EvtLb2Lll will use this contribution to b->sg decay at q2=0: "
         << m_omega << std::endl;
 
     if ( getNArg() > 6 )
         m_noTries = (long)( getArg( 6 ) );
     else
         m_noTries = 0;
 
     if ( getNArg() > 7 ) {
         if ( getArg( 7 ) < 0. ) {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << " ERROR: EvtLb2Lll expects positive maximum probability not : "
                 << getArg( 7 ) << std::endl;
             ::abort();
         }
         m_maxProbability = getArg( 7 );
     } else {
         m_maxProbability = 0.;
     }
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << " EvtLb2Lll maximum probability was set to " << m_maxProbability
         << std::endl;
     m_poleSize = 0;
 
     // Initialize Wilson coefficients by Buras and Munz
     // TODO: should have common W.C. source for all decays in EvtGen
     m_WC.CalculateAllCoefficients();
 }
 
 void EvtLb2Lll::initProbMax()
 {
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << " EvtLb2Lll is finding maximum probability ... " << std::endl;
 
-    if ( m_maxProbability == 0 ) {
+    if ( m_maxProbability < 1e-10 ) {
         EvtDiracParticle* parent = new EvtDiracParticle;
         parent->noLifeTime();
         parent->init( getParentId(),
                       EvtVector4R( EvtPDL::getMass( getParentId() ), 0, 0, 0 ) );
         parent->setDiagonalSpinDensity();
 
         EvtAmp amp;
         EvtId daughters[3] = {getDaug( 0 ), getDaug( 1 ), getDaug( 2 )};
         amp.init( getParentId(), 3, daughters );
         parent->makeDaughters( 3, daughters );
         EvtParticle* lambda = parent->getDaug( 0 );
         EvtParticle* lep1 = parent->getDaug( 1 );
         EvtParticle* lep2 = parent->getDaug( 2 );
         lambda->noLifeTime();
         lep1->noLifeTime();
         lep2->noLifeTime();
 
         EvtSpinDensity rho;
         rho.setDiag( parent->getSpinStates() );
 
         double M0 = EvtPDL::getMass( getParentId() );
         double mL = EvtPDL::getMass( getDaug( 0 ) );
         double m1 = EvtPDL::getMass( getDaug( 1 ) );
         double m2 = EvtPDL::getMass( getDaug( 2 ) );
 
         double q2, pstar, elambda, theta;
         double q2min = ( m1 + m2 ) * ( m1 + m2 );
         double q2max = ( M0 - mL ) * ( M0 - mL );
 
         EvtVector4R p4lambda, p4lep1, p4lep2, boost;
 
         EvtGenReport( EVTGEN_INFO, "EvtGen" )
             << " EvtLb2Lll is probing whole phase space ..." << std::endl;
 
         int i, j;
         double prob = 0;
         for ( i = 0; i <= 100; i++ ) {
             q2 = q2min + i * ( q2max - q2min ) / 100.;
             elambda = ( M0 * M0 + mL * mL - q2 ) / 2 / M0;
             if ( i == 0 )
                 pstar = 0;
             else
                 pstar = sqrt( q2 - ( m1 + m2 ) * ( m1 + m2 ) ) *
                         sqrt( q2 - ( m1 - m2 ) * ( m1 - m2 ) ) / 2 / sqrt( q2 );
             boost.set( M0 - elambda, 0, 0, +sqrt( elambda * elambda - mL * mL ) );
             if ( i != 100 ) {
                 p4lambda.set( elambda, 0, 0,
                               -sqrt( elambda * elambda - mL * mL ) );
             } else {
                 p4lambda.set( mL, 0, 0, 0 );
             }
             for ( j = 0; j <= 45; j++ ) {
                 theta = j * EvtConst::pi / 45;
                 p4lep1.set( sqrt( pstar * pstar + m1 * m1 ), 0,
                             +pstar * sin( theta ), +pstar * cos( theta ) );
                 p4lep2.set( sqrt( pstar * pstar + m2 * m2 ), 0,
                             -pstar * sin( theta ), -pstar * cos( theta ) );
                 if ( i != 100 )    // At maximal q2 we are already in correct frame as Lambda and W/Zvirtual are at rest
                 {
                     p4lep1 = boostTo( p4lep1, boost );
                     p4lep2 = boostTo( p4lep2, boost );
                 }
                 calcAmp( &amp, parent );
                 prob = rho.normalizedProb( amp.getSpinDensity() );
                 //std::cout << "q2:  " << q2 << " \t theta:  " << theta << " \t prob:  " << prob << std::endl;
                 //std::cout << "p1: " << p4lep1 << " p2: " << p4lep2 << " q2-q2min: " << q2-(m1+m2)*(m1+m2) << std::endl;
                 if ( prob > m_maxProbability ) {
                     EvtGenReport( EVTGEN_INFO, "EvtGen" )
                         << "  - probability " << prob << " found at q2 = " << q2
                         << " (" << 100 * ( q2 - q2min ) / ( q2max - q2min )
                         << " %) and theta = " << theta * 180 / EvtConst::pi
                         << std::endl;
                     m_maxProbability = prob;
                 }
             }
             //::abort();
         }
 
         //m_poleSize = 0.04*q2min;
         m_maxProbability *= 1.2;
         delete parent;
     }
 
+    if (m_maxProbability < 1e-10) {
+	EvtGenReport( EVTGEN_INFO, "EvtLb2Lll")
+	   << "EvtLb2Lll found zero max prob, setting to 1.5e6" << std::endl;
+	m_maxProbability = 1.5e6;
+    }
+
     setProbMax( m_maxProbability );
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << " EvtLb2Lll set up maximum probability to " << m_maxProbability
         << std::endl;
 }
 
 void EvtLb2Lll::decay( EvtParticle* parent )
 {
     //setWeight(parent->initializePhaseSpace(getNDaug(),getDaugs(),m_poleSize,1,2));
     parent->initializePhaseSpace( getNDaug(), getDaugs() );
     calcAmp( &_amp2, parent );
 }
 
 void EvtLb2Lll::calcAmp( EvtAmp* amp, EvtParticle* parent )
 {
     static long noTries = 0;
     static double delta = 0;
 
     EvtComplex Matrix[2][2][2][2];
 
     EvtComplex i1( 0, 1 );
 
     int i, j, spins[4];
     char ch;
 
     double r, M_L, M_Lb, M_s, M_c, M_b, q2, alpha, M_W, M_t;
     double M_psi[2] = {0, 0}, Gamma_psi[2] = {0, 0}, k_psi[2] = {0, 0};
     double F0_1, F0_2, a_F1, a_F2, b_F1, b_F2, F1, F2;
     double f_1, f_2, f_3, g_1, g_2, g_3, f_1T, f_2T, f_3T, g_1T, g_2T, g_3T,
         f_TV, f_TS, g_TV( 0.0 ), g_TS, f_T, g_T;
     EvtComplex A1, A2, A3, B1, B2, B3, D1, D2, D3, E1, E2, E3, N1, N2, H1, H2;
     EvtComplex C_SL, C_BR, C_LLtot, C_LRtot, C_LL, C_LR, C_RL, C_RR, C_LRLR,
         C_RLLR, C_LRRL, C_RLRL, C_T, C_TE;
     EvtComplex Yld, C_7eff, C_9eff;
     EvtComplex V_ts, V_tb;
 
     EvtVector4C lbar_Gmu_l[2][2], lbar_GmuG5_l[2][2], hbar_GmuPlusG5_h[2][2],
         hbar_GmuMinusG5_h[2][2], hbar_Gmu_h[2][2];
     EvtComplex lbar_l[2][2], lbar_G5_l[2][2], hbar_1PlusG5_h[2][2],
         hbar_1MinusG5_h[2][2], hbar_G5_h[2][2], hbar_h[2][2];
     EvtTensor4C lbar_Smunu_l[2][2], lbar_ESmunu_l[2][2],
         hbar_SmunuPlusG5_h[2][2], hbar_SmunuMinusG5_h[2][2], hbar_Smunu_h[2][2];
     EvtVector4R q_mu, P_mu;
 
     EvtDiracSpinor parent__spParent[2];
 
     M_Lb = parent->mass();
     M_L = parent->getDaug( 0 )->mass();
     M_s = 0.13;
     M_c = 1.35;
     M_b = 4.8;
     alpha = 1. / 137.036;
     M_W = 80.425;
     M_t = 174.3;
     M_psi[0] = 3.096916;
     M_psi[1] = 3.686093;
     if ( m_decayName == "Lambda_b0 -> Lambda0 e- e+" ||
          m_decayName == "anti-Lambda_b0 -> anti-Lambda0 e+ e-" ) {
         Gamma_psi[0] = 5.40;
         Gamma_psi[1] = 2.12;
     }
     if ( m_decayName == "Lambda_b0 -> Lambda0 mu- mu+" ||
          m_decayName == "anti-Lambda_b0 -> anti-Lambda0 mu+ mu-" ) {
         Gamma_psi[0] = 5.35;
         Gamma_psi[1] = 2.05;
     }
     if ( m_decayName == "Lambda_b0 -> Lambda0 tau- tau+" ||
          m_decayName == "anti-Lambda_b0 -> anti-Lambda0 tau+ tau-" ) {
         Gamma_psi[0] = 0.00;
         Gamma_psi[1] = 0.79;
     }
     if ( m_effectContribution == "LD" ) {
         k_psi[0] = 1.65;
         k_psi[1] = 1.65;
     }
     //G_F   = 1.16637e-5;
     //V_tb  = sqrt(1-pow(0.0413,2))*sqrt(1-pow(0.0037,2));
     //V_ts  = -sqrt(1-pow(0.2243,2))*0.0413-0.2243*sqrt(1-pow(0.0413,2))*0.0037*(cos(60*EvtConst::pi/180)+i1*sin(60*EvtConst::pi/180));
 
     P_mu = parent->getP4Restframe() + parent->getDaug( 0 )->getP4();
     q_mu = parent->getP4Restframe() - parent->getDaug( 0 )->getP4();
     q2 = q_mu.mass2();
 
     if ( m_noTries > 0 )
         if ( !( ( ++noTries ) % m_noTries ) )
             EvtGenReport( EVTGEN_DEBUG, "EvtGen" )
                 << " EvtLb2Lll already finished " << noTries
                 << " matrix element calculations" << std::endl;
 
     if ( m_FFtype == "HQET" ) {
         r = M_L * M_L / M_Lb / M_Lb;
         F0_1 = +0.462;
         F0_2 = -0.077;
         a_F1 = -0.0182;
         a_F2 = -0.0685;
         b_F1 = -0.000176;
         b_F2 = +0.001460;
         F1 = F0_1 / ( 1.0 - ( q2 / M_Lb / M_Lb ) *
                                 ( a_F1 - b_F1 * ( q2 / M_Lb / M_Lb ) ) );
         F2 = F0_2 / ( 1.0 - ( q2 / M_Lb / M_Lb ) *
                                 ( a_F2 - b_F2 * ( q2 / M_Lb / M_Lb ) ) );
         g_1 = f_1 = f_2T = g_2T = F1 + sqrt( r ) * F2;
         //std::cout << " F1: " << F1 << "  F2: " << F2 << "  r: " << r << "  M_L: " << M_L << "  M_Lb: " << M_Lb << std::endl;
         //std::cout << " sqrt(q2): " << sqrt(q2) << "  q2: " << q2 << "  M_Lb^2" << M_Lb*M_Lb << std::endl;
         g_2 = f_2 = g_3 = f_3 = g_TV = f_TV = F2 / M_Lb;
         g_TS = f_TS = 0;
         g_1T = f_1T = F2 / M_Lb * q2;
         g_3T = +F2 / M_Lb * ( M_Lb + M_L );
         f_3T = -F2 / M_Lb * ( M_Lb - M_L );
         f_T = f_2T - f_TS * q2;
         g_T = g_2T - g_TS * q2;
     } else if ( strstr( m_FFtype.c_str(), "HQET-delta=" ) == m_FFtype.c_str() ) {
         //EvtGenReport(EVTGEN_WARNING,"EvtGen") << " WARNING: HQET-delta FF model should be checked for correctness" << std::endl;
         if ( delta == 0 )
             sscanf( m_FFtype.c_str(), "%c%c%c%c%c%c%c%c%c%c%c%lf", &ch, &ch,
                     &ch, &ch, &ch, &ch, &ch, &ch, &ch, &ch, &ch, &delta );
         r = M_L * M_L / M_Lb / M_Lb;
         F0_1 = +0.462;
         F0_2 = -0.077;
         a_F1 = -0.0182;
         a_F2 = -0.0685;
         b_F1 = -0.000176;
         b_F2 = +0.001460;
         F1 = F0_1 / ( 1.0 - ( q2 / M_Lb / M_Lb ) *
                                 ( a_F1 - b_F1 * ( q2 / M_Lb / M_Lb ) ) );
         F2 = F0_2 / ( 1.0 - ( q2 / M_Lb / M_Lb ) *
                                 ( a_F2 - b_F2 * ( q2 / M_Lb / M_Lb ) ) );
         g_1 = f_1 = f_2T = g_2T = F1 + sqrt( r ) * F2;
         g_1 += delta * g_1;
         f_1 -= delta * f_1;
         g_2 = f_2 = g_3 = f_3 = g_TV = f_TV = F2 / M_Lb;
         g_TS = f_TS = 0;
         g_1T = f_1T = F2 / M_Lb * q2;
         g_3T = +F2 / M_Lb * ( M_Lb + M_L );
         f_3T = -F2 / M_Lb * ( M_Lb - M_L );
         f_T = f_2T - f_TS * q2;
         g_T = g_2T - g_TS * q2;
     } else if ( m_FFtype == "HQET-noF2" ) {
         //EvtGenReport(EVTGEN_WARNING,"EvtGen") << " WARNING: HQET-noF2 FF model should be checked for correctness" << std::endl;
         r = M_L * M_L / M_Lb / M_Lb;
         F0_1 = +0.462;
         a_F1 = -0.0182;
         b_F1 = -0.000176;
         F1 = F0_1 / ( 1.0 - ( q2 / M_Lb / M_Lb ) *
                                 ( a_F1 - b_F1 * ( q2 / M_Lb / M_Lb ) ) );
         g_1 = f_1 = f_2T = g_2T = F1;
         g_2 = f_2 = g_3 = f_3 = g_TV = f_TV = 0;
         g_TS = f_TS = 0;
         g_1T = f_1T = 0;
         g_3T = 0;
         f_3T = 0;
         f_T = f_2T - f_TS * q2;
         g_T = g_2T - g_TS * q2;
     } else {    // general relations for Form-Factors
         f_1 = f_2 = f_3 = g_1 = g_2 = g_3 = f_3T = g_3T = f_TS = g_TS = f_T =
             g_T = f_TV = 0;
         f_2T = f_T + f_TS * q2;
         f_1T = ( f_TV + f_TS * ( M_L + M_Lb ) ) * q2;
         f_1T = -q2 / ( M_Lb - M_L ) * f_3T;
         g_2T = g_T + g_TS * q2;
         g_1T = ( g_TV - g_TS * ( M_L - M_Lb ) ) * q2;
         g_1T = +q2 / ( M_Lb + M_L ) * g_3T;
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << " ERROR: EvtLb2Lll - unknown Form-Factors model: " << m_FFtype
             << " - this should never happen !" << std::endl;
         ::abort();
     }
 
     if ( m_HEPmodel == "SM" ) {
         C_LL = C_LR = C_RL = C_RR = C_LRLR = C_RLLR = C_LRRL = C_RLRL = C_T =
             C_TE = EvtComplex( 0, 0 );
         Yld = m_WC.Yld( q2, k_psi, Gamma_psi, M_psi, 2, m_WC.GetC1(),
                         m_WC.GetC2(), m_WC.GetC3(), m_WC.GetC4(), m_WC.GetC5(),
                         m_WC.GetC6(), 1. / alpha );
         C_7eff = m_WC.GetC7eff0() +
                  m_WC.C7b2sg( m_WC.GetStrongCouplingConst(), m_WC.GetEta(),
                               m_WC.GetC2(), M_t, M_W ) +
                  m_omega *
                      ( m_WC.hzs( M_c / M_b, q2 / M_b / M_b, M_b, M_b ) + Yld );
         C_9eff = Yld +
                  m_WC.C9efftilda( M_c / M_b, q2 / M_b / M_b,
                                   m_WC.GetStrongCouplingConst(), m_WC.GetC1(),
                                   m_WC.GetC2(), m_WC.GetC3(), m_WC.GetC4(),
                                   m_WC.GetC5(), m_WC.GetC6(), m_WC.GetC9tilda(),
                                   m_WC.GetRenormSchemePar() );
         C_SL = -2 * M_s * C_7eff;
         C_BR = -2 * M_b * C_7eff;
         C_LLtot = C_9eff - m_WC.GetC10tilda() + C_LL;
         C_LRtot = C_9eff + m_WC.GetC10tilda() + C_LR;
         //std::cout << "Yld: " << Yld << "  C7eff: " << C_7eff << "  C_9eff: " << C_9eff << "  Diff7: " << C_7eff-m_WC.GetC7eff0() << "  Diff9: " << C_9eff-m_WC.GetC9tilda() << std::endl;
     } else if ( m_HEPmodel == "-C7_SM" ) {
         C_LL = C_LR = C_RL = C_RR = C_LRLR = C_RLLR = C_LRRL = C_RLRL = C_T =
             C_TE = EvtComplex( 0, 0 );
         Yld = m_WC.Yld( q2, k_psi, Gamma_psi, M_psi, 2, m_WC.GetC1(),
                         m_WC.GetC2(), m_WC.GetC3(), m_WC.GetC4(), m_WC.GetC5(),
                         m_WC.GetC6(), 1. / alpha );
         C_7eff = m_WC.GetC7eff0() +
                  m_WC.C7b2sg( m_WC.GetStrongCouplingConst(), m_WC.GetEta(),
                               m_WC.GetC2(), M_t, M_W ) +
                  m_omega *
                      ( m_WC.hzs( M_c / M_b, q2 / M_b / M_b, M_b, M_b ) + Yld );
         C_9eff = Yld +
                  m_WC.C9efftilda( M_c / M_b, q2 / M_b / M_b,
                                   m_WC.GetStrongCouplingConst(), m_WC.GetC1(),
                                   m_WC.GetC2(), m_WC.GetC3(), m_WC.GetC4(),
                                   m_WC.GetC5(), m_WC.GetC6(), m_WC.GetC9tilda(),
                                   m_WC.GetRenormSchemePar() );
         C_SL = +2 * M_s * C_7eff;
         C_BR = +2 * M_b * C_7eff;
         C_LLtot = C_9eff - m_WC.GetC10tilda() + C_LL;
         C_LRtot = C_9eff + m_WC.GetC10tilda() + C_LR;
         //std::cout << "Yld: " << Yld << "  C7eff: " << C_7eff << "  C_9eff: " << C_9eff << "  Diff7: " << C_7eff-m_WC.GetC7eff0() << "  Diff9: " << C_9eff-m_WC.GetC9tilda() << std::endl;
     } else if ( m_HEPmodel == "SUSY-ChenGeng" ) {
         //EvtGenReport(EVTGEN_WARNING,"EvtGen") << " WARNING: SUSY-ChenGeng model should be checked for correctness" << std::endl;
         C_LL = C_LR = C_RL = C_RR = C_LRLR = C_RLLR = C_LRRL = C_RLRL = C_T =
             C_TE = EvtComplex( 0, 0 );
         EvtComplex d_u23LL = 0.1;
         EvtComplex d_u33RL = 0.65;
         EvtComplex d_d23LR = 0.03 * exp( i1 * EvtConst::pi * 2 / 5 );
         EvtComplex d_u23LR = -0.8 * exp( i1 * EvtConst::pi / 4 );
         EvtComplex C_7susy = -1.75 * d_u23LL - 0.25 * d_u23LR - 10.3 * d_d23LR;
         EvtComplex C_9susy = 0.82 * d_u23LR;
         EvtComplex C_10susy = -9.37 * d_u23LR + 1.4 * d_u23LR * d_u33RL +
                               2.7 * d_u23LL;
         Yld = m_WC.Yld( q2, k_psi, Gamma_psi, M_psi, 2, m_WC.GetC1(),
                         m_WC.GetC2(), m_WC.GetC3(), m_WC.GetC4(), m_WC.GetC5(),
                         m_WC.GetC6(), 1. / alpha );
         C_7eff = m_WC.GetC7eff0() + C_7susy * pow( m_WC.GetEta(), 16. / 23. ) +
                  m_WC.C7b2sg( m_WC.GetStrongCouplingConst(), m_WC.GetEta(),
                               m_WC.GetC2(), M_t, M_W ) +
                  m_omega *
                      ( m_WC.hzs( M_c / M_b, q2 / M_b / M_b, M_b, M_b ) + Yld );
         C_9eff = Yld + m_WC.C9efftilda( M_c / M_b, q2 / M_b / M_b,
                                         m_WC.GetStrongCouplingConst(),
                                         m_WC.GetC1(), m_WC.GetC2(), m_WC.GetC3(),
                                         m_WC.GetC4(), m_WC.GetC5(), m_WC.GetC6(),
                                         m_WC.GetC9tilda() + C_9susy,
                                         m_WC.GetRenormSchemePar() );
         C_SL = -2 * M_s * C_7eff;
         C_BR = -2 * M_b * C_7eff;
         C_LLtot = C_9eff - m_WC.GetC10tilda() - C_10susy + C_LL;
         C_LRtot = C_9eff + m_WC.GetC10tilda() + C_10susy + C_LR;
         //std::cout << "Yld: " << Yld << "  C7eff: " << C_7eff << "  C_9eff: " << C_9eff << "  Diff7: " << C_7eff-m_WC.GetC7eff0() << "  Diff9: " << C_9eff-m_WC.GetC9tilda() << std::endl;
     } else {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << " ERROR: EvtLb2Lll - unknown physics model: " << m_HEPmodel
             << " - this should never happen !" << std::endl;
         ::abort();
     }
 
     A1 = ( f_1T - g_1T ) * C_SL / q2 + ( f_1T + g_1T ) * C_BR / q2 +
          0.5 * ( f_1 - g_1 ) * ( C_LLtot + C_LRtot ) +
          0.5 * ( f_1 + g_1 ) * ( C_RL + C_RR );
     //std::cout << "f_1T: " << f_1T << "  g_1T: " << g_1T << "  C_SL: " << C_SL << "  C_BR: " << C_BR << "  f_1: " << f_1 << "  g_1: " << g_1 << "  C_LLtot: " << C_LLtot << "  C_LRtot: " << C_LRtot << "  C_RL: " << C_RL << "  C_RR: " << C_RR << std::endl;
     A2 = ( f_2T - g_2T ) * C_SL / q2 + ( f_2T + g_2T ) * C_BR / q2 +
          0.5 * ( f_2 - g_2 ) * ( C_LLtot + C_LRtot ) +
          0.5 * ( f_2 + g_2 ) * ( C_RL + C_RR );
     A3 = ( f_3T - g_3T ) * C_SL / q2 + ( f_3T + g_3T ) * C_BR / q2 +
          0.5 * ( f_3 - g_3 ) * ( C_LLtot + C_LRtot ) +
          0.5 * ( f_3 + g_3 ) * ( C_RL + C_RR );
 
     B1 = ( f_1T + g_1T ) * C_SL / q2 + ( f_1T - g_1T ) * C_BR / q2 +
          0.5 * ( f_1 + g_1 ) * ( C_LLtot + C_LRtot ) +
          0.5 * ( f_1 - g_1 ) * ( C_RL + C_RR );
     B2 = ( f_2T + g_2T ) * C_SL / q2 + ( f_2T - g_2T ) * C_BR / q2 +
          0.5 * ( f_2 + g_2 ) * ( C_LLtot + C_LRtot ) +
          0.5 * ( f_2 - g_2 ) * ( C_RL + C_RR );
     B3 = ( f_3T + g_3T ) * C_SL / q2 + ( f_3T - g_3T ) * C_BR / q2 +
          0.5 * ( f_3 + g_3 ) * ( C_LLtot + C_LRtot ) +
          0.5 * ( f_3 - g_3 ) * ( C_RL + C_RR );
 
     D1 = 0.5 * ( C_RR - C_RL ) * ( f_1 + g_1 ) +
          0.5 * ( C_LRtot - C_LLtot ) * ( f_1 - g_1 );
     D2 = 0.5 * ( C_RR - C_RL ) * ( f_2 + g_2 ) +
          0.5 * ( C_LRtot - C_LLtot ) * ( f_2 - g_2 );
     D3 = 0.5 * ( C_RR - C_RL ) * ( f_3 + g_3 ) +
          0.5 * ( C_LRtot - C_LLtot ) * ( f_3 - g_3 );
 
     E1 = 0.5 * ( C_RR - C_RL ) * ( f_1 - g_1 ) +
          0.5 * ( C_LRtot - C_LLtot ) * ( f_1 + g_1 );
     E2 = 0.5 * ( C_RR - C_RL ) * ( f_2 - g_2 ) +
          0.5 * ( C_LRtot - C_LLtot ) * ( f_2 + g_2 );
     E3 = 0.5 * ( C_RR - C_RL ) * ( f_3 - g_3 ) +
          0.5 * ( C_LRtot - C_LLtot ) * ( f_3 + g_3 );
 
     N1 = ( f_1 * ( M_Lb - M_L ) + f_3 * q2 ) / M_b *
          ( C_LRLR + C_RLLR + C_LRRL + C_RLRL );    // Should be mLb - mL
     N2 = ( f_1 * ( M_Lb - M_L ) + f_3 * q2 ) / M_b *
          ( C_LRLR + C_RLLR - C_LRRL - C_RLRL );
 
     H1 = ( g_1 * ( M_Lb + M_L ) - g_3 * q2 ) / M_b *
          ( C_LRLR - C_RLLR + C_LRRL - C_RLRL );
     H2 = ( g_1 * ( M_Lb + M_L ) - g_3 * q2 ) / M_b *
          ( C_LRLR - C_RLLR - C_LRRL + C_RLRL );
 
     for ( i = 0; i < 4; i++ ) {
         lbar_Gmu_l[i / 2][i % 2] =
             EvtLeptonVCurrent( parent->getDaug( 1 )->spParent( i / 2 ),
                                parent->getDaug( 2 )->spParent( i % 2 ) );
         lbar_GmuG5_l[i / 2][i % 2] =
             EvtLeptonACurrent( parent->getDaug( 1 )->spParent( i / 2 ),
                                parent->getDaug( 2 )->spParent( i % 2 ) );
         lbar_l[i / 2][i % 2] =
             EvtLeptonSCurrent( parent->getDaug( 1 )->spParent( i / 2 ),
                                parent->getDaug( 2 )->spParent( i % 2 ) );
         lbar_G5_l[i / 2][i % 2] =
             EvtLeptonPCurrent( parent->getDaug( 1 )->spParent( i / 2 ),
                                parent->getDaug( 2 )->spParent( i % 2 ) );
         lbar_Smunu_l[i / 2][i % 2] =
             EvtLeptonTCurrent( parent->getDaug( 1 )->spParent( i / 2 ),
                                parent->getDaug( 2 )->spParent( i % 2 ) );
         lbar_ESmunu_l[i / 2][i % 2] = dual(
             EvtLeptonTCurrent( parent->getDaug( 1 )->spParent( i / 2 ),
                                parent->getDaug( 2 )->spParent( i % 2 ) ) );
     }
 
     // TODO: polarization not yet introduced
     if ( m_polarizationIntroduction == "SpinDensityMatrix" ) {
         //parent->setSpinDensityForward();
         parent__spParent[0] = parent->sp( 0 );
         parent__spParent[1] = parent->sp( 1 );
     } else if ( m_polarizationIntroduction == "ModifiedSpinors" ) {
         parent__spParent[0] = parent->sp( 0 );
         parent__spParent[1] = parent->sp( 1 );
     } else if ( m_polarizationIntroduction == "Unpolarized" ) {
         parent__spParent[0] = parent->sp( 0 );
         parent__spParent[1] = parent->sp( 1 );
     } else {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << " ERROR: EvtLb2Lll - unknown polarization: "
             << m_polarizationIntroduction << " - this should never happen !"
             << std::endl;
         ::abort();
     }
 
     for ( i = 0; i < 4; i++ ) {
         hbar_GmuPlusG5_h[i / 2][i % 2] =
             EvtLeptonVCurrent( parent->getDaug( 0 )->spParent( i / 2 ),
                                parent__spParent[i % 2] ) +
             EvtLeptonACurrent( parent->getDaug( 0 )->spParent( i / 2 ),
                                parent__spParent[i % 2] );
         hbar_GmuMinusG5_h[i / 2][i % 2] = EvtLeptonVACurrent(
             parent->getDaug( 0 )->spParent( i / 2 ), parent__spParent[i % 2] );
         hbar_SmunuPlusG5_h[i / 2][i % 2] =
             EvtLeptonTCurrent( parent->getDaug( 0 )->spParent( i / 2 ),
                                parent__spParent[i % 2] ) +
             EvtLeptonTG5Current( parent->getDaug( 0 )->spParent( i / 2 ),
                                  parent__spParent[i % 2] );
         hbar_SmunuMinusG5_h[i / 2][i % 2] =
             EvtLeptonTCurrent( parent->getDaug( 0 )->spParent( i / 2 ),
                                parent__spParent[i % 2] ) -
             EvtLeptonTG5Current( parent->getDaug( 0 )->spParent( i / 2 ),
                                  parent__spParent[i % 2] );
         hbar_1PlusG5_h[i / 2][i % 2] =
             EvtLeptonSCurrent( parent->getDaug( 0 )->spParent( i / 2 ),
                                parent__spParent[i % 2] ) +
             EvtLeptonPCurrent( parent->getDaug( 0 )->spParent( i / 2 ),
                                parent__spParent[i % 2] );
         hbar_1MinusG5_h[i / 2][i % 2] =
             EvtLeptonSCurrent( parent->getDaug( 0 )->spParent( i / 2 ),
                                parent__spParent[i % 2] ) -
             EvtLeptonPCurrent( parent->getDaug( 0 )->spParent( i / 2 ),
                                parent__spParent[i % 2] );
         hbar_G5_h[i / 2][i % 2] = EvtLeptonPCurrent(
             parent->getDaug( 0 )->spParent( i / 2 ), parent__spParent[i % 2] );
         hbar_h[i / 2][i % 2] = EvtLeptonSCurrent(
             parent->getDaug( 0 )->spParent( i / 2 ), parent__spParent[i % 2] );
         hbar_Smunu_h[i / 2][i % 2] = EvtLeptonTCurrent(
             parent->getDaug( 0 )->spParent( i / 2 ), parent__spParent[i % 2] );
         hbar_Gmu_h[i / 2][i % 2] = EvtLeptonVCurrent(
             parent->getDaug( 0 )->spParent( i / 2 ), parent__spParent[i % 2] );
     }
 
     for ( i = 0; i < 4; i++ )
         for ( j = 0; j < 4; j++ ) {
             //std::cout << "--------------------------------------------------" << std::endl;
             //std::cout << "Matrix = " << Matrix[j/2][j%2][i/2][i%2] << std::endl;
             Matrix[j / 2][j % 2][i / 2][i % 2] +=
                 lbar_Gmu_l[i / 2][i % 2] *
                 ( A1 * hbar_GmuPlusG5_h[j / 2][j % 2] +
                   B1 * hbar_GmuMinusG5_h[j / 2][j % 2] );
             //std::cout << "Matrix = " << Matrix[j/2][j%2][i/2][i%2] << std::endl;
             //std::cout << "A1: " << A1 << " B1: " << B1 << " lbar_Gmu_l: " << lbar_Gmu_l[i/2][i%2] <<
             //             " hbar_GmuPlusG5_h: " << hbar_GmuPlusG5_h[j/2][j%2] << " hbar_GmuMinusG5_h: " << hbar_GmuMinusG5_h[j/2][j%2] <<
             //	           " sp1: " << parent->getDaug(1)->spParent(i/2) << " sp2: " << parent->getDaug(1)->spParent(i%2) << std::endl;
             Matrix[j / 2][j % 2][i / 2][i % 2] +=
                 lbar_Gmu_l[i / 2][i % 2] *
                 ( i1 * A2 * ( hbar_SmunuPlusG5_h[j / 2][j % 2].cont2( q_mu ) ) +
                   B2 * ( hbar_SmunuMinusG5_h[j / 2][j % 2].cont2( q_mu ) ) );
             //std::cout << "Matrix = " << Matrix[j/2][j%2][i/2][i%2] << std::endl;
             Matrix[j / 2][j % 2][i / 2][i % 2] +=
                 lbar_Gmu_l[i / 2][i % 2] *
                 ( ( A3 * hbar_1PlusG5_h[j / 2][j % 2] +
                     B3 * hbar_1MinusG5_h[j / 2][j % 2] ) *
                   q_mu );
             //std::cout << "Matrix = " << Matrix[j/2][j%2][i/2][i%2] << std::endl;
             Matrix[j / 2][j % 2][i / 2][i % 2] +=
                 lbar_GmuG5_l[i / 2][i % 2] *
                 ( D1 * hbar_GmuPlusG5_h[j / 2][j % 2] +
                   E1 * hbar_GmuMinusG5_h[j / 2][j % 2] );
             //std::cout << "Matrix = " << Matrix[j/2][j%2][i/2][i%2] << std::endl;
             Matrix[j / 2][j % 2][i / 2][i % 2] +=
                 lbar_GmuG5_l[i / 2][i % 2] *
                 ( i1 * D2 * ( hbar_SmunuPlusG5_h[j / 2][j % 2].cont2( q_mu ) ) +
                   E2 * ( hbar_SmunuMinusG5_h[j / 2][j % 2].cont2( q_mu ) ) );
             //std::cout << "Matrix = " << Matrix[j/2][j%2][i/2][i%2] << std::endl;
             Matrix[j / 2][j % 2][i / 2][i % 2] +=
                 lbar_GmuG5_l[i / 2][i % 2] *
                 ( ( D3 * hbar_1PlusG5_h[j / 2][j % 2] +
                     E3 * hbar_1MinusG5_h[j / 2][j % 2] ) *
                   q_mu );
             //std::cout << "Matrix = " << Matrix[j/2][j%2][i/2][i%2] << std::endl;
             Matrix[j / 2][j % 2][i / 2][i % 2] +=
                 lbar_l[i / 2][i % 2] *
                 ( N1 * hbar_h[j / 2][j % 2] + H1 * hbar_G5_h[j / 2][j % 2] );
             //std::cout << "Matrix = " << Matrix[j/2][j%2][i/2][i%2] << std::endl;
             Matrix[j / 2][j % 2][i / 2][i % 2] +=
                 lbar_G5_l[i / 2][i % 2] *
                 ( N2 * hbar_h[j / 2][j % 2] + H2 * hbar_G5_h[j / 2][j % 2] );
             //std::cout << "Matrix = " << Matrix[j/2][j%2][i/2][i%2] << std::endl;
             Matrix[j / 2][j % 2][i / 2][i % 2] +=
                 cont( lbar_Smunu_l[i / 2][i % 2],
                       4 * C_T * f_T * hbar_Smunu_h[j / 2][j % 2] );
             //std::cout << "Matrix = " << Matrix[j/2][j%2][i/2][i%2] << std::endl;
             Matrix[j / 2][j % 2][i / 2][i % 2] += cont(
                 lbar_Smunu_l[i / 2][i % 2],
                 -4 * C_T * f_TV * i1 *
                     ( EvtGenFunctions::directProd( q_mu, hbar_Gmu_h[j / 2][j % 2] ) -
                       EvtGenFunctions::directProd( hbar_Gmu_h[j / 2][j % 2],
                                                    q_mu ) ) );
             //std::cout << "Matrix = " << Matrix[j/2][j%2][i/2][i%2] << std::endl;
             Matrix[j / 2][j % 2][i / 2][i % 2] +=
                 cont( lbar_Smunu_l[i / 2][i % 2],
                       -4 * C_T * f_TS * i1 *
                           ( EvtGenFunctions::directProd( P_mu, q_mu ) -
                             EvtGenFunctions::directProd( q_mu, P_mu ) ) *
                           hbar_h[j / 2][j % 2] );
             //std::cout << "Matrix = " << Matrix[j/2][j%2][i/2][i%2] << std::endl;
             Matrix[j / 2][j % 2][i / 2][i % 2] +=
                 cont( lbar_ESmunu_l[i / 2][i % 2],
                       4 * C_TE * f_T * i1 * hbar_Smunu_h[j / 2][j % 2] );
             //std::cout << "Matrix = " << Matrix[j/2][j%2][i/2][i%2] << std::endl;
             Matrix[j / 2][j % 2][i / 2][i % 2] += cont(
                 lbar_ESmunu_l[i / 2][i % 2],
                 4 * C_TE * f_TV *
                     ( EvtGenFunctions::directProd( q_mu, hbar_Gmu_h[j / 2][j % 2] ) -
                       EvtGenFunctions::directProd( hbar_Gmu_h[j / 2][j % 2],
                                                    q_mu ) ) );
             //std::cout << "Matrix = " << Matrix[j/2][j%2][i/2][i%2] << std::endl;
             Matrix[j / 2][j % 2][i / 2][i % 2] +=
                 cont( lbar_ESmunu_l[i / 2][i % 2],
                       4 * C_TE * f_TS *
                           ( EvtGenFunctions::directProd( P_mu, q_mu ) -
                             EvtGenFunctions::directProd( q_mu, P_mu ) ) *
                           hbar_h[j / 2][j % 2] );
             //std::cout << "Matrix = " << Matrix[j/2][j%2][i/2][i%2] << std::endl;
             //Matrix[j/2][j%2][i/2][i%2] *= G_F*alpha/4/sqrt(2)/EvtConst::pi*V_tb*conj(V_ts);
             //std::cout << "Matrix = " << Matrix[j/2][j%2][i/2][i%2] << std::endl;
             //std::cout << "--------------------------------------------------" << std::endl;
             spins[0] = j % 2;
             spins[1] = j / 2;
             spins[2] = i / 2;
             spins[3] = i % 2;
             amp->vertex( spins, Matrix[j / 2][j % 2][i / 2][i % 2] );
         }
 
     //std::cout << "==================================================" << std::endl;
     //std::cout << "Lambda_b0:  " << parent->getP4Restframe() << std::endl;
     //std::cout << "Lambda0:  " << parent->getDaug(0)->getP4() << std::endl;
     //std::cout << "mu-:  " << parent->getDaug(1)->getP4() << std::endl;
     //std::cout << "mu+:  " << parent->getDaug(2)->getP4() << std::endl;
     //std::cout << "P_mu:  " << P_mu << std::endl;
     //std::cout << "q_mu:  " << q_mu << std::endl;
     //std::cout << "q2:  " << q2 << std::endl;
     //std::cout << "==================================================" << std::endl;
 
     return;
 }
 
 EvtTensor4C EvtLb2Lll::EvtLeptonTG5Current( const EvtDiracSpinor& d,
                                             const EvtDiracSpinor& dp )
 {
     // <u|sigma^munu*gamma^5|v>
 
     EvtTensor4C temp;
     temp.zero();
     EvtComplex i2( 0, 0.5 );
 
     static EvtGammaMatrix mat01 = EvtGammaMatrix::g0() *
                                   ( EvtGammaMatrix::g0() * EvtGammaMatrix::g1() -
                                     EvtGammaMatrix::g1() * EvtGammaMatrix::g0() ) *
                                   EvtGammaMatrix::g5();
     static EvtGammaMatrix mat02 = EvtGammaMatrix::g0() *
                                   ( EvtGammaMatrix::g0() * EvtGammaMatrix::g2() -
                                     EvtGammaMatrix::g2() * EvtGammaMatrix::g0() ) *
                                   EvtGammaMatrix::g5();
     static EvtGammaMatrix mat03 = EvtGammaMatrix::g0() *
                                   ( EvtGammaMatrix::g0() * EvtGammaMatrix::g3() -
                                     EvtGammaMatrix::g3() * EvtGammaMatrix::g0() ) *
                                   EvtGammaMatrix::g5();
     static EvtGammaMatrix mat12 = EvtGammaMatrix::g0() *
                                   ( EvtGammaMatrix::g1() * EvtGammaMatrix::g2() -
                                     EvtGammaMatrix::g2() * EvtGammaMatrix::g1() ) *
                                   EvtGammaMatrix::g5();
     static EvtGammaMatrix mat13 = EvtGammaMatrix::g0() *
                                   ( EvtGammaMatrix::g1() * EvtGammaMatrix::g3() -
                                     EvtGammaMatrix::g3() * EvtGammaMatrix::g1() ) *
                                   EvtGammaMatrix::g5();
     static EvtGammaMatrix mat23 = EvtGammaMatrix::g0() *
                                   ( EvtGammaMatrix::g2() * EvtGammaMatrix::g3() -
                                     EvtGammaMatrix::g3() * EvtGammaMatrix::g2() ) *
                                   EvtGammaMatrix::g5();
 
     temp.set( 0, 1, i2 * ( d * ( mat01 * dp ) ) );
     temp.set( 1, 0, -temp.get( 0, 1 ) );
 
     temp.set( 0, 2, i2 * ( d * ( mat02 * dp ) ) );
     temp.set( 2, 0, -temp.get( 0, 2 ) );
 
     temp.set( 0, 3, i2 * ( d * ( mat03 * dp ) ) );
     temp.set( 3, 0, -temp.get( 0, 3 ) );
 
     temp.set( 1, 2, i2 * ( d * ( mat12 * dp ) ) );
     temp.set( 2, 1, -temp.get( 1, 2 ) );
 
     temp.set( 1, 3, i2 * ( d * ( mat13 * dp ) ) );
     temp.set( 3, 1, -temp.get( 1, 3 ) );
 
     temp.set( 2, 3, i2 * ( d * ( mat23 * dp ) ) );
     temp.set( 3, 2, -temp.get( 2, 3 ) );
 
     return temp;
 }
diff --git a/src/EvtGenModels/EvtMelikhov.cpp b/src/EvtGenModels/EvtMelikhov.cpp
index 3ca2ebe..23c8b90 100644
--- a/src/EvtGenModels/EvtMelikhov.cpp
+++ b/src/EvtGenModels/EvtMelikhov.cpp
@@ -1,67 +1,72 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtMelikhov.hh"
 
 #include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtReport.hh"
 #include "EvtGenBase/EvtSemiLeptonicVectorAmp.hh"
 
 #include "EvtGenModels/EvtMelikhovFF.hh"
 
 #include <stdlib.h>
 #include <string>
 
 std::string EvtMelikhov::getName()
 {
     return "MELIKHOV";
 }
 
 EvtDecayBase* EvtMelikhov::clone()
 {
     return new EvtMelikhov;
 }
 
 void EvtMelikhov::decay( EvtParticle* p )
 {
     p->initializePhaseSpace( getNDaug(), getDaugs() );
     calcamp->CalcAmp( p, _amp2, Melikhovffmodel.get() );
 }
 
 void EvtMelikhov::init()
 {
     checkNArg( 1 );
     checkNDaug( 3 );
 
     //We expect the parent to be a scalar
     //and the daughters to be X lepton neutrino
 
     checkSpinParent( EvtSpinType::SCALAR );
 
     checkSpinDaughter( 0, EvtSpinType::VECTOR );
     checkSpinDaughter( 1, EvtSpinType::DIRAC );
     checkSpinDaughter( 2, EvtSpinType::NEUTRINO );
 
     Melikhovffmodel = std::make_unique<EvtMelikhovFF>( getArg( 0 ) );
     calcamp = std::make_unique<EvtSemiLeptonicVectorAmp>();
 }
+
+void EvtMelikhov::initProbMax()
+{
+    setProbMax( 10000.0 );
+}
diff --git a/src/EvtGenModels/EvtMultibody.cpp b/src/EvtGenModels/EvtMultibody.cpp
index 612359d..2defab6 100644
--- a/src/EvtGenModels/EvtMultibody.cpp
+++ b/src/EvtGenModels/EvtMultibody.cpp
@@ -1,97 +1,94 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtMultibody.hh"
 
 #include "EvtGenBase/EvtConst.hh"
 #include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtKine.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtReport.hh"
 #include "EvtGenBase/EvtResonance.hh"
 #include "EvtGenBase/EvtResonance2.hh"
 #include "EvtGenBase/EvtdFunction.hh"
 
 EvtMultibody::~EvtMultibody()
 {
     if ( _decayTree != NULL )
         delete _decayTree;
     _decayTree = NULL;
     if ( _ilist != NULL )
         delete[] _ilist;
     _ilist = NULL;
 }
 
 std::string EvtMultibody::getName()
 {
     return "D_MULTIBODY";
 }
 
 EvtDecayBase* EvtMultibody::clone()
 {
     return new EvtMultibody;
 }
 
 void EvtMultibody::init()
 {
     int N = getNArg();
 
     _decayTree = new EvtMTree( getDaugs(), getNDaug() );
     _ilist = new int[getNDaug() + 1];
 
     for ( int i = 0; i < N - 1; ++i ) {
         if ( getArgStr( i ) == "RESONANCE" ) {
             _decayTree->addtree( getArgStr( ++i ) );
         } else {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << "Syntax error at " << getArgStr( i ) << std::endl;
             ::abort();
         }
     }
 }
 
-// Set the maximum probability amplitude - if function is left blank then the
-// program will search for it.  This however is not deterministic and therefore
-// in the release cannot be in place.
 void EvtMultibody::initProbMax()
 {
-    // setProbMax(1.0);
+    setProbMax(1.0);
 }
 
 void EvtMultibody::decay( EvtParticle* p )
 {
     // Initialize the phase space before doing anything else!
     p->initializePhaseSpace( getNDaug(), getDaugs() );
 
     EvtSpinAmp amp = _decayTree->amplitude( p );
 
     vector<int> index = amp.iterallowedinit();
     vector<unsigned int> spins = amp.dims();
 
     do {
         for ( size_t i = 0; i < index.size(); ++i ) {
             _ilist[i] = index[i] + spins[i];
         }
 
         vertex( _ilist, amp( index ) );
     } while ( amp.iterateallowed( index ) );
 }
diff --git a/src/EvtGenModels/EvtPhiDalitz.cpp b/src/EvtGenModels/EvtPhiDalitz.cpp
index 91ae650..5c72b0d 100644
--- a/src/EvtGenModels/EvtPhiDalitz.cpp
+++ b/src/EvtGenModels/EvtPhiDalitz.cpp
@@ -1,163 +1,168 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtPhiDalitz.hh"
 
 #include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtReport.hh"
 #include "EvtGenBase/EvtVector4R.hh"
 
 #include <math.h>
 #include <stdlib.h>
 #include <string>
 
 // Implementation of KLOE measurement
 // PL B561: 55-60 (2003) + Erratum B609:449-450 (2005)
 // or hep-ex/0303016v2
 
 std::string EvtPhiDalitz::getName()
 {
     return "PHI_DALITZ";
 }
 
 EvtDecayBase* EvtPhiDalitz::clone()
 {
     return new EvtPhiDalitz;
 }
 
 void EvtPhiDalitz::init()
 {
     // check that there are 0 arguments
     checkNArg( 0 );
     checkNDaug( 3 );
 
     checkSpinParent( EvtSpinType::VECTOR );
 
     checkSpinDaughter( 0, EvtSpinType::SCALAR );
     checkSpinDaughter( 1, EvtSpinType::SCALAR );
     checkSpinDaughter( 2, EvtSpinType::SCALAR );
 
     _mRho = 0.7758;
     _gRho = 0.1439;
     _aD = 0.78;
     _phiD = -2.47;
     _aOmega = 0.0071;
     _phiOmega = -0.22;
 
     _locPip = -1;
     _locPim = -1;
     _locPi0 = -1;
 
     for ( int i = 0; i < 3; i++ ) {
         if ( getDaug( i ) == EvtPDL::getId( "pi+" ) )
             _locPip = i;
         if ( getDaug( i ) == EvtPDL::getId( "pi-" ) )
             _locPim = i;
         if ( getDaug( i ) == EvtPDL::getId( "pi0" ) )
             _locPi0 = i;
     }
     if ( _locPip == -1 || _locPim == -1 || _locPi0 == -1 ) {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << getModelName()
             << "generator expects daughters to be pi+ pi- pi0\n";
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "Found " << EvtPDL::name( getDaug( 0 ) ) << " "
             << EvtPDL::name( getDaug( 1 ) ) << " "
             << EvtPDL::name( getDaug( 2 ) ) << std::endl;
     }
 }
 
+void EvtPhiDalitz::initProbMax()
+{
+    setProbMax( 150.0 );
+}
+
 void EvtPhiDalitz::decay( EvtParticle* p )
 {
     EvtId PIP = EvtPDL::getId( "pi+" );
     EvtId PIM = EvtPDL::getId( "pi-" );
     EvtId PIZ = EvtPDL::getId( "pi0" );
     EvtId OMEGA = EvtPDL::getId( "omega" );
 
     p->initializePhaseSpace( getNDaug(), getDaugs() );
 
     EvtVector4R Ppip = p->getDaug( _locPip )->getP4();
     EvtVector4R Ppim = p->getDaug( _locPim )->getP4();
     EvtVector4R Ppi0 = p->getDaug( _locPi0 )->getP4();
     EvtVector4R Qp = ( Ppim + Ppi0 );
     EvtVector4R Qm = ( Ppip + Ppi0 );
     EvtVector4R Q0 = ( Ppip + Ppim );
     double m2_pip = pow( EvtPDL::getMeanMass( PIP ), 2 );
     double m2_pim = pow( EvtPDL::getMeanMass( PIM ), 2 );
     double m2_pi0 = pow( EvtPDL::getMeanMass( PIZ ), 2 );
     double M2rhop = pow( _mRho, 2 );
     double M2rhom = pow( _mRho, 2 );
     double M2rho0 = pow( _mRho, 2 );
     double M2omega = pow( EvtPDL::getMeanMass( OMEGA ), 2 );
 
     double Wrhop = _gRho;
     double Wrhom = _gRho;
     double Wrho0 = _gRho;
     double Womega = EvtPDL::getWidth( OMEGA );
 
     EvtComplex Atot( 0, 0 );
 
     //Rho+ Risonance Amplitude
     double Gp = Wrhop *
                 pow( ( ( Qp.mass2() - m2_pim - m2_pi0 ) / 2 - M2rhop / 4 ) /
                          ( M2rhop / 4 - ( m2_pim + m2_pi0 ) / 2 ),
                      3 / 2 ) *
                 ( M2rhop / Qp.mass2() );
     EvtComplex Drhop( ( Qp.mass2() - M2rhop ), Qp.mass() * Gp );
     EvtComplex A1( M2rhop / Drhop );
 
     //Rho- Risonance Amplitude
     double Gm = Wrhom *
                 pow( ( ( Qm.mass2() - m2_pip - m2_pi0 ) / 2 - M2rhom / 4 ) /
                          ( M2rhom / 4 - ( m2_pip + m2_pi0 ) / 2 ),
                      3 / 2 ) *
                 ( M2rhom / Qm.mass2() );
     EvtComplex Drhom( ( Qm.mass2() - M2rhom ), Qm.mass() * Gm );
     EvtComplex A2( M2rhom / Drhom );
 
     //Rho0 Risonance Amplitude
     double G0 = Wrho0 *
                 pow( ( ( Q0.mass2() - m2_pip - m2_pim ) / 2 - M2rho0 / 4 ) /
                          ( M2rho0 / 4 - ( m2_pip + m2_pim ) / 2 ),
                      3 / 2 ) *
                 ( M2rho0 / Q0.mass2() );
     EvtComplex Drho0( ( Q0.mass2() - M2rho0 ), Q0.mass() * G0 );
     EvtComplex A3( M2rho0 / Drho0 );
 
     //Omega Risonance Amplitude
     EvtComplex OmegaPhase( 0, _phiOmega );
     EvtComplex DOmega( ( Q0.mass2() - M2omega ), Q0.mass() * Womega );
     EvtComplex A4( _aOmega * M2omega * exp( OmegaPhase ) / DOmega );
 
     //Direct Decay Amplitude
     EvtComplex DirPhase( 0, _phiD );
     EvtComplex A5( _aD * exp( DirPhase ) );
 
     Atot = A1 + A2 + A3 + A4 + A5;
 
     vertex( 0, Atot );
     vertex( 1, Atot );
     vertex( 2, Atot );
 
     return;
 }
diff --git a/src/EvtGenModels/EvtRareLbToLll.cpp b/src/EvtGenModels/EvtRareLbToLll.cpp
index a6a8081..121a02e 100644
--- a/src/EvtGenModels/EvtRareLbToLll.cpp
+++ b/src/EvtGenModels/EvtRareLbToLll.cpp
@@ -1,503 +1,506 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtRareLbToLll.hh"
 
 #include "EvtGenBase/EvtComplex.hh"
 #include "EvtGenBase/EvtDiracParticle.hh"
 #include "EvtGenBase/EvtDiracSpinor.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtRaritaSchwinger.hh"
 #include "EvtGenBase/EvtSpinDensity.hh"
 #include "EvtGenBase/EvtTensor4C.hh"
 #include "EvtGenBase/EvtVector4C.hh"
 #include "EvtGenBase/EvtVector4R.hh"
 
 #include "EvtGenModels/EvtRareLbToLllFF.hh"
 #include "EvtGenModels/EvtRareLbToLllFFGutsche.hh"
 #include "EvtGenModels/EvtRareLbToLllFFlQCD.hh"
 
 #include <stdlib.h>
 
 // The module name specification
 std::string EvtRareLbToLll::getName()
 {
     return "RareLbToLll";
 }
 
 // The implementation of the clone() method
 EvtDecayBase* EvtRareLbToLll::clone()
 {
     return new EvtRareLbToLll;
 }
 
 void EvtRareLbToLll::init()
 {
-    checkNArg( 1 );
+    checkNArg( 0, 1 );
 
     // check that there are 3 daughters
     checkNDaug( 3 );
 
     // Parent should be spin 1/2 Lambda_b0
     const EvtSpinType::spintype spin = EvtPDL::getSpinType( getDaug( 0 ) );
 
     if ( !( spin == EvtSpinType::DIRAC || spin == EvtSpinType::RARITASCHWINGER ) ) {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << " EvtRareLbToLll expects DIRAC or RARITASWINGER daughter "
             << std::endl;
     }
 
     // We expect that the second and third daughters
     // are the ell+ and ell-
     checkSpinDaughter( 1, EvtSpinType::DIRAC );
     checkSpinDaughter( 2, EvtSpinType::DIRAC );
 
     // Work out whether we have electron mode
     const EvtIdSet leptons{ "e-", "e+" };
     if ( leptons.contains( getDaug( 1 ) ) ) {
       m_electronMode = true;
       EvtGenReport( EVTGEN_ERROR, "EvtGen" )
           << " EvtRareLbToLll has dielectron final state" << std::endl;
     }
 
-    std::string model = getArgStr( 0 );
+    std::string model{ "LQCD" };
+    if ( getNArg() == 1) {
+	model = getArgStr( 0 );
+    }
     if ( model == "Gutsche" ) {
         ffmodel_ = std::make_unique<EvtRareLbToLllFFGutsche>();
     } else if ( model == "LQCD" ) {
         ffmodel_ = std::make_unique<EvtRareLbToLllFFlQCD>();
     } else if ( model == "MR" ) {
         ffmodel_ = std::make_unique<EvtRareLbToLllFF>();
     } else {
         EvtGenReport( EVTGEN_INFO, "EvtGen" )
             << "  Unknown form-factor model, valid options are MR, LQCD, Gutsche."
-            << std::endl;
-        ::abort();
+            << "  Assuming LQCD form-factors... " << std::endl;
+        ffmodel_ = std::make_unique<EvtRareLbToLllFFlQCD>();
     }
     wcmodel_ = std::make_unique<EvtRareLbToLllWC>();
 
     ffmodel_->init();
 
     return;
 }
 
 void EvtRareLbToLll::initProbMax()
 {
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << " EvtRareLbToLll is finding maximum probability ... " << std::endl;
 
     m_maxProbability = 0;
 
     if ( m_maxProbability == 0 ) {
         EvtDiracParticle parent{};
         parent.noLifeTime();
         parent.init( getParentId(),
                      EvtVector4R( EvtPDL::getMass( getParentId() ), 0, 0, 0 ) );
         parent.setDiagonalSpinDensity();
 
         EvtAmp amp;
         EvtId daughters[3] = {getDaug( 0 ), getDaug( 1 ), getDaug( 2 )};
         amp.init( getParentId(), 3, daughters );
         parent.makeDaughters( 3, daughters );
         EvtParticle* lambda = parent.getDaug( 0 );
         EvtParticle* lep1 = parent.getDaug( 1 );
         EvtParticle* lep2 = parent.getDaug( 2 );
         lambda->noLifeTime();
         lep1->noLifeTime();
         lep2->noLifeTime();
 
         EvtSpinDensity rho;
         rho.setDiag( parent.getSpinStates() );
 
         const double M0 = EvtPDL::getMass( getParentId() );
         const double mL = EvtPDL::getMass( getDaug( 0 ) );
         const double m1 = EvtPDL::getMass( getDaug( 1 ) );
         const double m2 = EvtPDL::getMass( getDaug( 2 ) );
 
         const double q2min = ( m1 + m2 ) * ( m1 + m2 );
         const double q2max = ( M0 - mL ) * ( M0 - mL );
 
         EvtVector4R p4lambda, p4lep1, p4lep2, boost;
 
         EvtGenReport( EVTGEN_INFO, "EvtGen" )
             << " EvtRareLbToLll is probing whole phase space ..." << std::endl;
 
         double prob = 0;
         const int nsteps = 5000;
         for ( int i = 0; i <= nsteps; i++ ) {
             const double q2 = q2min + i * ( q2max - q2min ) / nsteps;
             const double elambda = ( M0 * M0 + mL * mL - q2 ) / 2 / M0;
             double pstar{0};
             if ( i != 0 ) {
                 pstar = sqrt( q2 - ( m1 + m2 ) * ( m1 + m2 ) ) *
                         sqrt( q2 - ( m1 - m2 ) * ( m1 - m2 ) ) / 2 / sqrt( q2 );
             }
             boost.set( M0 - elambda, 0, 0, +sqrt( elambda * elambda - mL * mL ) );
             if ( i != nsteps ) {
                 p4lambda.set( elambda, 0, 0,
                               -sqrt( elambda * elambda - mL * mL ) );
             } else {
                 p4lambda.set( mL, 0, 0, 0 );
             }
             for ( int j = 0; j <= 45; j++ ) {
                 const double theta = j * EvtConst::pi / 45;
                 p4lep1.set( sqrt( pstar * pstar + m1 * m1 ), 0,
                             +pstar * sin( theta ), +pstar * cos( theta ) );
                 p4lep2.set( sqrt( pstar * pstar + m2 * m2 ), 0,
                             -pstar * sin( theta ), -pstar * cos( theta ) );
 
                 if ( i != nsteps)    // At maximal q2 we are already in correct frame as Lambda and W/Zvirtual are at rest
                 {
                     p4lep1 = boostTo( p4lep1, boost );
                     p4lep2 = boostTo( p4lep2, boost );
                 }
                 lambda->init( getDaug( 0 ), p4lambda );
                 lep1->init( getDaug( 1 ), p4lep1 );
                 lep2->init( getDaug( 2 ), p4lep2 );
                 calcAmp( amp, parent );
                 prob = rho.normalizedProb( amp.getSpinDensity() );
                 // In case of electron mode add pole
                 if ( m_electronMode ) {
                     prob /= 1.0 + m_poleSize / ( q2*q2 );
                 }
  
                 if ( prob > m_maxProbability ) {
                     EvtGenReport( EVTGEN_INFO, "EvtGen" )
                         << "  - probability " << prob << " found at q2 = " << q2
                         << " (" << nsteps * ( q2 - q2min ) / ( q2max - q2min )
                         << " %) and theta = " << theta * 180 / EvtConst::pi
                         << std::endl;
                     m_maxProbability = prob;
                 }
             }
         }
 
         m_maxProbability *= 1.05;
     }
 
     setProbMax( m_maxProbability );
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << " EvtRareLbToLll set up maximum probability to " << m_maxProbability
         << std::endl;
 }
 
 void EvtRareLbToLll::decay( EvtParticle* parent )
 {
     // Phase space initialization depends on what leptons are
     if ( m_electronMode ) {
         setWeight( parent->initializePhaseSpace( getNDaug(), getDaugs(), false,
                                                  m_poleSize, 1, 2 ) );
     } else {
         parent->initializePhaseSpace( getNDaug(), getDaugs() );
     }
     calcAmp( _amp2, *parent );
 }
 
 bool EvtRareLbToLll::isParticle( const EvtParticle& parent ) const
 {
     const EvtIdSet partlist{ "Lambda_b0" };
 
     return partlist.contains( parent.getId() );
 }
 
 void EvtRareLbToLll::calcAmp( EvtAmp& amp, const EvtParticle& parent )
 {
     //parent->setDiagonalSpinDensity();
 
     const EvtParticle* lambda = parent.getDaug( 0 );
 
     const EvtIdSet leptons{ "e-", "mu-", "tau-" };
 
     const bool isparticle = isParticle( parent );
 
     const EvtParticle* lp = 0;
     const EvtParticle* lm = 0;
 
     if ( leptons.contains( parent.getDaug( 1 )->getId() ) ) {
         lp = parent.getDaug( 1 );
         lm = parent.getDaug( 2 );
     } else {
         lp = parent.getDaug( 2 );
         lm = parent.getDaug( 1 );
     }
 
     EvtVector4R P;
     P.set( parent.mass(), 0.0, 0.0, 0.0 );
 
     EvtVector4R q = lp->getP4() + lm->getP4();
     const double qsq = q.mass2();
 
     // Leptonic currents
     EvtVector4C LV[2][2];    // \bar{\ell} \gamma^{\mu} \ell
     EvtVector4C LA[2][2];    // \bar{\ell} \gamma^{\mu} \gamma^{5} \ell
 
     for ( int i = 0; i < 2; ++i ) {
         for ( int j = 0; j < 2; ++j ) {
             if ( isparticle ) {
                 LV[i][j] = EvtLeptonVCurrent( lp->spParent( i ),
                                               lm->spParent( j ) );
                 LA[i][j] = EvtLeptonACurrent( lp->spParent( i ),
                                               lm->spParent( j ) );
             } else {
                 LV[i][j] = EvtLeptonVCurrent( lp->spParent( 1 - i ),
                                               lm->spParent( 1 - j ) );
                 LA[i][j] = EvtLeptonACurrent( lp->spParent( 1 - i ),
                                               lm->spParent( 1 - j ) );
             }
         }
     }
 
     EvtRareLbToLllFF::FormFactors FF;
     //F, G, FT and GT
     ffmodel_->getFF( parent, *lambda, FF );
 
     EvtComplex C7eff = wcmodel_->GetC7Eff( qsq );
     EvtComplex C9eff = wcmodel_->GetC9Eff( qsq );
     EvtComplex C10eff = wcmodel_->GetC10Eff( qsq );
 
     EvtComplex AC[4];
     EvtComplex BC[4];
     EvtComplex DC[4];
     EvtComplex EC[4];
 
     // check to see if particle is same or opposite parity to Lb
     const int parity = ffmodel_->isNatural( *lambda ) ? 1 : -1;
 
     // Lambda spin type
     const EvtSpinType::spintype spin = EvtPDL::getSpinType( lambda->getId() );
 
     const double mb = 5.209;
 
     // Eq. 48 + 49
     for ( unsigned int i = 0; i < 4; ++i ) {
         if ( parity > 0 ) {
             AC[i] = -2. * mb * C7eff * FF.FT_[i] / qsq + C9eff * FF.F_[i];
             BC[i] = -2. * mb * C7eff * FF.GT_[i] / qsq - C9eff * FF.G_[i];
             DC[i] = C10eff * FF.F_[i];
             EC[i] = -C10eff * FF.G_[i];
         } else {
             AC[i] = -2. * mb * C7eff * FF.GT_[i] / qsq - C9eff * FF.G_[i];
             BC[i] = -2. * mb * C7eff * FF.FT_[i] / qsq + C9eff * FF.F_[i];
             DC[i] = -C10eff * FF.G_[i];
             EC[i] = C10eff * FF.F_[i];
         }
     }
 
     // handle particle -> antiparticle in Hadronic currents
     const double cv = ( isparticle > 0 ) ? 1.0 : -1.0 * parity;
     const double ca = ( isparticle > 0 ) ? 1.0 : +1.0 * parity;
     const double cs = ( isparticle > 0 ) ? 1.0 : +1.0 * parity;
     const double cp = ( isparticle > 0 ) ? 1.0 : -1.0 * parity;
 
     if ( EvtSpinType::DIRAC == spin ) {
         EvtVector4C H1[2][2];    // vector current
         EvtVector4C H2[2][2];    // axial-vector
 
         EvtVector4C T[6];
         // Hadronic currents
         for ( int i = 0; i < 2; ++i ) {
             for ( int j = 0; j < 2; ++j ) {
                 HadronicAmp( parent, *lambda, T, i, j );
 
                 H1[i][j] = ( cv * AC[0] * T[0] + ca * BC[0] * T[1] +
                              cs * AC[1] * T[2] + cp * BC[1] * T[3] +
                              cs * AC[2] * T[4] + cp * BC[2] * T[5] );
 
                 H2[i][j] = ( cv * DC[0] * T[0] + ca * EC[0] * T[1] +
                              cs * DC[1] * T[2] + cp * EC[1] * T[3] +
                              cs * DC[2] * T[4] + cp * EC[2] * T[5] );
             }
         }
 
         // Spin sums
         int spins[4];
 
         for ( int i = 0; i < 2; ++i ) {
             for ( int ip = 0; ip < 2; ++ip ) {
                 for ( int j = 0; j < 2; ++j ) {
                     for ( int jp = 0; jp < 2; ++jp ) {
                         spins[0] = i;
                         spins[1] = ip;
                         spins[2] = j;
                         spins[3] = jp;
 
                         EvtComplex M = H1[i][ip] * LV[j][jp] +
                                        H2[i][ip] * LA[j][jp];
 
                         amp.vertex( spins, M );
                     }
                 }
             }
         }
     } else if ( EvtSpinType::RARITASCHWINGER == spin ) {
         EvtVector4C T[8];
 
         EvtVector4C H1[2][4];    // vector current // swaped
         EvtVector4C H2[2][4];    // axial-vector
 
         // Build hadronic amplitude
         for ( int i = 0; i < 2; ++i ) {
             for ( int j = 0; j < 4; ++j ) {
                 HadronicAmpRS( parent, *lambda, T, i, j );
                 H1[i][j] = ( cv * AC[0] * T[0] + ca * BC[0] * T[1] +
                              cs * AC[1] * T[2] + cp * BC[1] * T[3] +
                              cs * AC[2] * T[4] + cp * BC[2] * T[5] +
                              cs * AC[3] * T[6] + cp * BC[3] * T[7] );
                 H2[i][j] = ( cv * DC[0] * T[0] + ca * EC[0] * T[1] +
                              cs * DC[1] * T[2] + cp * EC[1] * T[3] +
                              cs * DC[2] * T[4] + cp * EC[2] * T[5] +
                              cs * DC[3] * T[6] + cp * EC[3] * T[7] );
             }
         }
 
         // Spin sums
         int spins[4];
 
         for ( int i = 0; i < 2; ++i ) {
             for ( int ip = 0; ip < 4; ++ip ) {
                 for ( int j = 0; j < 2; ++j ) {
                     for ( int jp = 0; jp < 2; ++jp ) {
                         spins[0] = i;
                         spins[1] = ip;
                         spins[2] = j;
                         spins[3] = jp;
 
                         EvtComplex M = H1[i][ip] * LV[j][jp] +
                                        H2[i][ip] * LA[j][jp];
 
                         amp.vertex( spins, M );
                     }
                 }
             }
         }
     } else {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << " EvtRareLbToLll expects DIRAC or RARITASWINGER daughter "
             << std::endl;
     }
 
     return;
 }
 
 // spin 1/2 daughters
 
 void EvtRareLbToLll::HadronicAmp( const EvtParticle& parent,
                                   const EvtParticle& lambda, EvtVector4C* T,
                                   const int i, const int j )
 {
     const EvtDiracSpinor Sfinal = lambda.spParent( j );
     const EvtDiracSpinor Sinit = parent.sp( i );
 
     const EvtVector4R L = lambda.getP4();
 
     EvtVector4R P;
     P.set( parent.mass(), 0.0, 0.0, 0.0 );
 
     const double Pm = parent.mass();
     const double Lm = lambda.mass();
 
     // \bar{u} \gamma^{\mu} u
     T[0] = EvtLeptonVCurrent( Sfinal, Sinit );
 
     // \bar{u} \gamma^{\mu}\gamma^{5} u
     T[1] = EvtLeptonACurrent( Sfinal, Sinit );
 
     // \bar{u} v^{\mu} u
     T[2] = EvtLeptonSCurrent( Sfinal, Sinit ) * ( P / Pm );
 
     // \bar{u} v^{\mu} \gamma^{5} u
     T[3] = EvtLeptonPCurrent( Sfinal, Sinit ) * ( P / Pm );
 
     // \bar{u} v^{\prime\mu} u
     T[4] = EvtLeptonSCurrent( Sfinal, Sinit ) * ( L / Lm );
 
     // \bar{u} v^{\prime\mu} \gamma^{5}
     T[5] = EvtLeptonPCurrent( Sfinal, Sinit ) * ( L / Lm );
 
     // Where:
     // v = p_{\Lambda_b}/m_{\Lambda_b}
     // v^{\prime} =  p_{\Lambda}/m_{\Lambda}
 
     return;
 }
 
 // spin 3/2 daughters
 
 void EvtRareLbToLll::HadronicAmpRS( const EvtParticle& parent,
                                     const EvtParticle& lambda, EvtVector4C* T,
                                     const int i, const int j )
 {
     const EvtRaritaSchwinger Sfinal = lambda.spRSParent( j );
     const EvtDiracSpinor Sinit = parent.sp( i );
 
     EvtVector4R P;
     P.set( parent.mass(), 0.0, 0.0, 0.0 );
 
     const EvtVector4R L = lambda.getP4();
 
     EvtTensor4C ID;
     ID.setdiag( 1.0, 1.0, 1.0, 1.0 );
 
     EvtDiracSpinor Sprime;
 
     for ( int i = 0; i < 4; i++ ) {
         Sprime.set_spinor( i, Sfinal.getVector( i ) * P );
     }
 
     const double Pmsq = P.mass2();
     const double Pm = parent.mass();
     const double PmLm = Pm * lambda.mass();
 
     EvtVector4C V1, V2;
 
     for ( int i = 0; i < 4; i++ ) {
         V1.set( i, EvtLeptonSCurrent( Sfinal.getSpinor( i ), Sinit ) );
         V2.set( i, EvtLeptonPCurrent( Sfinal.getSpinor( i ), Sinit ) );
     }
 
     // \bar{u}_{alpha} v^{\alpha} \gamma^{\mu} u
     T[0] = EvtLeptonVCurrent( Sprime, Sinit ) * ( 1 / Pm );
 
     // \bar{u}_{alpha}  v^{\alpha} \gamma^{\mu} \gamma^{5} u
     T[1] = EvtLeptonACurrent( Sprime, Sinit ) * ( 1 / Pm );
 
     // \bar{u}_{\alpha} v^{\alpha} v^{\mu} u
     T[2] = EvtLeptonSCurrent( Sprime, Sinit ) * ( P / Pmsq );
 
     // \bar{u}_{\alpha} v^{\alpha} v^{\mu} \gamma^{5} u
     T[3] = EvtLeptonPCurrent( Sprime, Sinit ) * ( P / Pmsq );
 
     // \bar{u}_{\alpha} v^{\alpha} v^{\prime \mu} u
     T[4] = EvtLeptonSCurrent( Sprime, Sinit ) * ( L / PmLm );
 
     // \bar{u}_{\alpha} v^{\alpha} v^{\prime \mu} \gamma^{5} u
     T[5] = EvtLeptonPCurrent( Sprime, Sinit ) * ( L / PmLm );
 
     // \bar{u}_{\alpha} g^{\alpha\mu} u
     T[6] = ID.cont2( V1 );
 
     // \bar{u}_{\alpha} g^{\alpha\mu} \gamma^{5} u
     T[7] = ID.cont2( V2 );
 
     // Where:
     //  v = p_{\Lambda_b}/m_{\Lambda_b}
     //  v^{\prime} =  p_{\Lambda}/m_{\Lambda}
 
     return;
 }
diff --git a/src/EvtGenModels/EvtSSSCPT.cpp b/src/EvtGenModels/EvtSSSCPT.cpp
index 7a2b351..d34b486 100644
--- a/src/EvtGenModels/EvtSSSCPT.cpp
+++ b/src/EvtGenModels/EvtSSSCPT.cpp
@@ -1,95 +1,104 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtSSSCPT.hh"
 
 #include "EvtGenBase/EvtCPUtil.hh"
 #include "EvtGenBase/EvtConst.hh"
 #include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtId.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtReport.hh"
 
 #include <stdlib.h>
 #include <string>
 
 std::string EvtSSSCPT::getName()
 {
     return "SSS_CPT";
 }
 
 EvtDecayBase* EvtSSSCPT::clone()
 {
     return new EvtSSSCPT;
 }
 
 void EvtSSSCPT::init()
 {
     // check that there are 8 arguments
     checkNArg( 8 );
     checkNDaug( 2 );
+
+    // Set amplitude coeffs
+    setAmpCoeffs();
+}
+
+void EvtSSSCPT::setAmpCoeffs()
+{
+    P = EvtComplex( cos( -getArg( 0 ) ), sin( -getArg( 0 ) ) );
+    Q = EvtComplex( cos( getArg( 0 ) ), sin( getArg( 0 ) ) );
+    D = EvtComplex( getArg( 6 ) * cos( getArg( 7 ) ),
+                    getArg( 6 ) * sin( getArg( 7 ) ) );
+    Im = EvtComplex( 0.0, 1.0 );
+
+    A = EvtComplex( getArg( 2 ) * cos( getArg( 3 ) ),
+                    getArg( 2 ) * sin( getArg( 3 ) ) );
+    Abar = EvtComplex( getArg( 4 ) * cos( getArg( 5 ) ),
+                       getArg( 4 ) * sin( getArg( 5 ) ) );
+}
+
+void EvtSSSCPT::initProbMax()
+{
+    const double maxProb = 2.0 * abs2( A ) + 4.0 * abs2( Abar ) * abs2( D );
+    setProbMax( maxProb );
 }
 
 void EvtSSSCPT::decay( EvtParticle* p )
 {
     //added by Lange Jan4,2000
     static EvtId B0 = EvtPDL::getId( "B0" );
     static EvtId B0B = EvtPDL::getId( "anti-B0" );
 
     double t;
     EvtId other_b;
 
     EvtCPUtil::getInstance()->OtherB( p, t, other_b, 0.5 );
 
     p->initializePhaseSpace( getNDaug(), getDaugs() );
 
     EvtComplex amp;
 
-    EvtComplex A, Abar;
-    EvtComplex P, Q, D, Im;
-
-    P = EvtComplex( cos( -getArg( 0 ) ), sin( -getArg( 0 ) ) );
-    Q = EvtComplex( cos( getArg( 0 ) ), sin( getArg( 0 ) ) );
-    D = EvtComplex( getArg( 6 ) * cos( getArg( 7 ) ),
-                    getArg( 6 ) * sin( getArg( 7 ) ) );
-    Im = EvtComplex( 0.0, 1.0 );
-
-    A = EvtComplex( getArg( 2 ) * cos( getArg( 3 ) ),
-                    getArg( 2 ) * sin( getArg( 3 ) ) );
-    Abar = EvtComplex( getArg( 4 ) * cos( getArg( 5 ) ),
-                       getArg( 4 ) * sin( getArg( 5 ) ) );
-
     if ( other_b == B0B ) {
         amp = A * cos( getArg( 1 ) * t / ( 2 * EvtConst::c ) ) +
               Im * sin( getArg( 1 ) * t / ( 2 * EvtConst::c ) ) *
                   ( Q / P * A + 2.0 * D * Abar );
     }
     if ( other_b == B0 ) {
         amp = Abar * cos( getArg( 1 ) * t / ( 2 * EvtConst::c ) ) +
               Im * sin( getArg( 1 ) * t / ( 2 * EvtConst::c ) ) *
                   ( P / Q * A - 2.0 * D * Abar );
     }
 
     vertex( amp );
 
     return;
 }
diff --git a/src/EvtGenModels/EvtSSSCPpng.cpp b/src/EvtGenModels/EvtSSSCPpng.cpp
index 3a94c53..850fb19 100644
--- a/src/EvtGenModels/EvtSSSCPpng.cpp
+++ b/src/EvtGenModels/EvtSSSCPpng.cpp
@@ -1,163 +1,167 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtSSSCPpng.hh"
 
 #include "EvtGenBase/EvtCPUtil.hh"
 #include "EvtGenBase/EvtConst.hh"
 #include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtId.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtRandom.hh"
 #include "EvtGenBase/EvtReport.hh"
 
 #include <stdlib.h>
 #include <string>
 
 std::string EvtSSSCPpng::getName()
 {
     return "SSS_CP_PNG";
 }
 
 EvtDecayBase* EvtSSSCPpng::clone()
 {
     return new EvtSSSCPpng;
 }
 
 void EvtSSSCPpng::init()
 {
     // check that there are 7 arguments
     checkNArg( 7 );
     checkNDaug( 2 );
 
     checkSpinParent( EvtSpinType::SCALAR );
 
     checkSpinDaughter( 0, EvtSpinType::SCALAR );
     checkSpinDaughter( 1, EvtSpinType::SCALAR );
 }
 
 void EvtSSSCPpng::initProbMax()
 {
-    setProbMax( getArg( 5 ) * getArg( 5 ) * ( 1 + getArg( 6 ) * getArg( 6 ) ) );
+    const double ASq = getArg( 5 ) * getArg( 5 ) + getArg( 6 ) * getArg( 6 );
+    const double max = ASq * ( 1.0 + getArg( 4 ) * getArg( 4 ) );
+    setProbMax( max );
 }
 
 void EvtSSSCPpng::decay( EvtParticle* p )
 {
     //added by Lange Jan4,2000
     static EvtId B0 = EvtPDL::getId( "B0" );
     static EvtId B0B = EvtPDL::getId( "anti-B0" );
 
     double t;
     EvtId other_b;
 
     p->initializePhaseSpace( getNDaug(), getDaugs() );
 
     EvtComplex amp;
 
     EvtComplex A, Abar;
     //EvtComplex ACC, AbarCC;
 
     // assume single (top) quark dominance for the penguin.
 
     // old: a0=alpha, a1=dm, a2=1, a3=1, a4=0, a5=1, a6=0
     // new: a0=beta, a1=gamma, a2=delta, a3=dm, a4=1, a5=1=A_{T}, a6=A_{P}/A_{T}
 
     // e.g., for B -> pi pi
     // A_{T} = |V_{ub} V_{ud}| T
     // A_{P} = |V_{tb} V_{td}| P
     // P and T are purely hadronic matrix elements
     // P/T = 0.055, A_{P}/A_{T} = 0.2 (see Marrocchesi and Paver, hep-ph/9702353)
 
     // A = A_{T}( exp(i(beta+gamma)) + (A_{P}/A_{T}) exp(i(delta))
     // A_bar = same, except for the sign of the weak phases
     // here, delta = delta_{p}-delta_{t} (rel. strong phase)
 
     A = getArg( 5 ) *
         ( EvtComplex( cos( -getArg( 0 ) - getArg( 1 ) ),
                       sin( -getArg( 0 ) - getArg( 1 ) ) ) +
           getArg( 6 ) * EvtComplex( cos( getArg( 2 ) ), sin( getArg( 2 ) ) ) );
 
     Abar = getArg( 5 ) * ( EvtComplex( cos( getArg( 0 ) + getArg( 1 ) ),
                                        sin( getArg( 0 ) + getArg( 1 ) ) ) +
                            getArg( 6 ) * EvtComplex( cos( getArg( 2 ) ),
                                                      sin( getArg( 2 ) ) ) );
 
     // get fraction of B0 tags with these amplitudes
 
     //double xd = 0.65;
-    double ratio = 1 / ( 1 + 0.65 * 0.65 );
+    const double ratio = 1 / ( 1 + 0.65 * 0.65 );
 
     EvtComplex rf, rbarf;
 
     rf = EvtComplex( cos( 2.0 * getArg( 0 ) ), sin( 2.0 * getArg( 0 ) ) ) *
          Abar / A;
     rbarf = EvtComplex( 1.0 ) / rf;
 
-    double A2 = real( A ) * real( A ) + imag( A ) * imag( A );
-    double Abar2 = real( Abar ) * real( Abar ) + imag( Abar ) * imag( Abar );
+    const double A2 = real( A ) * real( A ) + imag( A ) * imag( A );
+    const double Abar2 = real( Abar ) * real( Abar ) +
+                         imag( Abar ) * imag( Abar );
 
-    double rf2 = real( rf ) * real( rf ) + imag( rf ) * imag( rf );
-    double rbarf2 = real( rbarf ) * real( rbarf ) + imag( rbarf ) * imag( rbarf );
+    const double rf2 = real( rf ) * real( rf ) + imag( rf ) * imag( rf );
+    const double rbarf2 = real( rbarf ) * real( rbarf ) +
+                          imag( rbarf ) * imag( rbarf );
 
     //fraction of B0 _tags_
-    double fract = ( Abar2 * ( 1 + rbarf2 + ( 1 - rbarf2 ) * ratio ) ) /
-                   ( Abar2 * ( 1 + rbarf2 + ( 1 - rbarf2 ) * ratio ) +
-                     A2 * ( 1 + rf2 + ( 1 - rf2 ) * ratio ) );
+    const double fract = ( Abar2 * ( 1 + rbarf2 + ( 1 - rbarf2 ) * ratio ) ) /
+                         ( Abar2 * ( 1 + rbarf2 + ( 1 - rbarf2 ) * ratio ) +
+                           A2 * ( 1 + rf2 + ( 1 - rf2 ) * ratio ) );
 
     EvtCPUtil::getInstance()->OtherB( p, t, other_b, fract );
 
     //this method works just as well -- NK
     //randomly generate the tag (B0 or B0B)
 
     //  double tag = EvtRandom::Flat(0.0,1.0);
     //  if (tag < 0.5) {
     //
     //   EvtCPUtil::OtherB(p,t,other_b,1.0);
     //   other_b = B0;
     //  }
     //  else {
     //
     //   EvtCPUtil::OtherB(p,t,other_b,0.0);
     //   other_b = B0B;
     //  }
 
     //mixing angle = -beta
 
     if ( other_b == B0B ) {
         amp = A * cos( getArg( 3 ) * t / ( 2 * EvtConst::c ) ) +
               EvtComplex( cos( 2.0 * getArg( 0 ) ), sin( 2.0 * getArg( 0 ) ) ) *
                   getArg( 4 ) * EvtComplex( 0.0, 1.0 ) * Abar *
                   sin( getArg( 3 ) * t / ( 2 * EvtConst::c ) );
     }
     if ( other_b == B0 ) {
         amp = A *
                   EvtComplex( cos( -2.0 * getArg( 0 ) ),
                               sin( -2.0 * getArg( 0 ) ) ) *
                   EvtComplex( 0.0, 1.0 ) *
                   sin( getArg( 3 ) * t / ( 2 * EvtConst::c ) ) +
               getArg( 4 ) * Abar * cos( getArg( 3 ) * t / ( 2 * EvtConst::c ) );
     }
 
     vertex( amp );
 
     return;
 }
diff --git a/src/EvtGenModels/EvtSVSCPiso.cpp b/src/EvtGenModels/EvtSVSCPiso.cpp
index bf6e0e3..bdd3846 100644
--- a/src/EvtGenModels/EvtSVSCPiso.cpp
+++ b/src/EvtGenModels/EvtSVSCPiso.cpp
@@ -1,322 +1,274 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtSVSCPiso.hh"
 
 #include "EvtGenBase/EvtCPUtil.hh"
 #include "EvtGenBase/EvtConst.hh"
 #include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtId.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtRandom.hh"
 #include "EvtGenBase/EvtReport.hh"
 #include "EvtGenBase/EvtVector4C.hh"
 
 #include <stdlib.h>
 #include <string>
 
 std::string EvtSVSCPiso::getName()
 {
     return "SVS_CP_ISO";
 }
 
 EvtDecayBase* EvtSVSCPiso::clone()
 {
     return new EvtSVSCPiso;
 }
 
 void EvtSVSCPiso::init()
 {
     // check that there are 27 arguments
     checkNArg( 27 );
     checkNDaug( 2 );
 
     checkSpinParent( EvtSpinType::SCALAR );
 
     checkSpinDaughter( 0, EvtSpinType::VECTOR );
     checkSpinDaughter( 1, EvtSpinType::SCALAR );
+
+    // Set amplitude coefficients
+    setAmpCoeffs();
+    // Calculate amplitude terms
+    calcAmpTerms();
 }
 
-void EvtSVSCPiso::initProbMax()
+void EvtSVSCPiso::setAmpCoeffs()
 {
-    //this might need some revision..
-
-    if ( ( EvtPDL::chg3( getDaug( 0 ) ) > 0 ) &&
-         ( EvtPDL::chg3( getDaug( 1 ) ) == 0 ) ) {
-        setProbMax( 2.0 * ( getArg( 3 ) * getArg( 3 ) +
-                            4.0 * getArg( 23 ) * getArg( 23 ) ) );
-    }
-
-    if ( ( EvtPDL::chg3( getDaug( 0 ) ) < 0 ) &&
-         ( EvtPDL::chg3( getDaug( 1 ) ) == 0 ) ) {
-        setProbMax( 2.0 * ( getArg( 5 ) * getArg( 5 ) +
-                            4.0 * getArg( 25 ) * getArg( 25 ) ) );
-    }
-
-    if ( ( EvtPDL::chg3( getDaug( 0 ) ) == 0 ) &&
-         ( EvtPDL::chg3( getDaug( 1 ) ) > 0 ) ) {
-        setProbMax( 2.0 * ( getArg( 7 ) * getArg( 7 ) +
-                            4.0 * getArg( 23 ) * getArg( 23 ) ) );
-    }
-
-    if ( ( EvtPDL::chg3( getDaug( 0 ) ) == 0 ) &&
-         ( EvtPDL::chg3( getDaug( 1 ) ) < 0 ) ) {
-        setProbMax( 2.0 * ( getArg( 9 ) * getArg( 9 ) +
-                            4.0 * getArg( 25 ) * getArg( 25 ) ) );
-    }
-
-    if ( ( EvtPDL::chg3( getDaug( 0 ) ) > 0 ) &&
-         ( EvtPDL::chg3( getDaug( 1 ) ) < 0 ) ) {
-        setProbMax(
-            2.0 * ( getArg( 11 ) * getArg( 11 ) + getArg( 23 ) * getArg( 23 ) +
-                    getArg( 19 ) * getArg( 19 ) + getArg( 13 ) * getArg( 13 ) +
-                    getArg( 25 ) * getArg( 25 ) + getArg( 21 ) * getArg( 21 ) ) );
-    }
-
-    if ( ( EvtPDL::chg3( getDaug( 0 ) ) < 0 ) &&
-         ( EvtPDL::chg3( getDaug( 1 ) ) > 0 ) ) {
-        setProbMax(
-            2.0 * ( getArg( 15 ) * getArg( 15 ) + getArg( 23 ) * getArg( 23 ) +
-                    getArg( 19 ) * getArg( 19 ) + getArg( 17 ) * getArg( 17 ) +
-                    getArg( 25 ) * getArg( 25 ) + getArg( 21 ) * getArg( 21 ) ) );
-    }
+    Tp0 = EvtComplex( getArg( 3 ) * cos( getArg( 4 ) ),
+                      getArg( 3 ) * sin( getArg( 4 ) ) );
+    Tp0_bar = EvtComplex( getArg( 5 ) * cos( getArg( 6 ) ),
+                          getArg( 5 ) * sin( getArg( 6 ) ) );
+    T0p = EvtComplex( getArg( 7 ) * cos( getArg( 8 ) ),
+                      getArg( 7 ) * sin( getArg( 8 ) ) );
+    T0p_bar = EvtComplex( getArg( 9 ) * cos( getArg( 10 ) ),
+                          getArg( 9 ) * sin( getArg( 10 ) ) );
+    Tpm = EvtComplex( getArg( 11 ) * cos( getArg( 12 ) ),
+                      getArg( 11 ) * sin( getArg( 12 ) ) );
+    Tpm_bar = EvtComplex( getArg( 13 ) * cos( getArg( 14 ) ),
+                          getArg( 13 ) * sin( getArg( 14 ) ) );
+    Tmp = EvtComplex( getArg( 15 ) * cos( getArg( 16 ) ),
+                      getArg( 15 ) * sin( getArg( 16 ) ) );
+    Tmp_bar = EvtComplex( getArg( 17 ) * cos( getArg( 18 ) ),
+                          getArg( 17 ) * sin( getArg( 18 ) ) );
+    P0 = EvtComplex( getArg( 19 ) * cos( getArg( 20 ) ),
+                     getArg( 19 ) * sin( getArg( 20 ) ) );
+    P0_bar = EvtComplex( getArg( 21 ) * cos( getArg( 22 ) ),
+                         getArg( 21 ) * sin( getArg( 22 ) ) );
+    P1 = EvtComplex( getArg( 23 ) * cos( getArg( 24 ) ),
+                     getArg( 23 ) * sin( getArg( 24 ) ) );
+    P1_bar = EvtComplex( getArg( 25 ) * cos( getArg( 26 ) ),
+                         getArg( 25 ) * sin( getArg( 26 ) ) );
+}
 
-    if ( ( EvtPDL::chg3( getDaug( 0 ) ) == 0 ) &&
-         ( EvtPDL::chg3( getDaug( 1 ) ) == 0 ) ) {
-        setProbMax(
-            2.0 * ( getArg( 7 ) * getArg( 7 ) + getArg( 3 ) * getArg( 3 ) +
-                    getArg( 11 ) * getArg( 11 ) + getArg( 15 ) * getArg( 15 ) +
-                    4.0 * getArg( 19 ) * getArg( 19 ) +
-                    getArg( 9 ) * getArg( 9 ) + getArg( 5 ) * getArg( 5 ) +
-                    getArg( 13 ) * getArg( 13 ) + getArg( 17 ) * getArg( 17 ) +
-                    4.0 * getArg( 21 ) * getArg( 21 ) ) );
-    }
+void EvtSVSCPiso::initProbMax()
+{
+    const double max1 = abs2( A_f ) + abs2( Abar_f );
+    const double max2 = abs2( A_fbar ) + abs2( Abar_fbar );
+    // Amplitude has momentum normalisation that roughly scales with (parent mass)/2
+    // so probability will scale with 0.25 * parenMassSq. Use 0.3 * parMassSq
+    // in case we get larger normalisation values
+    const double parMass = EvtPDL::getMeanMass( getParentId() );
+    const double max = 0.3 * parMass * parMass * ( max1 + max2 );
+    setProbMax( max );
 }
 
 void EvtSVSCPiso::decay( EvtParticle* p )
 {
     //added by Lange Jan4,2000
     static EvtId B0 = EvtPDL::getId( "B0" );
     static EvtId B0B = EvtPDL::getId( "anti-B0" );
 
     double t;
     EvtId other_b;
-    int charged( 0 );
 
     int first_time = 0;
     int flip = 0;
     EvtId ds[2];
 
-    //randomly generate the tag (B0 or B0B)
-
-    double tag = EvtRandom::Flat( 0.0, 1.0 );
+    // Randomly generate the tag (B0 or B0B)
+    const double tag = EvtRandom::Flat( 0.0, 1.0 );
     if ( tag < 0.5 ) {
         EvtCPUtil::getInstance()->OtherB( p, t, other_b, 1.0 );
         other_b = B0;
     } else {
         EvtCPUtil::getInstance()->OtherB( p, t, other_b, 0.0 );
         other_b = B0B;
     }
 
     if ( p->getNDaug() == 0 )
         first_time = 1;
 
     if ( first_time ) {
         if ( EvtRandom::Flat( 0.0, 1.0 ) < getArg( 2 ) )
             flip = 1;
     } else {
         if ( getDaug( 0 ) != p->getDaug( 0 )->getId() )
             flip = 1;
     }
 
     if ( !flip ) {
         ds[0] = getDaug( 0 );
         ds[1] = getDaug( 1 );
     } else {
         ds[0] = EvtPDL::chargeConj( getDaug( 0 ) );
         ds[1] = EvtPDL::chargeConj( getDaug( 1 ) );
     }
 
     p->initializePhaseSpace( getNDaug(), ds );
 
     EvtParticle *v, *s;
     v = p->getDaug( 0 );
     s = p->getDaug( 1 );
 
     EvtComplex amp;
 
-    EvtComplex A_f, Abar_f;
-    EvtComplex A_fbar, Abar_fbar;
-    EvtComplex Apm, Apm_bar, Amp, Amp_bar;
+    if ( charged == 0 ) {
+        if ( !flip ) {
+            if ( other_b == B0B ) {
+                amp = A_f * cos( getArg( 1 ) * t / ( 2 * EvtConst::c ) ) +
+                      EvtComplex( cos( -2.0 * getArg( 0 ) ),
+                                  sin( -2.0 * getArg( 0 ) ) ) *
+                          EvtComplex( 0.0, 1.0 ) * Abar_f *
+                          sin( getArg( 1 ) * t / ( 2 * EvtConst::c ) );
+            }
+            if ( other_b == B0 ) {
+                amp = A_f *
+                          EvtComplex( cos( 2.0 * getArg( 0 ) ),
+                                      sin( 2.0 * getArg( 0 ) ) ) *
+                          EvtComplex( 0.0, 1.0 ) *
+                          sin( getArg( 1 ) * t / ( 2 * EvtConst::c ) ) +
+                      Abar_f * cos( getArg( 1 ) * t / ( 2 * EvtConst::c ) );
+            }
+        } else {
+            if ( other_b == B0B ) {
+                amp = A_fbar * cos( getArg( 1 ) * t / ( 2 * EvtConst::c ) ) +
+                      EvtComplex( cos( -2.0 * getArg( 0 ) ),
+                                  sin( -2.0 * getArg( 0 ) ) ) *
+                          EvtComplex( 0.0, 1.0 ) * Abar_fbar *
+                          sin( getArg( 1 ) * t / ( 2 * EvtConst::c ) );
+            }
+            if ( other_b == B0 ) {
+                amp = A_fbar *
+                          EvtComplex( cos( 2.0 * getArg( 0 ) ),
+                                      sin( 2.0 * getArg( 0 ) ) ) *
+                          EvtComplex( 0.0, 1.0 ) *
+                          sin( getArg( 1 ) * t / ( 2 * EvtConst::c ) ) +
+                      Abar_fbar * cos( getArg( 1 ) * t / ( 2 * EvtConst::c ) );
+            }
+        }
 
-    EvtComplex Tp0, Tp0_bar, T0p, T0p_bar, Tpm, Tpm_bar, Tmp, Tmp_bar;
-    EvtComplex P1, P1_bar, P0, P0_bar;
+    } else {
+        amp = A_f;
+    }
 
-    Tp0 = EvtComplex( getArg( 3 ) * cos( getArg( 4 ) ),
-                      getArg( 3 ) * sin( getArg( 4 ) ) );
-    Tp0_bar = EvtComplex( getArg( 5 ) * cos( getArg( 6 ) ),
-                          getArg( 5 ) * sin( getArg( 6 ) ) );
-    T0p = EvtComplex( getArg( 7 ) * cos( getArg( 8 ) ),
-                      getArg( 7 ) * sin( getArg( 8 ) ) );
-    T0p_bar = EvtComplex( getArg( 9 ) * cos( getArg( 10 ) ),
-                          getArg( 9 ) * sin( getArg( 10 ) ) );
-    Tpm = EvtComplex( getArg( 11 ) * cos( getArg( 12 ) ),
-                      getArg( 11 ) * sin( getArg( 12 ) ) );
-    Tpm_bar = EvtComplex( getArg( 13 ) * cos( getArg( 14 ) ),
-                          getArg( 13 ) * sin( getArg( 14 ) ) );
-    Tmp = EvtComplex( getArg( 15 ) * cos( getArg( 16 ) ),
-                      getArg( 15 ) * sin( getArg( 16 ) ) );
-    Tmp_bar = EvtComplex( getArg( 17 ) * cos( getArg( 18 ) ),
-                          getArg( 17 ) * sin( getArg( 18 ) ) );
-    P0 = EvtComplex( getArg( 19 ) * cos( getArg( 20 ) ),
-                     getArg( 19 ) * sin( getArg( 20 ) ) );
-    P0_bar = EvtComplex( getArg( 21 ) * cos( getArg( 22 ) ),
-                         getArg( 21 ) * sin( getArg( 22 ) ) );
-    P1 = EvtComplex( getArg( 23 ) * cos( getArg( 24 ) ),
-                     getArg( 23 ) * sin( getArg( 24 ) ) );
-    P1_bar = EvtComplex( getArg( 25 ) * cos( getArg( 26 ) ),
-                         getArg( 25 ) * sin( getArg( 26 ) ) );
+    const EvtVector4R p4_parent = v->getP4() + s->getP4();
+    const double norm = 1.0 / v->getP4().d3mag();
+
+    vertex( 0, amp * norm * p4_parent * ( v->epsParent( 0 ) ) );
+    vertex( 1, amp * norm * p4_parent * ( v->epsParent( 1 ) ) );
+    vertex( 2, amp * norm * p4_parent * ( v->epsParent( 2 ) ) );
+
+    return;
+}
+
+void EvtSVSCPiso::calcAmpTerms()
+{
+    const int Q1 = EvtPDL::chg3( getDaug( 0 ) );
+    const int Q2 = EvtPDL::chg3( getDaug( 1 ) );
 
     //***********************charged modes****************************
 
-    if ( ( EvtPDL::chg3( getDaug( 0 ) ) > 0 ) &&
-         ( EvtPDL::chg3( getDaug( 1 ) ) == 0 ) ) {
+    if ( Q1 > 0 && Q2 == 0 ) {
         //V+ S0, so T+0 + 2 P1
 
         charged = 1;
         A_f = Tp0 + 2.0 * P1;
     }
 
-    if ( ( EvtPDL::chg3( getDaug( 0 ) ) < 0 ) &&
-         ( EvtPDL::chg3( getDaug( 1 ) ) == 0 ) ) {
+    if ( Q1 < 0 && Q2 == 0 ) {
         //V- S0, so T+0_bar + 2P1_bar
 
         charged = 1;
         A_f = Tp0_bar + 2.0 * P1_bar;
     }
 
-    if ( ( EvtPDL::chg3( getDaug( 0 ) ) == 0 ) &&
-         ( EvtPDL::chg3( getDaug( 1 ) ) > 0 ) ) {
+    if ( Q1 == 0 && Q2 > 0 ) {
         //V0 S+, so T0+ - 2 P1
 
         charged = 1;
         A_f = T0p - 2.0 * P1;
     }
 
-    if ( ( EvtPDL::chg3( getDaug( 0 ) ) == 0 ) &&
-         ( EvtPDL::chg3( getDaug( 1 ) ) < 0 ) ) {
+    if ( Q1 == 0 && Q2 < 0 ) {
         //V0 S-, so T0+_bar - 2 P1_bar
 
         charged = 1;
         A_f = T0p_bar - 2.0 * P1_bar;
     }
 
     //***********************neutral modes***************************
 
     //V+ S-, so Af = T+- + P1 + P0
     Apm = Tpm + P1 + P0;
     Apm_bar = Tpm_bar + P1_bar + P0_bar;
 
     //V- S+, so Af = T-+ - P1 + P0
     Amp = Tmp - P1 + P0;
     Amp_bar = Tmp_bar - P1_bar + P0;
 
-    if ( ( EvtPDL::chg3( getDaug( 0 ) ) > 0 ) &&
-         ( EvtPDL::chg3( getDaug( 1 ) ) < 0 ) ) {
+    if ( Q1 > 0 && Q2 < 0 ) {
         //V+ S-
         charged = 0;
         A_f = Apm;
         Abar_f = Apm_bar;
         A_fbar = Amp;
         Abar_fbar = Amp_bar;
     }
 
-    if ( ( EvtPDL::chg3( getDaug( 0 ) ) < 0 ) &&
-         ( EvtPDL::chg3( getDaug( 1 ) ) > 0 ) ) {
+    if ( Q1 < 0 && Q2 > 0 ) {
         //V- S+
         charged = 0;
         A_f = Amp;
         Abar_f = Amp_bar;
         A_fbar = Apm;
         Abar_fbar = Apm_bar;
     }
 
-    if ( ( EvtPDL::chg3( getDaug( 0 ) ) == 0 ) &&
-         ( EvtPDL::chg3( getDaug( 1 ) ) == 0 ) ) {
+    if ( Q1 == 0 && Q2 == 0 ) {
         //V0 S0
         charged = 0;
         A_f = T0p + Tp0 - Tpm - Tmp - 2.0 * P0;
         Abar_f = T0p_bar + Tp0_bar - Tpm_bar - Tmp_bar - 2.0 * P0_bar;
         A_fbar = A_f;
         Abar_fbar = Abar_f;
     }
-
-    if ( charged == 0 ) {
-        if ( !flip ) {
-            if ( other_b == B0B ) {
-                amp = A_f * cos( getArg( 1 ) * t / ( 2 * EvtConst::c ) ) +
-                      EvtComplex( cos( -2.0 * getArg( 0 ) ),
-                                  sin( -2.0 * getArg( 0 ) ) ) *
-                          EvtComplex( 0.0, 1.0 ) * Abar_f *
-                          sin( getArg( 1 ) * t / ( 2 * EvtConst::c ) );
-            }
-            if ( other_b == B0 ) {
-                amp = A_f *
-                          EvtComplex( cos( 2.0 * getArg( 0 ) ),
-                                      sin( 2.0 * getArg( 0 ) ) ) *
-                          EvtComplex( 0.0, 1.0 ) *
-                          sin( getArg( 1 ) * t / ( 2 * EvtConst::c ) ) +
-                      Abar_f * cos( getArg( 1 ) * t / ( 2 * EvtConst::c ) );
-            }
-        } else {
-            if ( other_b == B0B ) {
-                amp = A_fbar * cos( getArg( 1 ) * t / ( 2 * EvtConst::c ) ) +
-                      EvtComplex( cos( -2.0 * getArg( 0 ) ),
-                                  sin( -2.0 * getArg( 0 ) ) ) *
-                          EvtComplex( 0.0, 1.0 ) * Abar_fbar *
-                          sin( getArg( 1 ) * t / ( 2 * EvtConst::c ) );
-            }
-            if ( other_b == B0 ) {
-                amp = A_fbar *
-                          EvtComplex( cos( 2.0 * getArg( 0 ) ),
-                                      sin( 2.0 * getArg( 0 ) ) ) *
-                          EvtComplex( 0.0, 1.0 ) *
-                          sin( getArg( 1 ) * t / ( 2 * EvtConst::c ) ) +
-                      Abar_fbar * cos( getArg( 1 ) * t / ( 2 * EvtConst::c ) );
-            }
-        }
-
-    } else
-        amp = A_f;
-
-    EvtVector4R p4_parent;
-
-    p4_parent = v->getP4() + s->getP4();
-
-    double norm = 1.0 / v->getP4().d3mag();
-
-    vertex( 0, amp * norm * p4_parent * ( v->epsParent( 0 ) ) );
-    vertex( 1, amp * norm * p4_parent * ( v->epsParent( 1 ) ) );
-    vertex( 2, amp * norm * p4_parent * ( v->epsParent( 2 ) ) );
-
-    return;
 }
diff --git a/src/EvtGenModels/EvtSVVHelCPMix.cpp b/src/EvtGenModels/EvtSVVHelCPMix.cpp
index e383da3..43e6993 100644
--- a/src/EvtGenModels/EvtSVVHelCPMix.cpp
+++ b/src/EvtGenModels/EvtSVVHelCPMix.cpp
@@ -1,304 +1,294 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtSVVHelCPMix.hh"
 
 #include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtId.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtReport.hh"
 #include "EvtGenBase/EvtTensor3C.hh"
 #include "EvtGenBase/EvtTensor4C.hh"
 #include "EvtGenBase/EvtVector3C.hh"
 #include "EvtGenBase/EvtVector3R.hh"
 #include "EvtGenBase/EvtVector4C.hh"
 
 #include <ctype.h>
 #include <fstream>
 #include <iostream>
 #include <stdlib.h>
 #include <string>
 
 std::string EvtSVVHelCPMix::getName()
 {
     return "SVVHELCPMIX";
 }
 
 EvtDecayBase* EvtSVVHelCPMix::clone()
 {
     return new EvtSVVHelCPMix;
 }
 
 void EvtSVVHelCPMix::init()
 {
     // check that there are 12 arguments
     checkNArg( 12 );
     checkNDaug( 2 );
 
     checkSpinParent( EvtSpinType::SCALAR );
 
     checkSpinDaughter( 0, EvtSpinType::VECTOR );
     checkSpinDaughter( 1, EvtSpinType::VECTOR );
 
     hp = EvtComplex( getArg( 0 ) * cos( getArg( 1 ) ),
                      getArg( 0 ) * sin( getArg( 1 ) ) );
     h0 = EvtComplex( getArg( 2 ) * cos( getArg( 3 ) ),
                      getArg( 2 ) * sin( getArg( 3 ) ) );
     hm = EvtComplex( getArg( 4 ) * cos( getArg( 5 ) ),
                      getArg( 4 ) * sin( getArg( 5 ) ) );
     averageM = getArg( 6 );
     deltaM = getArg( 7 );
     gamma = getArg( 8 );
     deltagamma = getArg( 9 );
     weakmixingphase = EvtComplex( cos( getArg( 10 ) ), sin( getArg( 10 ) ) );
     weakdirectphase = EvtComplex( cos( getArg( 11 ) ), sin( getArg( 11 ) ) );
 }
 
 void EvtSVVHelCPMix::initProbMax()
 {
     setProbMax( getArg( 0 ) * getArg( 0 ) + getArg( 2 ) * getArg( 2 ) +
                 getArg( 4 ) * getArg( 4 ) );
 }
 
 void EvtSVVHelCPMix::decay( EvtParticle* p )
 {
     EvtParticle* parent = p;
     EvtAmp& amp = _amp2;
     EvtId n_v1 = getDaug( 0 );
     EvtId n_v2 = getDaug( 1 );
 
     //  Routine to decay a vector into a vector and scalar.  Started
     //  by ryd on Oct 17, 1996.
     // Modified by J.Catmore to take account of CP-violation and mixing
 
     int tndaug = 2;
     EvtId tdaug[2];
     EvtId Bs = EvtPDL::getId( "B_s0" );
     EvtId antiBs = EvtPDL::getId( "anti-B_s0" );
     tdaug[0] = n_v1;
     tdaug[1] = n_v2;
 
     // Phase space and kinematics
 
     parent->initializePhaseSpace( tndaug, tdaug );
 
     EvtParticle *v1, *v2;
     v1 = parent->getDaug( 0 );
     v2 = parent->getDaug( 1 );
 
     EvtVector4R momv1 = v1->getP4();
 
     EvtVector3R v1dir( momv1.get( 1 ), momv1.get( 2 ), momv1.get( 3 ) );
     v1dir = v1dir / v1dir.d3mag();
 
     // Definition of quantities used in construction of complex amplitudes:
 
     EvtTensor3C M;    // Tensor as defined in EvtGen manual, equ 117
     EvtComplex a, b,
         c;    // Helicity amplitudes; EvtGen manual eqns 126-128, also see Phys Lett B 369 p144-150 eqn 15
     //EvtComplex deltamu = EvtComplex(deltaM, -0.5*deltagamma); // See Phys Rev D 34 p1404
 
     // conversion from times in mm/c to natural units [GeV]^-1
     double t = ( ( parent->getLifetime() ) / 2.998e11 ) * 6.58e-25;
 
     // The following two quantities defined in Phys Rev D 34 p1404
     EvtComplex fplus = EvtComplex( cos( averageM * t ),
                                    -1. * sin( averageM * t ) ) *
                        exp( -( gamma / 2.0 ) * t ) *
                        ( cos( 0.5 * deltaM * t ) * cosh( 0.25 * deltagamma * t ) +
                          EvtComplex( 0.0, sin( 0.5 * deltaM * t ) *
                                               sinh( 0.25 * deltagamma * t ) ) );
     EvtComplex fminus =
         EvtComplex( cos( averageM * t ), -1. * sin( averageM * t ) ) *
         exp( -( gamma / 2.0 ) * t ) * EvtComplex( 0.0, 1.0 ) *
         ( sin( 0.5 * deltaM * t ) * cosh( 0.25 * deltagamma * t ) -
           EvtComplex( 0.0, 1.0 ) * sinh( 0.25 * deltagamma * t ) *
               cos( 0.5 * deltaM * t ) );
 
     // See EvtGen manual pp 106-107
 
     a = -0.5 * ( hp + hm );
     b = EvtComplex( 0.0, 0.5 ) * ( hp - hm );
     c = ( h0 + 0.5 * ( hp + hm ) );
 
     M = a * EvtTensor3C::id() + b * EvtGenFunctions::eps( v1dir ) +
         c * EvtGenFunctions::directProd( v1dir, v1dir );
 
     EvtVector3C t0 = M.cont1( v1->eps( 0 ).vec().conj() );
     EvtVector3C t1 = M.cont1( v1->eps( 1 ).vec().conj() );
     EvtVector3C t2 = M.cont1( v1->eps( 2 ).vec().conj() );
 
     EvtVector3C eps0 = v2->eps( 0 ).vec().conj();
     EvtVector3C eps1 = v2->eps( 1 ).vec().conj();
     EvtVector3C eps2 = v2->eps( 2 ).vec().conj();
 
     // We need two sets of equations, one for mesons which were in the Bs state at t=0, and another
     // for those which were in the antiBs state. Each equation consists of a sum of amplitudes - mod-squaring gives the interference terms.
 
     EvtComplex amplSum00, amplSum01, amplSum02;
     EvtComplex amplSum10, amplSum11, amplSum12;
     EvtComplex amplSum20, amplSum21, amplSum22;
 
     // First the Bs state:
 
     if ( parent->getId() == Bs ) {
         amplSum00 = ( fplus * weakdirectphase * t0 * eps0 ) +
                     ( fminus * ( 1.0 / weakdirectphase ) * weakmixingphase *
                       t0 * eps0 );
         amplSum01 = ( fplus * weakdirectphase * t0 * eps1 ) +
                     ( fminus * ( 1.0 / weakdirectphase ) * weakmixingphase *
                       t0 * eps1 );
         amplSum02 = ( fplus * weakdirectphase * t0 * eps2 ) +
                     ( fminus * ( 1.0 / weakdirectphase ) * weakmixingphase *
                       t0 * eps2 );
 
         amplSum10 = ( fplus * weakdirectphase * t1 * eps0 ) +
                     ( fminus * ( 1.0 / weakdirectphase ) * weakmixingphase *
                       t1 * eps0 );
         amplSum11 = ( fplus * weakdirectphase * t1 * eps1 ) +
                     ( fminus * ( 1.0 / weakdirectphase ) * weakmixingphase *
                       t1 * eps1 );
         amplSum12 = ( fplus * weakdirectphase * t1 * eps2 ) +
                     ( fminus * ( 1.0 / weakdirectphase ) * weakmixingphase *
                       t1 * eps2 );
 
         amplSum20 = ( fplus * weakdirectphase * t2 * eps0 ) +
                     ( fminus * ( 1.0 / weakdirectphase ) * weakmixingphase *
                       t2 * eps0 );
         amplSum21 = ( fplus * weakdirectphase * t2 * eps1 ) +
                     ( fminus * ( 1.0 / weakdirectphase ) * weakmixingphase *
                       t2 * eps1 );
         amplSum22 = ( fplus * weakdirectphase * t2 * eps2 ) +
                     ( fminus * ( 1.0 / weakdirectphase ) * weakmixingphase *
                       t2 * eps2 );
     }
 
     // Now the anti-Bs state:
 
     if ( parent->getId() == antiBs ) {
         amplSum00 = ( fminus * weakdirectphase * ( 1.0 / weakmixingphase ) *
                       t0 * eps0 ) +
                     ( fplus * ( 1.0 / weakdirectphase ) * t0 * eps0 );
         amplSum01 = ( fminus * weakdirectphase * ( 1.0 / weakmixingphase ) *
                       t0 * eps1 ) +
                     ( fplus * ( 1.0 / weakdirectphase ) * t0 * eps1 );
         amplSum02 = ( fminus * weakdirectphase * ( 1.0 / weakmixingphase ) *
                       t0 * eps2 ) +
                     ( fplus * ( 1.0 / weakdirectphase ) * t0 * eps2 );
 
         amplSum10 = ( fminus * weakdirectphase * ( 1.0 / weakmixingphase ) *
                       t1 * eps0 ) +
                     ( fplus * ( 1.0 / weakdirectphase ) * t1 * eps0 );
         amplSum11 = ( fminus * weakdirectphase * ( 1.0 / weakmixingphase ) *
                       t1 * eps1 ) +
                     ( fplus * ( 1.0 / weakdirectphase ) * t1 * eps1 );
         amplSum12 = ( fminus * weakdirectphase * ( 1.0 / weakmixingphase ) *
                       t1 * eps2 ) +
                     ( fplus * ( 1.0 / weakdirectphase ) * t1 * eps2 );
 
         amplSum20 = ( fminus * weakdirectphase * ( 1.0 / weakmixingphase ) *
                       t2 * eps0 ) +
                     ( fplus * ( 1.0 / weakdirectphase ) * t2 * eps0 );
         amplSum21 = ( fminus * weakdirectphase * ( 1.0 / weakmixingphase ) *
                       t2 * eps1 ) +
                     ( fplus * ( 1.0 / weakdirectphase ) * t2 * eps1 );
         amplSum22 = ( fminus * weakdirectphase * ( 1.0 / weakmixingphase ) *
                       t2 * eps2 ) +
                     ( fplus * ( 1.0 / weakdirectphase ) * t2 * eps2 );
     }
 
-    // Now set the amplitude
-
+    // Now set the amplitudes
     amp.vertex( 0, 0, amplSum00 );
-    EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "00: " << amplSum00 << std::endl;
     amp.vertex( 0, 1, amplSum01 );
-    EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "01: " << amplSum01 << std::endl;
     amp.vertex( 0, 2, amplSum02 );
-    EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "02: " << amplSum02 << std::endl;
 
     amp.vertex( 1, 0, amplSum10 );
-    EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "10: " << amplSum10 << std::endl;
     amp.vertex( 1, 1, amplSum11 );
-    EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "11: " << amplSum11 << std::endl;
     amp.vertex( 1, 2, amplSum12 );
-    EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "12: " << amplSum12 << std::endl;
 
     amp.vertex( 2, 0, amplSum20 );
-    EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "20: " << amplSum20 << std::endl;
     amp.vertex( 2, 1, amplSum21 );
-    EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "21: " << amplSum21 << std::endl;
     amp.vertex( 2, 2, amplSum22 );
-    EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "22: " << amplSum22 << std::endl;
 
     return;
 }
 
 std::string EvtSVVHelCPMix::getParamName( int i )
 {
     switch ( i ) {
         case 0:
             return "plusHelAmp";
         case 1:
             return "plusHelAmpPhase";
         case 2:
             return "zeroHelAmp";
         case 3:
             return "zeroHelAmpPhase";
         case 4:
             return "minusHelAmp";
         case 5:
             return "minusHelAmpPhase";
         case 6:
             return "averageM";
         case 7:
             return "deltaM";
         case 8:
             return "gamma";
         case 9:
             return "deltaGamma";
         case 10:
             return "weakMixPhase";
         case 11:
             return "weakDirectPhase";
         default:
             return "";
     }
 }
 
 std::string EvtSVVHelCPMix::getParamDefault( int i )
 {
     switch ( i ) {
         case 0:
             return "1.0";
         case 1:
             return "0.0";
         case 2:
             return "1.0";
         case 3:
             return "0.0";
         case 4:
             return "1.0";
         case 5:
             return "0.0";
         default:
             return "";
     }
 }
diff --git a/src/EvtGenModels/EvtSingleParticle.cpp b/src/EvtGenModels/EvtSingleParticle.cpp
index d4eed40..8ef0114 100644
--- a/src/EvtGenModels/EvtSingleParticle.cpp
+++ b/src/EvtGenModels/EvtSingleParticle.cpp
@@ -1,141 +1,146 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtSingleParticle.hh"
 
 #include "EvtGenBase/EvtConst.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtRandom.hh"
 #include "EvtGenBase/EvtReport.hh"
 
 #include <stdlib.h>
 #include <string>
 using std::endl;
 
 std::string EvtSingleParticle::getName()
 {
     return "SINGLE";
 }
 
 EvtDecayBase* EvtSingleParticle::clone()
 {
     return new EvtSingleParticle();
 }
 
+void EvtSingleParticle::initProbMax()
+{
+    noProbMax();
+}
+
 void EvtSingleParticle::init()
 {
     //turn off checks for charge conservation
     disableCheckQ();
 
     if ( ( getNArg() == 6 ) || ( getNArg() == 4 ) || ( getNArg() == 2 ) ) {
         if ( getNArg() == 6 ) {
             //copy the arguments into eaiser to remember names!
 
             pmin = getArg( 0 );
             pmax = getArg( 1 );
 
             cthetamin = getArg( 2 );
             cthetamax = getArg( 3 );
 
             phimin = getArg( 4 );
             phimax = getArg( 5 );
         }
 
         if ( getNArg() == 4 ) {
             //copy the arguments into eaiser to remember names!
 
             pmin = getArg( 0 );
             pmax = getArg( 1 );
 
             cthetamin = getArg( 2 );
             cthetamax = getArg( 3 );
 
             phimin = 0.0;
             phimax = EvtConst::twoPi;
         }
 
         if ( getNArg() == 2 ) {
             //copy the arguments into eaiser to remember names!
 
             pmin = getArg( 0 );
             pmax = getArg( 1 );
 
             cthetamin = -1.0;
             cthetamax = 1.0;
 
             phimin = 0.0;
             phimax = EvtConst::twoPi;
         }
 
     } else {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "EvtSingleParticle generator expected "
             << " 6, 4, or 2 arguments but found:" << getNArg() << endl;
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "Will terminate execution!" << endl;
         ::abort();
     }
 
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "The single particle generator has been configured:" << endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << pmax << " > p > " << pmin << endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << cthetamax << " > costheta > " << cthetamin << endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << phimax << " > phi > " << phimin << endl;
 }
 
 void EvtSingleParticle::decay( EvtParticle* p )
 {
     EvtParticle* d;
     EvtVector4R p4;
 
     double mass = EvtPDL::getMass( getDaug( 0 ) );
 
     p->makeDaughters( getNDaug(), getDaugs() );
     d = p->getDaug( 0 );
 
     //generate flat distribution in p
     //we are now in the parents restframe! This means the
     //restframe of the e+e- collison.
     double pcm = EvtRandom::Flat( pmin, pmax );
     //generate flat distribution in phi.
     double phi = EvtRandom::Flat( phimin, phimax );
 
     double cthetalab;
 
     do {
         //generate flat distribution in costheta
         double ctheta = EvtRandom::Flat( cthetamin, cthetamax );
         double stheta = sqrt( 1.0 - ctheta * ctheta );
         p4.set( sqrt( mass * mass + pcm * pcm ), pcm * cos( phi ) * stheta,
                 pcm * sin( phi ) * stheta, pcm * ctheta );
 
         d->init( getDaug( 0 ), p4 );
 
         //get 4 vector in the lab frame!
         EvtVector4R p4lab = d->getP4Lab();
         cthetalab = p4lab.get( 3 ) / p4lab.d3mag();
     } while ( cthetalab > cthetamax || cthetalab < cthetamin );
 
     return;
 }
diff --git a/src/EvtGenModels/EvtSll.cpp b/src/EvtGenModels/EvtSll.cpp
index cecb16c..f94fb1d 100644
--- a/src/EvtGenModels/EvtSll.cpp
+++ b/src/EvtGenModels/EvtSll.cpp
@@ -1,80 +1,115 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtSll.hh"
 
 #include "EvtGenBase/EvtDiracSpinor.hh"
 #include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtReport.hh"
 #include "EvtGenBase/EvtVector4C.hh"
 
 #include <iostream>
 #include <stdlib.h>
 #include <string>
 
 std::string EvtSll::getName()
 {
     return "SLL";
 }
 
 EvtDecayBase* EvtSll::clone()
 {
     return new EvtSll;
 }
 
 void EvtSll::init()
 {
     // check that there are 0 arguments
     checkNArg( 0 );
     checkNDaug( 2 );
 
     checkSpinParent( EvtSpinType::SCALAR );
 
     checkSpinDaughter( 0, EvtSpinType::DIRAC );
     checkSpinDaughter( 1, EvtSpinType::DIRAC );
 }
 
+void EvtSll::initProbMax()
+{
+    const int eID = abs( EvtPDL::getStdHep( EvtPDL::getId( "e-" ) ) );
+    const int muID = abs( EvtPDL::getStdHep( EvtPDL::getId( "mu-" ) ) );
+    const int tauID = abs( EvtPDL::getStdHep( EvtPDL::getId( "tau-" ) ) );
+
+    const int lep1 = abs( EvtPDL::getStdHep( getDaug( 0 ) ) );
+    const int lep2 = abs( EvtPDL::getStdHep( getDaug( 1 ) ) );
+
+    // tau tau mode
+    double maxProb{ 1000.0 };
+
+    // Modify probability based on lepton pair (including lepton violation modes)
+    if ( ( lep1 == tauID && lep2 == muID ) || ( lep1 == muID && lep2 == tauID ) ) {
+        // tau mu or mu tau
+        maxProb = 400.0;
+    } else if ( ( lep1 == tauID && lep2 == eID ) ||
+                ( lep1 == eID && lep2 == tauID ) ) {
+        // tau e or e tau
+        maxProb = 400.0;
+    } else if ( lep1 == muID && lep2 == muID ) {
+        // mu mu
+        maxProb = 4.0;
+    } else if ( ( lep1 == muID && lep2 == eID ) ||
+                ( lep1 == eID && lep2 == muID ) ) {
+        // mu e or e mu
+        maxProb = 2.0;
+    } else if ( lep1 == eID && lep2 == eID ) {
+        // e e
+        maxProb = 1e-4;
+    }
+
+    setProbMax( maxProb );
+}
+
 void EvtSll::decay( EvtParticle* p )
 {
     p->initializePhaseSpace( getNDaug(), getDaugs() );
 
     EvtParticle *l1, *l2;
     l1 = p->getDaug( 0 );
     l2 = p->getDaug( 1 );
     EvtVector4R p4_p;
     p4_p.set( p->mass(), 0.0, 0.0, 0.0 );
 
     EvtVector4C l11, l12, l21, l22;
 
     l11 = EvtLeptonVACurrent( l1->spParent( 0 ), l2->spParent( 0 ) );
     l12 = EvtLeptonVACurrent( l1->spParent( 0 ), l2->spParent( 1 ) );
     l21 = EvtLeptonVACurrent( l1->spParent( 1 ), l2->spParent( 0 ) );
     l22 = EvtLeptonVACurrent( l1->spParent( 1 ), l2->spParent( 1 ) );
 
     vertex( 0, 0, p4_p * l11 );
     vertex( 0, 1, p4_p * l12 );
     vertex( 1, 0, p4_p * l21 );
     vertex( 1, 1, p4_p * l22 );
 
     return;
 }
diff --git a/src/EvtGenModels/EvtTVP.cpp b/src/EvtGenModels/EvtTVP.cpp
index 91c962d..a55650a 100644
--- a/src/EvtGenModels/EvtTVP.cpp
+++ b/src/EvtGenModels/EvtTVP.cpp
@@ -1,216 +1,216 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtTVP.hh"
 
 #include "EvtGenBase/EvtDiracSpinor.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtSpinType.hh"
 #include "EvtGenBase/EvtTensor4C.hh"
 #include "EvtGenBase/EvtVector4C.hh"
 
 #include <cmath>
 
 std::string EvtTVP::getName()
 {
     return "TVP";
 }
 
 EvtDecayBase* EvtTVP::clone()
 {
     return new EvtTVP;
 }
 
 void EvtTVP::decay( EvtParticle* root )
 {
     if ( getNDaug() == 2 ) {
         decay_2body( root );
     } else if ( getNDaug() == 3 ) {
         decay_3body( root );
     }
 }
 
 void EvtTVP::init()
 {
     checkSpinParent( EvtSpinType::TENSOR );
 
     if ( getNDaug() == 2 ) {    // chi -> gamma psi radiative mode
         checkNArg( 0 );
         checkSpinDaughter( 0, EvtSpinType::PHOTON );
         checkSpinDaughter( 1, EvtSpinType::VECTOR );
     } else if ( getNDaug() == 3 ) {    // chi -> psi lepton lepton
         checkNDaug( 3 );
         checkSpinDaughter( 0, EvtSpinType::VECTOR );
         checkSpinDaughter( 1, EvtSpinType::DIRAC );
         checkSpinDaughter( 2, EvtSpinType::DIRAC );
         checkNArg( 1 );
         delta = getArg( 0 );
     }
 }
 
 void EvtTVP::initProbMax()
 {
     if ( getNDaug() == 2 ) {
         const EvtId parId = getParentId();
         if ( parId == EvtPDL::getId( "chi_b2" ) ) {
             setProbMax( 15.0 );
         } else {
-            setProbMax( 2.0 );
+            setProbMax( 2.5 );
         }
 
     } else if ( getNDaug() == 3 ) {
         double dSq = delta * delta;
         double denom = dSq - 0.2;
         double ratio( 1.0 );
         if ( fabs( denom ) > 1e-10 ) {
             ratio = dSq / denom;
         }
         double ffCor = ratio * ratio;
 
         const EvtId daugId = getDaug( 1 );
         const EvtId parId = getParentId();
 
         if ( daugId == EvtPDL::getId( "mu+" ) ||
              daugId == EvtPDL::getId( "mu-" ) ) {
             if ( parId == EvtPDL::getId( "chi_c2" ) ) {
                 setProbMax( ffCor * 85.0 );    // tested on 1e6 events
             } else if ( parId == EvtPDL::getId( "chi_b2" ) ) {
                 setProbMax( ffCor * 750.0 );    // tested on 1e6 events
             }
 
         } else if ( daugId == EvtPDL::getId( "e+" ) ||
                     daugId == EvtPDL::getId( "e-" ) ) {
             if ( parId == EvtPDL::getId( "chi_c2" ) ) {
                 setProbMax( ffCor * 3.5e3 );    // tested on 1e5 events
             } else if ( parId == EvtPDL::getId( "chi_b2" ) ) {
                 setProbMax( ffCor * 2.6e4 );
             }
         }
     }
 }
 
 void EvtTVP::decay_2body( EvtParticle* root )
 {
     root->initializePhaseSpace( getNDaug(), getDaugs() );
 
     // Photon is the first particle and psi is the second
     // to ensure decay file backwards compatibility
     EvtParticle* photon = root->getDaug( 0 );
     EvtParticle* psi = root->getDaug( 1 );
 
     EvtVector4R p = psi->getP4(),    // psi momentum
         k = photon->getP4();         // Photon momentum
 
     for ( int iPsi = 0; iPsi < 3; iPsi++ ) {
         EvtVector4C epsPsi = psi->epsParent( iPsi ).conj();
 
         for ( int iGamma = 0; iGamma < 2; iGamma++ ) {
             EvtVector4C epsGamma = photon->epsParentPhoton( iGamma ).conj();
 
             for ( int iChi = 0; iChi < 5; iChi++ ) {
                 EvtTensor4C epsChi = root->epsTensor( iChi );
 
                 // Baranov PRD 85,014034 (2012), Eq 11
                 // amp = p^mu epsPsi^a epsChi_{a b} [k_mu epsGamma_b  - k_b epsGamma_mu]
                 EvtVector4C eee = epsChi.cont1( epsPsi );
                 EvtVector4C vvv = ( p * k ) * eee - ( k * eee ) * p;
                 EvtComplex amp = vvv * epsGamma;
                 vertex( iChi, iGamma, iPsi, amp );
             }
         }
     }
 }
 
 void EvtTVP::decay_3body( EvtParticle* root )
 {
     root->initializePhaseSpace( getNDaug(), getDaugs() );
     EvtParticle* psi = root->getDaug( 0 );
     EvtParticle* mup = root->getDaug( 1 );
     EvtParticle* mum = root->getDaug( 2 );
 
     EvtVector4R p = psi->getP4(),    // psi momentum
         k1 = mup->getP4(),           // mu+ momentum
         k2 = mum->getP4(),           // mu- momentum
         k = k1 + k2;                 // photon momentum
 
     double kSq = k * k;
 
     // The decay amplitude needs four-vector products. Make sure we have
     // valid values for these, otherwise set the amplitude to zero.
     // We need to set _amp2 (EvtDecayAmp) via the vertex() function call
     // even when the amplitude is zero, otherwise the amplitude from the
     // previous accepted event will be used, potentially leading to biases
 
     // Selection on k^2 to avoid inefficient generation for the electron modes
     bool validAmp( true );
     if ( kSq < 1e-3 ) {
         validAmp = false;
     }
 
     double dSq = delta * delta;
     double dSqDenom = dSq - kSq;
     if ( fabs( dSqDenom ) < 1e-10 ) {
         validAmp = false;
     }
 
     double factor( 1.0 );
     if ( validAmp ) {
         factor = dSq / ( dSqDenom * kSq );
     }
 
     // Calculate the amplitude terms, looping over the psi and lepton states
     int iPols[4] = {0, 0, 0, 0};
 
     for ( int iChi = 0; iChi < 5; iChi++ ) {
         iPols[0] = iChi;
         EvtTensor4C epsChi = root->epsTensor( iChi );
 
         for ( int iPsi = 0; iPsi < 3; iPsi++ ) {
             iPols[1] = iPsi;
             EvtVector4C epsPsi = psi->epsParent( iPsi ).conj();
 
             for ( int iMplus = 0; iMplus < 2; iMplus++ ) {
                 iPols[2] = iMplus;
                 EvtDiracSpinor spMplus = mup->spParent( iMplus );
 
                 for ( int iMminus = 0; iMminus < 2; iMminus++ ) {
                     iPols[3] = iMminus;
                     EvtDiracSpinor spMminus = mum->spParent( iMminus );
                     EvtVector4C epsGamma = EvtLeptonVCurrent( spMplus, spMminus );
 
                     // Based on Baranov PRD 85,014034 (2012), Eq 11
                     // amp = p^mu epsPsi^a epsChi_{a b} [k_mu epsGamma_b  - k_b epsGamma_mu]/k^2
                     EvtVector4C eee = epsChi.cont1( epsPsi );
                     EvtVector4C vvv = ( p * k ) * eee - ( k * eee ) * p;
                     EvtComplex amp( 0.0, 0.0 );
                     if ( validAmp ) {
                         amp = vvv * epsGamma;
                     }
                     amp *= factor;
 
                     // Set the amplitude matrix element using the vertex function
                     vertex( iPols, amp );
                 }
             }
         }
     }
 }
diff --git a/src/EvtGenModels/EvtVtoSll.cpp b/src/EvtGenModels/EvtVtoSll.cpp
index a640aa5..b6d7cb2 100644
--- a/src/EvtGenModels/EvtVtoSll.cpp
+++ b/src/EvtGenModels/EvtVtoSll.cpp
@@ -1,111 +1,111 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtVtoSll.hh"
 
 #include "EvtGenBase/EvtDiracSpinor.hh"
 #include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtReport.hh"
 #include "EvtGenBase/EvtTensor4C.hh"
 #include "EvtGenBase/EvtVector4C.hh"
 
 #include <iostream>
 #include <stdlib.h>
 #include <string>
 
 std::string EvtVtoSll::getName()
 {
     return "VTOSLL";
 }
 
 EvtDecayBase* EvtVtoSll::clone()
 {
     return new EvtVtoSll;
 }
 
 void EvtVtoSll::init()
 {
     // check that there are 0 arguments
     checkNArg( 0 );
     checkNDaug( 3 );
 
     checkSpinParent( EvtSpinType::VECTOR );
 
     checkSpinDaughter( 0, EvtSpinType::SCALAR );
     checkSpinDaughter( 1, EvtSpinType::DIRAC );
     checkSpinDaughter( 2, EvtSpinType::DIRAC );
 }
 
 void EvtVtoSll::initProbMax()
 {
-    //setProbMax(1.0);
+    setProbMax(10.0);
 }
 
 void EvtVtoSll::decay( EvtParticle* p )
 {
     p->initializePhaseSpace( getNDaug(), getDaugs() );
 
     EvtParticle *l1, *l2;
     l1 = p->getDaug( 1 );
     l2 = p->getDaug( 2 );
 
     EvtVector4C l11, l12, l21, l22;
     l11 = EvtLeptonVCurrent( l1->spParent( 0 ), l2->spParent( 0 ) );
     l12 = EvtLeptonVCurrent( l1->spParent( 0 ), l2->spParent( 1 ) );
     l21 = EvtLeptonVCurrent( l1->spParent( 1 ), l2->spParent( 0 ) );
     l22 = EvtLeptonVCurrent( l1->spParent( 1 ), l2->spParent( 1 ) );
 
     EvtVector4C eps0 = p->eps( 0 );
     EvtVector4C eps1 = p->eps( 1 );
     EvtVector4C eps2 = p->eps( 2 );
 
     EvtVector4R P = p->getP4Restframe();
     EvtVector4R k = l1->getP4() + l2->getP4();
     double k2 = k * k;
 
     EvtTensor4C T( dual( EvtGenFunctions::directProd( P, ( 1.0 / k2 ) * k ) ) );
 
     double M2 = p->mass();
     M2 *= M2;
     double m2 = l1->mass();
     m2 *= m2;
 
     double norm = 1.0 / sqrt( 2 * M2 + 4 * m2 - 4 * m2 * m2 / M2 );
 
     vertex( 0, 0, 0, norm * ( eps0 * T.cont2( l11 ) ) );
     vertex( 0, 0, 1, norm * ( eps0 * T.cont2( l12 ) ) );
     vertex( 0, 1, 0, norm * ( eps0 * T.cont2( l21 ) ) );
     vertex( 0, 1, 1, norm * ( eps0 * T.cont2( l22 ) ) );
 
     vertex( 1, 0, 0, norm * ( eps1 * T.cont2( l11 ) ) );
     vertex( 1, 0, 1, norm * ( eps1 * T.cont2( l12 ) ) );
     vertex( 1, 1, 0, norm * ( eps1 * T.cont2( l21 ) ) );
     vertex( 1, 1, 1, norm * ( eps1 * T.cont2( l22 ) ) );
 
     vertex( 2, 0, 0, norm * ( eps2 * T.cont2( l11 ) ) );
     vertex( 2, 0, 1, norm * ( eps2 * T.cont2( l12 ) ) );
     vertex( 2, 1, 0, norm * ( eps2 * T.cont2( l21 ) ) );
     vertex( 2, 1, 1, norm * ( eps2 * T.cont2( l22 ) ) );
 
     return;
 }
diff --git a/src/EvtGenModels/EvtVubBLNPHybrid.cpp b/src/EvtGenModels/EvtVubBLNPHybrid.cpp
index 504e973..cf95cdb 100644
--- a/src/EvtGenModels/EvtVubBLNPHybrid.cpp
+++ b/src/EvtGenModels/EvtVubBLNPHybrid.cpp
@@ -1,1182 +1,1182 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtVubBLNPHybrid.hh"
 
 #include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtRandom.hh"
 #include "EvtGenBase/EvtReport.hh"
 #include "EvtGenBase/EvtVector4R.hh"
 
 #include "EvtGenModels/EvtItgPtrFunction.hh"
 #include "EvtGenModels/EvtItgSimpsonIntegrator.hh"
 #include "EvtGenModels/EvtPFermi.hh"
 
 #include <stdlib.h>
 #include <string>
 
 // For incomplete gamma function
 #include "math.h"
 #include "signal.h"
 #define ITMAX 100
 #define EPS 3.0e-7
 #define FPMIN 1.0e-30
 
 using std::cout;
 using std::endl;
 
 std::string EvtVubBLNPHybrid::getName()
 {
     return "VUB_BLNPHYBRID";
 }
 
 EvtDecayBase* EvtVubBLNPHybrid::clone()
 {
     return new EvtVubBLNPHybrid;
 }
 
 void EvtVubBLNPHybrid::init()
 {
-    // check that there are at least 3 arguments
+    // check number of arguments
     if ( getNArg() < EvtVubBLNPHybrid::nParameters ) {
         EvtGenReport( EVTGEN_ERROR, "EvtVubBLNPHybrid" )
             << "EvtVubBLNPHybrid generator expected "
             << "at least " << EvtVubBLNPHybrid::nParameters
             << " arguments but found: " << getNArg()
             << "\nWill terminate execution!" << endl;
         ::abort();
     } else if ( getNArg() == EvtVubBLNPHybrid::nParameters ) {
         EvtGenReport( EVTGEN_WARNING, "EvtVubBLNPHybrid" )
             << "EvtVubBLNPHybrid: generate B -> Xu l nu events "
             << "without using the hybrid reweighting." << endl;
         _noHybrid = true;
     } else if ( getNArg() <
                 EvtVubBLNPHybrid::nParameters + EvtVubBLNPHybrid::nVariables ) {
         EvtGenReport( EVTGEN_ERROR, "EvtVubBLNPHybrid" )
             << "EvtVubBLNPHybrid could not read number of bins for "
             << "all variables used in the reweighting\n"
             << "Will terminate execution!" << endl;
         ::abort();
     }
 
     // get parameters (declared in the header file)
 
     // Input parameters
     mBB = 5.2792;
     lambda2 = 0.12;
 
     // Shape function parameters
     b = getArg( 0 );
     Lambda = getArg( 1 );
     Ecut = 1.8;
     wzero = mBB - 2 * Ecut;
 
     // SF and SSF modes
     itype = (int)getArg( 5 );
     dtype = getArg( 5 );
     isubl = (int)getArg( 6 );
 
     // flags
     flag1 = (int)getArg( 7 );
     flag2 = (int)getArg( 8 );
     flag3 = (int)getArg( 9 );
 
     // Quark mass
     mb = 4.61;
 
     // hidden parameter what and SF stuff
     const double xlow = 0;
     const double xhigh = mBB;
     const int aSize = 10000;
     EvtPFermi pFermi( Lambda, b );
     // pf is the cumulative distribution normalized to 1.
     _pf.resize( aSize );
     for ( int i = 0; i < aSize; i++ ) {
         double what = xlow + (double)( i + 0.5 ) / ( (double)aSize ) *
                                  ( xhigh - xlow );
         if ( i == 0 )
             _pf[i] = pFermi.getSFBLNP( what );
         else
             _pf[i] = _pf[i - 1] + pFermi.getSFBLNP( what );
     }
     for ( size_t i = 0; i < _pf.size(); i++ ) {
         _pf[i] /= _pf[_pf.size() - 1];
     }
 
     // Matching scales
     muh = mBB * getArg( 2 );    // 0.5
     mui = getArg( 3 );          // 1.5
     mubar = getArg( 4 );        // 1.5
 
     // Perturbative quantities
     CF = 4.0 / 3.0;
     CA = 3.0;
     double nf = 4.0;
 
     beta0 = 11.0 / 3.0 * CA - 2.0 / 3.0 * nf;
     beta1 = 34.0 / 3.0 * CA * CA - 10.0 / 3.0 * CA * nf - 2.0 * CF * nf;
     beta2 = 2857.0 / 54.0 * CA * CA * CA +
             ( CF * CF - 205.0 / 18.0 * CF * CA - 1415.0 / 54.0 * CA * CA ) * nf +
             ( 11.0 / 9.0 * CF + 79.0 / 54.0 * CA ) * nf * nf;
 
     zeta3 = 1.0 + 1 / 8.0 + 1 / 27.0 + 1 / 64.0;
 
     Gamma0 = 4 * CF;
     Gamma1 = CF * ( ( 268.0 / 9.0 - 4.0 * M_PI * M_PI / 3.0 ) * CA -
                     40.0 / 9.0 * nf );
     Gamma2 = 16 * CF *
              ( ( 245.0 / 24.0 - 67.0 / 54.0 * M_PI * M_PI +
                  +11.0 / 180.0 * pow( M_PI, 4 ) + 11.0 / 6.0 * zeta3 ) *
                    CA * CA *
                    +( -209.0 / 108.0 + 5.0 / 27.0 * M_PI * M_PI -
                       7.0 / 3.0 * zeta3 ) *
                    CA * nf +
                ( -55.0 / 24.0 + 2 * zeta3 ) * CF * nf - nf * nf / 27.0 );
 
     gp0 = -5.0 * CF;
     gp1 = -8.0 * CF *
           ( ( 3.0 / 16.0 - M_PI * M_PI / 4.0 + 3 * zeta3 ) * CF +
             ( 1549.0 / 432.0 + 7.0 / 48.0 * M_PI * M_PI - 11.0 / 4.0 * zeta3 ) *
                 CA -
             ( 125.0 / 216.0 + M_PI * M_PI / 24.0 ) * nf );
 
     // Lbar and mupisq
 
     Lbar = Lambda;    // all models
     mupisq = 3 * Lambda * Lambda / b;
     if ( itype == 1 )
         mupisq = 3 * Lambda * Lambda / b;
     if ( itype == 2 )
         mupisq = 3 * Lambda * Lambda *
                  ( Gamma( 1 + 0.5 * b ) * Gamma( 0.5 * b ) /
                        pow( Gamma( 0.5 + 0.5 * b ), 2 ) -
                    1 );
 
     // moment2 for SSFs
     moment2 = pow( 0.3, 3 );
 
     // inputs for total rate (T for Total); use BLNP notebook defaults
     flagpower = 1;
     flag2loop = 1;
 
     // stuff for the integrator
     maxLoop = 20;
     //precision = 1.0e-3;
     precision = 2.0e-2;
 
     // vector of global variables, to pass to static functions (which can't access globals);
     gvars.push_back( 0.0 );       // 0
     gvars.push_back( 0.0 );       // 1
     gvars.push_back( mui );       // 2
     gvars.push_back( b );         // 3
     gvars.push_back( Lambda );    // 4
     gvars.push_back( mBB );       // 5
     gvars.push_back( mb );        // 6
     gvars.push_back( wzero );     // 7
     gvars.push_back( beta0 );     // 8
     gvars.push_back( beta1 );     // 9
     gvars.push_back( beta2 );     // 10
     gvars.push_back( dtype );     // 11
 
     // check that there are 3 daughters and 10 arguments
     checkNDaug( 3 );
     // A. Volk: check for number of arguments is not necessary
     //checkNArg(10);
 
     if ( _noHybrid )
         return;    // Without hybrid weighting, nothing else to do
 
     _bins_mX = std::vector<double>( abs( (int)getArg( 10 ) ) );
     _bins_q2 = std::vector<double>( abs( (int)getArg( 11 ) ) );
     _bins_El = std::vector<double>( abs( (int)getArg( 12 ) ) );
 
     int nextArg = EvtVubBLNPHybrid::nParameters + EvtVubBLNPHybrid::nVariables;
 
     _nbins = _bins_mX.size() * _bins_q2.size() *
              _bins_El.size();    // Binning of weight table
 
     int expectArgs = nextArg + _bins_mX.size() + _bins_q2.size() +
                      _bins_El.size() + _nbins;
 
     if ( getNArg() < expectArgs ) {
         EvtGenReport( EVTGEN_ERROR, "EvtVubBLNPHybrid" )
             << " finds " << getNArg() << " arguments, expected " << expectArgs
             << ".  Something is wrong with the tables of weights or thresholds."
             << "\nWill terminate execution!" << endl;
         ::abort();
     }
 
     // read bin boundaries from decay.dec
     for ( auto& b : _bins_mX )
         b = getArg( nextArg++ );
     _masscut = _bins_mX[0];
     for ( auto& b : _bins_q2 )
         b = getArg( nextArg++ );
     for ( auto& b : _bins_El )
         b = getArg( nextArg++ );
 
     // read in weights (and rescale to range 0..1)
     readWeights( nextArg );
 }
 
 void EvtVubBLNPHybrid::initProbMax()
 {
     noProbMax();
 }
 
 void EvtVubBLNPHybrid::decay( EvtParticle* Bmeson )
 {
     int j;
 
     EvtParticle *xuhad( nullptr ), *lepton( nullptr ), *neutrino( nullptr );
     EvtVector4R p4;
     double EX( 0. ), sh( 0. ), El( 0. ), ml( 0. );
     double Pp, Pm, Pl, pdf, qsq, mpi, ratemax;
 
     double xhigh, xlow, what;
     double mX;
 
     bool rew( true );
     while ( rew ) {
         Bmeson->initializePhaseSpace( getNDaug(), getDaugs() );
 
         xuhad = Bmeson->getDaug( 0 );
         lepton = Bmeson->getDaug( 1 );
         neutrino = Bmeson->getDaug( 2 );
 
         mBB = Bmeson->mass();
         ml = lepton->mass();
 
         //  get SF value
         xlow = 0;
         xhigh = mBB;
         // the case for alphas = 0 is not considered
         what = 2 * xhigh;
         while ( what > xhigh || what < xlow ) {
             what = findBLNPWhat();
             what = xlow + what * ( xhigh - xlow );
         }
 
         bool tryit = true;
 
         while ( tryit ) {
             // generate pp between 0 and
             // Flat(min, max) gives R(max - min) + min, where R = random btwn 0 and 1
 
             Pp = EvtRandom::Flat( 0, mBB );    // P+ = EX - |PX|
             Pl = EvtRandom::Flat( 0, mBB );    // mBB - 2El
             Pm = EvtRandom::Flat( 0, mBB );    // P- = EX + |PX|
 
             sh = Pm * Pp;
             EX = 0.5 * ( Pm + Pp );
             qsq = ( mBB - Pp ) * ( mBB - Pm );
             El = 0.5 * ( mBB - Pl );
 
             // Need maximum rate.  Waiting for Mr. Paz to give it to me.
             // Meanwhile, use this.
             ratemax = 3.0;    // From trial and error - most events below 3.0
 
             // kinematic bounds (Eq. 2)
             mpi = 0.14;
             if ( ( Pp > 0 ) && ( Pp <= Pl ) && ( Pl <= Pm ) && ( Pm < mBB ) &&
                  ( El > ml ) && ( sh > 4 * mpi * mpi ) ) {
                 // Probability of pass proportional to PDF
                 pdf = rate3( Pp, Pl, Pm );
                 double testRan = EvtRandom::Flat( 0., ratemax );
                 if ( pdf >= testRan )
                     tryit = false;
             }
         }
 
         // compute all kinematic variables needed for reweighting
         mX = sqrt( sh );
 
         // Reweighting in bins of mX, q2, El
         if ( _nbins > 0 ) {
             double xran1 = EvtRandom::Flat();
             double w = 1.0;
             if ( !_noHybrid )
                 w = getWeight( mX, qsq, El );
             if ( w >= xran1 )
                 rew = false;
         } else {
             rew = false;
         }
     }
     // o.k. we have the three kineamtic variables
     // now calculate a flat cos Theta_H [-1,1] distribution of the
     // hadron flight direction w.r.t the B flight direction
     // because the B is a scalar and should decay isotropic.
     // Then chose a flat Phi_H [0,2Pi] w.r.t the B flight direction
     // and and a flat Phi_L [0,2Pi] in the W restframe w.r.t the
     // W flight direction.
 
     double ctH = EvtRandom::Flat( -1, 1 );
     double phH = EvtRandom::Flat( 0, 2 * M_PI );
     double phL = EvtRandom::Flat( 0, 2 * M_PI );
 
     // now compute the four vectors in the B Meson restframe
 
     double ptmp, sttmp;
     // calculate the hadron 4 vector in the B Meson restframe
 
     sttmp = sqrt( 1 - ctH * ctH );
     ptmp = sqrt( EX * EX - sh );
     double pHB[4] = {EX, ptmp * sttmp * cos( phH ), ptmp * sttmp * sin( phH ),
                      ptmp * ctH};
     p4.set( pHB[0], pHB[1], pHB[2], pHB[3] );
     xuhad->init( getDaug( 0 ), p4 );
 
     if ( _storeWhat ) {
         // cludge to store the hidden parameter what with the decay;
         // the lifetime of the Xu is abused for this purpose.
         // tau = 1 ps corresponds to ctau = 0.3 mm -> in order to
         // stay well below BaBars sensitivity we take what/(10000 GeV).
         // To extract what back from the StdHepTrk its necessary to get
         // delta_ctau = Xu->decayVtx()->point().distanceTo(XuDaughter->decayVtx()->point());
         //
         // what = delta_ctau * 100000 * Mass_Xu/Momentum_Xu
         //
         xuhad->setLifetime( what / 10000. );
     }
 
     // calculate the W 4 vector in the B Meson restrframe
 
     double apWB = ptmp;
     double pWB[4] = {mBB - EX, -pHB[1], -pHB[2], -pHB[3]};
 
     // first go in the W restframe and calculate the lepton and
     // the neutrino in the W frame
 
     double mW2 = mBB * mBB + sh - 2 * mBB * EX;
     double beta = ptmp / pWB[0];
     double gamma = pWB[0] / sqrt( mW2 );
 
     double pLW[4];
 
     ptmp = ( mW2 - ml * ml ) / 2 / sqrt( mW2 );
     pLW[0] = sqrt( ml * ml + ptmp * ptmp );
 
     double ctL = ( El - gamma * pLW[0] ) / beta / gamma / ptmp;
     if ( ctL < -1 )
         ctL = -1;
     if ( ctL > 1 )
         ctL = 1;
     sttmp = sqrt( 1 - ctL * ctL );
 
     // eX' = eZ x eW
     double xW[3] = {-pWB[2], pWB[1], 0};
     // eZ' = eW
     double zW[3] = {pWB[1] / apWB, pWB[2] / apWB, pWB[3] / apWB};
 
     double lx = sqrt( xW[0] * xW[0] + xW[1] * xW[1] );
     for ( j = 0; j < 2; j++ )
         xW[j] /= lx;
 
     // eY' = eZ' x eX'
     double yW[3] = {-pWB[1] * pWB[3], -pWB[2] * pWB[3],
                     pWB[1] * pWB[1] + pWB[2] * pWB[2]};
     double ly = sqrt( yW[0] * yW[0] + yW[1] * yW[1] + yW[2] * yW[2] );
     for ( j = 0; j < 3; j++ )
         yW[j] /= ly;
 
     // p_lep = |p_lep| * (  sin(Theta) * cos(Phi) * eX'
     //                    + sin(Theta) * sin(Phi) * eY'
     //                    + cos(Theta) *            eZ')
     for ( j = 0; j < 3; j++ )
         pLW[j + 1] = sttmp * cos( phL ) * ptmp * xW[j] +
                      sttmp * sin( phL ) * ptmp * yW[j] + ctL * ptmp * zW[j];
 
     double apLW = ptmp;
 
     // boost them back in the B Meson restframe
 
     double appLB = beta * gamma * pLW[0] + gamma * ctL * apLW;
 
     ptmp = sqrt( El * El - ml * ml );
     double ctLL = appLB / ptmp;
 
     if ( ctLL > 1 )
         ctLL = 1;
     if ( ctLL < -1 )
         ctLL = -1;
 
     double pLB[4] = {El, 0, 0, 0};
     double pNB[4] = {pWB[0] - El, 0, 0, 0};
 
     for ( j = 1; j < 4; j++ ) {
         pLB[j] = pLW[j] + ( ctLL * ptmp - ctL * apLW ) / apWB * pWB[j];
         pNB[j] = pWB[j] - pLB[j];
     }
 
     p4.set( pLB[0], pLB[1], pLB[2], pLB[3] );
     lepton->init( getDaug( 1 ), p4 );
 
     p4.set( pNB[0], pNB[1], pNB[2], pNB[3] );
     neutrino->init( getDaug( 2 ), p4 );
 }
 
 double EvtVubBLNPHybrid::rate3( double Pp, double Pl, double Pm )
 {
     // rate3 in units of GF^2*Vub^2/pi^3
 
     double factor = 1.0 / 16 * ( mBB - Pp ) * U1lo( muh, mui ) *
                     pow( ( Pm - Pp ) / ( mBB - Pp ), alo( muh, mui ) );
 
     double doneJS = DoneJS( Pp, Pm, mui );
     double done1 = Done1( Pp, Pm, mui );
     double done2 = Done2( Pp, Pm, mui );
     double done3 = Done3( Pp, Pm, mui );
 
     // The EvtSimpsonIntegrator returns zero for bad integrals.
     // So if any of the integrals are zero (ie bad), return zero.
     // This will cause pdf = 0, so the event will not pass.
     // I hope this will not introduce a bias.
     if ( doneJS * done1 * done2 * done3 == 0.0 ) {
         //cout << "Integral failed: (Pp, Pm, Pl) = (" << Pp << ", " << Pm << ", " << Pl << ")" << endl;
         return 0.0;
     }
     //  if (doneJS*done1*done2*done3 != 0.0) {
     //    cout << "Integral OK: (Pp, Pm, Pl) = (" << Pp << ", " << Pm << ", " << Pl << ")" << endl;
     //}
 
     double f1 = F1( Pp, Pm, muh, mui, mubar, doneJS, done1 );
     double f2 = F2( Pp, Pm, muh, mui, mubar, done3 );
     double f3 = F3( Pp, Pm, muh, mui, mubar, done2 );
     double answer = factor * ( ( mBB + Pl - Pp - Pm ) * ( Pm - Pl ) * f1 +
                                2 * ( Pl - Pp ) * ( Pm - Pl ) * f2 +
                                ( mBB - Pm ) * ( Pm - Pp ) * f3 );
     return answer;
 }
 
 double EvtVubBLNPHybrid::F1( double Pp, double Pm, double muh, double mui,
                              double mubar, double doneJS, double done1 )
 {
     std::vector<double> vars( 12 );
     vars[0] = Pp;
     vars[1] = Pm;
     for ( int j = 2; j < 12; j++ ) {
         vars[j] = gvars[j];
     }
 
     double y = ( Pm - Pp ) / ( mBB - Pp );
     double ah = CF * alphas( muh, vars ) / 4 / M_PI;
     double ai = CF * alphas( mui, vars ) / 4 / M_PI;
     double abar = CF * alphas( mubar, vars ) / 4 / M_PI;
     double lambda1 = -mupisq;
 
     double t1 = -4 * ai / ( Pp - Lbar ) * ( 2 * log( ( Pp - Lbar ) / mui ) + 1 );
     double t2 = 1 + dU1nlo( muh, mui ) + anlo( muh, mui ) * log( y );
     double t3 = -4.0 * pow( log( y * mb / muh ), 2 ) +
                 10.0 * log( y * mb / muh ) - 4.0 * log( y ) -
                 2.0 * log( y ) / ( 1 - y ) - 4.0 * PolyLog( 2, 1 - y ) -
                 M_PI * M_PI / 6.0 - 12.0;
     double t4 = 2 * pow( log( y * mb * Pp / ( mui * mui ) ), 2 ) -
                 3 * log( y * mb * Pp / ( mui * mui ) ) + 7 - M_PI * M_PI;
 
     double t5 = -wS( Pp ) + 2 * t( Pp ) +
                 ( 1.0 / y - 1.0 ) * ( u( Pp ) - v( Pp ) );
     double t6 = -( lambda1 + 3.0 * lambda2 ) / 3.0 +
                 1.0 / pow( y, 2 ) * ( 4.0 / 3.0 * lambda1 - 2.0 * lambda2 );
 
     double shapePp = Shat( Pp, vars );
 
     double answer = ( t2 + ah * t3 + ai * t4 ) * shapePp + ai * doneJS +
                     1 / ( mBB - Pp ) * ( flag2 * abar * done1 + flag1 * t5 ) +
                     1 / pow( mBB - Pp, 2 ) * flag3 * shapePp * t6;
     if ( Pp > Lbar + mui / exp( 0.5 ) )
         answer = answer + t1;
     return answer;
 }
 
 double EvtVubBLNPHybrid::F2( double Pp, double Pm, double muh, double /* mui */,
                              double mubar, double done3 )
 {
     std::vector<double> vars( 12 );
     vars[0] = Pp;
     vars[1] = Pm;
     for ( int j = 2; j < 12; j++ ) {
         vars[j] = gvars[j];
     }
 
     double y = ( Pm - Pp ) / ( mBB - Pp );
     double lambda1 = -mupisq;
     double ah = CF * alphas( muh, vars ) / 4 / M_PI;
     double abar = CF * alphas( mubar, vars ) / 4 / M_PI;
 
     double t6 = -wS( Pp ) - 2 * t( Pp ) + 1.0 / y * ( t( Pp ) + v( Pp ) );
     double t7 = 1 / pow( y, 2 ) * ( 2.0 / 3.0 * lambda1 + 4.0 * lambda2 ) -
                 1 / y * ( 2.0 / 3.0 * lambda1 + 3.0 / 2.0 * lambda2 );
 
     double shapePp = Shat( Pp, vars );
 
     double answer = ah * log( y ) / ( 1 - y ) * shapePp +
                     1 / ( mBB - Pp ) *
                         ( flag2 * abar * 0.5 * done3 + flag1 / y * t6 ) +
                     1.0 / pow( mBB - Pp, 2 ) * flag3 * shapePp * t7;
     return answer;
 }
 
 double EvtVubBLNPHybrid::F3( double Pp, double Pm, double /*muh*/,
                              double /* mui */, double mubar, double done2 )
 {
     std::vector<double> vars( 12 );
     vars[0] = Pp;
     vars[1] = Pm;
     for ( int j = 2; j < 12; j++ ) {
         vars[j] = gvars[j];
     }
 
     double y = ( Pm - Pp ) / ( mBB - Pp );
     double lambda1 = -mupisq;
     double abar = CF * alphas( mubar, vars ) / 4 / M_PI;
 
     double t7 = 1.0 / pow( y, 2 ) * ( -2.0 / 3.0 * lambda1 + lambda2 );
 
     double shapePp = Shat( Pp, vars );
 
     double answer = 1.0 / ( Pm - Pp ) * flag2 * 0.5 * y * abar * done2 +
                     1.0 / pow( mBB - Pp, 2 ) * flag3 * shapePp * t7;
     return answer;
 }
 
 double EvtVubBLNPHybrid::DoneJS( double Pp, double Pm, double /* mui */ )
 {
     std::vector<double> vars( 12 );
     vars[0] = Pp;
     vars[1] = Pm;
     for ( int j = 2; j < 12; j++ ) {
         vars[j] = gvars[j];
     }
 
     double lowerlim = 0.001 * Pp;
     double upperlim = ( 1.0 - 0.001 ) * Pp;
 
     auto func = EvtItgPtrFunction{&IntJS, lowerlim, upperlim, vars};
     auto integ = EvtItgSimpsonIntegrator{func, precision, maxLoop};
     return integ.evaluate( lowerlim, upperlim );
 }
 
 double EvtVubBLNPHybrid::Done1( double Pp, double Pm, double /* mui */ )
 {
     std::vector<double> vars( 12 );
     vars[0] = Pp;
     vars[1] = Pm;
     for ( int j = 2; j < 12; j++ ) {
         vars[j] = gvars[j];
     }
 
     double lowerlim = 0.001 * Pp;
     double upperlim = ( 1.0 - 0.001 ) * Pp;
 
     auto func = EvtItgPtrFunction{&Int1, lowerlim, upperlim, vars};
     auto integ = EvtItgSimpsonIntegrator{func, precision, maxLoop};
     return integ.evaluate( lowerlim, upperlim );
 }
 
 double EvtVubBLNPHybrid::Done2( double Pp, double Pm, double /* mui */ )
 {
     std::vector<double> vars( 12 );
     vars[0] = Pp;
     vars[1] = Pm;
     for ( int j = 2; j < 12; j++ ) {
         vars[j] = gvars[j];
     }
 
     double lowerlim = 0.001 * Pp;
     double upperlim = ( 1.0 - 0.001 ) * Pp;
 
     auto func = EvtItgPtrFunction{&Int2, lowerlim, upperlim, vars};
     auto integ = EvtItgSimpsonIntegrator{func, precision, maxLoop};
     return integ.evaluate( lowerlim, upperlim );
 }
 
 double EvtVubBLNPHybrid::Done3( double Pp, double Pm, double /* mui */ )
 {
     std::vector<double> vars( 12 );
     vars[0] = Pp;
     vars[1] = Pm;
     for ( int j = 2; j < 12; j++ ) {
         vars[j] = gvars[j];
     }
 
     double lowerlim = 0.001 * Pp;
     double upperlim = ( 1.0 - 0.001 ) * Pp;
 
     auto func = EvtItgPtrFunction{&Int3, lowerlim, upperlim, vars};
     auto integ = EvtItgSimpsonIntegrator{func, precision, maxLoop};
     return integ.evaluate( lowerlim, upperlim );
 }
 
 double EvtVubBLNPHybrid::Int1( double what, const std::vector<double>& vars )
 {
     return Shat( what, vars ) * g1( what, vars );
 }
 
 double EvtVubBLNPHybrid::Int2( double what, const std::vector<double>& vars )
 {
     return Shat( what, vars ) * g2( what, vars );
 }
 
 double EvtVubBLNPHybrid::Int3( double what, const std::vector<double>& vars )
 {
     return Shat( what, vars ) * g3( what, vars );
 }
 
 double EvtVubBLNPHybrid::IntJS( double what, const std::vector<double>& vars )
 {
     double Pp = vars[0];
     double Pm = vars[1];
     double mui = vars[2];
     double mBB = vars[5];
     double mb = vars[6];
     double y = ( Pm - Pp ) / ( mBB - Pp );
 
     return 1 / ( Pp - what ) * ( Shat( what, vars ) - Shat( Pp, vars ) ) *
            ( 4 * log( y * mb * ( Pp - what ) / ( mui * mui ) ) - 3 );
 }
 
 double EvtVubBLNPHybrid::g1( double w, const std::vector<double>& vars )
 {
     double Pp = vars[0];
     double Pm = vars[1];
     double mBB = vars[5];
     double y = ( Pm - Pp ) / ( mBB - Pp );
     double x = ( Pp - w ) / ( mBB - Pp );
 
     double q1 = ( 1 + x ) * ( 1 + x ) * y * ( x + y );
     double q2 = y * ( -9 + 10 * y ) + x * x * ( -12.0 + 13.0 * y ) +
                 2 * x * ( -8.0 + 6 * y + 3 * y * y );
     double q3 = 4 / x * log( y + y / x );
     double q4 = 3.0 * pow( x, 4 ) * ( -2.0 + y ) - 2 * pow( y, 3 ) -
                 4 * pow( x, 3 ) * ( 2.0 + y ) - 2 * x * y * y * ( 4 + y ) -
                 x * x * y * ( 12 + 4 * y + y * y );
     double q5 = log( 1 + y / x );
 
     double answer = q2 / q1 - q3 - 2 * q4 * q5 / ( q1 * y * x );
     return answer;
 }
 
 double EvtVubBLNPHybrid::g2( double w, const std::vector<double>& vars )
 {
     double Pp = vars[0];
     double Pm = vars[1];
     double mBB = vars[5];
     double y = ( Pm - Pp ) / ( mBB - Pp );
     double x = ( Pp - w ) / ( mBB - Pp );
 
     double q1 = ( 1 + x ) * ( 1 + x ) * pow( y, 3 ) * ( x + y );
     double q2 = 10.0 * pow( x, 4 ) + y * y +
                 3.0 * pow( x, 2 ) * y * ( 10.0 + y ) +
                 pow( x, 3 ) * ( 12.0 + 19.0 * y ) +
                 x * y * ( 8.0 + 4.0 * y + y * y );
     double q3 = 5 * pow( x, 4 ) + 2.0 * y * y +
                 6.0 * pow( x, 3 ) * ( 1.0 + 2.0 * y ) +
                 4.0 * x * y * ( 1 + 2.0 * y ) + x * x * y * ( 18.0 + 5.0 * y );
     double q4 = log( 1 + y / x );
 
     double answer = 2.0 / q1 * ( y * q2 - 2 * x * q3 * q4 );
     return answer;
 }
 
 double EvtVubBLNPHybrid::g3( double w, const std::vector<double>& vars )
 {
     double Pp = vars[0];
     double Pm = vars[1];
     double mBB = vars[5];
     double y = ( Pm - Pp ) / ( mBB - Pp );
     double x = ( Pp - w ) / ( mBB - Pp );
 
     double q1 = ( 1 + x ) * ( 1 + x ) * pow( y, 3 ) * ( x + y );
     double q2 = 2.0 * pow( y, 3 ) * ( -11.0 + 2.0 * y ) -
                 10.0 * pow( x, 4 ) * ( 6 - 6 * y + y * y ) +
                 x * y * y * ( -94.0 + 29.0 * y + 2.0 * y * y ) +
                 2.0 * x * x * y * ( -72.0 + 18.0 * y + 13.0 * y * y ) -
                 x * x * x * ( 72.0 + 42.0 * y - 70.0 * y * y + 3.0 * y * y * y );
     double q3 = -6.0 * x * ( -5.0 + y ) * pow( y, 3 ) + 4 * pow( y, 4 ) +
                 5 * pow( x, 5 ) * ( 6 - 6 * y + y * y ) -
                 4 * x * x * y * y * ( -20.0 + 6 * y + y * y ) +
                 pow( x, 3 ) * y * ( 90.0 - 10.0 * y - 28.0 * y * y + y * y * y ) +
                 pow( x, 4 ) * ( 36.0 + 36.0 * y - 50.0 * y * y + 4 * y * y * y );
     double q4 = log( 1 + y / x );
 
     double answer = q2 / q1 + 2 / q1 / y * q3 * q4;
     return answer;
 }
 
 double EvtVubBLNPHybrid::Shat( double w, const std::vector<double>& vars )
 {
     double mui = vars[2];
     double b = vars[3];
     double Lambda = vars[4];
     double wzero = vars[7];
     int itype = (int)vars[11];
 
     double norm = 0.0;
     double shape = 0.0;
 
     if ( itype == 1 ) {
         double Lambar = ( Lambda / b ) *
                         ( Gamma( 1 + b ) - Gamma( 1 + b, b * wzero / Lambda ) ) /
                         ( Gamma( b ) - Gamma( b, b * wzero / Lambda ) );
         double muf = wzero - Lambar;
         double mupisq = 3 * pow( Lambda, 2 ) / pow( b, 2 ) *
                             ( Gamma( 2 + b ) -
                               Gamma( 2 + b, b * wzero / Lambda ) ) /
                             ( Gamma( b ) - Gamma( b, b * wzero / Lambda ) ) -
                         3 * Lambar * Lambar;
         norm = Mzero( muf, mui, mupisq, vars ) * Gamma( b ) /
                ( Gamma( b ) - Gamma( b, b * wzero / Lambda ) );
         shape = pow( b, b ) / Lambda / Gamma( b ) * pow( w / Lambda, b - 1 ) *
                 exp( -b * w / Lambda );
     }
 
     if ( itype == 2 ) {
         double dcoef = pow( Gamma( 0.5 * ( 1 + b ) ) / Gamma( 0.5 * b ), 2 );
         double t1 = wzero * wzero * dcoef / ( Lambda * Lambda );
         double Lambar =
             Lambda * ( Gamma( 0.5 * ( 1 + b ) ) - Gamma( 0.5 * ( 1 + b ), t1 ) ) /
             pow( dcoef, 0.5 ) / ( Gamma( 0.5 * b ) - Gamma( 0.5 * b, t1 ) );
         double muf = wzero - Lambar;
         double mupisq = 3 * Lambda * Lambda *
                             ( Gamma( 1 + 0.5 * b ) - Gamma( 1 + 0.5 * b, t1 ) ) /
                             dcoef / ( Gamma( 0.5 * b ) - Gamma( 0.5 * b, t1 ) ) -
                         3 * Lambar * Lambar;
         norm = Mzero( muf, mui, mupisq, vars ) * Gamma( 0.5 * b ) /
                ( Gamma( 0.5 * b ) -
                  Gamma( 0.5 * b, wzero * wzero * dcoef / ( Lambda * Lambda ) ) );
         shape = 2 * pow( dcoef, 0.5 * b ) / Lambda / Gamma( 0.5 * b ) *
                 pow( w / Lambda, b - 1 ) *
                 exp( -dcoef * w * w / ( Lambda * Lambda ) );
     }
 
     double answer = norm * shape;
     return answer;
 }
 
 double EvtVubBLNPHybrid::Mzero( double muf, double mu, double mupisq,
                                 const std::vector<double>& vars )
 {
     double CF = 4.0 / 3.0;
     double amu = CF * alphas( mu, vars ) / M_PI;
     double answer = 1 -
                     amu * ( pow( log( muf / mu ), 2 ) + log( muf / mu ) +
                             M_PI * M_PI / 24.0 ) +
                     amu * ( log( muf / mu ) - 0.5 ) * mupisq / ( 3 * muf * muf );
     return answer;
 }
 
 double EvtVubBLNPHybrid::wS( double w )
 {
     double answer = ( Lbar - w ) * Shat( w, gvars );
     return answer;
 }
 
 double EvtVubBLNPHybrid::t( double w )
 {
     double t1 = -3 * lambda2 / mupisq * ( Lbar - w ) * Shat( w, gvars );
     double myf = myfunction( w, Lbar, moment2 );
     double myBIK = myfunctionBIK( w, Lbar, moment2 );
     double answer = t1;
 
     if ( isubl == 1 )
         answer = t1;
     if ( isubl == 3 )
         answer = t1 - myf;
     if ( isubl == 4 )
         answer = t1 + myf;
     if ( isubl == 5 )
         answer = t1 - myBIK;
     if ( isubl == 6 )
         answer = t1 + myBIK;
 
     return answer;
 }
 
 double EvtVubBLNPHybrid::u( double w )
 {
     double u1 = -2 * ( Lbar - w ) * Shat( w, gvars );
     double myf = myfunction( w, Lbar, moment2 );
     double myBIK = myfunctionBIK( w, Lbar, moment2 );
     double answer = u1;
 
     if ( isubl == 1 )
         answer = u1;
     if ( isubl == 3 )
         answer = u1 + myf;
     if ( isubl == 4 )
         answer = u1 - myf;
     if ( isubl == 5 )
         answer = u1 + myBIK;
     if ( isubl == 6 )
         answer = u1 - myBIK;
 
     return answer;
 }
 
 double EvtVubBLNPHybrid::v( double w )
 {
     double v1 = 3 * lambda2 / mupisq * ( Lbar - w ) * Shat( w, gvars );
     double myf = myfunction( w, Lbar, moment2 );
     double myBIK = myfunctionBIK( w, Lbar, moment2 );
     double answer = v1;
 
     if ( isubl == 1 )
         answer = v1;
     if ( isubl == 3 )
         answer = v1 - myf;
     if ( isubl == 4 )
         answer = v1 + myf;
     if ( isubl == 5 )
         answer = v1 - myBIK;
     if ( isubl == 6 )
         answer = v1 + myBIK;
 
     return answer;
 }
 
 double EvtVubBLNPHybrid::myfunction( double w, double Lbar, double mom2 )
 {
     double bval = 5.0;
     double x = w / Lbar;
     double factor = 0.5 * mom2 * pow( bval / Lbar, 3 );
     double answer = factor * exp( -bval * x ) *
                     ( 1 - 2 * bval * x + 0.5 * bval * bval * x * x );
     return answer;
 }
 
 double EvtVubBLNPHybrid::myfunctionBIK( double w, double Lbar, double /* mom2 */ )
 {
     double aval = 10.0;
     double normBIK = ( 4 - M_PI ) * M_PI * M_PI / 8 / ( 2 - M_PI ) / aval + 1;
     double z = 3 * M_PI * w / 8 / Lbar;
     double q = M_PI * M_PI * 2 * pow( M_PI * aval, 0.5 ) * exp( -aval * z * z ) /
                    ( 4 * M_PI - 8 ) * ( 1 - 2 * pow( aval / M_PI, 0.5 ) * z ) +
                8 / pow( 1 + z * z, 4 ) *
                    ( z * log( z ) + 0.5 * z * ( 1 + z * z ) -
                      M_PI / 4 * ( 1 - z * z ) );
     double answer = q / normBIK;
     return answer;
 }
 
 double EvtVubBLNPHybrid::dU1nlo( double muh, double mui )
 {
     double ai = alphas( mui, gvars );
     double ah = alphas( muh, gvars );
 
     double q1 = ( ah - ai ) / ( 4 * M_PI * beta0 );
     double q2 = log( mb / muh ) * Gamma1 + gp1;
     double q3 = 4 * beta1 * ( log( mb / muh ) * Gamma0 + gp0 ) +
                 Gamma2 * ( 1 - ai / ah );
     double q4 = beta1 * beta1 * Gamma0 * ( -1.0 + ai / ah ) /
                 ( 4 * pow( beta0, 3 ) );
     double q5 = -beta2 * Gamma0 * ( 1.0 + ai / ah ) +
                 beta1 * Gamma1 * ( 3 - ai / ah );
     double q6 = beta1 * beta1 * Gamma0 * ( ah - ai ) / beta0 -
                 beta2 * Gamma0 * ah + beta1 * Gamma1 * ai;
 
     double answer =
         q1 * ( q2 - q3 / 4 / beta0 + q4 + q5 / ( 4 * beta0 * beta0 ) ) +
         1 / ( 8 * M_PI * beta0 * beta0 * beta0 ) * log( ai / ah ) * q6;
     return answer;
 }
 
 double EvtVubBLNPHybrid::U1lo( double muh, double mui )
 {
     double epsilon = 0.0;
     double answer = pow( mb / muh, -2 * aGamma( muh, mui, epsilon ) ) *
                     exp( 2 * Sfun( muh, mui, epsilon ) -
                          2 * agp( muh, mui, epsilon ) );
     return answer;
 }
 
 double EvtVubBLNPHybrid::Sfun( double mu1, double mu2, double epsilon )
 {
     double a1 = alphas( mu1, gvars ) / 4 / M_PI;
     double a2 = alphas( mu2, gvars ) / alphas( mu1, gvars );
 
     double answer = S0( a1, a2 ) + S1( a1, a2 ) + epsilon * S2( a1, a2 );
     return answer;
 }
 
 double EvtVubBLNPHybrid::S0( double a1, double r )
 {
     double answer = -Gamma0 / ( 4.0 * beta0 * beta0 * a1 ) *
                     ( -1.0 + 1.0 / r + log( r ) );
     return answer;
 }
 
 double EvtVubBLNPHybrid::S1( double /* a1 */, double r )
 {
     double answer = Gamma0 / ( 4 * beta0 * beta0 ) *
                     ( 0.5 * log( r ) * log( r ) * beta1 / beta0 +
                       ( Gamma1 / Gamma0 - beta1 / beta0 ) * ( 1 - r + log( r ) ) );
     return answer;
 }
 
 double EvtVubBLNPHybrid::S2( double a1, double r )
 {
     double w1 = pow( beta1, 2 ) / pow( beta0, 2 ) - beta2 / beta0 -
                 beta1 * Gamma1 / ( beta0 * Gamma0 ) + Gamma2 / Gamma0;
     double w2 = pow( beta1, 2 ) / pow( beta0, 2 ) - beta2 / beta0;
     double w3 = beta1 * Gamma1 / ( beta0 * Gamma0 ) - beta2 / beta0;
     double w4 = a1 * Gamma0 / ( 4 * beta0 * beta0 );
 
     double answer = w4 *
                     ( -0.5 * pow( 1 - r, 2 ) * w1 + w2 * ( 1 - r ) * log( r ) +
                       w3 * ( 1 - r + r * log( r ) ) );
     return answer;
 }
 
 double EvtVubBLNPHybrid::aGamma( double mu1, double mu2, double epsilon )
 {
     double a1 = alphas( mu1, gvars );
     double a2 = alphas( mu2, gvars );
     double answer = Gamma0 / ( 2 * beta0 ) * log( a2 / a1 ) +
                     epsilon * ( a2 - a1 ) / ( 8.0 * M_PI ) *
                         ( Gamma1 / beta0 - beta1 * Gamma0 / ( beta0 * beta0 ) );
     return answer;
 }
 
 double EvtVubBLNPHybrid::agp( double mu1, double mu2, double epsilon )
 {
     double a1 = alphas( mu1, gvars );
     double a2 = alphas( mu2, gvars );
     double answer = gp0 / ( 2 * beta0 ) * log( a2 / a1 ) +
                     epsilon * ( a2 - a1 ) / ( 8.0 * M_PI ) *
                         ( gp1 / beta0 - beta1 * gp0 / ( beta0 * beta0 ) );
     return answer;
 }
 
 double EvtVubBLNPHybrid::alo( double muh, double mui )
 {
     return -2.0 * aGamma( muh, mui, 0 );
 }
 
 double EvtVubBLNPHybrid::anlo( double muh, double mui )
 {    // d/depsilon of aGamma
 
     double ah = alphas( muh, gvars );
     double ai = alphas( mui, gvars );
     double answer = ( ah - ai ) / ( 8.0 * M_PI ) *
                     ( Gamma1 / beta0 - beta1 * Gamma0 / ( beta0 * beta0 ) );
     return answer;
 }
 
 double EvtVubBLNPHybrid::alphas( double mu, const std::vector<double>& vars )
 {
     // Note: Lambda4 and Lambda5 depend on mbMS = 4.25
     // So if you change mbMS, then you will have to recalculate them.
 
     double beta0 = vars[8];
     double beta1 = vars[9];
     double beta2 = vars[10];
 
     double Lambda4 = 0.298791;
     double lg = 2 * log( mu / Lambda4 );
     double answer = 4 * M_PI / ( beta0 * lg ) *
                     ( 1 - beta1 * log( lg ) / ( beta0 * beta0 * lg ) +
                       beta1 * beta1 / ( beta0 * beta0 * beta0 * beta0 * lg * lg ) *
                           ( ( log( lg ) - 0.5 ) * ( log( lg ) - 0.5 ) -
                             5.0 / 4.0 + beta2 * beta0 / ( beta1 * beta1 ) ) );
     return answer;
 }
 
 double EvtVubBLNPHybrid::PolyLog( double v, double z )
 {
     if ( z >= 1 )
         cout << "Error in EvtVubBLNPHybrid: 2nd argument to PolyLog is >= 1."
              << endl;
 
     double sum = 0.0;
     for ( int k = 1; k < 101; k++ ) {
         sum = sum + pow( z, k ) / pow( k, v );
     }
     return sum;
 }
 
 double EvtVubBLNPHybrid::Gamma( double z )
 {
     if ( z <= 0 )
         return 0;
 
     double v = lgamma( z );
     return exp( v );
 }
 
 double EvtVubBLNPHybrid::Gamma( double a, double x )
 {
     double LogGamma;
     /*    if (x<0.0 || a<= 0.0) raise(SIGFPE);*/
     if ( x < 0.0 )
         x = 0.0;
     if ( a <= 0.0 )
         a = 1.e-50;
     LogGamma = lgamma( a );
     if ( x < ( a + 1.0 ) )
         return gamser( a, x, LogGamma );
     else
         return 1.0 - gammcf( a, x, LogGamma );
 }
 
 /* ------------------Incomplete gamma function-----------------*/
 /* ------------------via its series representation-------------*/
 
 double EvtVubBLNPHybrid::gamser( double a, double x, double LogGamma )
 {
     double n;
     double ap, del, sum;
 
     ap = a;
     del = sum = 1.0 / a;
     for ( n = 1; n < ITMAX; n++ ) {
         ++ap;
         del *= x / ap;
         sum += del;
         if ( fabs( del ) < fabs( sum ) * EPS )
             return sum * exp( -x + a * log( x ) - LogGamma );
     }
     raise( SIGFPE );
 
     return 0.0;
 }
 
 /* ------------------Incomplete gamma function complement------*/
 /* ------------------via its continued fraction representation-*/
 
 double EvtVubBLNPHybrid::gammcf( double a, double x, double LogGamma )
 {
     double an, b, c, d, del, h;
     int i;
 
     b = x + 1.0 - a;
     c = 1.0 / FPMIN;
     d = 1.0 / b;
     h = d;
     for ( i = 1; i < ITMAX; i++ ) {
         an = -i * ( i - a );
         b += 2.0;
         d = an * d + b;
         if ( fabs( d ) < FPMIN )
             d = FPMIN;
         c = b + an / c;
         if ( fabs( c ) < FPMIN )
             c = FPMIN;
         d = 1.0 / d;
         del = d * c;
         h *= del;
         if ( fabs( del - 1.0 ) < EPS )
             return exp( -x + a * log( x ) - LogGamma ) * h;
     }
     raise( SIGFPE );
 
     return 0.0;
 }
 
 double EvtVubBLNPHybrid::findBLNPWhat()
 {
     double ranNum = EvtRandom::Flat();
     double oOverBins = 1.0 / ( float( _pf.size() ) );
     int nBinsBelow = 0;    // largest k such that I[k] is known to be <= rand
     int nBinsAbove = _pf.size();    // largest k such that I[k] is known to be >  rand
     int middle;
 
     while ( nBinsAbove > nBinsBelow + 1 ) {
         middle = ( nBinsAbove + nBinsBelow + 1 ) >> 1;
         if ( ranNum >= _pf[middle] ) {
             nBinsBelow = middle;
         } else {
             nBinsAbove = middle;
         }
     }
 
     double bSize = _pf[nBinsAbove] - _pf[nBinsBelow];
     // binMeasure is always aProbFunc[nBinsBelow],
 
     if ( bSize == 0 ) {
         // rand lies right in a bin of measure 0.  Simply return the center
         // of the range of that bin.  (Any value between k/N and (k+1)/N is
         // equally good, in this rare case.)
         return ( nBinsBelow + .5 ) * oOverBins;
     }
 
     double bFract = ( ranNum - _pf[nBinsBelow] ) / bSize;
 
     return ( nBinsBelow + bFract ) * oOverBins;
 }
 
 double EvtVubBLNPHybrid::getWeight( double mX, double q2, double El )
 {
     int ibin_mX = -1;
     int ibin_q2 = -1;
     int ibin_El = -1;
 
     for ( unsigned i = 0; i < _bins_mX.size(); i++ ) {
         if ( mX >= _bins_mX[i] )
             ibin_mX = i;
     }
     for ( unsigned i = 0; i < _bins_q2.size(); i++ ) {
         if ( q2 >= _bins_q2[i] )
             ibin_q2 = i;
     }
     for ( unsigned i = 0; i < _bins_El.size(); i++ ) {
         if ( El >= _bins_El[i] )
             ibin_El = i;
     }
     int ibin = ibin_mX + ibin_q2 * _bins_mX.size() +
                ibin_El * _bins_mX.size() * _bins_q2.size();
 
     if ( ( ibin_mX < 0 ) || ( ibin_q2 < 0 ) || ( ibin_El < 0 ) ) {
         EvtGenReport( EVTGEN_ERROR, "EvtVubHybrid" )
             << "Cannot determine hybrid weight "
             << "for this event "
             << "-> assign weight = 0" << endl;
         return 0.0;
     }
 
     return _weights[ibin];
 }
 
 void EvtVubBLNPHybrid::readWeights( int startArg )
 {
     _weights.resize( _nbins );
 
     double maxw = 0.0;
     for ( auto& w : _weights ) {
         w = getArg( startArg++ );
         if ( w > maxw )
             maxw = w;
     }
 
     if ( maxw == 0 ) {
         EvtGenReport( EVTGEN_ERROR, "EvtVubBLNPHybrid" )
             << "EvtVub generator expected at least one "
             << " weight > 0, but found none! "
             << "Will terminate execution!" << endl;
         ::abort();
     }
 
     // rescale weights (to be in range 0..1)
     for ( auto& w : _weights )
         w /= maxw;
 }
diff --git a/src/EvtGenModels/EvtVubNLO.cpp b/src/EvtGenModels/EvtVubNLO.cpp
index a658f2e..3f3c41e 100644
--- a/src/EvtGenModels/EvtVubNLO.cpp
+++ b/src/EvtGenModels/EvtVubNLO.cpp
@@ -1,732 +1,732 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtVubNLO.hh"
 
 #include "EvtGenBase/EvtDiLog.hh"
 #include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtRandom.hh"
 #include "EvtGenBase/EvtReport.hh"
 #include "EvtGenBase/EvtVector4R.hh"
 
 #include "EvtGenModels/EvtBtoXsgammaFermiUtil.hh"
 #include "EvtGenModels/EvtItgPtrFunction.hh"
 #include "EvtGenModels/EvtItgSimpsonIntegrator.hh"
 #include "EvtGenModels/EvtPFermi.hh"
 
 #include <array>
 #include <stdlib.h>
 #include <string>
 
 using std::cout;
 using std::endl;
 
 EvtVubNLO::~EvtVubNLO()
 {
     cout << " max pdf : " << _gmax << endl;
     cout << " efficiency : " << (float)_ngood / (float)_ntot << endl;
 }
 
 std::string EvtVubNLO::getName()
 {
     return "VUB_NLO";
 }
 
 EvtDecayBase* EvtVubNLO::clone()
 {
     return new EvtVubNLO;
 }
 
 void EvtVubNLO::init()
 {
     // max pdf
     _gmax = 0;
     _ntot = 0;
     _ngood = 0;
     _lbar = -1000;
     _mupi2 = -1000;
 
-    // check that there are at least 6 arguments
+    // check number of arguments
     int npar = 8;
     if ( getNArg() < npar ) {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "EvtVubNLO generator expected "
             << " at least npar arguments  but found: " << getNArg() << endl;
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "Will terminate execution!" << endl;
         ::abort();
     }
     // this is the shape function parameter
     _mb = getArg( 0 );
     _b = getArg( 1 );
     _lambdaSF = getArg( 2 );    // shape function lambda is different from lambda
     _mui = 1.5;                 // GeV (scale)
     _kpar = getArg( 3 );        // 0
     _idSF = abs( (int)getArg(
         4 ) );    // type of shape function 1: exponential (from Neubert)
     int nbins = abs( (int)getArg( 5 ) );
     _masses.resize( nbins );
     _weights.resize( nbins );
 
     // Shape function normalization
     _mB = 5.28;    // temporary B meson mass for normalization
 
     std::vector<double> sCoeffs( 11 );
     sCoeffs[3] = _b;
     sCoeffs[4] = _mb;
     sCoeffs[5] = _mB;
     sCoeffs[6] = _idSF;
     sCoeffs[7] = lambda_SF();
     sCoeffs[8] = mu_h();
     sCoeffs[9] = mu_i();
     sCoeffs[10] = 1.;
     _SFNorm = SFNorm( sCoeffs );    // SF normalization;
 
     cout << " pdf 0.66, 1.32 , 4.32 " << tripleDiff( 0.66, 1.32, 4.32 ) << endl;
     cout << " pdf 0.23,0.37,3.76 " << tripleDiff( 0.23, 0.37, 3.76 ) << endl;
     cout << " pdf 0.97,4.32,4.42 " << tripleDiff( 0.97, 4.32, 4.42 ) << endl;
     cout << " pdf 0.52,1.02,2.01 " << tripleDiff( 0.52, 1.02, 2.01 ) << endl;
     cout << " pdf 1.35,1.39,2.73 " << tripleDiff( 1.35, 1.39, 2.73 ) << endl;
 
     if ( getNArg() - npar + 2 != int( 2 * _weights.size() ) ) {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "EvtVubNLO generator expected " << _weights.size()
             << " masses and weights but found: " << ( getNArg() - npar ) / 2
             << endl;
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "Will terminate execution!" << endl;
         ::abort();
     }
     int j = npar - 2;
     double maxw = 0.;
     for ( unsigned i = 0; i < _masses.size(); i++ ) {
         _masses[i] = getArg( j++ );
         if ( i > 0 && _masses[i] <= _masses[i - 1] ) {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << "EvtVubNLO generator expected "
                 << " mass bins in ascending order!"
                 << "Will terminate execution!" << endl;
             ::abort();
         }
         _weights[i] = getArg( j++ );
         if ( _weights[i] < 0 ) {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << "EvtVubNLO generator expected "
                 << " weights >= 0, but found: " << _weights[i] << endl;
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << "Will terminate execution!" << endl;
             ::abort();
         }
         if ( _weights[i] > maxw )
             maxw = _weights[i];
     }
     if ( maxw == 0 ) {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "EvtVubNLO generator expected at least one "
             << " weight > 0, but found none! "
             << "Will terminate execution!" << endl;
         ::abort();
     }
     for ( auto& w : _weights )
         w /= maxw;
 
     // the maximum dGamma*p2 value depends on alpha_s only:
 
     //  _dGMax = 0.05;
     _dGMax = 150.;
 
     // for the Fermi Motion we need a B-Meso\n mass - but it's not critical
     // to get an exact value; in order to stay in the phase space for
     // B+- and B0 use the smaller mass
 
     // check that there are 3 daughters
     checkNDaug( 3 );
 }
 
 void EvtVubNLO::initProbMax()
 {
     noProbMax();
 }
 
 void EvtVubNLO::decay( EvtParticle* p )
 {
     // B+ -> u-bar specflav l+ nu
 
     EvtParticle *xuhad, *lepton, *neutrino;
     EvtVector4R p4;
 
     double pp, pm, pl, ml, El( 0.0 ), Eh( 0.0 ), sh( 0.0 );
 
     p->initializePhaseSpace( getNDaug(), getDaugs() );
 
     xuhad = p->getDaug( 0 );
     lepton = p->getDaug( 1 );
     neutrino = p->getDaug( 2 );
 
     _mB = p->mass();
     ml = lepton->mass();
 
     bool tryit = true;
 
     while ( tryit ) {
         // pm=(E_H+P_H)
         pm = EvtRandom::Flat( 0., 1 );
         pm = pow( pm, 1. / 3. ) * _mB;
         // pl=mB-2*El
         pl = EvtRandom::Flat( 0., 1 );
         pl = sqrt( pl ) * pm;
         // pp=(E_H-P_H)
         pp = EvtRandom::Flat( 0., pl );
 
         _ntot++;
 
         El = ( _mB - pl ) / 2.;
         Eh = ( pp + pm ) / 2;
         sh = pp * pm;
 
         double pdf( 0. );
         if ( pp < pl && El > ml && sh > _masses[0] * _masses[0] &&
              _mB * _mB + sh - 2 * _mB * Eh > ml * ml ) {
             double xran = EvtRandom::Flat( 0, _dGMax );
             pdf = tripleDiff( pp, pl, pm );    // triple differential distribution
             //      cout <<" P+,P-,Pl,Pdf= "<<pp <<" "<<pm<<" "<<pl<<" "<<pdf<<endl;
             if ( pdf > _dGMax ) {
                 EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                     << "EvtVubNLO pdf above maximum: " << pdf
                     << " P+,P-,Pl,Pdf= " << pp << " " << pm << " " << pl << " "
                     << pdf << endl;
                 //::abort();
             }
             if ( pdf >= xran )
                 tryit = false;
 
             if ( pdf > _gmax )
                 _gmax = pdf;
         } else {
             //      cout <<" EvtVubNLO incorrect kinematics  sh= "<<sh<<"EH "<<Eh<<endl;
         }
 
         // reweight the Mx distribution
         if ( !tryit && !_weights.empty() ) {
             _ngood++;
             double xran1 = EvtRandom::Flat();
             double m = sqrt( sh );
             unsigned j = 0;
             while ( j < _masses.size() && m > _masses[j] )
                 j++;
             double w = _weights[j - 1];
             if ( w < xran1 )
                 tryit = true;    // through away this candidate
         }
     }
 
     //  cout <<" max prob "<<gmax<<" " << pp<<" "<<y<<" "<<x<<endl;
 
     // o.k. we have the three kineamtic variables
     // now calculate a flat cos Theta_H [-1,1] distribution of the
     // hadron flight direction w.r.t the B flight direction
     // because the B is a scalar and should decay isotropic.
     // Then chose a flat Phi_H [0,2Pi] w.r.t the B flight direction
     // and and a flat Phi_L [0,2Pi] in the W restframe w.r.t the
     // W flight direction.
 
     double ctH = EvtRandom::Flat( -1, 1 );
     double phH = EvtRandom::Flat( 0, 2 * M_PI );
     double phL = EvtRandom::Flat( 0, 2 * M_PI );
 
     // now compute the four vectors in the B Meson restframe
 
     double ptmp, sttmp;
     // calculate the hadron 4 vector in the B Meson restframe
 
     sttmp = sqrt( 1 - ctH * ctH );
     ptmp = sqrt( Eh * Eh - sh );
     double pHB[4] = {Eh, ptmp * sttmp * cos( phH ), ptmp * sttmp * sin( phH ),
                      ptmp * ctH};
     p4.set( pHB[0], pHB[1], pHB[2], pHB[3] );
     xuhad->init( getDaug( 0 ), p4 );
 
     // calculate the W 4 vector in the B Meson restrframe
 
     double apWB = ptmp;
     double pWB[4] = {_mB - Eh, -pHB[1], -pHB[2], -pHB[3]};
 
     // first go in the W restframe and calculate the lepton and
     // the neutrino in the W frame
 
     double mW2 = _mB * _mB + sh - 2 * _mB * Eh;
     //  if(mW2<0.1){
     //  cout <<" low Q2! "<<pp<<" "<<epp<<" "<<x<<" "<<y<<endl;
     //}
     double beta = ptmp / pWB[0];
     double gamma = pWB[0] / sqrt( mW2 );
 
     double pLW[4];
 
     ptmp = ( mW2 - ml * ml ) / 2 / sqrt( mW2 );
     pLW[0] = sqrt( ml * ml + ptmp * ptmp );
 
     double ctL = ( El - gamma * pLW[0] ) / beta / gamma / ptmp;
     if ( ctL < -1 )
         ctL = -1;
     if ( ctL > 1 )
         ctL = 1;
     sttmp = sqrt( 1 - ctL * ctL );
 
     // eX' = eZ x eW
     double xW[3] = {-pWB[2], pWB[1], 0};
     // eZ' = eW
     double zW[3] = {pWB[1] / apWB, pWB[2] / apWB, pWB[3] / apWB};
 
     double lx = sqrt( xW[0] * xW[0] + xW[1] * xW[1] );
     for ( int j = 0; j < 2; j++ )
         xW[j] /= lx;
 
     // eY' = eZ' x eX'
     double yW[3] = {-pWB[1] * pWB[3], -pWB[2] * pWB[3],
                     pWB[1] * pWB[1] + pWB[2] * pWB[2]};
     double ly = sqrt( yW[0] * yW[0] + yW[1] * yW[1] + yW[2] * yW[2] );
     for ( int j = 0; j < 3; j++ )
         yW[j] /= ly;
 
     // p_lep = |p_lep| * (  sin(Theta) * cos(Phi) * eX'
     //                    + sin(Theta) * sin(Phi) * eY'
     //                    + cos(Theta) *            eZ')
     for ( int j = 0; j < 3; j++ )
         pLW[j + 1] = sttmp * cos( phL ) * ptmp * xW[j] +
                      sttmp * sin( phL ) * ptmp * yW[j] + ctL * ptmp * zW[j];
 
     double apLW = ptmp;
 
     // boost them back in the B Meson restframe
 
     double appLB = beta * gamma * pLW[0] + gamma * ctL * apLW;
 
     ptmp = sqrt( El * El - ml * ml );
     double ctLL = appLB / ptmp;
 
     if ( ctLL > 1 )
         ctLL = 1;
     if ( ctLL < -1 )
         ctLL = -1;
 
     double pLB[4] = {El, 0, 0, 0};
     double pNB[8] = {pWB[0] - El, 0, 0, 0};
 
     for ( int j = 1; j < 4; j++ ) {
         pLB[j] = pLW[j] + ( ctLL * ptmp - ctL * apLW ) / apWB * pWB[j];
         pNB[j] = pWB[j] - pLB[j];
     }
 
     p4.set( pLB[0], pLB[1], pLB[2], pLB[3] );
     lepton->init( getDaug( 1 ), p4 );
 
     p4.set( pNB[0], pNB[1], pNB[2], pNB[3] );
     neutrino->init( getDaug( 2 ), p4 );
 
     return;
 }
 
 double EvtVubNLO::tripleDiff( double pp, double pl, double pm )
 {
     std::vector<double> sCoeffs( 11 );
     sCoeffs[0] = pp;
     sCoeffs[1] = pl;
     sCoeffs[2] = pm;
     sCoeffs[3] = _b;
     sCoeffs[4] = _mb;
     sCoeffs[5] = _mB;
     sCoeffs[6] = _idSF;
     sCoeffs[7] = lambda_SF();
     sCoeffs[8] = mu_h();
     sCoeffs[9] = mu_i();
     sCoeffs[10] = _SFNorm;    // SF normalization;
 
     double c1 = ( _mB + pl - pp - pm ) * ( pm - pl );
     double c2 = 2 * ( pl - pp ) * ( pm - pl );
     double c3 = ( _mB - pm ) * ( pm - pp );
     double aF1 = F10( sCoeffs );
     double aF2 = F20( sCoeffs );
     double aF3 = F30( sCoeffs );
     double td0 = c1 * aF1 + c2 * aF2 + c3 * aF3;
 
     auto func = EvtItgPtrFunction{&integrand, 0., _mB, sCoeffs};
     auto jetSF = EvtItgSimpsonIntegrator{func, 0.01, 25};
     double smallfrac =
         0.000001;    // stop a bit before the end to avoid problems with numerical integration
     double tdInt = jetSF.evaluate( 0, pp * ( 1 - smallfrac ) );
 
     double SU = U1lo( mu_h(), mu_i() ) *
                 pow( ( pm - pp ) / ( _mB - pp ), alo( mu_h(), mu_i() ) );
     double TD = ( _mB - pp ) * SU * ( td0 + tdInt );
 
     return TD;
 }
 
 double EvtVubNLO::integrand( double omega, const std::vector<double>& coeffs )
 {
     //double pp=coeffs[0];
     double c1 = ( coeffs[5] + coeffs[1] - coeffs[0] - coeffs[2] ) *
                 ( coeffs[2] - coeffs[1] );
     double c2 = 2 * ( coeffs[1] - coeffs[0] ) * ( coeffs[2] - coeffs[1] );
     double c3 = ( coeffs[5] - coeffs[2] ) * ( coeffs[2] - coeffs[0] );
 
     return c1 * F1Int( omega, coeffs ) + c2 * F2Int( omega, coeffs ) +
            c3 * F3Int( omega, coeffs );
 }
 
 double EvtVubNLO::F10( const std::vector<double>& coeffs )
 {
     double pp = coeffs[0];
     double y = ( coeffs[2] - coeffs[0] ) / ( coeffs[5] - coeffs[0] );
     double mui = coeffs[9];
     double muh = coeffs[8];
     double z = 1 - y;
     double result = U1nlo( muh, mui ) / U1lo( muh, mui );
 
     result += anlo( muh, mui ) * log( y );
 
     result += C_F( muh ) *
               ( -4 * pow( log( y * coeffs[4] / muh ), 2 ) +
                 10 * log( y * coeffs[4] / muh ) - 4 * log( y ) -
                 2 * log( y ) / ( 1 - y ) - 4.0 * EvtDiLog::DiLog( z ) -
                 pow( EvtConst::pi, 2 ) / 6. - 12 );
 
     result += C_F( mui ) *
               ( 2 * pow( log( y * coeffs[4] * pp / pow( mui, 2 ) ), 2 ) -
                 3 * log( y * coeffs[4] * pp / pow( mui, 2 ) ) + 7 -
                 pow( EvtConst::pi, 2 ) );
     result *= shapeFunction( pp, coeffs );
     // changes due to SSF
     result += ( -subS( coeffs ) + 2 * subT( coeffs ) +
                 ( subU( coeffs ) - subV( coeffs ) ) * ( 1 / y - 1. ) ) /
               ( coeffs[5] - pp );
     result += shapeFunction( pp, coeffs ) / pow( ( coeffs[5] - coeffs[0] ), 2 ) *
               ( -5 * ( lambda1() + 3 * lambda2() ) / 6 +
                 2 * ( 2 * lambda1() / 3 - lambda2() ) / pow( y, 2 ) );
     //  result +=  (subS(coeffs)+subT(coeffs)+(subU(coeffs)-subV(coeffs))/y)/(coeffs[5]-pp);
     // this part has been added after Feb '05
 
     //result += shapeFunction(pp,coeffs)/pow((coeffs[5]-coeffs[0]),2)*((lambda1()+3*lambda2())/6+2*(2*lambda1()/3-lambda2())/pow(y,2));
     return result;
 }
 
 double EvtVubNLO::F1Int( double omega, const std::vector<double>& coeffs )
 {
     double pp = coeffs[0];
     double y = ( coeffs[2] - coeffs[0] ) / ( coeffs[5] - coeffs[0] );
     // mubar == mui
     return C_F( coeffs[9] ) *
            ( ( shapeFunction( omega, coeffs ) - shapeFunction( pp, coeffs ) ) *
                  ( 4 * log( y * coeffs[4] * ( pp - omega ) / pow( coeffs[9], 2 ) ) -
                    3 ) /
                  ( pp - omega ) +
              ( g1( y, ( pp - omega ) / ( coeffs[5] - coeffs[0] ) ) /
                ( coeffs[5] - pp ) * shapeFunction( omega, coeffs ) ) );
 }
 
 double EvtVubNLO::F20( const std::vector<double>& coeffs )
 {
     double pp = coeffs[0];
     double y = ( coeffs[2] - coeffs[0] ) / ( coeffs[5] - coeffs[0] );
     double result = C_F( coeffs[8] ) * log( y ) / ( 1 - y ) *
                         shapeFunction( pp, coeffs ) -
                     1 / y *
                         ( subS( coeffs ) + 2 * subT( coeffs ) -
                           ( subT( coeffs ) + subV( coeffs ) ) / y ) /
                         ( coeffs[5] - pp );
     // added after Feb '05
     result += shapeFunction( pp, coeffs ) /
               pow( ( coeffs[5] - coeffs[0] ) * y, 2 ) *
               ( 2 * lambda1() / 3 + 4 * lambda2() -
                 y * ( 7 / 6 * lambda1() + 3 * lambda2() ) );
     return result;
 }
 
 double EvtVubNLO::F2Int( double omega, const std::vector<double>& coeffs )
 {
     double pp = coeffs[0];
     double y = ( coeffs[2] - coeffs[0] ) / ( coeffs[5] - coeffs[0] );
     return C_F( coeffs[9] ) *
            g3( y, ( pp - omega ) / ( coeffs[5] - coeffs[0] ) ) *
            shapeFunction( omega, coeffs ) / ( coeffs[5] - pp );
 }
 
 double EvtVubNLO::F30( const std::vector<double>& coeffs )
 {
     double y = ( coeffs[2] - coeffs[0] ) / ( coeffs[5] - coeffs[0] );
     return shapeFunction( coeffs[0], coeffs ) /
            pow( ( coeffs[5] - coeffs[0] ) * y, 2 ) *
            ( -2 * lambda1() / 3 + lambda2() );
 }
 
 double EvtVubNLO::F3Int( double omega, const std::vector<double>& coeffs )
 {
     double pp = coeffs[0];
     double y = ( coeffs[2] - coeffs[0] ) / ( coeffs[5] - coeffs[0] );
     return C_F( coeffs[9] ) *
            g3( y, ( pp - omega ) / ( coeffs[5] - coeffs[0] ) ) / 2 *
            shapeFunction( omega, coeffs ) / ( coeffs[2] - coeffs[0] );
 }
 
 double EvtVubNLO::g1( double y, double x )
 {
     double result = ( y * ( -9 + 10 * y ) + x * x * ( -12 + 13 * y ) +
                       2 * x * ( -8 + 6 * y + 3 * y * y ) ) /
                     y / pow( 1 + x, 2 ) / ( x + y );
     result -= 4 * log( ( 1 + 1 / x ) * y ) / x;
     result -= 2 * log( 1 + y / x ) *
               ( 3 * pow( x, 4 ) * ( -2 + y ) - 2 * pow( y, 3 ) -
                 4 * pow( x, 3 ) * ( 2 + y ) - 2 * x * y * y * ( 4 + y ) -
                 x * x * y * ( 12 + 4 * y + y * y ) ) /
               x / pow( ( 1 + x ) * y, 2 ) / ( x + y );
     return result;
 }
 
 double EvtVubNLO::g2( double y, double x )
 {
     double result = y * ( 10 * pow( x, 4 ) + y * y + 3 * x * x * y * ( 10 + y ) +
                           pow( x, 3 ) * ( 12 + 19 * y ) +
                           x * y * ( 8 + 4 * y + y * y ) );
     result -= 2 * x * log( 1 + y / x ) *
               ( 5 * pow( x, 4 ) + 2 * y * y + 6 * pow( x, 3 ) * ( 1 + 2 * y ) +
                 4 * y * x * ( 1 + 2 * y ) + x * x * y * ( 18 + 5 * y ) );
     result *= 2 / ( pow( y * ( 1 + x ), 2 ) * y * ( x + y ) );
     return result;
 }
 
 double EvtVubNLO::g3( double y, double x )
 {
     double result = ( 2 * pow( y, 3 ) * ( -11 + 2 * y ) -
                       10 * pow( x, 4 ) * ( 6 - 6 * y + y * y ) +
                       x * y * y * ( -94 + 29 * y + 2 * y * y ) +
                       2 * x * x * y * ( -72 + 18 * y + 13 * y * y ) -
                       pow( x, 3 ) *
                           ( 72 + 42 * y - 70 * y * y + 3 * pow( y, 3 ) ) ) /
                     ( pow( y * ( 1 + x ), 2 ) * y * ( x + y ) );
     result += 2 * log( 1 + y / x ) *
               ( -6 * x * pow( y, 3 ) * ( -5 + y ) + 4 * pow( y, 4 ) +
                 5 * pow( x, 5 ) * ( 6 - 6 * y + y * y ) -
                 4 * pow( x * y, 2 ) * ( -20 + 6 * y + y * y ) +
                 pow( x, 3 ) * y * ( 90 - 10 * y - 28 * y * y + pow( y, 3 ) ) +
                 pow( x, 4 ) * ( 36 + 36 * y - 50 * y * y + 4 * pow( y, 3 ) ) ) /
               ( pow( ( 1 + x ) * y * y, 2 ) * ( x + y ) );
     return result;
 }
 
 /* old version (before Feb 05 notebook from NNeubert
 
 double
 EvtVubNLO::F1Int(double omega,const std::vector<double> &coeffs){
   double pp=coeffs[0];
   double y=(coeffs[2]-coeffs[0])/(coeffs[5]-coeffs[0]);
   // mubar == mui
   return C_F(coeffs[9])*(
 			 (shapeFunction(omega,coeffs)-shapeFunction(pp,coeffs))*(4*log(y*coeffs[4]*(pp-omega)/pow(coeffs[9],2))-3)/(pp-omega)-
 			 (1./y/(coeffs[5]-pp)*shapeFunction(omega,coeffs)*(5-6*y+4*(3-y)*log((pp-omega)/y/coeffs[4])))
 			 );
 }
 
 
 double
 EvtVubNLO::F2Int(double omega,const std::vector<double> &coeffs){
   double pp=coeffs[0];
   double y=(coeffs[2]-coeffs[0])/(coeffs[5]-coeffs[0]);
   return C_F(coeffs[9])*shapeFunction(omega,coeffs)*(2-11/y-4/y*log((pp-omega)/y/coeffs[4]))/(coeffs[5]-pp);
 }
 
 double
 EvtVubNLO::F3(const std::vector<double> &coeffs){
   return C_F(coeffs[9])*shapeFunction(omega,coeffs)/(coeffs[2]-coeffs[0]);
 }
 */
 
 double EvtVubNLO::SFNorm( const std::vector<double>& /*coeffs*/ )
 {
     double omega0 = 1.68;        //normalization scale (mB-2*1.8)
     if ( _idSF == 1 ) {          // exponential SF
         double omega0 = 1.68;    //normalization scale (mB-2*1.8)
         return M0( mu_i(), omega0 ) * pow( _b, _b ) / lambda_SF() /
                ( Gamma( _b ) - Gamma( _b, _b * omega0 / lambda_SF() ) );
     } else if ( _idSF == 2 ) {    // Gaussian SF
         double c = cGaus( _b );
         return M0( mu_i(), omega0 ) * 2 / lambda_SF() /
                pow( c, -( 1 + _b ) / 2. ) /
                ( Gamma( ( 1 + _b ) / 2 ) -
                  Gamma( ( 1 + _b ) / 2, pow( omega0 / lambda_SF(), 2 ) * c ) );
     } else {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" ) << "unknown SF " << _idSF << endl;
         return -1;
     }
 }
 
 double EvtVubNLO::shapeFunction( double omega, const std::vector<double>& sCoeffs )
 {
     if ( sCoeffs[6] == 1 ) {
         return sCoeffs[10] * expShapeFunction( omega, sCoeffs );
     } else if ( sCoeffs[6] == 2 ) {
         return sCoeffs[10] * gausShapeFunction( omega, sCoeffs );
     } else {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "EvtVubNLO : unknown shape function # " << sCoeffs[6] << endl;
     }
     return -1.;
 }
 
 // SSF
 double EvtVubNLO::subS( const std::vector<double>& c )
 {
     return ( lambda_bar( 1.68 ) - c[0] ) * shapeFunction( c[0], c );
 }
 double EvtVubNLO::subT( const std::vector<double>& c )
 {
     return -3 * lambda2() * subS( c ) / mu_pi2( 1.68 );
 }
 double EvtVubNLO::subU( const std::vector<double>& c )
 {
     return -2 * subS( c );
 }
 double EvtVubNLO::subV( const std::vector<double>& c )
 {
     return -subT( c );
 }
 
 double EvtVubNLO::lambda_bar( double omega0 )
 {
     if ( _lbar < 0 ) {
         if ( _idSF == 1 ) {    // exponential SF
             double rat = omega0 * _b / lambda_SF();
             _lbar = lambda_SF() / _b *
                     ( Gamma( 1 + _b ) - Gamma( 1 + _b, rat ) ) /
                     ( Gamma( _b ) - Gamma( _b, rat ) );
         } else if ( _idSF == 2 ) {    // Gaussian SF
             double c = cGaus( _b );
             _lbar = lambda_SF() *
                     ( Gamma( 1 + _b / 2 ) -
                       Gamma( 1 + _b / 2, pow( omega0 / lambda_SF(), 2 ) * c ) ) /
                     ( Gamma( ( 1 + _b ) / 2 ) -
                       Gamma( ( 1 + _b ) / 2,
                              pow( omega0 / lambda_SF(), 2 ) * c ) ) /
                     sqrt( c );
         }
     }
     return _lbar;
 }
 
 double EvtVubNLO::mu_pi2( double omega0 )
 {
     if ( _mupi2 < 0 ) {
         if ( _idSF == 1 ) {    // exponential SF
             double rat = omega0 * _b / lambda_SF();
             _mupi2 = 3 * ( pow( lambda_SF() / _b, 2 ) *
                                ( Gamma( 2 + _b ) - Gamma( 2 + _b, rat ) ) /
                                ( Gamma( _b ) - Gamma( _b, rat ) ) -
                            pow( lambda_bar( omega0 ), 2 ) );
         } else if ( _idSF == 2 ) {    // Gaussian SF
             double c = cGaus( _b );
             double m1 = Gamma( ( 3 + _b ) / 2 ) -
                         Gamma( ( 3 + _b ) / 2,
                                pow( omega0 / lambda_SF(), 2 ) * c );
             double m2 = Gamma( 1 + _b / 2 ) -
                         Gamma( 1 + _b / 2, pow( omega0 / lambda_SF(), 2 ) * c );
             double m3 = Gamma( ( 1 + _b ) / 2 ) -
                         Gamma( ( 1 + _b ) / 2,
                                pow( omega0 / lambda_SF(), 2 ) * c );
             _mupi2 = 3 * pow( lambda_SF(), 2 ) *
                      ( m1 / m3 - pow( m2 / m3, 2 ) ) / c;
         }
     }
     return _mupi2;
 }
 
 double EvtVubNLO::M0( double mui, double omega0 )
 {
     double mf = omega0 - lambda_bar( omega0 );
     return 1 + 4 * C_F( mui ) *
                    ( -pow( log( mf / mui ), 2 ) - log( mf / mui ) -
                      pow( EvtConst::pi / 2, 2 ) / 6. +
                      mu_pi2( omega0 ) / 3 / pow( mf, 2 ) *
                          ( log( mf / mui ) - 0.5 ) );
 }
 
 double EvtVubNLO::alphas( double mu )
 {
     double Lambda4 = 0.302932;
     double lg = 2 * log( mu / Lambda4 );
     return 4 * EvtConst::pi / lg / beta0() *
            ( 1 - beta1() * log( lg ) / pow( beta0(), 2 ) / lg +
              pow( beta1() / lg, 2 ) / pow( beta0(), 4 ) *
                  ( pow( log( lg ) - 0.5, 2 ) - 1.25 +
                    beta2() * beta0() / pow( beta1(), 2 ) ) );
 }
 
 double EvtVubNLO::gausShapeFunction( double omega,
                                      const std::vector<double>& sCoeffs )
 {
     double b = sCoeffs[3];
     double l = sCoeffs[7];
     double wL = omega / l;
 
     return pow( wL, b ) * exp( -cGaus( b ) * wL * wL );
 }
 
 double EvtVubNLO::expShapeFunction( double omega,
                                     const std::vector<double>& sCoeffs )
 {
     double b = sCoeffs[3];
     double l = sCoeffs[7];
     double wL = omega / l;
 
     return pow( wL, b - 1 ) * exp( -b * wL );
 }
 
 double EvtVubNLO::Gamma( double z )
 {
     std::array<double, 6> gammaCoeffs{
         76.18009172947146,  -86.50532032941677,    24.01409824083091,
         -1.231739572450155, 0.1208650973866179e-2, -0.5395239384953e-5};
 
     //Lifted from Numerical Recipies in C
     double y = z;
     double x = z;
 
     double tmp = x + 5.5;
     tmp = tmp - ( x + 0.5 ) * log( tmp );
     double ser = 1.000000000190015;
 
     for ( const auto& gammaCoeff : gammaCoeffs ) {
         y += 1.0;
         ser += gammaCoeff / y;
     }
 
     return exp( -tmp + log( 2.5066282746310005 * ser / x ) );
 }
 
 double EvtVubNLO::Gamma( double z, double tmin )
 {
     std::vector<double> c( 1 );
     c[0] = z;
     auto func = EvtItgPtrFunction{&dgamma, tmin, 100., c};
     auto jetSF = EvtItgSimpsonIntegrator{func, 0.001};
     return jetSF.evaluate( tmin, 100. );
 }
diff --git a/src/EvtGenModels/EvtbTosllAli.cpp b/src/EvtGenModels/EvtbTosllAli.cpp
index 78d7a4a..04971af 100644
--- a/src/EvtGenModels/EvtbTosllAli.cpp
+++ b/src/EvtGenModels/EvtbTosllAli.cpp
@@ -1,105 +1,105 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtbTosllAli.hh"
 
 #include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtReport.hh"
 
 #include "EvtGenModels/EvtbTosllAliFF.hh"
 #include "EvtGenModels/EvtbTosllAmp.hh"
 #include "EvtGenModels/EvtbTosllScalarAmp.hh"
 #include "EvtGenModels/EvtbTosllVectorAmp.hh"
 
 #include <stdlib.h>
 #include <string>
 using std::endl;
 
 std::string EvtbTosllAli::getName()
 {
     return "BTOSLLALI";
 }
 
 EvtDecayBase* EvtbTosllAli::clone()
 {
     return new EvtbTosllAli;
 }
 
 void EvtbTosllAli::decay( EvtParticle* p )
 {
     setWeight( p->initializePhaseSpace( getNDaug(), getDaugs(), false,
                                         _poleSize, 1, 2 ) );
 
     _calcamp->CalcAmp( p, _amp2, _aliffmodel.get() );
 }
 
 void EvtbTosllAli::initProbMax()
 {
     EvtId parnum, mesnum, l1num, l2num;
 
     parnum = getParentId();
     mesnum = getDaug( 0 );
     l1num = getDaug( 1 );
     l2num = getDaug( 2 );
 
     //This routine sets the _poleSize.
     double mymaxprob = _calcamp->CalcMaxProb( parnum, mesnum, l1num, l2num,
                                               _aliffmodel.get(), _poleSize );
-
+    mymaxprob *= 1.25; // Increase to avoid maxprob errors
     setProbMax( mymaxprob );
 }
 
 void EvtbTosllAli::init()
 {
     checkNArg( 0 );
     checkNDaug( 3 );
 
     //We expect the parent to be a scalar
     //and the daughters to be X lepton+ lepton-
 
     checkSpinParent( EvtSpinType::SCALAR );
 
     EvtSpinType::spintype mesontype = EvtPDL::getSpinType( getDaug( 0 ) );
 
     if ( !( mesontype == EvtSpinType::VECTOR ||
             mesontype == EvtSpinType::SCALAR ) ) {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "EvtbTosllAli generator expected "
             << " a SCALAR or VECTOR 1st daughter, found:"
             << EvtPDL::name( getDaug( 0 ) ).c_str() << endl;
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "Will terminate execution!" << endl;
         ::abort();
     }
 
     checkSpinDaughter( 1, EvtSpinType::DIRAC );
     checkSpinDaughter( 2, EvtSpinType::DIRAC );
 
     _aliffmodel = std::make_unique<EvtbTosllAliFF>();
     if ( mesontype == EvtSpinType::SCALAR ) {
         _calcamp = std::make_unique<EvtbTosllScalarAmp>();
     }
     if ( mesontype == EvtSpinType::VECTOR ) {
         _calcamp = std::make_unique<EvtbTosllVectorAmp>();
     }
 }
diff --git a/src/EvtGenModels/EvtbsToLLLLAmp.cpp b/src/EvtGenModels/EvtbsToLLLLAmp.cpp
index 7a34a05..ad1412b 100644
--- a/src/EvtGenModels/EvtbsToLLLLAmp.cpp
+++ b/src/EvtGenModels/EvtbsToLLLLAmp.cpp
@@ -1,822 +1,822 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtbsToLLLLAmp.hh"
 
 #include "EvtGenBase/EvtAmp.hh"
 #include "EvtGenBase/EvtComplex.hh"
 #include "EvtGenBase/EvtDiracSpinor.hh"
 #include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtId.hh"
 #include "EvtGenBase/EvtIdSet.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtReport.hh"
 #include "EvtGenBase/EvtScalarParticle.hh"
 #include "EvtGenBase/EvtTensor4C.hh"
 #include "EvtGenBase/EvtVector4C.hh"
 
 #include "EvtGenModels/EvtbTosllWilsCoeffNLO.hh"
 #include "EvtGenModels/Evtbs2llGammaFFMNT.hh"
 
 #include <cstdlib>
 
 // input:   *parent      - the pointer to the parent particle (B-meson, the
 //                                          object of the EvtParticle class);
 //          *formFactors - the pointer to instance of EvtbTosllGammaFF class object;
 //          *WilsCoeff   - the pointer to the Standart Model Wilson Coefficients class;
 //           mu          - the scale parameter, GeV;
 //           Nf          - number of "effective" flavors (for b-quark Nf=5);
 //           res_swch    - resonant switching parameter:
 //                         = 0 the resonant contribution switched OFF,
 //                         = 1 the resonant contribution switched ON;
 //           ias         - switching parameter for \alpha_s(M_Z) value:
 //                         = 0 PDG 1sigma minimal alpha_s(M_Z),
 //                         = 1 PDG average value  alpha_s(M_Z),
 //                         = 2 PDG 1sigma maximal alpha_s(M_Z).
 //           Wolfenstein parameterization for CKM matrix
 //                         CKM_A, CKM_lambda, CKM_barrho, CKM_bareta
 
 void EvtbsToLLLLAmp::CalcAmp( EvtParticle* parent, EvtAmp& amp,
                               Evtbs2llGammaFF* formFactors,
                               EvtbTosllWilsCoeffNLO* WilsCoeff, double mu,
                               int Nf, int res_swch, int ias, double CKM_A,
                               double CKM_lambda, double CKM_barrho,
                               double CKM_bareta )
 {
     //  FILE *mytest;
 
     int il1 = 0, il2 = 1, il3 = 2,
         il4 = 3;    // leptons are the first, second, thirds
                     //                      and fourth daughter particles
 
     EvtComplex unit1( 1.0, 0.0 );    // real unit
     EvtComplex uniti( 0.0, 1.0 );    // imaginary unit
 
     double M1 = parent->mass();                    // B - meson mass, GeV
     double ml = parent->getDaug( il1 )->mass();    // leptonic mass, GeV
     double mq = 0.0;    // light quark mass from the dispersion QM, GeV
     double mc = formFactors->getQuarkMass(
         4 );    // m_c mass from the dispersion QM, GeV
     double mb = formFactors->getQuarkMass(
         5 );               // m_b mass from the dispersion QM, GeV
     double Mw = 80.403;    // GeV W-boson mass, GeV
     double mt = 174.2;     // GeV t-quark mass, GeV
     double fb = 0.0;       // leptonic decay constant of B-meson, Gev
 
     EvtComplex Vtb, Vtq, Vub, Vuq, Vcb,
         Vcq;                  // V_{tb}, V_{tq}, V_{ub}, V_{uq}, V_{cb}, V_{cq}
     EvtComplex CKM_factor;    // V^*_{tq}*V_{tb}, where q={d,s}
     EvtComplex lambda_qu;     // V^*_{uq}*V_{ub}/V^*_{tq}*V_{tb}, where q={d,s}
     EvtComplex lambda_qc;     // V^*_{cq}*V_{cb}/V^*_{tq}*V_{tb}, where q={d,s}
     double Relambda_qu, Imlambda_qu;
 
     //
     // Setting of the mq and CKM matrix elements for different Bq-mesons tipes
     //
     EvtId idparent = parent->getId();    // Bq-meson Id
     EvtId IdMu1, IdMu2, IdMu3, IdMu4;
 
     if ( idparent == EvtPDL::getId( std::string( "B_s0" ) ) ||
          idparent == EvtPDL::getId( std::string( "anti-B_s0" ) ) ) {
         mq = formFactors->getQuarkMass( 3 );    // m_s mass from the dispersion QM
         fb = 0.24;                              // leptonic decay constant
             // V_{ts}
         Vtq = unit1 * ( 1.0 - 0.5 * pow( CKM_lambda, 2.0 ) ) +
               pow( CKM_lambda, 2.0 ) *
                   ( CKM_barrho * unit1 + CKM_bareta * uniti ) /
                   sqrt( 1.0 - pow( CKM_lambda, 2.0 ) );
         Vtq = -CKM_A * pow( CKM_lambda, 2.0 ) * Vtq;
         // V_{us}
         Vuq = CKM_lambda * unit1;
         // V_{cs}
         Vcq = unit1 - 0.5 * pow( CKM_lambda, 2.0 ) -
               0.125 * pow( CKM_lambda, 4.0 ) * ( 1.0 + 4.0 * pow( CKM_A, 2.0 ) );
     }
 
     if ( idparent == EvtPDL::getId( std::string( "B0" ) ) ||
          idparent == EvtPDL::getId( std::string( "anti-B0" ) ) ) {
         mq = formFactors->getQuarkMass( 2 );    // m_d mass from the dispersion QM
         fb = 0.20;                              // leptonic decay constant
             // V_{td}
         Vtq = unit1 - ( 1.0 - 0.5 * pow( CKM_lambda, 2.0 ) ) *
                           ( CKM_barrho * unit1 + CKM_bareta * uniti ) /
                           sqrt( 1.0 - pow( CKM_lambda, 2.0 ) );
         Vtq = CKM_A * pow( CKM_lambda, 3.0 ) * Vtq;
         // V_{ud}
         Vuq = unit1 * ( 1.0 - 0.5 * pow( CKM_lambda, 2.0 ) -
                         0.125 * pow( CKM_lambda, 4.0 ) );
         // V_{cd}
         Vcq = unit1 *
               ( -CKM_lambda +
                 0.5 * pow( CKM_A, 2.0 ) * pow( CKM_lambda, 5.0 ) *
                     ( 1.0 - 2.0 * ( CKM_barrho * unit1 + CKM_bareta * uniti ) /
                                 sqrt( 1.0 - pow( CKM_lambda, 2.0 ) ) ) );
     }
 
     if ( mq < 0.001 ) {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "\n\n The function EvtbsToLLLLAmp::CalcAmp(...)"
             << "\n Error in the mq setting!"
             << "\n mq = " << mq << "< 0.001"
             << "\n idparent = " << idparent << std::endl;
         ::abort();
     }
 
     Vtb = unit1 * ( 1.0 - 0.5 * pow( CKM_A * CKM_lambda * CKM_lambda,
                                      2.0 ) );    // V_{tb}
     Vub = CKM_A * pow( CKM_lambda, 3.0 ) *
           ( CKM_barrho * unit1 - CKM_bareta * uniti ) /
           sqrt( 1.0 - pow( CKM_lambda, 2.0 ) );      // V_{ub}
     Vcb = unit1 * CKM_A * pow( CKM_lambda, 2.0 );    // V_{cb}
 
     CKM_factor = conj( Vtq ) * Vtb;    // V^*_{tq}*V_{tb}
 
     lambda_qu = conj( Vuq ) * Vub /
                 CKM_factor;    // V^*_{uq}*V_{ub}/V^*_{tq}*V_{tb}
     Relambda_qu = real( lambda_qu );
     Imlambda_qu = imag( lambda_qu );
 
     lambda_qc = conj( Vcq ) * Vcb /
                 CKM_factor;    // V^*_{cq}*V_{cb}/V^*_{tq}*V_{tb}
 
     //
     // Setting the leptonic kinematical properties
     //
 
     // to find charges of ell^+ and ell^- in the B-meson  daughters
     int charge1 = ( EvtPDL::chg3( parent->getDaug( il1 )->getId() ) ) / 3;
     int charge2 = ( EvtPDL::chg3( parent->getDaug( il2 )->getId() ) ) / 3;
     int charge3 = ( EvtPDL::chg3( parent->getDaug( il3 )->getId() ) ) / 3;
     int charge4 = ( EvtPDL::chg3( parent->getDaug( il4 )->getId() ) ) / 3;
     if ( ( abs( charge1 ) != 1 ) || ( abs( charge2 ) != 1 ) ||
          ( abs( charge3 ) != 1 ) || ( abs( charge4 ) != 1 ) ||
          ( charge1 + charge2 + charge3 + charge4 != 0 ) ) {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "\n\n The function EvtbsToLLLLAmp::CalcAmp(...)"
             << "\n Error in the leptonic charge definition!"
             << "\n charge1             =" << charge1
             << "\n charge2             =" << charge2
             << "\n charge3             =" << charge3
             << "\n charge4             =" << charge4
             << "\n number of daughters =" << parent->getNDaug() << std::endl;
         ::abort();
     }
 
     EvtParticle* lep1Plus = 0;
     EvtParticle* lep1Minus = 0;
     EvtParticle* lep2Plus = 0;
     EvtParticle* lep2Minus = 0;
 
     EvtVector4R p;    // B-meson momentum in the B-rest frame
     EvtVector4R q;    // first transition 4-momentum in the B-rest frame
     EvtVector4R k;    // second transition 4-momentum in the B-rest frame
 
     double q2;    // Mandelstam variable s=q^2
 
     // Nondimentional 4-momentums
     EvtVector4R hatp;
     EvtVector4R hatq;
     EvtVector4R hatk;
 
     EvtVector4R qsecond;    // first transition 4-momentum in the B-rest frame
     EvtVector4R ksecond;    // second transition 4-momentum in the B-rest frame
 
     double q2second;    // Mandelstam variable s=q^2
 
     // Nondimentional 4-momentums
     EvtVector4R hatpsecond;
     EvtVector4R hatqsecond;
     EvtVector4R hatksecond;
 
     EvtVector4R k_1;    // 4-momentum of ell^+ in the B-rest frame
     EvtVector4R k_2;    // 4-momentum of ell^- in the B-rest frame
     EvtVector4R k_3;    // 4-momentum of ell^+ in the B-rest frame
     EvtVector4R k_4;    // 4-momentum of ell^- in the B-rest frame
 
     k_1.set( 0.0, 0.0, 0.0, 0.0 );
     k_2.set( 0.0, 0.0, 0.0, 0.0 );
     k_3.set( 0.0, 0.0, 0.0, 0.0 );
     k_4.set( 0.0, 0.0, 0.0, 0.0 );
 
     if ( ( charge1 + charge2 == 0 ) && ( charge3 + charge4 == 0 ) ) {
         // positive charged lepton 1
         lep1Plus = ( charge1 > charge2 ) ? parent->getDaug( il1 )
                                          : parent->getDaug( il2 );
         // negative charged lepton 1
         lep1Minus = ( charge1 < charge2 ) ? parent->getDaug( il1 )
                                           : parent->getDaug( il2 );
         if ( charge1 > charge2 ) {
             k_1 = parent->getDaug( il1 )->getP4();
             k_2 = parent->getDaug( il2 )->getP4();
             IdMu1 = parent->getDaug( il1 )->getId();
             IdMu2 = parent->getDaug( il2 )->getId();
         } else {
             k_1 = parent->getDaug( il2 )->getP4();
             k_2 = parent->getDaug( il1 )->getP4();
             IdMu1 = parent->getDaug( il2 )->getId();
             IdMu2 = parent->getDaug( il1 )->getId();
         }
         // positive charged lepton 2
         lep2Plus = ( charge3 > charge4 ) ? parent->getDaug( il3 )
                                          : parent->getDaug( il4 );
         // negative charged lepton 2
         lep2Minus = ( charge3 < charge4 ) ? parent->getDaug( il3 )
                                           : parent->getDaug( il4 );
         if ( charge3 > charge4 ) {
             k_3 = parent->getDaug( il3 )->getP4();
             k_4 = parent->getDaug( il4 )->getP4();
             IdMu3 = parent->getDaug( il3 )->getId();
             IdMu4 = parent->getDaug( il4 )->getId();
         } else {
             k_3 = parent->getDaug( il4 )->getP4();
             k_4 = parent->getDaug( il3 )->getP4();
             IdMu3 = parent->getDaug( il4 )->getId();
             IdMu4 = parent->getDaug( il3 )->getId();
         }
     }
     if ( ( charge1 + charge3 == 0 ) && ( charge2 + charge4 == 0 ) ) {
         // positive charged lepton 1
         lep1Plus = ( charge1 > charge3 ) ? parent->getDaug( il1 )
                                          : parent->getDaug( il3 );
         // negative charged lepton 1
         lep1Minus = ( charge1 < charge3 ) ? parent->getDaug( il1 )
                                           : parent->getDaug( il3 );
         if ( charge1 > charge3 ) {
             k_1 = parent->getDaug( il1 )->getP4();
             k_2 = parent->getDaug( il3 )->getP4();
             IdMu1 = parent->getDaug( il1 )->getId();
             IdMu2 = parent->getDaug( il3 )->getId();
         } else {
             k_1 = parent->getDaug( il3 )->getP4();
             k_2 = parent->getDaug( il1 )->getP4();
             IdMu1 = parent->getDaug( il3 )->getId();
             IdMu2 = parent->getDaug( il1 )->getId();
         }
         // positive charged lepton 2
         lep2Plus = ( charge2 > charge4 ) ? parent->getDaug( il2 )
                                          : parent->getDaug( il4 );
         // negative charged lepton 2
         lep2Minus = ( charge2 < charge4 ) ? parent->getDaug( il2 )
                                           : parent->getDaug( il4 );
         if ( charge2 > charge4 ) {
             k_3 = parent->getDaug( il2 )->getP4();
             k_4 = parent->getDaug( il4 )->getP4();
             IdMu3 = parent->getDaug( il2 )->getId();
             IdMu4 = parent->getDaug( il4 )->getId();
         } else {
             k_3 = parent->getDaug( il4 )->getP4();
             k_4 = parent->getDaug( il2 )->getP4();
             IdMu3 = parent->getDaug( il4 )->getId();
             IdMu4 = parent->getDaug( il2 )->getId();
         }
     }
 
     p = parent->getP4Restframe();
     hatp = p / M1;
 
     //
     // The calculation of the FIRST part of the amplitude
     //
 
     q = k_1 + k_2;
     k = k_3 + k_4;
     q2 = q.mass2();    // Mandelstam variable s=q^2
     hatq = q / M1;
     hatk = k / M1;
 
     // The Wilson Coefficients preparation according to the paper
     // A.J.Buras, M.Munz, Phys.Rev.D52, p.189 (1995)
     double c1, c2;
     EvtComplex a1, c7gam, c9eff_b2q, c9eff_barb2barq, c10a;
 
     // Excluded of the J/psi and psi' resonant area
     if ( ( res_swch == 1 ) && ( q2 >= 9.199 ) && ( q2 <= 15.333 ) ) {
         c1 = 0.0;
         c2 = 0.0;
         a1 = unit1 * 0.0;
         c7gam = unit1 * 0.0;
         c9eff_b2q = unit1 * 0.0;
         c9eff_barb2barq = unit1 * 0.0;
         c10a = unit1 * 0.0;
     } else {
         c1 = WilsCoeff->C1( mu, Mw, Nf, ias );
         c2 = WilsCoeff->C2( mu, Mw, Nf, ias );
         a1 = unit1 * ( c1 + c2 / 3.0 );
         c7gam = WilsCoeff->GetC7Eff( mu, Mw, mt, Nf, ias );
         c9eff_b2q = WilsCoeff->GetC9Eff( 0, res_swch, ias, Nf, q2, mb, mq, mc, mu,
                                          mt, Mw, ml, Relambda_qu, Imlambda_qu );
         c9eff_barb2barq = WilsCoeff->GetC9Eff( 1, res_swch, ias, Nf, q2, mb, mq,
                                                mc, mu, mt, Mw, ml, Relambda_qu,
                                                Imlambda_qu );
         c10a = WilsCoeff->GetC10Eff( mt, Mw );
     }
 
     EvtComplex Fv,
         Fa;    // The change of the sign is included in the amplitudes definition!
     EvtComplex Ftv_b2q, Ftv_barb2barq;
     EvtComplex Fta_b2q, Fta_barb2barq;
 
     // Excluded of the J/psi and psi' resonant area
     if ( ( res_swch == 1 ) && ( q2 >= 9.199 ) && ( q2 <= 15.333 ) ) {
         fb = 0.0;
         Fa = unit1 * 0.0;
         Fv = unit1 * 0.0;
         Fta_b2q = unit1 * 0.0;
         Fta_barb2barq = unit1 * 0.0;
         Ftv_b2q = unit1 * 0.0;
         Ftv_barb2barq = unit1 * 0.0;
     } else {
         if ( fb < 0.01 ) {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << "\n\n The function EvtbsToLLLLAmp::CalcAmp(...)"
                 << "\n Leptonic decay constant fb is not uninitialized in this function!"
                 << " fb = " << fb << std::endl;
             ::abort();
         }
 
         // For \bar B^0_q -> l^+ l^- gamma
         formFactors->getPhotonFF( 0, fb, parent->getId(), q2, M1, mb, mq, c7gam,
                                   a1, lambda_qu, lambda_qc, Fv, Fa, Ftv_b2q,
                                   Fta_b2q );
 
         // For B^0_q -> l^+ l^- gamma
         formFactors->getPhotonFF( 1, fb, parent->getId(), q2, M1, mb, mq, c7gam,
                                   a1, lambda_qu, lambda_qc, Fv, Fa,
                                   Ftv_barb2barq, Fta_barb2barq );
     }
 
     // The functions for the hadronic matrix element calculation
     EvtComplex a_b2q, a_barb2barq, b_b2q, b_barb2barq, c_b2q, c_barb2barq;
     EvtComplex e_b2q, e_barb2barq, f_b2q, f_barb2barq, g_b2q, g_barb2barq;
 
     a_b2q = c9eff_b2q * Fv + 2.0 * c7gam * Ftv_b2q * mb * M1 / q2;
     a_barb2barq = c9eff_barb2barq * Fv +
                   2.0 * c7gam * Ftv_barb2barq * mb * M1 / q2;
 
     b_b2q = ( c9eff_b2q * Fa + 2.0 * c7gam * Fta_b2q * mb * M1 / q2 ) *
             ( hatp * hatk );
     b_barb2barq = ( c9eff_barb2barq * Fa +
                     2.0 * c7gam * Fta_barb2barq * mb * M1 / q2 ) *
                   ( hatp * hatk );
 
     c_b2q = c9eff_b2q * Fa + 2.0 * c7gam * Fta_b2q * mb * M1 / q2;
     c_barb2barq = c9eff_barb2barq * Fa +
                   2.0 * c7gam * Fta_barb2barq * mb * M1 / q2;
 
     e_b2q = c10a * Fv;
     e_barb2barq = e_b2q;
 
     f_b2q = c10a * Fa * ( hatp * hatk );
     f_barb2barq = f_b2q;
 
     g_b2q = c10a * Fa;
     g_barb2barq = g_b2q;
 
     //
     // The calculation of the SECOND part of the amplitude
     //
 
     qsecond = k_1 + k_4;
     ksecond = k_3 + k_2;
     q2second = qsecond.mass2();    // Mandelstam variable s=q^2
     hatqsecond = qsecond / M1;
     hatksecond = ksecond / M1;
 
     // Excluded of the J/psi and psi' resonant area
     if ( ( res_swch == 1 ) && ( q2second >= 9.199 ) && ( q2second <= 15.333 ) ) {
         c1 = 0.0;
         c2 = 0.0;
         a1 = unit1 * 0.0;
         c7gam = unit1 * 0.0;
         c9eff_b2q = unit1 * 0.0;
         c9eff_barb2barq = unit1 * 0.0;
         c10a = unit1 * 0.0;
     } else {
         c1 = WilsCoeff->C1( mu, Mw, Nf, ias );
         c2 = WilsCoeff->C2( mu, Mw, Nf, ias );
         a1 = unit1 * ( c1 + c2 / 3.0 );
         c7gam = WilsCoeff->GetC7Eff( mu, Mw, mt, Nf, ias );
         c9eff_b2q = WilsCoeff->GetC9Eff( 0, res_swch, ias, Nf, q2second, mb, mq,
                                          mc, mu, mt, Mw, ml, Relambda_qu,
                                          Imlambda_qu );
         c9eff_barb2barq = WilsCoeff->GetC9Eff( 1, res_swch, ias, Nf, q2second,
                                                mb, mq, mc, mu, mt, Mw, ml,
                                                Relambda_qu, Imlambda_qu );
         c10a = WilsCoeff->GetC10Eff( mt, Mw );
     }
 
     // Excluded of the J/psi and psi' resonant area
     if ( ( res_swch == 1 ) && ( q2second >= 9.199 ) && ( q2second <= 15.333 ) ) {
         fb = 0.0;
         Fa = unit1 * 0.0;
         Fv = unit1 * 0.0;
         Fta_b2q = unit1 * 0.0;
         Fta_barb2barq = unit1 * 0.0;
         Ftv_b2q = unit1 * 0.0;
         Ftv_barb2barq = unit1 * 0.0;
     } else {
         if ( fb < 0.01 ) {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << "\n\n The function EvtbsToLLLLAmp::CalcAmp(...)"
                 << "\n Leptonic decay constant fb is not uninitialized in this function!"
                 << " fb = " << fb << std::endl;
             ::abort();
         }
 
         // For \bar B^0_q -> l^+ l^- gamma
         formFactors->getPhotonFF( 0, fb, parent->getId(), q2second, M1, mb, mq,
                                   c7gam, a1, lambda_qu, lambda_qc, Fv, Fa,
                                   Ftv_b2q, Fta_b2q );
 
         // For B^0_q -> l^+ l^- gamma
         formFactors->getPhotonFF( 1, fb, parent->getId(), q2second, M1, mb, mq,
                                   c7gam, a1, lambda_qu, lambda_qc, Fv, Fa,
                                   Ftv_barb2barq, Fta_barb2barq );
     }
 
     // The functions for the hadronic matrix element calculation
     EvtComplex a_b2qsecond, a_barb2barqsecond, b_b2qsecond, b_barb2barqsecond,
         c_b2qsecond, c_barb2barqsecond;
     EvtComplex e_b2qsecond, e_barb2barqsecond, f_b2qsecond, f_barb2barqsecond,
         g_b2qsecond, g_barb2barqsecond;
 
     a_b2qsecond = c9eff_b2q * Fv + 2.0 * c7gam * Ftv_b2q * mb * M1 / q2second;
     a_barb2barqsecond = c9eff_barb2barq * Fv +
                         2.0 * c7gam * Ftv_barb2barq * mb * M1 / q2second;
 
     b_b2qsecond = ( c9eff_b2q * Fa + 2.0 * c7gam * Fta_b2q * mb * M1 / q2second ) *
                   ( hatpsecond * hatksecond );
     b_barb2barqsecond = ( c9eff_barb2barq * Fa +
                           2.0 * c7gam * Fta_barb2barq * mb * M1 / q2second ) *
                         ( hatpsecond * hatksecond );
 
     c_b2qsecond = c9eff_b2q * Fa + 2.0 * c7gam * Fta_b2q * mb * M1 / q2second;
     c_barb2barqsecond = c9eff_barb2barq * Fa +
                         2.0 * c7gam * Fta_barb2barq * mb * M1 / q2second;
 
     e_b2qsecond = c10a * Fv;
     e_barb2barqsecond = e_b2qsecond;
 
     f_b2qsecond = c10a * Fa * ( hatpsecond * hatksecond );
     f_barb2barqsecond = f_b2qsecond;
 
     g_b2qsecond = c10a * Fa;
     g_barb2barqsecond = g_b2qsecond;
 
     EvtTensor4C T1, T2;    // Tensor structures for
     EvtTensor4C T1second,
         T2second;    //                the hadronic matrix element calculation
 
     // B - and barB - mesons descriptors
     static EvtIdSet bmesons( "anti-B0", "anti-B_s0" );
     static EvtIdSet bbarmesons( "B0", "B_s0" );
 
     EvtId parentID = parent->getId();
 
     if ( bmesons.contains( parentID ) ) {
         // The amplitude for the decay barB -> gamma ell^+ ell^-  or
         // b \bar q -> gamma ell^+ ell^-
 
         T1 = a_b2q * unit1 * dual( EvtGenFunctions::directProd( hatq, hatk ) ) -
              b_b2q * uniti * EvtTensor4C::g() +
              c_b2q * uniti * EvtGenFunctions::directProd( hatk, hatq );
 
         T2 = e_b2q * unit1 * dual( EvtGenFunctions::directProd( hatp, hatk ) ) -
              f_b2q * uniti * EvtTensor4C::g() +
              g_b2q * uniti * EvtGenFunctions::directProd( hatk, hatq );
 
         T1second = a_b2qsecond * unit1 *
                        dual( EvtGenFunctions::directProd( hatqsecond,
                                                           hatksecond ) ) -
                    b_b2qsecond * uniti * EvtTensor4C::g() +
                    c_b2qsecond * uniti *
                        EvtGenFunctions::directProd( hatksecond, hatqsecond );
 
         T2second = e_b2qsecond * unit1 *
                        dual( EvtGenFunctions::directProd( hatpsecond,
                                                           hatksecond ) ) -
                    f_b2qsecond * uniti * EvtTensor4C::g() +
                    g_b2qsecond * uniti *
                        EvtGenFunctions::directProd( hatksecond, hatqsecond );
 
         int i1, i2, i3, i4;    // leptonic spin structures counters
         int leptonicspin[4];    // array for the saving of the leptonic spin configuration
 
         // Tables for correspondings
         // l^+(k_1) && lep1Plus  && k_1 && i1
         // l^-(k_2) && lep1Minus && k_2 && i2
         // l^+(k_3) && lep2Plus  && k_3 && i3
         // l^-(k_4) && lep2Minus && k_4 && i4
 
         for ( i2 = 0; i2 < 2; i2++ ) {
             leptonicspin[0] = i2;
             for ( i1 = 0; i1 < 2; i1++ ) {
                 leptonicspin[1] = i1;
                 for ( i4 = 0; i4 < 2; i4++ ) {
                     leptonicspin[2] = i4;
                     for ( i3 = 0; i3 < 2; i3++ ) {
                         leptonicspin[3] = i3;
                         EvtVector4C VL2L1, AL2L1, VL4L3;
                         EvtVector4C E1, E2;
                         EvtVector4C VL2L1second, AL2L1second, VL4L3second;
                         EvtVector4C E1second, E2second;
 
                         VL2L1 = EvtLeptonVCurrent( lep1Minus->spParent( i2 ),
                                                    lep1Plus->spParent( i1 ) );
                         AL2L1 = EvtLeptonACurrent( lep1Minus->spParent( i2 ),
                                                    lep1Plus->spParent( i1 ) );
                         VL4L3 = EvtLeptonVCurrent( lep2Minus->spParent( i4 ),
                                                    lep2Plus->spParent( i3 ) );
                         E1 = T1.cont2( VL4L3 );
                         E2 = T2.cont2( VL4L3 );
 
                         VL2L1second = EvtLeptonVCurrent(
                             lep2Minus->spParent( i2 ), lep1Plus->spParent( i1 ) );
                         AL2L1second = EvtLeptonACurrent(
                             lep2Minus->spParent( i2 ), lep1Plus->spParent( i1 ) );
                         VL4L3second = EvtLeptonVCurrent(
                             lep1Minus->spParent( i4 ), lep2Plus->spParent( i3 ) );
                         E1second = T1second.cont2( VL4L3second );
                         E2second = T2second.cont2( VL4L3second );
 
                         amp.vertex( leptonicspin,
                                     CKM_factor * ( VL2L1 * E1 + AL2L1 * E2 +
                                                    VL2L1second * E1second +
                                                    AL2L1second * E2second ) );
 
                         //            EvtGenReport(EVTGEN_ERROR,"EvtGen")
                         //             << "\n\n ============================================================================"
                         //             << "\n The matrix element (first + second) = "
                         //             <<     CKM_factor*(VL2L1*E1+AL2L1*E2+VL2L1second*E1second+AL2L1second*E2second)
                         //             << "\n The matrix element (only first) = "
                         //             <<     CKM_factor*(VL2L1*E1+AL2L1*E2)
                         //             << "============================================================================\n\n"
                         //             << std::endl;
                     }
                 }
             }
         }
 
         //    EvtGenReport(EVTGEN_ERROR,"EvtGen") << "\n The function EvtbsToLLLLAmp::CalcAmp(...) passed with arguments:"
         //      << "\n ============================================================================"
         //      << "\n Input parameters:"
         //      << "\n mu = " << mu
         //      << "\n Nf =" << Nf
         //      << "\n res_swch = " << res_swch
         //      << "\n ias = " << ias
         //      << "\n CKM_A = " << CKM_A
         //      << "\n CKM_lambda = " << CKM_lambda
         //      << "\n CKM_barrho = " << CKM_barrho
         //      << "\n CKM_bareta = " << CKM_bareta
         //      << "\n CKM_factor = " << CKM_factor
         //      << "\n ============================================================================"
         //      << "\n Kinematics:"
         //      << "\n k_1        = " << k_1
         //      << "\n m_ell_1  =" << parent->getDaug(il1)->mass()
         //      << "\n k_2        = " << k_2
         //      << "\n m_ell_2  =" << parent->getDaug(il2)->mass()
         //      << "\n k_3        = " << k_3
         //      << "\n m_ell_3  =" << parent->getDaug(il3)->mass()
         //      << "\n k_4        = " << k_4
         //      << "\n m_ell_4  =" << parent->getDaug(il4)->mass()
         //      << "\n p          = " << p
         //      << "\n q          = " << q
         //      << "\n k          = " << k
         //      << "\n ============================================================================"
         //      << "\n Form-factors"
         //      << "\n Fv            = " << Fv
         //      << "\n Fa            = " << Fa
         //      << "\n Ftv_b2q       = " << Ftv_b2q
         //      << "\n Fta_b2q       = " << Fta_b2q
         //      << "\n Ftv_barb2barq = " << Ftv_barb2barq
         //      << "\n Fta_barb2barq = " << Fta_barb2barq
         //      << "\n fb            = " << fb
         //      << "\n ============================================================================"
         //      << "\n Wilson Coefficients:"
         //      << "\n Re(c7gam)           = " << real(c7gam)
         //      << " Im(c7gam)           = " << imag(c7gam)
         //      << "\n Re(c9eff_b2q)       = " << real(c9eff_b2q)
         //      << " Im(c9eff_b2q)       = " << imag(c9eff_b2q)
         //      << "\n Re(c9eff_barb2barq) = " << real(c9eff_barb2barq)
         //      << " Im(c9eff_barb2barq) = " << imag(c9eff_barb2barq)
         //      << "\n Re(c10a)            = " << real(c10a)
         //      << " Im(c10a)            = " << imag(c10a)
         //      << "\n ============================================================================"
         //      << "\n Functions in the matrix element:"
         //      << "\n a_b2q  = " << a_b2q
         //      << "\n b_b2q  = " << b_b2q
         //      << "\n c_b2q  = " << c_b2q
         //      << "\n e_b2q  = " << e_b2q
         //      << "\n f_b2q  = " << f_b2q
         //      << "\n g_b2q  = " << g_b2q
         //      << "\n ============================================================================"
         //      << "\n Partical Properties:"
         //      << "\n IdB     = " << idparent  << " == " << EvtPDL::getId(std::string("anti-B_s0"))
         //      << "\n IdMu1   = " << IdMu1           << " == " << EvtPDL::getId(std::string("mu+"))
         //      << "\n IdMu2   = " << IdMu2           << " == " << EvtPDL::getId(std::string("mu-"))
         //      << "\n IdMu3   = " << IdMu3           << " == " << EvtPDL::getId(std::string("mu+"))
         //      << "\n IdMu4   = " << IdMu4           << " == " << EvtPDL::getId(std::string("mu-"))
         //      << "\n\n\n\n"
         //      << std::endl;
 
     } else {
         if ( bbarmesons.contains( parentID ) ) {
             // The amplitude for the decay B -> gamma ell^+ ell^- or
             // q bar b -> gamma ell^+ ell^-
 
             T1 = -a_barb2barq * unit1 *
                      dual( EvtGenFunctions::directProd( hatq, hatk ) ) -
                  b_barb2barq * uniti * EvtTensor4C::g() +
                  c_barb2barq * uniti * EvtGenFunctions::directProd( hatk, hatq );
 
             T2 = -e_barb2barq * unit1 *
                      dual( EvtGenFunctions::directProd( hatq, hatk ) ) -
                  f_barb2barq * uniti * EvtTensor4C::g() +
                  g_barb2barq * uniti * EvtGenFunctions::directProd( hatk, hatq );
 
             T1second = -a_barb2barqsecond * unit1 *
                            dual( EvtGenFunctions::directProd( hatqsecond,
                                                               hatksecond ) ) -
                        b_barb2barqsecond * uniti * EvtTensor4C::g() +
                        c_barb2barqsecond * uniti *
                            EvtGenFunctions::directProd( hatksecond, hatqsecond );
 
             T2second = -e_barb2barqsecond * unit1 *
                            dual( EvtGenFunctions::directProd( hatpsecond,
                                                               hatksecond ) ) -
                        f_barb2barqsecond * uniti * EvtTensor4C::g() +
                        g_barb2barqsecond * uniti *
                            EvtGenFunctions::directProd( hatksecond, hatqsecond );
 
             int i1, i2, i3, i4;    // leptonic spin structures counters
             int leptonicspin[4];    // array for the saving of the leptonic spin configuration
 
             // Tables for correspondings
             // l^+(k_1) && lep1Plus  && k_1 && i1
             // l^-(k_2) && lep1Minus && k_2 && i2
             // l^+(k_3) && lep2Plus  && k_3 && i3
             // l^-(k_4) && lep2Minus && k_4 && i4
 
-            for ( i2 = 1; i2 < 0; i2-- ) {
+            for ( i2 = 1; i2 > -1; i2-- ) {
                 leptonicspin[0] = i2;
-                for ( i1 = 1; i1 < 0; i1-- ) {
+                for ( i1 = 1; i1 > -1; i1-- ) {
                     leptonicspin[1] = i1;
-                    for ( i4 = 1; i4 < 0; i4-- ) {
+                    for ( i4 = 1; i4 > -1; i4-- ) {
                         leptonicspin[2] = i4;
-                        for ( i3 = 1; i3 < 0; i3-- ) {
+                        for ( i3 = 1; i3 > -1; i3-- ) {
                             leptonicspin[3] = i3;
                             EvtVector4C VL2L1, AL2L1, VL4L3;
                             EvtVector4C E1, E2;
                             EvtVector4C VL2L1second, AL2L1second, VL4L3second;
                             EvtVector4C E1second, E2second;
 
                             VL2L1 = EvtLeptonVCurrent( lep1Minus->spParent( i2 ),
                                                        lep1Plus->spParent( i1 ) );
                             AL2L1 = EvtLeptonACurrent( lep1Minus->spParent( i2 ),
                                                        lep1Plus->spParent( i1 ) );
                             VL4L3 = EvtLeptonVCurrent( lep2Minus->spParent( i4 ),
                                                        lep2Plus->spParent( i3 ) );
                             E1 = T1.cont2( VL4L3 );
                             E2 = T2.cont2( VL4L3 );
 
                             VL2L1second =
                                 EvtLeptonVCurrent( lep2Minus->spParent( i2 ),
                                                    lep1Plus->spParent( i1 ) );
                             AL2L1second =
                                 EvtLeptonACurrent( lep2Minus->spParent( i2 ),
                                                    lep1Plus->spParent( i1 ) );
                             VL4L3second =
                                 EvtLeptonVCurrent( lep1Minus->spParent( i4 ),
                                                    lep2Plus->spParent( i3 ) );
                             E1second = T1second.cont2( VL4L3second );
                             E2second = T2second.cont2( VL4L3second );
 
                             amp.vertex( leptonicspin,
                                         conj( CKM_factor ) *
                                             ( VL2L1 * E1 + AL2L1 * E2 +
                                               VL2L1second * E1second +
                                               AL2L1second * E2second ) );
                         }
                     }
                 }
             }
 
             //    EvtGenReport(EVTGEN_ERROR,"EvtGen") << "\n The function EvtbsToLLLLAmp::CalcAmp(...) passed with arguments:"
             //      << "\n ============================================================================"
             //      << "\n Input parameters:"
             //      << "\n mu = " << mu
             //      << "\n Nf =" << Nf
             //      << "\n res_swch = " << res_swch
             //      << "\n ias = " << ias
             //      << "\n CKM_A = " << CKM_A
             //      << "\n CKM_lambda = " << CKM_lambda
             //      << "\n CKM_barrho = " << CKM_barrho
             //      << "\n CKM_bareta = " << CKM_bareta
             //      << "\n CKM_factor = " << CKM_factor
             //      << "\n ============================================================================"
             //      << "\n Kinematics:"
             //      << "\n k_1        = " << k_1
             //      << "\n m_ell_1  =" << parent->getDaug(il1)->mass()
             //      << "\n k_2        = " << k_2
             //      << "\n m_ell_2  =" << parent->getDaug(il2)->mass()
             //      << "\n k_3        = " << k_3
             //      << "\n m_ell_3  =" << parent->getDaug(il3)->mass()
             //      << "\n k_4        = " << k_4
             //      << "\n m_ell_4  =" << parent->getDaug(il4)->mass()
             //      << "\n p          = " << p
             //      << "\n q          = " << q
             //      << "\n k          = " << k
             //      << "\n ============================================================================"
             //      << "\n Form-factors"
             //      << "\n Fv            = " << Fv
             //      << "\n Fa            = " << Fa
             //      << "\n Ftv_b2q       = " << Ftv_b2q
             //      << "\n Fta_b2q       = " << Fta_b2q
             //      << "\n Ftv_barb2barq = " << Ftv_barb2barq
             //      << "\n Fta_barb2barq = " << Fta_barb2barq
             //      << "\n fb            = " << fb
             //      << "\n ============================================================================"
             //      << "\n Wilson Coefficients:"
             //      << "\n Re(c7gam)           = " << real(c7gam)
             //      << " Im(c7gam)           = " << imag(c7gam)
             //      << "\n Re(c9eff_b2q)       = " << real(c9eff_b2q)
             //      << " Im(c9eff_b2q)       = " << imag(c9eff_b2q)
             //      << "\n Re(c9eff_barb2barq) = " << real(c9eff_barb2barq)
             //      << " Im(c9eff_barb2barq) = " << imag(c9eff_barb2barq)
             //      << "\n Re(c10a)            = " << real(c10a)
             //      << " Im(c10a)            = " << imag(c10a)
             //      << "\n ============================================================================"
             //      << "\n Functions in the matrix element:"
             //      << "\n a_barb2barq  = " << a_barb2barq
             //      << "\n b_barb2barq  = " << b_barb2barq
             //      << "\n c_barb2barq  = " << c_barb2barq
             //      << "\n e_barb2barq  = " << e_barb2barq
             //      << "\n f_barb2barq  = " << f_barb2barq
             //      << "\n g_barb2barq  = " << g_barb2barq
             //      << "\n ============================================================================"
             //      << "\n Partical Properties:"
             //      << "\n IdB     = " << idparent       << " == " << EvtPDL::getId(std::string("B_s0"))
             //      << "\n IdMu1   = " << IdMu1           << " == " << EvtPDL::getId(std::string("mu+"))
             //      << "\n IdMu2   = " << IdMu2           << " == " << EvtPDL::getId(std::string("mu-"))
             //      << "\n IdMu3   = " << IdMu3           << " == " << EvtPDL::getId(std::string("mu+"))
             //      << "\n IdMu4   = " << IdMu4           << " == " << EvtPDL::getId(std::string("mu-"))
             //      << "\n\n\n\n"
             //      << std::endl;
         } else {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << "\n\n The function EvtbsToLLLLAmp::CalcAmp(...)"
                 << "\n Wrong Bq-meson number" << std::endl;
             ::abort();
         }
     }
 }
 
 //
 // The decays Bq ->  ell^+ ell^- ell^+ ell^- maximum probability calculation
 //
 double EvtbsToLLLLAmp::CalcMaxProb(
     //                                     EvtId parnum,
     //                                     EvtId l1num, EvtId l2num,
     //                                     EvtId l3num, EvtId l4num,
     //		                       Evtbs2llGammaFF *formFactors,
     //                                     EvtbTosllWilsCoeffNLO *WilsCoeff,
     //                                     double mu, int Nf,
     //                                     int res_swch, int ias,
     //                                     double CKM_A, double CKM_lambda,
     //                                     double CKM_barrho, double CKM_bareta
 )
 {
-    double maxfoundprob = 5.0;    // maximum of the probability
+    double maxfoundprob = 10.0;    // maximum of the probability
 
     return maxfoundprob;
 }
 
 // Triangular function
 double EvtbsToLLLLAmp::lambda( double a, double b, double c )
 {
     double l;
 
     l = pow( a, 2.0 ) + pow( b, 2.0 ) + pow( c, 2.0 ) - 2.0 * a * b -
         2.0 * a * c - 2.0 * b * c;
 
     return l;
 }
diff --git a/src/EvtGenModels/EvtbsToLLLLHyperCPAmp.cpp b/src/EvtGenModels/EvtbsToLLLLHyperCPAmp.cpp
index fce3cf7..40b090e 100644
--- a/src/EvtGenModels/EvtbsToLLLLHyperCPAmp.cpp
+++ b/src/EvtGenModels/EvtbsToLLLLHyperCPAmp.cpp
@@ -1,605 +1,605 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 #include "EvtGenModels/EvtbsToLLLLHyperCPAmp.hh"
 
 #include "EvtGenBase/EvtAmp.hh"
 #include "EvtGenBase/EvtComplex.hh"
 #include "EvtGenBase/EvtDiracSpinor.hh"
 #include "EvtGenBase/EvtGenKine.hh"
 #include "EvtGenBase/EvtId.hh"
 #include "EvtGenBase/EvtIdSet.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtPatches.hh"
 #include "EvtGenBase/EvtReport.hh"
 #include "EvtGenBase/EvtScalarParticle.hh"
 #include "EvtGenBase/EvtTensor4C.hh"
 #include "EvtGenBase/EvtVector4C.hh"
 
 #include <cstdlib>
 
 // input:   *parent      - the pointer to the parent particle (B-meson, the
 //                                               object of the EvtParticle class);
 //               mS      - the mass of the scalar sgoldstino "S" (GeV);
 //               mP      - the mass of the pseudoscalar sgoldstino "P" (GeV);
 //           gammaS      - the decay width of the scalar sgoldstino "S" (GeV);
 //           gammaP      - the decay width of the pseudoscalar sgoldstino "P" (GeV);
 //           mLiiLR      -
 //               Fc      - coupling constant (GeV^2);
 //        mDijLL(RR)     - parameters for \bar Bq-decays
 //        mDjiLL(RR)     - parameters for Bq-decays (i <-> j!)
 //                         d==1, s==2, b==3
 //
 void EvtbsToLLLLHyperCPAmp::CalcAmp( EvtParticle* parent, EvtAmp& amp,
                                      double mS, double mP, double gammaS,
                                      double gammaP, double mLiiLR, double Fc,
                                      double mD23LL, double mD23RR, double mD32LL,
                                      double mD32RR, double mD13LL, double mD13RR,
                                      double mD31LL, double mD31RR )
 {
     //  FILE *mytest;
 
     int il1 = 0, il2 = 1, il3 = 2,
         il4 = 3;    // leptons are the first, second, thirds
                     //                      and fourth daughter particles
 
     EvtComplex unit1( 1.0, 0.0 );    // real unit
     EvtComplex uniti( 0.0, 1.0 );    // imaginary unit
 
     parent->mass();     // B - meson mass, GeV
     double fb = 0.0;    // leptonic decay constant of B-meson, GeV
 
     double Cl = 0.0;    // LPL and LSL - vertexes
     if ( Fc != 0.0 ) {
         Cl = mLiiLR * mLiiLR / ( sqrt( 2 ) * Fc );
     }
     if ( Cl == 0.0 ) {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "\n\n The function EvtbsToLLLLHyperCPAmp::CalcAmp(...)"
             << "\n Error in the Cl setting!"
             << "\n     Cl = " << Cl << "\n mLiiLR = " << mLiiLR
             << "\n     Fc = " << Fc << std::endl;
         ::abort();
     }
 
     EvtComplex MS = unit1 * mS -
                     uniti * gammaS /
                         2.0;    // complex mass of the scalar sgoldstino
     EvtComplex MP = unit1 * mP -
                     uniti * gammaP /
                         2.0;    // complex mass of the pseudoscalar sgoldstino
 
     //
     // Setting of the different Bq-mesons tipes
     //
     EvtId idparent = parent->getId();    // Bq-meson Id
     EvtId IdMu1, IdMu2, IdMu3, IdMu4;
 
     double CB = 0.0;
 
     if ( idparent == EvtPDL::getId( std::string( "B_s0" ) ) ) {
         fb = 0.24;    // leptonic decay constant
         CB = mD32LL * mD32LL + mD32RR * mD32RR;
     }
 
     if ( idparent == EvtPDL::getId( std::string( "anti-B_s0" ) ) ) {
         fb = 0.24;    // leptonic decay constant
         CB = mD23LL * mD23LL + mD23RR * mD23RR;
     }
 
     if ( idparent == EvtPDL::getId( std::string( "B0" ) ) ) {
         fb = 0.20;    // leptonic decay constant
         CB = mD31LL * mD31LL + mD31RR * mD31RR;
     }
 
     if ( idparent == EvtPDL::getId( std::string( "anti-B0" ) ) ) {
         fb = 0.20;    // leptonic decay constant
         CB = mD13LL * mD13LL + mD13RR * mD13RR;
     }
 
     if ( CB == 0.0 ) {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "\n\n The function EvtbsToLLLLHyperCPAmp::CalcAmp(...)"
             << "\n Error in the CB setting!"
             << "\n       CB = " << CB << "\n   mD32LL = " << mD32LL
             << "\n   mD32RR = " << mD32RR << "\n   mD23LL = " << mD23LL
             << "\n   mD23RR = " << mD23RR << "\n   mD31LL = " << mD31LL
             << "\n   mD31RR = " << mD31RR << "\n   mD13LL = " << mD13LL
             << "\n   mD13RR = " << mD13RR << "\n idparent = " << idparent
             << std::endl;
         ::abort();
     }
 
     //
     // Setting the leptonic kinematical properties
     //
 
     // to find charges of ell^+ and ell^- in the B-meson  daughters
     int charge1 = ( EvtPDL::chg3( parent->getDaug( il1 )->getId() ) ) / 3;
     int charge2 = ( EvtPDL::chg3( parent->getDaug( il2 )->getId() ) ) / 3;
     int charge3 = ( EvtPDL::chg3( parent->getDaug( il3 )->getId() ) ) / 3;
     int charge4 = ( EvtPDL::chg3( parent->getDaug( il4 )->getId() ) ) / 3;
     if ( ( abs( charge1 ) != 1 ) || ( abs( charge2 ) != 1 ) ||
          ( abs( charge3 ) != 1 ) || ( abs( charge4 ) != 1 ) ||
          ( charge1 + charge2 + charge3 + charge4 != 0 ) ) {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "\n\n The function EvtbsToLLLLHyperCPAmp::CalcAmp(...)"
             << "\n Error in the leptonic charge definition!"
             << "\n charge1             =" << charge1
             << "\n charge2             =" << charge2
             << "\n charge3             =" << charge3
             << "\n charge4             =" << charge4
             << "\n number of daughters =" << parent->getNDaug() << std::endl;
         ::abort();
     }
 
     EvtParticle* lep1Plus = 0;
     EvtParticle* lep1Minus = 0;
     EvtParticle* lep2Plus = 0;
     EvtParticle* lep2Minus = 0;
 
     EvtVector4R p;    // B-meson momentum in the B-rest frame
 
     EvtVector4R q;    // first transition 4-momentum in the B-rest frame
     EvtVector4R k;    // second transition 4-momentum in the B-rest frame
     double q2;        // Mandelstam variable s=q^2
     double k2;        // Mandelstam variable t=k^2
 
     EvtVector4R qsecond;    // first transition 4-momentum in the B-rest frame
     EvtVector4R ksecond;    // second transition 4-momentum in the B-rest frame
     double q2second;        // Mandelstam variable s=q^2
     double k2second;        // Mandelstam variable t=k^2
 
     EvtVector4R k_1;    // 4-momentum of ell^+ in the B-rest frame
     EvtVector4R k_2;    // 4-momentum of ell^- in the B-rest frame
     EvtVector4R k_3;    // 4-momentum of ell^+ in the B-rest frame
     EvtVector4R k_4;    // 4-momentum of ell^- in the B-rest frame
 
     k_1.set( 0.0, 0.0, 0.0, 0.0 );
     k_2.set( 0.0, 0.0, 0.0, 0.0 );
     k_3.set( 0.0, 0.0, 0.0, 0.0 );
     k_4.set( 0.0, 0.0, 0.0, 0.0 );
 
     if ( ( charge1 + charge2 == 0 ) && ( charge3 + charge4 == 0 ) ) {
         // positive charged lepton 1
         lep1Plus = ( charge1 > charge2 ) ? parent->getDaug( il1 )
                                          : parent->getDaug( il2 );
         // negative charged lepton 1
         lep1Minus = ( charge1 < charge2 ) ? parent->getDaug( il1 )
                                           : parent->getDaug( il2 );
         if ( charge1 > charge2 ) {
             k_1 = parent->getDaug( il1 )->getP4();
             k_2 = parent->getDaug( il2 )->getP4();
             IdMu1 = parent->getDaug( il1 )->getId();
             IdMu2 = parent->getDaug( il2 )->getId();
         } else {
             k_1 = parent->getDaug( il2 )->getP4();
             k_2 = parent->getDaug( il1 )->getP4();
             IdMu1 = parent->getDaug( il2 )->getId();
             IdMu2 = parent->getDaug( il1 )->getId();
         }
         // positive charged lepton 2
         lep2Plus = ( charge3 > charge4 ) ? parent->getDaug( il3 )
                                          : parent->getDaug( il4 );
         // negative charged lepton 2
         lep2Minus = ( charge3 < charge4 ) ? parent->getDaug( il3 )
                                           : parent->getDaug( il4 );
         if ( charge3 > charge4 ) {
             k_3 = parent->getDaug( il3 )->getP4();
             k_4 = parent->getDaug( il4 )->getP4();
             IdMu3 = parent->getDaug( il3 )->getId();
             IdMu4 = parent->getDaug( il4 )->getId();
         } else {
             k_3 = parent->getDaug( il4 )->getP4();
             k_4 = parent->getDaug( il3 )->getP4();
             IdMu3 = parent->getDaug( il4 )->getId();
             IdMu4 = parent->getDaug( il3 )->getId();
         }
     }
     if ( ( charge1 + charge3 == 0 ) && ( charge2 + charge4 == 0 ) ) {
         // positive charged lepton 1
         lep1Plus = ( charge1 > charge3 ) ? parent->getDaug( il1 )
                                          : parent->getDaug( il3 );
         // negative charged lepton 1
         lep1Minus = ( charge1 < charge3 ) ? parent->getDaug( il1 )
                                           : parent->getDaug( il3 );
         if ( charge1 > charge3 ) {
             k_1 = parent->getDaug( il1 )->getP4();
             k_2 = parent->getDaug( il3 )->getP4();
             IdMu1 = parent->getDaug( il1 )->getId();
             IdMu2 = parent->getDaug( il3 )->getId();
         } else {
             k_1 = parent->getDaug( il3 )->getP4();
             k_2 = parent->getDaug( il1 )->getP4();
             IdMu1 = parent->getDaug( il3 )->getId();
             IdMu2 = parent->getDaug( il1 )->getId();
         }
         // positive charged lepton 2
         lep2Plus = ( charge2 > charge4 ) ? parent->getDaug( il2 )
                                          : parent->getDaug( il4 );
         // negative charged lepton 2
         lep2Minus = ( charge2 < charge4 ) ? parent->getDaug( il2 )
                                           : parent->getDaug( il4 );
         if ( charge2 > charge4 ) {
             k_3 = parent->getDaug( il2 )->getP4();
             k_4 = parent->getDaug( il4 )->getP4();
             IdMu3 = parent->getDaug( il2 )->getId();
             IdMu4 = parent->getDaug( il4 )->getId();
         } else {
             k_3 = parent->getDaug( il4 )->getP4();
             k_4 = parent->getDaug( il2 )->getP4();
             IdMu3 = parent->getDaug( il4 )->getId();
             IdMu4 = parent->getDaug( il2 )->getId();
         }
     }
 
     p = parent->getP4Restframe();
 
     //
     // The calculation of the FIRST part of the amplitude
     //
 
     q = k_1 + k_2;
     k = k_3 + k_4;
     q2 = q.mass2();    // Mandelstam variable s=q^2
     k2 = k.mass2();    // Mandelstam variable t=k^2
 
     //
     // The calculation of the SECOND part of the amplitude
     //
 
     qsecond = k_1 + k_4;
     ksecond = k_3 + k_2;
     q2second = qsecond.mass2();    // Mandelstam variable s=q^2
     k2second = ksecond.mass2();    // Mandelstam variable t=k^2
 
     // B - and barB - mesons descriptors
     static EvtIdSet bmesons( "anti-B0", "anti-B_s0" );
     static EvtIdSet bbarmesons( "B0", "B_s0" );
 
     EvtId parentID = parent->getId();
 
     if ( bmesons.contains( parentID ) ) {
         // The amplitude for the decay barB -> ell^+ ell^- ell^+ ell^-  or
         // b \bar q -> ell^+ ell^- ell^+ ell^-
 
         int i1, i2, i3, i4;    // leptonic spin structures counters
         int leptonicspin[4];    // array for the saving of the leptonic spin configuration
 
         // Tables for correspondings
         // l^+(k_1) && lep1Plus  && k_1 && i1
         // l^-(k_2) && lep1Minus && k_2 && i2
         // l^+(k_3) && lep2Plus  && k_3 && i3
         // l^-(k_4) && lep2Minus && k_4 && i4
 
         for ( i2 = 0; i2 < 2; i2++ ) {
             leptonicspin[0] = i2;
             for ( i1 = 0; i1 < 2; i1++ ) {
                 leptonicspin[1] = i1;
                 for ( i4 = 0; i4 < 2; i4++ ) {
                     leptonicspin[2] = i4;
                     for ( i3 = 0; i3 < 2; i3++ ) {
                         leptonicspin[3] = i3;
 
                         EvtComplex SL2L1, PL4L3;
                         EvtComplex SL2L1second, PL4L3second;
 
                         SL2L1 = EvtLeptonSCurrent( lep1Minus->spParent( i2 ),
                                                    lep1Plus->spParent( i1 ) );
                         PL4L3 = EvtLeptonPCurrent( lep2Minus->spParent( i4 ),
                                                    lep2Plus->spParent( i3 ) );
 
                         SL2L1second = EvtLeptonSCurrent(
                             lep2Minus->spParent( i2 ), lep1Plus->spParent( i1 ) );
                         PL4L3second = EvtLeptonPCurrent(
                             lep1Minus->spParent( i4 ), lep2Plus->spParent( i3 ) );
 
                         amp.vertex(
                             leptonicspin,
                             Cl * Cl * CB * fb *
                                 ( SL2L1 * PL4L3 * ( q2 - k2 ) /
                                       ( ( q2 - MS * MS ) * ( k2 - MP * MP ) ) -
                                   SL2L1second * PL4L3second *
                                       ( q2second - k2second ) /
                                       ( ( q2second - MS * MS ) *
                                         ( k2second - MP * MP ) ) ) /
                                 ( 4.0 * Fc * Fc ) );
                     }
                 }
             }
         }
 
         //    EvtGenReport(EVTGEN_ERROR,"EvtGen") << "\n The function EvtbsToLLLLHyperCPAmp::CalcAmp(...) passed with arguments:"
         //      << "\n ============================================================================"
         //      << "\n Input parameters:"
         //      << "\n     mS = " << mS
         //      << "\n     mP = " << mP
         //      << "\n gammaS = " << gammaS
         //      << "\n gammaP = " << gammaP
         //      << "\n mLiiLR = " << mLiiLR
         //      << "\n     Fc = " << Fc
         //      << "\n mD23LL = " << mD23LL
         //      << "\n mD23RR = " << mD23RR
         //      << "\n mD32LL = " << mD32LL
         //      << "\n mD32RR = " << mD32RR
         //      << "\n mD13LL = " << mD13LL
         //      << "\n mD13RR = " << mD13RR
         //      << "\n mD31LL = " << mD31LL
         //      << "\n mD31RR = " << mD31RR
         //      << "\n ============================================================================"
         //      << "\n Kinematics:"
         //      << "\n k_1        = " << k_1
         //      << "\n m_ell_1    =" << parent->getDaug(il1)->mass()
         //      << "\n k_2        = " << k_2
         //      << "\n m_ell_2    =" << parent->getDaug(il2)->mass()
         //      << "\n k_3        = " << k_3
         //      << "\n m_ell_3    =" << parent->getDaug(il3)->mass()
         //      << "\n k_4        = " << k_4
         //      << "\n m_ell_4    =" << parent->getDaug(il4)->mass()
         //      << "\n p          = " << p
         //      << "\n q          = " << q
         //      << "\n k          = " << k
         //      << "\n qsecond    = " << qsecond
         //      << "\n ksecond    = " << ksecond
         //      << "\n ============================================================================"
         //      << "\n Form-factors"
         //      << "\n fb         = " << fb
         //      << "\n ============================================================================"
         //      << "\n Coefficients:"
         //      << "\n Cl         = " << Cl
         //      << "\n CB         = " << CB
         //      << "\n ============================================================================"
         //      << "\n Partical Properties:"
         //      << "\n IdB     = " << idparent  << " == " << EvtPDL::getId(std::string("anti-B_s0"))
         //      << "\n IdMu1   = " << IdMu1           << " == " << EvtPDL::getId(std::string("mu+"))
         //      << "\n IdMu2   = " << IdMu2           << " == " << EvtPDL::getId(std::string("mu-"))
         //      << "\n IdMu3   = " << IdMu3           << " == " << EvtPDL::getId(std::string("mu+"))
         //      << "\n IdMu4   = " << IdMu4           << " == " << EvtPDL::getId(std::string("mu-"))
         //      << "\n\n\n\n"
         //      << std::endl;
 
     } else {
         if ( bbarmesons.contains( parentID ) ) {
             // The amplitude for the decay B -> ell^+ ell^- ell^+ ell^- or
             // q bar b -> ell^+ ell^- ell^+ ell^-
 
             int i1, i2, i3, i4;    // leptonic spin structures counters
             int leptonicspin[4];    // array for the saving of the leptonic spin configuration
 
             // Tables for correspondings
             // l^+(k_1) && lep1Plus  && k_1 && i1
             // l^-(k_2) && lep1Minus && k_2 && i2
             // l^+(k_3) && lep2Plus  && k_3 && i3
             // l^-(k_4) && lep2Minus && k_4 && i4
 
-            for ( i2 = 1; i2 < 0; i2-- ) {
+            for ( i2 = 1; i2 > -1; i2-- ) {
                 leptonicspin[0] = i2;
-                for ( i1 = 1; i1 < 0; i1-- ) {
+                for ( i1 = 1; i1 > -1; i1-- ) {
                     leptonicspin[1] = i1;
-                    for ( i4 = 1; i4 < 0; i4-- ) {
+                    for ( i4 = 1; i4 > -1; i4-- ) {
                         leptonicspin[2] = i4;
-                        for ( i3 = 1; i3 < 0; i3-- ) {
+                        for ( i3 = 1; i3 > -1; i3-- ) {
                             leptonicspin[3] = i3;
 
                             EvtComplex SL2L1, PL4L3;
                             EvtComplex SL2L1second, PL4L3second;
 
                             SL2L1 = EvtLeptonSCurrent( lep1Minus->spParent( i2 ),
                                                        lep1Plus->spParent( i1 ) );
                             PL4L3 = EvtLeptonPCurrent( lep2Minus->spParent( i4 ),
                                                        lep2Plus->spParent( i3 ) );
 
                             SL2L1second =
                                 EvtLeptonSCurrent( lep2Minus->spParent( i2 ),
                                                    lep1Plus->spParent( i1 ) );
                             PL4L3second =
                                 EvtLeptonPCurrent( lep1Minus->spParent( i4 ),
                                                    lep2Plus->spParent( i3 ) );
 
                             amp.vertex( leptonicspin,
                                         Cl * Cl * CB * fb *
                                             ( SL2L1 * PL4L3 * ( q2 - k2 ) /
                                                   ( ( q2 - MS * MS ) *
                                                     ( k2 - MP * MP ) ) -
                                               SL2L1second * PL4L3second *
                                                   ( q2second - k2second ) /
                                                   ( ( q2second - MS * MS ) *
                                                     ( k2second - MP * MP ) ) ) /
                                             ( 4.0 * Fc * Fc ) );
                         }
                     }
                 }
             }
 
             //    EvtGenReport(EVTGEN_ERROR,"EvtGen") << "\n The function EvtbsToLLLLHyperCPAmp::CalcAmp(...) passed with arguments:"
             //      << "\n ============================================================================"
             //      << "\n Input parameters:"
             //      << "\n     mS = " << mS
             //      << "\n     mP = " << mP
             //      << "\n gammaS = " << gammaS
             //      << "\n gammaP = " << gammaP
             //      << "\n mLiiLR = " << mLiiLR
             //      << "\n     Fc = " << Fc
             //      << "\n mD23LL = " << mD23LL
             //      << "\n mD23RR = " << mD23RR
             //      << "\n mD32LL = " << mD32LL
             //      << "\n mD32RR = " << mD32RR
             //      << "\n mD13LL = " << mD13LL
             //      << "\n mD13RR = " << mD13RR
             //      << "\n mD31LL = " << mD31LL
             //      << "\n mD31RR = " << mD31RR
             //      << "\n ============================================================================"
             //      << "\n Kinematics:"
             //      << "\n k_1        = " << k_1
             //      << "\n m_ell_1    =" << parent->getDaug(il1)->mass()
             //      << "\n k_2        = " << k_2
             //      << "\n m_ell_2    =" << parent->getDaug(il2)->mass()
             //      << "\n k_3        = " << k_3
             //      << "\n m_ell_3    =" << parent->getDaug(il3)->mass()
             //      << "\n k_4        = " << k_4
             //      << "\n m_ell_4    =" << parent->getDaug(il4)->mass()
             //      << "\n p          = " << p
             //      << "\n q          = " << q
             //      << "\n k          = " << k
             //      << "\n qsecond    = " << qsecond
             //      << "\n ksecond    = " << ksecond
             //      << "\n ============================================================================"
             //      << "\n Form-factors"
             //      << "\n fb         = " << fb
             //      << "\n ============================================================================"
             //      << "\n Coefficients:"
             //      << "\n Cl         = " << Cl
             //      << "\n CB         = " << CB
             //      << "\n ============================================================================"
             //      << "\n Partical Properties:"
             //      << "\n IdB     = " << idparent  << " == " << EvtPDL::getId(std::string("anti-B_s0"))
             //      << "\n IdMu1   = " << IdMu1           << " == " << EvtPDL::getId(std::string("mu+"))
             //      << "\n IdMu2   = " << IdMu2           << " == " << EvtPDL::getId(std::string("mu-"))
             //      << "\n IdMu3   = " << IdMu3           << " == " << EvtPDL::getId(std::string("mu+"))
             //      << "\n IdMu4   = " << IdMu4           << " == " << EvtPDL::getId(std::string("mu-"))
             //      << "\n\n\n\n"
             //      << std::endl;
 
         } else {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << "\n\n The function EvtbsToLLLLHyperCPAmp::CalcAmp(...)"
                 << "\n Wrong Bq-meson number" << std::endl;
             ::abort();
         }
     }
 }
 
 //
 // The decays Bq ->  ell^+ ell^- ell^+ ell^- maximum probability calculation
 //
 double EvtbsToLLLLHyperCPAmp::CalcMaxProb(
     EvtId parnum, EvtId l1num, EvtId /*l2num*/, EvtId /*l3num*/,
     EvtId /*l4num*/, double mS, double mP, double gammaS, double gammaP,
     double mLiiLR, double Fc, double mD23LL, double mD23RR, double mD32LL,
     double mD32RR, double mD13LL, double mD13RR, double mD31LL, double mD31RR )
 {
     if ( Fc == 0.0 ) {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "\n\n The function EvtbsToLLLLHyperCPAmp::CalcMaxProb"
             << "\n Error in the Fc setting!"
             << "\n       Fc = " << Fc << "\n   mD32LL = " << mD32LL
             << "\n   mD32RR = " << mD32RR << "\n   mD23LL = " << mD23LL
             << "\n   mD23RR = " << mD23RR << "\n   mD31LL = " << mD31LL
             << "\n   mD31RR = " << mD31RR << "\n   mD13LL = " << mD13LL
             << "\n   mD13RR = " << mD13RR << "\n   parnum = " << parnum
             << std::endl;
         ::abort();
     }
 
     double Cl = 0.0;    // LPL and LSL - vertexes
     if ( Fc != 0.0 ) {
         Cl = mLiiLR * mLiiLR / ( sqrt( 2 ) * Fc );
     }
     if ( Cl == 0.0 ) {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "\n\n The function EvtbsToLLLLHyperCPAmp::CalcMaxProb"
             << "\n Error in the Cl setting!"
             << "\n     Cl = " << Cl << "\n mLiiLR = " << mLiiLR
             << "\n     Fc = " << Fc << std::endl;
         ::abort();
     }
 
     //
     // Setting of the different Bq-mesons tipes
     //
 
     double fb = 0.0;
     double CB = 0.0;
 
     if ( parnum == EvtPDL::getId( std::string( "B_s0" ) ) ) {
         fb = 0.24;    // leptonic decay constant
         CB = mD32LL * mD32LL + mD32RR * mD32RR;
     }
 
     if ( parnum == EvtPDL::getId( std::string( "anti-B_s0" ) ) ) {
         fb = 0.24;    // leptonic decay constant
         CB = mD23LL * mD23LL + mD23RR * mD23RR;
     }
 
     if ( parnum == EvtPDL::getId( std::string( "B0" ) ) ) {
         fb = 0.20;    // leptonic decay constant
         CB = mD31LL * mD31LL + mD31RR * mD31RR;
     }
 
     if ( parnum == EvtPDL::getId( std::string( "anti-B0" ) ) ) {
         fb = 0.20;    // leptonic decay constant
         CB = mD13LL * mD13LL + mD13RR * mD13RR;
     }
 
     if ( CB == 0.0 ) {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "\n\n The function EvtbsToLLLLHyperCPAmp::CalcMaxProb"
             << "\n Error in the CB setting!"
             << "\n       CB = " << CB << "\n   mD32LL = " << mD32LL
             << "\n   mD32RR = " << mD32RR << "\n   mD23LL = " << mD23LL
             << "\n   mD23RR = " << mD23RR << "\n   mD31LL = " << mD31LL
             << "\n   mD31RR = " << mD31RR << "\n   mD13LL = " << mD13LL
             << "\n   mD13RR = " << mD13RR << "\n   parnum = " << parnum
             << std::endl;
         ::abort();
     }
 
     double M1 = EvtPDL::getMeanMass( parnum );    // B - meson mass
     EvtPDL::getMeanMass( l1num );                 // leptonic mass
 
     // We find the maximum amplitude probability
     double maxfoundprob = Cl * Cl * CB * fb *
                           fabs( mS * mS + mP * mP + M1 * M1 ) * 10000000.0 /
                           ( 4.0 * Fc * Fc * mS * gammaS * mP * gammaP );
 
     if ( maxfoundprob <= 0.0 ) {
         EvtGenReport( EVTGEN_ERROR, "EvtGen" )
             << "\n\n In the function EvtbsToLLLLHyperCPAmp::CalcMaxProb"
             << "\n maxfoundprob = " << maxfoundprob << " < 0 or =0!"
             << "\n           mS = " << mS << "\n           mP = " << mP
             << "\n       gammaS = " << gammaS << "\n       gammaP = " << gammaP
             << "\n       mLiiLR = " << mLiiLR << "\n           Fc = " << Fc
             << "\n       mD32LL = " << mD32LL << "\n       mD32RR = " << mD32RR
             << "\n       mD23LL = " << mD23LL << "\n       mD23RR = " << mD23RR
             << "\n       mD31LL = " << mD31LL << "\n       mD31RR = " << mD31RR
             << "\n       mD13LL = " << mD13LL << "\n       mD13RR = " << mD13RR
             << "\n       parnum = " << parnum << std::endl;
         ::abort();
     }
 
     EvtGenReport( EVTGEN_NOTICE, "EvtGen" )
         << "\n maxfoundprob (...) = " << maxfoundprob << std::endl;
 
     maxfoundprob *= 1.01;
 
     return maxfoundprob;
 }
 
 // Triangular function
 double EvtbsToLLLLHyperCPAmp::lambda( double a, double b, double c )
 {
     double l;
 
     l = pow( a, 2.0 ) + pow( b, 2.0 ) + pow( c, 2.0 ) - 2.0 * a * b -
         2.0 * a * c - 2.0 * b * c;
 
     return l;
 }
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 18ca882..0bc4183 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,55 +1,60 @@
 
 ########################################################################
 # Copyright 1998-2020 CERN for the benefit of the EvtGen authors       #
 #                                                                      #
 # This file is part of EvtGen.                                         #
 #                                                                      #
 # EvtGen is free software: you can redistribute it and/or modify       #
 # it under the terms of the GNU General Public License as published by #
 # the Free Software Foundation, either version 3 of the License, or    #
 # (at your option) any later version.                                  #
 #                                                                      #
 # EvtGen is distributed in the hope that it will be useful,            #
 # but WITHOUT ANY WARRANTY; without even the implied warranty of       #
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        #
 # GNU General Public License for more details.                         #
 #                                                                      #
 # You should have received a copy of the GNU General Public License    #
 # along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     #
 ########################################################################
 
 
 # the test executables require ROOT for histogramming etc.
 find_package(ROOT QUIET COMPONENTS Hist)
-if (ROOT_FOUND)
+find_package(nlohmann_json 3.6.1 QUIET)
+if (ROOT_FOUND AND nlohmann_json_FOUND)
     add_library(root_interface INTERFACE IMPORTED)
     target_include_directories(root_interface INTERFACE ${ROOT_INCLUDE_DIRS})
     target_link_libraries(root_interface INTERFACE ${ROOT_LIBRARIES})
 
     # build each of the executables
-    foreach( test_exe evt_dalitz evtgenlhc_test1 example1 exampleWriteHepMC )
+    foreach( test_exe evt_dalitz evtgenlhc_test1 example1 exampleWriteHepMC testDecayModel )
         add_executable(${test_exe} ${test_exe}.cc)
         target_link_libraries(${test_exe} PRIVATE EvtGen)
         if (EVTGEN_HEPMC3)
             target_compile_definitions(${test_exe} PRIVATE EVTGEN_HEPMC3)
         endif()
         if( EVTGEN_PYTHIA OR EVTGEN_PHOTOS OR EVTGEN_TAUOLA )
             target_compile_definitions(${test_exe} PRIVATE EVTGEN_EXTERNAL)
             target_link_libraries(${test_exe} PRIVATE EvtGenExternal)
         endif()
         target_link_libraries(${test_exe} PRIVATE root_interface)
     endforeach()
 
+    # testDecayModel needs nlohmann_json as well
+    target_link_libraries(testDecayModel PRIVATE nlohmann_json::nlohmann_json)
+
     # install the executables
-    install(TARGETS evt_dalitz evtgenlhc_test1 example1 exampleWriteHepMC
+    install(TARGETS evt_dalitz evtgenlhc_test1 example1 exampleWriteHepMC testDecayModel
         DESTINATION ${CMAKE_INSTALL_DATADIR}/EvtGen/test
         )
 
     # install the decay files, macros, scripts, etc.
     install(DIRECTORY exampleFiles DESTINATION ${CMAKE_INSTALL_DATADIR}/EvtGen/test)
-    install(FILES do_tests
+    install(DIRECTORY jsonFiles DESTINATION ${CMAKE_INSTALL_DATADIR}/EvtGen/test)
+    install(FILES do_tests runTests.py makeSrcDepsJson makeModelsJson
         DESTINATION ${CMAKE_INSTALL_DATADIR}/EvtGen/test
         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
 else()
-    message(WARNING "Could not find ROOT, cannot build test executables")
+    message(WARNING "Could not find ROOT and/or nlohmann_json, cannot build test executables")
 endif()
diff --git a/test/do_tests b/test/do_tests
index fcff10f..a817216 100755
--- a/test/do_tests
+++ b/test/do_tests
@@ -1,101 +1,100 @@
 #!/bin/bash
 
 ########################################################################
 # Copyright 1998-2020 CERN for the benefit of the EvtGen authors       #
 #                                                                      #
 # This file is part of EvtGen.                                         #
 #                                                                      #
 # EvtGen is free software: you can redistribute it and/or modify       #
 # it under the terms of the GNU General Public License as published by #
 # the Free Software Foundation, either version 3 of the License, or    #
 # (at your option) any later version.                                  #
 #                                                                      #
 # EvtGen is distributed in the hope that it will be useful,            #
 # but WITHOUT ANY WARRANTY; without even the implied warranty of       #
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        #
 # GNU General Public License for more details.                         #
 #                                                                      #
 # You should have received a copy of the GNU General Public License    #
 # along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     #
 ########################################################################
 
 time ./evtgenlhc_test1 file 1000 exampleFiles/GENERIC.DEC  
 time ./evtgenlhc_test1 print 100 exampleFiles/GENERIC.DEC  
 time ./evtgenlhc_test1 filevpho 1000 exampleFiles/GENERIC.DEC
 time ./evtgenlhc_test1 test1 1000
 time ./evtgenlhc_test1 chi1kstar 1000
 time ./evtgenlhc_test1 test2 1000
 time ./evtgenlhc_test1 omega 1000
 time ./evtgenlhc_test1 alias
 time ./evtgenlhc_test1 photos 1000
 time ./evtgenlhc_test1 trackmult 1000
 time ./evtgenlhc_test1 generic 1000
 time ./evtgenlhc_test1 generic 1000 exampleFiles/generic.list
 time ./evtgenlhc_test1 generic 1000 exampleFiles/genericlong.list
 time ./evtgenlhc_test1 finalstates 1000
 time ./evtgenlhc_test1 kstarnunu 1000
 time ./evtgenlhc_test1 bsmix 10000
 time ./evtgenlhc_test1 BtoXsgamma 1000
 time ./evtgenlhc_test1 BtoK1273gamma 1000
 time ./evtgenlhc_test1 pi0dalitz 1000 
 time ./evtgenlhc_test1 ddalitz 1000
 time ./evtgenlhc_test1 kstarll 1000
 time ./evtgenlhc_test1 kll 1000
 time ./evtgenlhc_test1 hll 1000 pimm
 time ./evtgenlhc_test1 hll 1000 piee
 time ./evtgenlhc_test1 hll 1000 pi0mm
 time ./evtgenlhc_test1 hll 1000 pi0ee
 time ./evtgenlhc_test1 vectorisr 10000
 time ./evtgenlhc_test1 bsquark 1000
 time ./evtgenlhc_test1 k3gamma 1000
 time ./evtgenlhc_test1 lambda 1000
 time ./evtgenlhc_test1 tautaupipi 1000
 time ./evtgenlhc_test1 tautauee 1000
 time ./evtgenlhc_test1 tautau2pi2pi 1000
 time ./evtgenlhc_test1 tautau3pi3pi 1000
 time ./evtgenlhc_test1 jpsikstar 1000 0
 time ./evtgenlhc_test1 jpsikstar 1000 1
 time ./evtgenlhc_test1 jpsikstar 1000 2
 time ./evtgenlhc_test1 jpsikstar 1000 3
 time ./evtgenlhc_test1 jpsikstar 1000 4
 time ./evtgenlhc_test1 svvcplh 1000
 time ./evtgenlhc_test1 svscplh 1000
 time ./evtgenlhc_test1 ssdcp 10000
 time ./evtgenlhc_test1 kstarstargamma 1000
 time ./evtgenlhc_test1 dstarpi 10000
 time ./evtgenlhc_test1 etacphiphi 10000
 time ./evtgenlhc_test1 vvpipi 1000
 time ./evtgenlhc_test1 svvhelamp 1000
 time ./evtgenlhc_test1 partwave 1000
 time ./evtgenlhc_test1 twobody 1000 exampleFiles/TWOBODY1.DEC twobody1.root
 time ./evtgenlhc_test1 twobody 1000 exampleFiles/TWOBODY2.DEC twobody2.root
 time ./evtgenlhc_test1 twobody 1000 exampleFiles/TWOBODY3.DEC twobody3.root
 time ./evtgenlhc_test1 pipipi 1000
 time ./evtgenlhc_test1 bhadronic 1000
 time ./evtgenlhc_test1 singleb 1000
 time ./evtgenlhc_test1 pipi 1000
 time ./evtgenlhc_test1 pipipipi 1000
 time ./evtgenlhc_test1 a2pi 1000 
 time ./evtgenlhc_test1 helamp 1000 exampleFiles/HELAMP1_D2STGAMMA.DEC helamp1_D2stgamma.root
 time ./evtgenlhc_test1 helamp2 1000
 time ./evtgenlhc_test1 lambda 1000
 time ./evtgenlhc_test1 d2pi 1000
 time ./evtgenlhc_test1 a1pi 1000
 time ./evtgenlhc_test1 cptest 1000 
 time ./evtgenlhc_test1 pipicpt 1000
 time ./evtgenlhc_test1 jpsiks 1000
 time ./evtgenlhc_test1 dump 10
 time ./evtgenlhc_test1 genericcont 1000
 time ./evtgenlhc_test1 d1 1000
 time ./evtgenlhc_test1 mix 1000
 time ./evtgenlhc_test1 bmix 10000 exampleFiles/BMIX_1.DEC bmix1.root
 time ./evtgenlhc_test1 bmix 10000 exampleFiles/BMIX_2.DEC bmix2.root
 time ./evtgenlhc_test1 semic 10000
 time ./evtgenlhc_test1 ddk 10000
 time ./evtgenlhc_test1 checkmass 10000 511
 time ./evtgenlhc_test1 jpsipolarization 10000
 time ./evtgenlhc_test1 checkrotboost
 time ./evtgenlhc_test1 baryonic 1000
 time ./evtgenlhc_test1 phspdecaytimecut 10000
 time ./evtgenlhc_test1 3bodyPhsp 1000000
-time ./evtgenlhc_test1 flatSqDalitz 1000000
diff --git a/test/evtgenlhc_test1.cc b/test/evtgenlhc_test1.cc
index 1406497..279d92f 100644
--- a/test/evtgenlhc_test1.cc
+++ b/test/evtgenlhc_test1.cc
@@ -1,5951 +1,5885 @@
 
 /***********************************************************************
 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
 *                                                                      *
 * This file is part of EvtGen.                                         *
 *                                                                      *
 * EvtGen is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * EvtGen is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
 ***********************************************************************/
 
 //#@# Dalitz plot for D0 --> K- pi+ pi0 decay:
 //#@# 1: Mass(K-, pi+)
 //#@# 2: Mass(pi+,pi0)
 //
 //  Description:
 //
 //     This program invokes the EvtGen event generator package
 //     for testing various decay models that are implemented.
 
 #include "EvtGen/EvtGen.hh"
 
 #include "EvtGenBase/EvtAbsRadCorr.hh"
 #include "EvtGenBase/EvtComplex.hh"
 #include "EvtGenBase/EvtConst.hh"
 #include "EvtGenBase/EvtDecayBase.hh"
 #include "EvtGenBase/EvtDecayTable.hh"
 #include "EvtGenBase/EvtDiracSpinor.hh"
 #include "EvtGenBase/EvtGammaMatrix.hh"
 #include "EvtGenBase/EvtIdSet.hh"
 #include "EvtGenBase/EvtKine.hh"
 #include "EvtGenBase/EvtMTRandomEngine.hh"
 #include "EvtGenBase/EvtPDL.hh"
 #include "EvtGenBase/EvtParser.hh"
 #include "EvtGenBase/EvtParticle.hh"
 #include "EvtGenBase/EvtParticleFactory.hh"
 #include "EvtGenBase/EvtRadCorr.hh"
 #include "EvtGenBase/EvtRandom.hh"
 #include "EvtGenBase/EvtRandomEngine.hh"
 #include "EvtGenBase/EvtReport.hh"
 #include "EvtGenBase/EvtSecondary.hh"
 #include "EvtGenBase/EvtSimpleRandomEngine.hh"
 #include "EvtGenBase/EvtStdHep.hh"
 #include "EvtGenBase/EvtTensor4C.hh"
 #include "EvtGenBase/EvtVector4C.hh"
 #include "EvtGenBase/EvtVector4R.hh"
 #include "EvtGenBase/EvtVectorParticle.hh"
 
 #ifdef EVTGEN_EXTERNAL
 #include "EvtGenExternal/EvtExternalGenList.hh"
 #endif
 
 #include "TApplication.h"
 #include "TFile.h"
 #include "TH1.h"
 #include "TH2.h"
 #include "TROOT.h"
-#include "TTree.h"
 #include "TString.h"
+#include "TTree.h"
 
 #include <cmath>
 #include <cstdio>
 #include <cstdlib>
 #include <fstream>
 #include <sstream>
 #include <string>
 #include <vector>
 
 using std::vector;
 
 void runFile( int nevent, char* fname, EvtGen& myGenerator );
 void runPrint( int nevent, char* fname, EvtGen& myGenerator );
 void runFileVpho( int nevent, char* fname, EvtGen& myGenerator );
 void runTest1( int nevent, EvtGen& myGenerator );
 void runTest2( int nevent, EvtGen& myGenerator );
 void runOmega( int nevent, EvtGen& myGenerator );
 void runChi1Kstar( int nevent, EvtGen& myGenerator );
 void runPi0Dalitz( int nevent, EvtGen& myGenerator );
 void runMix( int nevent, EvtGen& myGenerator );
 void runBMix( int nevent, EvtGen& myGenerator, std::string userFile,
               std::string rootFile );
 void runDDalitz( int nevent, EvtGen& myGenerator );
 void runPiPiCPT( int nevent, EvtGen& myGenerator );
 void runPiPiPiPi( int nevent, EvtGen& myGenerator );
 void runD2Pi( int nevent, EvtGen& myGenerator );
 void runJetsetTab3( int nevent, EvtGen& myGenerator );
 void runHelAmp( int nevent, EvtGen& myGenerator, std::string userFile,
                 std::string rootFile );
 void runHelAmp2( int nevent, EvtGen& myGenerator );
 void runJpsiKs( int nevent, EvtGen& myGenerator );
 void runDump( int nevent, EvtGen& myGenerator );
 void runD1( int nevent, EvtGen& myGenerator );
 void runGenericCont( int nevent, EvtGen& myGenerator );
 void runPiPiPi( int nevent, EvtGen& myGenerator );
 void runBHadronic( int nevent, EvtGen& myGenerator );
 void runSingleB( int nevent, EvtGen& myGenerator );
 void runA2Pi( int nevent, EvtGen& myGenerator );
 void runAlias();
 void runRepeat( int nevent );
 void runPhotos( int nevent, EvtGen& myGenerator );
 void runTrackMult( int nevent, EvtGen& myGenerator );
 void runGeneric( int neventOrig, EvtGen& myGenerator, std::string listfile );
 void runFinalStates( int nevent, EvtGen& myGenerator );
 std::vector<std::string> findFinalState( EvtParticle* p );
 void runKstarnunu( int nevent, EvtGen& myGenerator );
 void runBsmix( int nevent, EvtGen& myGenerator );
 void runTauTauPiPi( int nevent, EvtGen& myGenerator );
 void runTauTauEE( int nevent, EvtGen& myGenerator );
 void runTauTau2Pi2Pi( int nevent, EvtGen& myGenerator );
 void runTauTau3Pi3Pi( int nevent, EvtGen& myGenerator );
 void runJPsiKstar( int nevent, EvtGen& myGenerator, int modeInt );
 void runSVVCPLH( int nevent, EvtGen& myGenerator );
 void runSVSCPLH( int nevent, EvtGen& myGenerator );
 void runSSDCP( int nevent, EvtGen& myGenerator );
 void runKstarstargamma( int nevent, EvtGen& myGenerator );
 void runDSTARPI( int nevent, EvtGen& myGenerator );
 void runETACPHIPHI( int nevent, EvtGen& myGenerator );
 void runVVPiPi( int nevent, EvtGen& myGenerator );
 void runSVVHelAmp( int nevent, EvtGen& myGenerator );
 void runSVVHelAmp2( int nevent, EvtGen& myGenerator );
 void runPartWave( int nevent, EvtGen& myGenerator );
 void runPartWave2( int nevent, EvtGen& myGenerator );
 void runTwoBody( int nevent, EvtGen& myGenerator, std::string decfile,
                  std::string rootFile );
 void runPiPi( int nevent, EvtGen& myGenerator );
 void runA1Pi( int nevent, EvtGen& myGenerator );
 void runCPTest( int nevent, EvtGen& myGenerator );
 void runSemic( int nevent, EvtGen& myGenerator );
 void runKstarll( int nevent, EvtGen& myGenerator );
 void runKll( int nevent, EvtGen& myGenerator );
 void runHll( int nevent, EvtGen& myGenerator, char* mode );
 void runVectorIsr( int nevent, EvtGen& myGenerator );
 void runBsquark( int nevent, EvtGen& myGenerator );
 void runK3gamma( int nevent, EvtGen& myGenerator );
 void runLambda( int nevent, EvtGen& myGenerator );
 void runBtoXsgamma( int nevent, EvtGen& myGenerator );
 void runBtoK1273gamma( int nevent, EvtGen& myGenerator );
 void runCheckRotBoost();
 void runMassCheck( int nevent, EvtGen& myGenerator, int partnum );
 void runJpsiPolarization( int nevent, EvtGen& myGenerator );
 void runDDK( int nevent, EvtGen& myGenerator );
 void runPhspDecaytimeCut( int nevent, EvtGen& myGenerator );
 
 int countInclusive( std::string name, EvtParticle* root, TH1F* mom = 0,
                     TH1F* mass = 0 );
 int countInclusiveParent( std::string name, EvtParticle* root, EvtIdSet setIds,
                           TH1F* mom = 0 );
 int countInclusiveSubTree( std::string name, EvtParticle* root, EvtIdSet setIds,
                            TH1F* mom = 0 );
 void runBaryonic( int nEvent, EvtGen& myGenerator );
 void run3BPhspRegion( int nEvent, EvtGen& myGenerator );
-void runFlatSqDalitz( int nEvent, EvtGen& myGenerator );
 void runFourBody( int nevent, EvtGen& myGenerator );
 
 int main( int argc, char* argv[] )
 {
     // Define the random number generator
     EvtRandomEngine* myRandomEngine = 0;
 
 #ifdef EVTGEN_CPP11
     // Use the Mersenne-Twister generator (C++11 only)
     myRandomEngine = new EvtMTRandomEngine();
 #else
     myRandomEngine = new EvtSimpleRandomEngine();
 #endif
 
     if ( !TROOT::Initialized() ) {
         static TROOT root( "RooTuple", "RooTuple ROOT in EvtGen" );
     }
     if ( argc == 1 ) {
         EvtVector4R p( 0.0, 1.0, 0.0, 0.0 );
         EvtVector4R k( 0.0, 0.0, 1.0, 0.0 );
 
         EvtTensor4C T = dual( EvtGenFunctions::directProd( p, k ) );
 
         EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "p:" << p << std::endl;
         EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "k:" << k << std::endl;
         EvtGenReport( EVTGEN_INFO, "EvtGen" )
             << "T=dual(directProd(p,k)):" << T << std::endl;
         EvtGenReport( EVTGEN_INFO, "EvtGen" )
             << "T03:" << T.get( 0, 3 ) << std::endl;
         return 1;
     }
 
     EvtAbsRadCorr* radCorrEngine = 0;
     std::list<EvtDecayBase*> extraModels;
 
 #ifdef EVTGEN_EXTERNAL
     bool convertPythiaCodes( false );
     bool useEvtGenRandom( true );
     EvtExternalGenList genList( convertPythiaCodes, "", "gamma", useEvtGenRandom );
     radCorrEngine = genList.getPhotosModel();
     extraModels = genList.getListOfModels();
 #endif
 
     EvtGen myGenerator( "../DECAY.DEC", "../evt.pdl", myRandomEngine,
                         radCorrEngine, &extraModels );
 
     if ( !strcmp( argv[1], "file" ) ) {
         int nevent = atoi( argv[2] );
         runFile( nevent, argv[3], myGenerator );
     }
 
     if ( !strcmp( argv[1], "print" ) ) {
         int nevent = atoi( argv[2] );
         runPrint( nevent, argv[3], myGenerator );
     }
 
     if ( !strcmp( argv[1], "filevpho" ) ) {
         int nevent = atoi( argv[2] );
         runFileVpho( nevent, argv[3], myGenerator );
     }
 
     if ( !strcmp( argv[1], "test1" ) ) {
         int nevent = atoi( argv[2] );
         runTest1( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "chi1kstar" ) ) {
         int nevent = atoi( argv[2] );
         runChi1Kstar( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "test2" ) ) {
         int nevent = atoi( argv[2] );
         runTest2( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "omega" ) ) {
         int nevent = atoi( argv[2] );
         runOmega( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "alias" ) ) {
         runAlias();
     }
 
     if ( !strcmp( argv[1], "repeat" ) ) {
         int nevent = atoi( argv[2] );
         runRepeat( nevent );
     }
 
     if ( !strcmp( argv[1], "photos" ) ) {
         int nevent = atoi( argv[2] );
         runPhotos( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "trackmult" ) ) {
         int nevent = atoi( argv[2] );
         runTrackMult( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "generic" ) ) {
         int nevent = atoi( argv[2] );
         std::string listfile( "" );
         if ( argc == 4 )
             listfile = argv[3];
         runGeneric( nevent, myGenerator, listfile );
     }
 
     if ( !strcmp( argv[1], "finalstates" ) ) {
         int nevent = atoi( argv[2] );
         runFinalStates( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "kstarnunu" ) ) {
         int nevent = atoi( argv[2] );
         runKstarnunu( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "bsmix" ) ) {
         int nevent = atoi( argv[2] );
         runBsmix( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "BtoXsgamma" ) ) {
         int nevent = atoi( argv[2] );
         runBtoXsgamma( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "BtoK1273gamma" ) ) {
         int nevent = atoi( argv[2] );
         runBtoK1273gamma( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "pi0dalitz" ) ) {
         int nevent = atoi( argv[2] );
         runPi0Dalitz( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "ddalitz" ) ) {
         int nevent = atoi( argv[2] );
         runDDalitz( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "kstarll" ) ) {
         int nevent = atoi( argv[2] );
         runKstarll( nevent, myGenerator );
     }
     if ( !strcmp( argv[1], "kll" ) ) {
         int nevent = atoi( argv[2] );
         runKll( nevent, myGenerator );
     }
     if ( !strcmp( argv[1], "hll" ) ) {
         int nevent = atoi( argv[2] );
         runHll( nevent, myGenerator, argv[3] );
     }
 
     if ( !strcmp( argv[1], "vectorisr" ) ) {
         int nevent = atoi( argv[2] );
         runVectorIsr( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "bsquark" ) ) {
         int nevent = atoi( argv[2] );
         runBsquark( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "k3gamma" ) ) {
         int nevent = atoi( argv[2] );
         runK3gamma( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "lambda" ) ) {
         int nevent = atoi( argv[2] );
         runLambda( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "tautaupipi" ) ) {
         int nevent = atoi( argv[2] );
         runTauTauPiPi( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "tautauee" ) ) {
         int nevent = atoi( argv[2] );
         runTauTauEE( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "tautau2pi2pi" ) ) {
         int nevent = atoi( argv[2] );
         runTauTau2Pi2Pi( nevent, myGenerator );
     }
     if ( !strcmp( argv[1], "tautau3pi3pi" ) ) {
         int nevent = atoi( argv[2] );
         runTauTau3Pi3Pi( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "jpsikstar" ) ) {
         int nevent = atoi( argv[2] );
         int modeInt = atoi( argv[3] );
         runJPsiKstar( nevent, myGenerator, modeInt );
     }
 
     if ( !strcmp( argv[1], "svvcplh" ) ) {
         int nevent = atoi( argv[2] );
         runSVVCPLH( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "svscplh" ) ) {
         int nevent = atoi( argv[2] );
         runSVSCPLH( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "ssdcp" ) ) {
         int nevent = atoi( argv[2] );
         runSSDCP( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "kstarstargamma" ) ) {
         int nevent = atoi( argv[2] );
         runKstarstargamma( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "dstarpi" ) ) {
         int nevent = atoi( argv[2] );
         runDSTARPI( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "etacphiphi" ) ) {
         int nevent = atoi( argv[2] );
         runETACPHIPHI( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "vvpipi" ) ) {
         int nevent = atoi( argv[2] );
         runVVPiPi( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "svvhelamp" ) ) {
         int nevent = atoi( argv[2] );
         runSVVHelAmp( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "partwave" ) ) {
         int nevent = atoi( argv[2] );
         runPartWave( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "partwave2" ) ) {
         int nevent = atoi( argv[2] );
         runPartWave2( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "twobody" ) ) {
         int nevent = atoi( argv[2] );
         runTwoBody( nevent, myGenerator, argv[3], argv[4] );
     }
 
     if ( !strcmp( argv[1], "pipipi" ) ) {
         int nevent = atoi( argv[2] );
         runPiPiPi( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "bhadronic" ) ) {
         int nevent = atoi( argv[2] );
         runBHadronic( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "singleb" ) ) {
         int nevent = atoi( argv[2] );
         runSingleB( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "pipi" ) ) {
         int nevent = atoi( argv[2] );
         runPiPi( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "pipipipi" ) ) {
         int nevent = atoi( argv[2] );
         runPiPiPiPi( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "a2pi" ) ) {
         int nevent = atoi( argv[2] );
         runA2Pi( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "helamp" ) ) {
         int nevent = atoi( argv[2] );
         runHelAmp( nevent, myGenerator, argv[3], argv[4] );
     }
 
     if ( !strcmp( argv[1], "helamp2" ) ) {
         int nevent = atoi( argv[2] );
         runHelAmp2( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "d2pi" ) ) {
         int nevent = atoi( argv[2] );
         runD2Pi( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "a1pi" ) ) {
         int nevent = atoi( argv[2] );
         runA1Pi( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "cptest" ) ) {
         int nevent = atoi( argv[2] );
         runCPTest( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "pipicpt" ) ) {
         int nevent = atoi( argv[2] );
         runPiPiCPT( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "jpsiks" ) ) {
         int nevent = atoi( argv[2] );
         runJpsiKs( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "dump" ) ) {
         int nevent = atoi( argv[2] );
         runDump( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "genericcont" ) ) {
         int nevent = atoi( argv[2] );
         runGenericCont( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "d1" ) ) {
         int nevent = atoi( argv[2] );
         runD1( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "mix" ) ) {
         int nevent = atoi( argv[2] );
         runMix( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "bmix" ) ) {
         int nevent = atoi( argv[2] );
         runBMix( nevent, myGenerator, argv[3], argv[4] );
     }
 
     if ( !strcmp( argv[1], "semic" ) ) {
         int nevent = atoi( argv[2] );
         runSemic( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "ddk" ) ) {
         int nevent = atoi( argv[2] );
         runDDK( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "checkmass" ) ) {
         int nevent = atoi( argv[2] );
         int partnum = atoi( argv[3] );
         runMassCheck( nevent, myGenerator, partnum );
     }
 
     if ( !strcmp( argv[1], "jpsipolarization" ) ) {
         int nevent = atoi( argv[2] );
         runJpsiPolarization( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "phspdecaytimecut" ) ) {
         int nevent = atoi( argv[2] );
         runPhspDecaytimeCut( nevent, myGenerator );
     }
 
     if ( !strcmp( argv[1], "3bodyPhsp" ) ) {
         int nevent = atoi( argv[2] );
         EvtRadCorr::setNeverRadCorr();
         run3BPhspRegion( nevent, myGenerator );
     }
 
-    if ( !strcmp( argv[1], "flatSqDalitz" ) ) {
-        int nevent = atoi( argv[2] );
-        EvtRadCorr::setNeverRadCorr();
-        runFlatSqDalitz( nevent, myGenerator );
-    }
-
     if ( !strcmp( argv[1], "4bodyPhsp" ) ) {
         int nevent = atoi( argv[2] );
         EvtRadCorr::setNeverRadCorr();
         runFourBody( nevent, myGenerator );
     }
 
     //*******************************************************
     //test of the rotations and boosts performed in EvtGen.
     // Added by Lange and Ryd Jan 5,2000.
     //*******************************************************
 
     if ( !strcmp( argv[1], "checkrotboost" ) ) {
         runCheckRotBoost();
     }
 
     if ( !strcmp( argv[1], "baryonic" ) ) {
         runBaryonic( atoi( argv[2] ), myGenerator );
     }
 
     delete myRandomEngine;
     return 0;
 }
 
 void runFile( int nevent, char* fname, EvtGen& myGenerator )
 {
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
 
     int count;
 
     char udecay_name[100];
 
     strcpy( udecay_name, fname );
 
     myGenerator.readUDecay( udecay_name );
 
     count = 1;
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runPrint( int nevent, char* fname, EvtGen& myGenerator )
 {
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
 
     int count;
 
     char udecay_name[100];
 
     strcpy( udecay_name, fname );
 
     myGenerator.readUDecay( udecay_name );
 
     count = 1;
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         root_part->printTree();
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runFileVpho( int nevent, char* fname, EvtGen& myGenerator )
 {
     static EvtId VPHO = EvtPDL::getId( std::string( "vpho" ) );
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
 
     int count;
 
     char udecay_name[100];
 
     strcpy( udecay_name, fname );
 
     myGenerator.readUDecay( udecay_name );
 
     count = 1;
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( VPHO,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 ///////////////
 
 void runJpsiPolarization( int nevent, EvtGen& myGenerator )
 {
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
     static EvtId JPSI = EvtPDL::getId( std::string( "J/psi" ) );
 
     int count;
 
     myGenerator.readUDecay( "exampleFiles/GENERIC.DEC" );
     myGenerator.readUDecay( "exampleFiles/JPSITOLL.DEC" );
     TFile* file = new TFile( "jpsipolar.root", "RECREATE" );
 
     TH1F* coshel = new TH1F( "h1", "cos hel", 50, -1.0, 1.0 );
     TH1F* coshelHigh = new TH1F( "h2", "cos hel pstar gt 1.1", 50, -1.0, 1.0 );
     TH1F* coshelLow = new TH1F( "h3", "cos hel pstar lt 1.1", 50, -1.0, 1.0 );
 
     count = 1;
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       p_init );
 
         root_part->setVectorSpinDensity();
         myGenerator.generateDecay( root_part );
         EvtParticle* p = root_part;
 
         do {
             if ( p->getId() == JPSI ) {
                 EvtVector4R p4psi = p->getP4Lab();
                 EvtVector4R p4Daug = p->getDaug( 0 )->getP4Lab();
                 double dcostheta = EvtDecayAngle( p_init, p4psi, p4Daug );
                 coshel->Fill( dcostheta );
                 if ( p4psi.d3mag() > 1.1 ) {
                     coshelHigh->Fill( dcostheta );
                 } else {
                     coshelLow->Fill( dcostheta );
                 }
             }
             p = p->nextIter( root_part );
         } while ( p != 0 );
 
         root_part->deleteTree();
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
 
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runMassCheck( int nevent, EvtGen& /*myGenerator*/, int partnum )
 {
     int count;
     static EvtId myPart = EvtPDL::evtIdFromStdHep( partnum );
     TFile* file = new TFile( "checkmass.root", "RECREATE" );
 
     TH1F* mass = new TH1F( "h1", "Mass", 500, 0.0, 2.5 );
 
     count = 1;
     do {
         mass->Fill( EvtPDL::getMass( myPart ) );
     } while ( count++ < nevent );
     file->Write();
     file->Close();
 
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runPi0Dalitz( int nevent, EvtGen& myGenerator )
 {
     static EvtId PI0 = EvtPDL::getId( std::string( "pi0" ) );
 
     TFile* file = new TFile( "pi0dalitz.root", "RECREATE" );
 
     TH1F* q2 = new TH1F( "h1", "q2", 50, 0.0, 0.02 );
 
     int count;
 
     myGenerator.readUDecay( "exampleFiles/PI0DALITZ.DEC" );
 
     count = 1;
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( PI0 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( PI0,
                                                                       p_init );
 
         root_part->setDiagonalSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         EvtVector4R ep = root_part->getDaug( 0 )->getP4Lab();
         EvtVector4R em = root_part->getDaug( 1 )->getP4Lab();
         //EvtVector4R gamma=root_part->getDaug(2)->getP4Lab();
 
         q2->Fill( ( ep + em ).mass2() );
         //      EvtGenReport(EVTGEN_INFO,"EvtGen") << ep << em << gamma <<std::endl;
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
 
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 //*******************************************************************************
 void runTest1( int nevent, EvtGen& myGenerator )
 {
     //  TFile *file=new TFile("test1.root", "RECREATE");
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
 
     //  int first=0;
     //  char **second;
     //  TApplication *theApp = new TApplication("App", &first, second);
     TFile* file = new TFile( "test1.root", "RECREATE", "Example" );
     TH1F* costhetaB = new TH1F( "hcosthetaB", "costhetaB", 50, -1.0, 1.0 );
     TH1F* phiB = new TH1F( "hphiB", "phiB", 50, -EvtConst::pi, EvtConst::pi );
     TH1F* Elep = new TH1F( "hEl", "E?l!", 50, 0.0, 2.5 );
     TH1F* q2 = new TH1F( "hq2", "q^2!", 44, 0.0, 11.0 );
     TH1F* ctv = new TH1F( "hctv", "ctv", 50, -1.0, 1.0 );
     TH1F* chi_low_ctv = new TH1F( "hcostv1", "[h] for cos[Q]?V!\"L#0", 50, 0.0,
                                   EvtConst::twoPi );
     TH1F* chi_high_ctv = new TH1F( "hcostv2", "[h] for cos[Q]?V!\"G#0", 50, 0.0,
                                    EvtConst::twoPi );
     TH1F* dt = new TH1F( "hdt", "dt", 50, -5.0, 5.0 );
 
     int count;
 
     EvtVector4R p4b0, p4b0b, p4dstar, p4e, p4nu, p4d, p4pi, p4pip, p4pim;
     char udecay_name[100];
 
     strcpy( udecay_name, "exampleFiles/TEST1.DEC" );
 
     //    EvtGen myGenerator(decay_name,pdttable_name,myRandomEngine);
 
     myGenerator.readUDecay( udecay_name );
     double costhetaV;
 
     count = 1;
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         p4b0 = root_part->getDaug( 0 )->getP4Lab();
         p4b0b = root_part->getDaug( 1 )->getP4Lab();
 
         p4dstar = root_part->getDaug( 0 )->getDaug( 0 )->getP4Lab();
         p4e = root_part->getDaug( 0 )->getDaug( 1 )->getP4Lab();
         p4nu = root_part->getDaug( 0 )->getDaug( 2 )->getP4Lab();
 
         p4d = root_part->getDaug( 0 )->getDaug( 0 )->getDaug( 0 )->getP4Lab();
         p4pi = root_part->getDaug( 0 )->getDaug( 0 )->getDaug( 1 )->getP4Lab();
 
         p4pip = root_part->getDaug( 1 )->getDaug( 0 )->getP4Lab();
         p4pim = root_part->getDaug( 1 )->getDaug( 1 )->getP4Lab();
 
         costhetaB->Fill( p4b0.get( 3 ) / p4b0.d3mag() );
         phiB->Fill( atan2( p4b0.get( 1 ), p4b0.get( 2 ) ) );
         Elep->Fill( p4b0 * p4e / p4b0.mass() );
         q2->Fill( ( p4e + p4nu ).mass2() );
         dt->Fill( root_part->getDaug( 1 )->getLifetime() -
                   root_part->getDaug( 0 )->getLifetime() );
         costhetaV = EvtDecayAngle( p4b0, p4d + p4pi, p4d );
         ctv->Fill( costhetaV );
         if ( costhetaV < 0.0 ) {
             chi_low_ctv->Fill( EvtDecayAngleChi( p4b0, p4d, p4pi, p4e, p4nu ) );
         } else {
             chi_high_ctv->Fill( EvtDecayAngleChi( p4b0, p4d, p4pi, p4e, p4nu ) );
         }
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
     file->Write();
     file->Close();
     //  delete theApp;
     //  hfile.write();
 
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 //*******************************************************************************
 void runDDK( int nevent, EvtGen& myGenerator )
 {
     //  TFile *file=new TFile("test1.root", "RECREATE");
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
 
     int count;
 
     char udecay_name[100];
 
     strcpy( udecay_name, "exampleFiles/GENERIC.DEC" );
 
     myGenerator.readUDecay( udecay_name );
 
     count = 1;
 
     static EvtId kp = EvtPDL::getId( std::string( "K+" ) );
     static EvtId km = EvtPDL::getId( std::string( "K-" ) );
     static EvtId ks = EvtPDL::getId( std::string( "K_S0" ) );
     static EvtId kl = EvtPDL::getId( std::string( "K_L0" ) );
     static EvtId k0 = EvtPDL::getId( std::string( "K0" ) );
     static EvtId kb = EvtPDL::getId( std::string( "anti-K0" ) );
 
     static EvtId d0 = EvtPDL::getId( std::string( "D0" ) );
     static EvtId dp = EvtPDL::getId( std::string( "D+" ) );
     static EvtId dm = EvtPDL::getId( std::string( "D-" ) );
     static EvtId db = EvtPDL::getId( std::string( "anti-D0" ) );
 
     static EvtIdSet theKs( kp, km, ks, kl, k0, kb );
     static EvtIdSet theDs( d0, dp, dm, db );
 
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
     static EvtId B0B = EvtPDL::getId( std::string( "anti-B0" ) );
     static EvtId BP = EvtPDL::getId( std::string( "B+" ) );
     static EvtId BM = EvtPDL::getId( std::string( "B-" ) );
 
     static EvtIdSet theBs( B0B, B0, BP, BM );
 
     int nDDK = 0;
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         EvtParticle* theB01 = root_part->getDaug( 0 );
         EvtParticle* theB02 = root_part->getDaug( 1 );
 
         int nD = 0;
         int nK = 0;
 
         EvtParticle* p = theB01;
         do {
             EvtId type = p->getId();
             EvtId typePar = p->getParent()->getId();
             if ( theDs.contains( type ) )
                 nD++;
             if ( theKs.contains( type ) && theBs.contains( typePar ) )
                 nK++;
             p = p->nextIter( theB01 );
         } while ( p != 0 );
         if ( nD == 2 && nK == 1 )
             nDDK++;
 
         nD = 0;
         nK = 0;
 
         p = theB02;
         do {
             EvtId type = p->getId();
             EvtId typePar = p->getParent()->getId();
             if ( theDs.contains( type ) )
                 nD++;
             if ( theKs.contains( type ) && theBs.contains( typePar ) )
                 nK++;
             p = p->nextIter( theB02 );
         } while ( p != 0 );
         if ( nD == 2 && nK == 1 )
             nDDK++;
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << nDDK << " " << ( count - 1 ) << " "
         << nDDK / float( 2 * ( count - 1 ) ) << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 //*******************************************************************************
 
 void runTest2( int nevent, EvtGen& myGenerator )
 {
     TFile* file = new TFile( "test2.root", "RECREATE" );
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
     TH1F* costhetaB = new TH1F( "h1", "cos[Q]?B!", 50, -1.0, 1.0 );
     TH1F* phiB = new TH1F( "h2", "[f]?B!", 50, -EvtConst::pi, EvtConst::pi );
 
     TH1F* dt = new TH1F( "h3", "[D]t", 100, -5.0, 5.0 );
     TH1F* costhetaJpsi = new TH1F( "h4", "cos[Q]?J/[y]!", 50, -1.0, 1.0 );
     TH1F* costhetaKstar = new TH1F( "h5", "cos[Q]?K*!", 50, -1.0, 1.0 );
     TH1F* chi = new TH1F( "h6", "[h]", 50, 0.0, EvtConst::twoPi );
     TH1F* chi1 = new TH1F( "h26", "[h] [D]t\"L#0", 50, 0.0, EvtConst::twoPi );
     TH1F* chi2 = new TH1F( "h27", "[h] [D]t\"G#0", 50, 0.0, EvtConst::twoPi );
 
     TH1F* costhetaomega = new TH1F( "h7", "costhetaomega", 50, -1.0, 1.0 );
     TH1F* costhetaomega1 = new TH1F( "h20", "costhetaomega1", 50, -1.0, 1.0 );
     TH1F* costhetaomega2 = new TH1F( "h21", "costhetaomega2", 50, -1.0, 1.0 );
     TH1F* costhetaomega3 = new TH1F( "h22", "costhetaomega3", 50, -1.0, 1.0 );
     TH1F* omegaamp = new TH1F( "h8", "omegaamp", 50, 0.0, 0.05 );
     TH1F* omegaamp1 = new TH1F( "h9", "omegaamp1", 50, 0.0, 0.05 );
     TH1F* omegaamp2 = new TH1F( "h10", "omegaamp2", 50, 0.0, 0.05 );
     TH1F* omegaamp3 = new TH1F( "h11", "omegaamp3", 50, 0.0, 0.05 );
 
     TH2F* chi1vscoskstarl = new TH2F( "h30", "[h] vs. cos[Q]?J/[y]! [D]t\"L#0",
                                       20, 0.0, EvtConst::twoPi, 20, -1.0, 1.0 );
 
     TH2F* chi1vscoskstarg = new TH2F( "h31", "[h] vs. cos[Q]?J/[y]! [D]t\"G#0",
                                       20, 0.0, EvtConst::twoPi, 20, -1.0, 1.0 );
 
     int count = 1;
 
     EvtVector4R p4_b0, p4_b0b, p4_psi, p4_kstar, p4_mup, p4_mum;
     EvtVector4R p4_kz, p4_pi0, p4_pi1, p4_pi2, p4_pi3, p4_omega;
     EvtVector4R p4_pi1_omega, p4_pi2_omega, p4_pi3_omega;
     char udecay_name[100];
 
     strcpy( udecay_name, "exampleFiles/TEST2.DEC" );
     //EvtGen myGenerator(decay_name,pdttable_name,myRandomEngine);
     myGenerator.readUDecay( udecay_name );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         p4_b0 = root_part->getDaug( 0 )->getP4Lab();
         p4_b0b = root_part->getDaug( 1 )->getP4Lab();
         p4_psi = root_part->getDaug( 1 )->getDaug( 0 )->getP4Lab();
         p4_kstar = root_part->getDaug( 1 )->getDaug( 1 )->getP4Lab();
         p4_mup = root_part->getDaug( 1 )->getDaug( 0 )->getDaug( 0 )->getP4Lab();
         p4_mum = root_part->getDaug( 1 )->getDaug( 0 )->getDaug( 1 )->getP4Lab();
         p4_kz = root_part->getDaug( 1 )->getDaug( 1 )->getDaug( 0 )->getP4Lab();
         p4_pi0 = root_part->getDaug( 1 )->getDaug( 1 )->getDaug( 1 )->getP4Lab();
 
         p4_omega = root_part->getDaug( 0 )->getDaug( 0 )->getP4Lab();
         p4_pi1 = root_part->getDaug( 0 )->getDaug( 0 )->getDaug( 0 )->getP4Lab();
         p4_pi2 = root_part->getDaug( 0 )->getDaug( 0 )->getDaug( 1 )->getP4Lab();
         p4_pi3 = root_part->getDaug( 0 )->getDaug( 0 )->getDaug( 2 )->getP4Lab();
 
         //get momentum in the omega restframe
         p4_pi1_omega =
             root_part->getDaug( 0 )->getDaug( 0 )->getDaug( 0 )->getP4();
         p4_pi2_omega =
             root_part->getDaug( 0 )->getDaug( 0 )->getDaug( 1 )->getP4();
         p4_pi3_omega =
             root_part->getDaug( 0 )->getDaug( 0 )->getDaug( 2 )->getP4();
 
         EvtVector3R p3_perp =
             cross( EvtVector3R( p4_pi2_omega.get( 0 ), p4_pi2_omega.get( 1 ),
                                 p4_pi2_omega.get( 2 ) ),
                    EvtVector3R( p4_pi3_omega.get( 0 ), p4_pi3_omega.get( 1 ),
                                 p4_pi3_omega.get( 2 ) ) );
 
         EvtVector4R p4_perp( p3_perp.d3mag(), p3_perp.get( 0 ),
                              p3_perp.get( 1 ), p3_perp.get( 2 ) );
 
         root_part->getDaug( 0 )->getDaug( 0 )->getDaug( 0 )->setP4( p4_perp );
 
         p4_perp = root_part->getDaug( 0 )->getDaug( 0 )->getDaug( 0 )->getP4Lab();
 
         EvtVector4R p4_perpprime = p4_omega - p4_perp;
 
         double d_omegaamp = EvtVector3R( p4_pi1_omega.get( 0 ),
                                          p4_pi1_omega.get( 1 ),
                                          p4_pi1_omega.get( 2 ) ) *
                             p3_perp;
 
         d_omegaamp *= d_omegaamp;
         d_omegaamp *= 20.0;
 
         double d_dt = root_part->getDaug( 1 )->getLifetime() -
                       root_part->getDaug( 0 )->getLifetime();
         double d_costhetaJpsi = EvtDecayAngle( p4_b0b, p4_mup + p4_mum, p4_mup );
         double d_costhetaKstar = EvtDecayAngle( p4_b0b, p4_pi0 + p4_kz, p4_pi0 );
         double d_chi = EvtDecayAngleChi( p4_b0b, p4_pi0, p4_kz, p4_mup, p4_mum );
         costhetaB->Fill( p4_b0.get( 3 ) / p4_b0.d3mag() );
         phiB->Fill( atan2( p4_b0.get( 1 ), p4_b0.get( 2 ) ) );
 
         dt->Fill( d_dt );
         costhetaJpsi->Fill( d_costhetaJpsi );
         costhetaKstar->Fill( d_costhetaKstar );
         chi->Fill( d_chi );
 
         if ( d_dt < 0.0 ) {
             chi1->Fill( d_chi );
             chi1vscoskstarl->Fill( d_chi, d_costhetaJpsi, 1.0 );
         }
 
         if ( d_dt > 0.0 ) {
             chi2->Fill( d_chi );
             chi1vscoskstarg->Fill( d_chi, d_costhetaJpsi, 1.0 );
         }
 
         double d_costhetaomega = EvtDecayAngle( p4_b0b, p4_perp + p4_perpprime,
                                                 p4_perp );
 
         costhetaomega->Fill( d_costhetaomega );
         if ( d_omegaamp < 0.001 )
             costhetaomega1->Fill( d_costhetaomega );
         if ( d_omegaamp > 0.02 )
             costhetaomega2->Fill( d_costhetaomega );
         if ( std::fabs( d_omegaamp - 0.015 ) < 0.005 )
             costhetaomega3->Fill( d_costhetaomega );
 
         omegaamp->Fill( d_omegaamp );
         if ( d_costhetaomega < -0.5 )
             omegaamp1->Fill( d_omegaamp );
         if ( d_costhetaomega > 0.5 )
             omegaamp2->Fill( d_omegaamp );
         if ( std::fabs( d_costhetaomega ) < 0.5 )
             omegaamp3->Fill( d_omegaamp );
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runOmega( int nevent, EvtGen& myGenerator )
 {
     TFile* file = new TFile( "omega.root", "RECREATE" );
     static EvtId OMEGA = EvtPDL::getId( std::string( "omega" ) );
 
     TH2F* dalitz = new TH2F( "h1", "E1 vs E2", 50, 0.0, 0.5, 50, 0.0, 0.5 );
 
     int count = 1;
 
     char udecay_name[100];
 
     strcpy( udecay_name, "exampleFiles/OMEGA.DEC" );
     myGenerator.readUDecay( udecay_name );
 
     do {
         EvtVector4R p_init( EvtPDL::getMeanMass( OMEGA ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( OMEGA,
                                                                       p_init );
         //root_part->setDiagonalSpinDensity();
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         dalitz->Fill( root_part->getDaug( 0 )->getP4().get( 0 ),
                       root_part->getDaug( 1 )->getP4().get( 0 ), 1.0 );
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runChi1Kstar( int nevent, EvtGen& myGenerator )
 {
     TFile* file = new TFile( "chi1kstar.root", "RECREATE" );
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
 
     TH1F* costhetaChi1 = new TH1F( "h1", "cos[Q]?J/[x]!", 50, -1.0, 1.0 );
     TH1F* costhetaKstar = new TH1F( "h2", "cos[Q]?K*!", 50, -1.0, 1.0 );
     TH1F* chi = new TH1F( "h3", "[x]", 50, -EvtConst::pi, EvtConst::pi );
 
     int count = 1;
 
     EvtVector4R p4_b, p4_chi, p4_kstar, p4_gamma, p4_psi, p4_k, p4_p;
 
     char udecay_name[100];
 
     strcpy( udecay_name, "exampleFiles/CHI1KSTAR.DEC" );
 
     myGenerator.readUDecay( udecay_name );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( B0 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( B0, p_init );
         myGenerator.generateDecay( root_part );
 
         p4_b = root_part->getP4Lab();
         p4_chi = root_part->getDaug( 0 )->getP4Lab();
         p4_kstar = root_part->getDaug( 1 )->getP4Lab();
         p4_psi = root_part->getDaug( 0 )->getDaug( 0 )->getP4Lab();
         p4_gamma = root_part->getDaug( 0 )->getDaug( 1 )->getP4Lab();
         p4_k = root_part->getDaug( 1 )->getDaug( 0 )->getP4Lab();
         p4_p = root_part->getDaug( 1 )->getDaug( 1 )->getP4Lab();
 
         double d_costhetaChi1 = EvtDecayAngle( p4_b, p4_chi, p4_psi );
         double d_costhetaKstar = EvtDecayAngle( p4_b, p4_kstar, p4_k );
         double d_chi = EvtDecayAngleChi( p4_b, p4_k, p4_p, p4_psi, p4_gamma );
 
         if ( d_chi > EvtConst::pi )
             d_chi -= EvtConst::twoPi;
 
         costhetaChi1->Fill( d_costhetaChi1 );
         costhetaKstar->Fill( d_costhetaKstar );
         chi->Fill( d_chi );
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runAlias()
 {
     EvtId idpip = EvtPDL::getId( std::string( "pi+" ) );
     EvtPDL::alias( idpip, std::string( "my_pi+" ) );
     EvtId myidpip = EvtPDL::getId( std::string( "my_pi+" ) );
 
     EvtId idpim = EvtPDL::getId( std::string( "pi-" ) );
     EvtPDL::alias( idpim, std::string( "my_pi-" ) );
     EvtId myidpim = EvtPDL::getId( std::string( "my_pi-" ) );
 
     EvtId idpi0 = EvtPDL::getId( std::string( "pi0" ) );
     EvtPDL::alias( idpi0, std::string( "my_pi0" ) );
     EvtId myidpi0 = EvtPDL::getId( std::string( "my_pi0" ) );
 
     EvtPDL::aliasChgConj( myidpip, myidpim );
 
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "Id    pi+:" << idpip << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "Id    pi-:" << idpim << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "Id    pi0:" << idpi0 << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "Id my_pi+:" << myidpip << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "Id my_pi-:" << myidpim << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "Id my_pi0:" << myidpi0 << std::endl;
 
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "Chg conj    pi+:" << EvtPDL::chargeConj( idpip ) << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "Chg conj    pi-:" << EvtPDL::chargeConj( idpim ) << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "Chg conj    pi0:" << EvtPDL::chargeConj( idpi0 ) << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "Chg conj my_pi+:" << EvtPDL::chargeConj( myidpip ) << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "Chg conj my_pi-:" << EvtPDL::chargeConj( myidpim ) << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "Chg conj my_pi0:" << EvtPDL::chargeConj( myidpi0 ) << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runRepeat( int nevent )
 {
     int i;
 
     for ( i = 0; i < nevent; i++ ) {
         EvtDecayTable::getInstance()->readDecayFile(
             std::string( "../DECAY.DEC" ) );
     }
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runPhotos( int nevent, EvtGen& myGenerator )
 {
     static EvtId PSI = EvtPDL::getId( std::string( "J/psi" ) );
 
     TFile* file = new TFile( "photos.root", "RECREATE" );
 
     TH1F* mee = new TH1F( "h1", "mee", 60, 3.0, 3.12 );
 
     int count = 1;
 
     EvtVector4R e1, e2;
 
     char udecay_name[100];
     strcpy( udecay_name, "exampleFiles/PHOTOS.DEC" );
     //EvtGen myGenerator(decay_name,pdttable_name,myRandomEngine);
     myGenerator.readUDecay( udecay_name );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( PSI ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( PSI,
                                                                       p_init );
         root_part->setDiagonalSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         e1 = root_part->getDaug( 0 )->getP4Lab();
         e2 = root_part->getDaug( 1 )->getP4Lab();
 
         mee->Fill( ( e1 + e2 ).mass() );
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runFinalStates( int nevent, EvtGen& myGenerator )
 {
     //Parse the table of particles to find..
 
     EvtParser parser;
     parser.read( std::string( "exampleFiles/finalstates.list" ) );
 
     std::vector<std::string> dList[20];
     int dListNum[20];
     std::vector<std::string>* dListItem = 0;
     std::string dListName[20];
     int ik, lk;
     std::string tk = "";
     int tline = -1;
     std::string parent;
     for ( ik = 0; ik < parser.getNToken(); ik++ ) {
         lk = tline;
         tline = parser.getLineofToken( ik );
         tk = parser.getToken( ik );
 
         if ( lk != tline && tline > 2 ) {
             if ( tline > 1 ) {
                 dList[tline - 3] = *dListItem;
                 dListItem = new std::vector<std::string>;
                 dListNum[tline - 3] = 0;
                 dListName[tline - 2] = parser.getToken( ik );
             }
         } else {
             if ( tline == 1 ) {
                 //This is the parent particle name
                 parent = parser.getToken( ik );
                 dListItem = new std::vector<std::string>;
             } else {
                 //This is one of the daughters
                 if ( tline != 2 || ( lk == tline ) ) {
                     dListItem->push_back( parser.getToken( ik ) );
                 }
                 if ( tline == 2 && ( lk != tline ) ) {
                     dListName[tline - 2] = parser.getToken( ik );
                 }
             }
         }
     }
     dList[tline - 2] = *dListItem;
     dListNum[tline - 2] = 0;
 
     static EvtId parId = EvtPDL::getId( parent );
     int count = 0;
     do {
         if ( count == 1000 * ( count / 1000 ) ) {
             //if (count==1*(count/1)) {
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << "Event:" << count << std::endl;
             //EvtGenReport(EVTGEN_INFO,"EvtGen") << HepRandom::getTheSeed()<<std::endl;
         }
         EvtVector4R p_init( EvtPDL::getMass( parId ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( parId,
                                                                       p_init );
         if ( parent == "Upsilon(4S)" ) {
             root_part->setVectorSpinDensity();
         } else {
             root_part->setDiagonalSpinDensity();
         }
 
         myGenerator.generateDecay( root_part );
 
         EvtParticle* p = root_part;
 
         std::vector<std::string> fs = findFinalState( p );
 
         int j;
         for ( j = 0; j < ( tline - 1 ); j++ ) {
             std::vector<std::string> temp = dList[j];
             if ( temp.size() == fs.size() ) {
                 bool foundIt = true;
                 unsigned int k, l;
                 std::vector<bool> alreadyUsed( temp.size() );
                 for ( k = 0; k < temp.size(); k++ ) {
                     bool foundThisOne = false;
                     for ( l = 0; l < temp.size(); l++ ) {
                         if ( k == 0 )
                             alreadyUsed[l] = false;
                         if ( foundThisOne || alreadyUsed[l] )
                             continue;
                         if ( temp[k] == fs[l] ) {
                             alreadyUsed[l] = true;
                             foundThisOne = true;
                             //	      EvtGenReport(EVTGEN_INFO,"EvtGen") << "found daughter " << k << " " << l << std::endl;
                         }
                     }
                     if ( !foundThisOne )
                         foundIt = false;
                 }
                 if ( foundIt ) {    //EvtGenReport(EVTGEN_INFO,"EvtGen") << "found a cand \n"; (histo1[j])->Fill(0.5);
                     //EvtGenReport(EVTGEN_INFO,"EvtGen") << "found one " << j << std::endl;
                     dListNum[j]++;
                 }
             }
         }
 
         root_part->deleteTree();
         count++;
     } while ( count < nevent );
     int j;
     for ( j = 0; j < ( tline - 1 ); j++ )
         EvtGenReport( EVTGEN_INFO, "EvtGen" )
             << dListName[j].c_str() << " " << j << " " << dListNum[j] << " "
             << count << " " << ( dListNum[j] / ( 1.0 * count ) ) << std::endl;
 
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 std::vector<std::string> findFinalState( EvtParticle* tree )
 {
     EvtParticle* p = tree;
     std::vector<std::string> fs;
     static EvtId ep = EvtPDL::getId( std::string( "e+" ) );
     static EvtId em = EvtPDL::getId( std::string( "e-" ) );
     static EvtId kp = EvtPDL::getId( std::string( "K+" ) );
     static EvtId km = EvtPDL::getId( std::string( "K-" ) );
     static EvtId mup = EvtPDL::getId( std::string( "mu+" ) );
     static EvtId mum = EvtPDL::getId( std::string( "mu-" ) );
     static EvtId pip = EvtPDL::getId( std::string( "pi+" ) );
     static EvtId pim = EvtPDL::getId( std::string( "pi-" ) );
     static EvtId pi0 = EvtPDL::getId( std::string( "pi0" ) );
     static EvtId pr = EvtPDL::getId( std::string( "p+" ) );
     static EvtId apr = EvtPDL::getId( std::string( "anti-p-" ) );
     static EvtId ne = EvtPDL::getId( std::string( "n0" ) );
     static EvtId ane = EvtPDL::getId( std::string( "anti-n0" ) );
 
     do {
         EvtId type = p->getId();
 
         if ( type == ep )
             fs.push_back( std::string( "e+" ) );
         if ( type == em )
             fs.push_back( std::string( "e-" ) );
         if ( type == mup )
             fs.push_back( std::string( "mu+" ) );
         if ( type == mum )
             fs.push_back( std::string( "mu-" ) );
         if ( type == kp )
             fs.push_back( std::string( "K+" ) );
         if ( type == km )
             fs.push_back( std::string( "K-" ) );
         if ( type == pip )
             fs.push_back( std::string( "pi+" ) );
         if ( type == pim )
             fs.push_back( std::string( "pi-" ) );
         if ( type == pi0 )
             fs.push_back( std::string( "pi0" ) );
         if ( type == pr )
             fs.push_back( std::string( "p+" ) );
         if ( type == apr )
             fs.push_back( std::string( "anti-p-" ) );
         if ( type == ne )
             fs.push_back( std::string( "n0" ) );
         if ( type == ane )
             fs.push_back( std::string( "anti-n0" ) );
 
         p = p->nextIter();
 
     } while ( p != 0 );
 
     return fs;
 }
 void runTrackMult( int nevent, EvtGen& myGenerator )
 {
     TFile* file = new TFile( "trackmult.root", "RECREATE" );
 
     TH1F* trackAll = new TH1F( "trackAll", "trackAll", 12, 1.0, 25.0 );
     TH1F* trackNoSL = new TH1F( "trackNoSL", "trackNoSL", 12, 1.0, 25.0 );
     TH1F* track1SL = new TH1F( "track1SL", "track1SL", 12, 1.0, 25.0 );
     TH1F* track2SL = new TH1F( "track2SL", "track2SL", 12, 1.0, 25.0 );
 
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
 
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
     static EvtId B0B = EvtPDL::getId( std::string( "anti-B0" ) );
     static EvtId BP = EvtPDL::getId( std::string( "B+" ) );
     static EvtId BM = EvtPDL::getId( std::string( "B-" ) );
 
     //look for these tracks in generic events
     static EvtId ep = EvtPDL::getId( std::string( "e+" ) );
     static EvtId em = EvtPDL::getId( std::string( "e-" ) );
     static EvtId mup = EvtPDL::getId( std::string( "mu+" ) );
     static EvtId mum = EvtPDL::getId( std::string( "mu-" ) );
     static EvtId pip = EvtPDL::getId( std::string( "pi+" ) );
     static EvtId pim = EvtPDL::getId( std::string( "pi-" ) );
     static EvtId kp = EvtPDL::getId( std::string( "K+" ) );
     static EvtId km = EvtPDL::getId( std::string( "K-" ) );
     static EvtId pp = EvtPDL::getId( std::string( "p+" ) );
     static EvtId pm = EvtPDL::getId( std::string( "anti-p-" ) );
 
     static EvtIdSet theTracks( ep, em, mup, mum, pip, pim, kp, km, pp, pm );
     static EvtIdSet theLeptons( ep, em, mup, mum );
     static EvtIdSet theBs( B0, B0B, BP, BM );
 
     int count = 1;
 
     EvtParticle* p;
 
     myGenerator.readUDecay( "exampleFiles/GENERIC.DEC" );
 
     int totTracks = 0;
     int totTracksNoSL = 0;
     int totTracks1SL = 0;
     int totTracks2SL = 0;
     int totNoSL = 0;
     int tot1SL = 0;
     int tot2SL = 0;
 
     do {
         int evTracks = 0;
 
         if ( count == 1000 * ( count / 1000 ) ) {
             EvtGenReport( EVTGEN_INFO, "EvtGen" ) << count << std::endl;
             //EvtGenReport(EVTGEN_INFO,"EvtGen") << HepRandom::getTheSeed()<<std::endl;
         }
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         p = root_part;
 
         int howManySL = 0;
 
         do {
             if ( theTracks.contains( p->getId() ) ) {
                 totTracks += 1;
                 evTracks += 1;
             }
             if ( theLeptons.contains( p->getId() ) ) {
                 if ( p->getParent() ) {
                     if ( theBs.contains( p->getParent()->getId() ) )
                         howManySL += 1;
                 }
             }
             p = p->nextIter( root_part );
 
         } while ( p != 0 );
 
         //Now need to figure out which histogram to book
         trackAll->Fill( evTracks );
         if ( howManySL == 0 ) {
             trackNoSL->Fill( evTracks );
             totNoSL += 1;
             totTracksNoSL += evTracks;
         }
         if ( howManySL == 1 ) {
             track1SL->Fill( evTracks );
             tot1SL += 1;
             totTracks1SL += evTracks;
         }
         if ( howManySL == 2 ) {
             track2SL->Fill( evTracks );
             tot2SL += 1;
             totTracks2SL += evTracks;
         }
 
         root_part->deleteTree();
     } while ( count++ < nevent );
 
     double aveMulti = float( totTracks ) / float( nevent );
     double aveMultiNoSL = float( totTracksNoSL ) / float( totNoSL );
     double aveMulti1SL = float( totTracks1SL ) / float( tot1SL );
     double aveMulti2SL = float( totTracks2SL ) / float( tot2SL );
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "Your average multiplicity=" << aveMulti << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "Your average multiplicity for no B->semileptonic events="
         << aveMultiNoSL << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "Your average multiplicity for 1 B->semileptonic events="
         << aveMulti1SL << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "Your average multiplicity for 2 B->semileptonic events="
         << aveMulti2SL << std::endl;
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runGeneric( int neventOrig, EvtGen& myGenerator, std::string listfile )
 {
     int nevent = abs( neventOrig );
 
     //Parse the table of particles to find..
 
     TFile* file = new TFile( "generic.root", "RECREATE" );
 
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
     static EvtId VPHO = EvtPDL::getId( std::string( "vpho" ) );
 
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
     static EvtId B0B = EvtPDL::getId( std::string( "anti-B0" ) );
     static EvtId BP = EvtPDL::getId( std::string( "B+" ) );
     static EvtId BM = EvtPDL::getId( std::string( "B-" ) );
 
     static EvtIdSet theBs( B0B, B0, BP, BM );
     static EvtIdSet theB0B( B0B );
     static EvtIdSet theB0( B0 );
     static EvtIdSet theBP( BP );
     static EvtIdSet theBM( BM );
 
     static EvtId D0 = EvtPDL::getId( std::string( "D0" ) );
     static EvtId D0B = EvtPDL::getId( std::string( "anti-D0" ) );
     static EvtId DP = EvtPDL::getId( std::string( "D+" ) );
     static EvtId DM = EvtPDL::getId( std::string( "D-" ) );
 
     static EvtIdSet theDs( D0B, D0, DP, DM );
     static EvtIdSet theD0B( D0B );
     static EvtIdSet theD0( D0 );
     static EvtIdSet theDP( DP );
     static EvtIdSet theDM( DM );
 
     int count;
     char udecay_name[100];
 
     strcpy( udecay_name, "exampleFiles/GENERIC.DEC" );
     myGenerator.readUDecay( udecay_name );
 
     if ( listfile != "" ) {
         EvtParser parser;
         if ( parser.read( listfile ) != 0 ) {
             EvtGenReport( EVTGEN_ERROR, "EvtGen" )
                 << "Will terminate." << std::endl;
             exit( -1 );
         }
 
         std::vector<TH1F*> histo1( parser.getNToken() );
         std::vector<TH1F*> histo2( parser.getNToken() );
         std::vector<TH1F*> massHisto( parser.getNToken() );
 
         int ik;
         std::string tk, tkname;
         for ( ik = 0; ik < ( parser.getNToken() / 2 ); ik++ ) {
             tk = parser.getToken( 2 * ik );
             tkname = parser.getToken( 1 + 2 * ik );
             histo1[ik] = new TH1F( tkname.c_str(), tkname.c_str(), 30, 0.0, 3.0 );
             char* directName;
             directName = new char[( strlen( tkname.c_str() ) + 8 )];
             directName = strcpy( directName, tkname.c_str() );
             directName = strcat( directName, "Direct" );
             histo2[ik] = new TH1F( directName, directName, 30, 0.0, 3.0 );
             delete directName;
 
             char* massName;
             massName = new char[( strlen( tkname.c_str() ) + 4 )];
             massName = strcpy( massName, tkname.c_str() );
             massName = strcat( massName, "Mass" );
             massHisto[ik] = new TH1F( massName, massName, 3000, 0.0, 5.0 );
             delete massName;
         }
 
         count = 1;
         std::vector<int> temp( parser.getNToken() / 2, 0 );
         std::vector<int> tempB( parser.getNToken() / 2, 0 );
         std::vector<int> tempB0B( parser.getNToken() / 2, 0 );
         std::vector<int> tempB0( parser.getNToken() / 2, 0 );
         std::vector<int> tempBP( parser.getNToken() / 2, 0 );
         std::vector<int> tempBM( parser.getNToken() / 2, 0 );
         std::vector<int> tempD( parser.getNToken() / 2, 0 );
         std::vector<int> tempD0B( parser.getNToken() / 2, 0 );
         std::vector<int> tempD0( parser.getNToken() / 2, 0 );
         std::vector<int> tempDP( parser.getNToken() / 2, 0 );
         std::vector<int> tempDM( parser.getNToken() / 2, 0 );
 
         do {
             //EvtGenReport(EVTGEN_INFO,"EvtGen") << "new event\n";
             if ( count == 1000 * ( count / 1000 ) ) {
                 EvtGenReport( EVTGEN_INFO, "EvtGen" ) << count << std::endl;
                 //EvtGenReport(EVTGEN_INFO,"EvtGen") << HepRandom::getTheSeed()<<std::endl;
             }
             EvtVector4R p_init( sqrt( EvtPDL::getMass( UPS4 ) *
                                           EvtPDL::getMass( UPS4 ) +
                                       5.9 * 5.9 ),
                                 0.0, 0.0, 5.9 );
 
             EvtParticle* root_part = 0;
             if ( neventOrig > 0 ) {
                 root_part = EvtParticleFactory::particleFactory( UPS4, p_init );
             } else {
                 root_part = EvtParticleFactory::particleFactory( VPHO, p_init );
             }
 
             root_part->setVectorSpinDensity();
 
             myGenerator.generateDecay( root_part );
 
             //EvtStdHep stdhep;
             //stdhep.init();
             //root_part->makeStdHep(stdhep);
             //EvtGenReport(EVTGEN_INFO,"EvtGen") <<stdhep<<std::endl;
             //EvtGenReport(EVTGEN_INFO,"EvtGen") <<secondary<<std::endl;
             std::string token;
             int itok;
             for ( itok = 0; itok < ( parser.getNToken() / 2 ); itok++ ) {
                 token = parser.getToken( 2 * itok );
                 //temp[itok]+=countInclusive(token,root_part);
                 temp[itok] += countInclusive( token, root_part, histo1[itok],
                                               massHisto[itok] );
                 tempB[itok] += countInclusiveParent( token, root_part, theBs,
                                                      histo2[itok] );
                 tempB0[itok] += countInclusiveSubTree( token, root_part, theB0 );
                 tempB0B[itok] += countInclusiveSubTree( token, root_part, theB0B );
                 tempBP[itok] += countInclusiveSubTree( token, root_part, theBP );
                 tempBM[itok] += countInclusiveSubTree( token, root_part, theBM );
                 //	  tempD[itok]+=countInclusiveParent(token,root_part,theDs);
                 //	  tempD0[itok]+=countInclusiveSubTree(token,root_part,theD0);
                 //	  tempD0B[itok]+=countInclusiveSubTree(token,root_part,theD0B);
                 //	  tempDP[itok]+=countInclusiveSubTree(token,root_part,theDP);
                 //	  tempDM[itok]+=countInclusiveSubTree(token,root_part,theDM);
             }
 
             //	numd0+=countInclusive("D0",root_part);
             //	numd0b+=countInclusive("anti-D0",root_part);
             //	numdp+=countInclusive("D+",root_part);
             //	numdm+=countInclusive("D-",root_part);
 
             //	root_part->printTree();
             root_part->deleteTree();
         } while ( count++ < nevent );
 
         int itok;
         std::string token;
         for ( itok = 0; itok < ( parser.getNToken() / 2 ); itok++ ) {
             token = parser.getToken( 2 * itok );
             float br = 0.5 * float( temp[itok] ) / float( nevent );
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << "Found " << temp[itok] << " " << token.c_str() << " in "
                 << nevent << " events. Average number of " << token.c_str()
                 << " per B meson=" << br << std::endl;
 
             br = 0.5 * float( tempB[itok] ) / float( nevent );
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << "Found " << tempB[itok] << " " << token.c_str()
                 << " produced directly in decays of B mesons avg. br.fr.=" << br
                 << std::endl;
             br = 2.0 * float( tempB0[itok] ) / float( nevent );
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << "Found " << tempB0[itok] << " " << token.c_str()
                 << " in decay tree of B0, br.fr.=" << br << std::endl;
             br = 2.0 * float( tempB0B[itok] ) / float( nevent );
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << "Found " << tempB0B[itok] << " " << token.c_str()
                 << " in decay tree of anti-B0, br.fr.=" << br << std::endl;
             br = 2.0 * float( tempBP[itok] ) / float( nevent );
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << "Found " << tempBP[itok] << " " << token.c_str()
                 << " in decay tree of B+, br.fr.=" << br << std::endl;
             br = 2.0 * float( tempBM[itok] ) / float( nevent );
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << "Found " << tempBM[itok] << " " << token.c_str()
                 << " in decay tree of B-,  br.fr.=" << br << std::endl;
 
             //	br=0.5*float(tempD[itok])/float(numd0+numd0b+numdm+numdp);
             //	EvtGenReport(EVTGEN_INFO,"EvtGen") << "Found "<<tempD[itok]<<" "<<token
             //	     << " produced directly in decays of D mesons avg. br.fr.="
             //	     <<br<<std::endl;
             //	br=2.0*float(tempD0[itok])/float(numd0);
             //	EvtGenReport(EVTGEN_INFO,"EvtGen") << "Found "<<tempD0[itok]<<" "<<token
             //	     << " in decay of D0,  br.fr.="<<br<<std::endl;
             //	br=2.0*float(tempD0B[itok])/float(numd0b);
             //	EvtGenReport(EVTGEN_INFO,"EvtGen") << "Found "<<tempD0B[itok]<<" "<<token
             //	     << " in decay of anti-D0, br.fr.="<<br<<std::endl;
             //	br=2.0*float(tempDP[itok])/float(numdp);
             //	EvtGenReport(EVTGEN_INFO,"EvtGen") << "Found "<<tempDP[itok]<<" "<<token
             //	     << " in decay of D+,  br.fr.="<<br<<std::endl;
             //	br=2.0*float(tempDM[itok])/float(numdm);
             //	EvtGenReport(EVTGEN_INFO,"EvtGen") << "Found "<<tempDM[itok]<<" "<<token
             //	     << " in decay of D-,  br.fr.="<<br<<std::endl;
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << "*******************************************\n";
         }
     } else {
         count = 1;
         do {
             if ( count == 1000 * ( count / 1000 ) ) {
                 EvtGenReport( EVTGEN_INFO, "EvtGen" ) << count << std::endl;
                 //EvtGenReport(EVTGEN_INFO,"EvtGen") << HepRandom::getTheSeed()<<std::endl;
             }
             EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
             EvtParticle* root_part = 0;
             if ( neventOrig > 0 ) {
                 root_part = EvtParticleFactory::particleFactory( UPS4, p_init );
             } else {
                 root_part = EvtParticleFactory::particleFactory( VPHO, p_init );
             }
 
             root_part->setVectorSpinDensity();
 
             myGenerator.generateDecay( root_part );
 
             root_part->deleteTree();
 
         } while ( count++ < nevent );
     }
     file->Write();
     file->Close();
 
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runKstarnunu( int nevent, EvtGen& myGenerator )
 {
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
     //static EvtId B0B=EvtPDL::getId(std::string("anti-B0"));
 
     TFile* file = new TFile( "kstarnunu.root", "RECREATE" );
 
     TH1F* q2 = new TH1F( "h1", "q2", 50, 0.0, 25.0 );
     TH1F* enu = new TH1F( "h2", "Neutrino energy", 50, 0.0, 5.0 );
     TH1F* x = new TH1F( "h3", "Total neutrino energy/B mass", 50, 0.5, 0.9 );
 
     int count;
 
     EvtVector4R kstar, nu, nub;
     char udecay_name[100];
 
     strcpy( udecay_name, "exampleFiles/KSTARNUNU.DEC" );
     //EvtGen myGenerator(decay_name,pdttable_name,myRandomEngine);
     myGenerator.readUDecay( udecay_name );
 
     count = 1;
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( B0 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( B0, p_init );
         root_part->setDiagonalSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         kstar = root_part->getDaug( 0 )->getP4Lab();
         nu = root_part->getDaug( 1 )->getP4Lab();
         nub = root_part->getDaug( 2 )->getP4Lab();
 
         q2->Fill( ( nu + nub ).mass2() );
         enu->Fill( nu.get( 0 ) );
         x->Fill( ( nu.get( 0 ) + nub.get( 0 ) ) / root_part->mass() );
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runBsmix( int nevent, EvtGen& myGenerator )
 {
     static EvtId BS0 = EvtPDL::getId( std::string( "B_s0" ) );
     static EvtId BSB = EvtPDL::getId( std::string( "anti-B_s0" ) );
 
     TFile* file = new TFile( "bsmix.root", "RECREATE" );
 
     TH1F* tmix = new TH1F( "h1", "tmix (mm)", 100, 0.0, 5.0 );
     TH1F* tnomix = new TH1F( "h2", "tnomix (mm)", 100, 0.0, 5.0 );
 
     int count;
 
     char udecay_name[100];
     strcpy( udecay_name, "exampleFiles/BSMIX.DEC" );
     //EvtGen myGenerator(decay_name,pdttable_name,myRandomEngine);
     myGenerator.readUDecay( udecay_name );
 
     count = 1;
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( BS0 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( BS0,
                                                                       p_init );
         root_part->setDiagonalSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         double t = root_part->getLifetime();
         int mix = 0;
 
         if ( root_part->getNDaug() == 1 ) {
             if ( root_part->getDaug( 0 )->getId() == BSB ) {
                 mix = 1;
             }
         }
 
         if ( mix == 0 )
             tnomix->Fill( t );
         if ( mix == 1 )
             tmix->Fill( t );
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runSemic( int nevent, EvtGen& myGenerator )
 {
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
 
     static EvtId EP = EvtPDL::getId( std::string( "e+" ) );
     static EvtId EM = EvtPDL::getId( std::string( "e-" ) );
 
     static EvtId DST0 = EvtPDL::getId( std::string( "D*0" ) );
     static EvtId DSTB = EvtPDL::getId( std::string( "anti-D*0" ) );
     static EvtId DSTP = EvtPDL::getId( std::string( "D*+" ) );
     static EvtId DSTM = EvtPDL::getId( std::string( "D*-" ) );
     static EvtId D0 = EvtPDL::getId( std::string( "D0" ) );
     static EvtId D0B = EvtPDL::getId( std::string( "anti-D0" ) );
     static EvtId DP = EvtPDL::getId( std::string( "D+" ) );
     static EvtId DM = EvtPDL::getId( std::string( "D-" ) );
 
     static EvtId D1P1P = EvtPDL::getId( std::string( "D_1+" ) );
     static EvtId D1P1N = EvtPDL::getId( std::string( "D_1-" ) );
     static EvtId D1P10 = EvtPDL::getId( std::string( "D_10" ) );
     static EvtId D1P1B = EvtPDL::getId( std::string( "anti-D_10" ) );
 
     static EvtId D3P2P = EvtPDL::getId( std::string( "D_2*+" ) );
     static EvtId D3P2N = EvtPDL::getId( std::string( "D_2*-" ) );
     static EvtId D3P20 = EvtPDL::getId( std::string( "D_2*0" ) );
     static EvtId D3P2B = EvtPDL::getId( std::string( "anti-D_2*0" ) );
 
     static EvtId D3P1P = EvtPDL::getId( std::string( "D'_1+" ) );
     static EvtId D3P1N = EvtPDL::getId( std::string( "D'_1-" ) );
     static EvtId D3P10 = EvtPDL::getId( std::string( "D'_10" ) );
     static EvtId D3P1B = EvtPDL::getId( std::string( "anti-D'_10" ) );
 
     static EvtId D3P0P = EvtPDL::getId( std::string( "D_0*+" ) );
     static EvtId D3P0N = EvtPDL::getId( std::string( "D_0*-" ) );
     static EvtId D3P00 = EvtPDL::getId( std::string( "D_0*0" ) );
     static EvtId D3P0B = EvtPDL::getId( std::string( "anti-D_0*0" ) );
 
     static EvtId D23S1P = EvtPDL::getId( std::string( "D*(2S)+" ) );
     static EvtId D23S1N = EvtPDL::getId( std::string( "D*(2S)-" ) );
     static EvtId D23S10 = EvtPDL::getId( std::string( "D*(2S)0" ) );
     static EvtId D23S1B = EvtPDL::getId( std::string( "anti-D*(2S)0" ) );
 
     static EvtIdSet radExitDstar( D23S1P, D23S1N, D23S10, D23S1B );
 
     TFile* file = new TFile( "semic.root", "RECREATE" );
 
     TH1F* Dpe_q2 = new TH1F( "h11", "q2 for B0B ->D+ e- nu", 50, 0.0, 12.0 );
     TH1F* Dpe_elep = new TH1F( "h12", "Elep for B0B ->D+ e- nu", 50, 0.0, 2.5 );
     TH1F* Dme_q2 = new TH1F( "h13", "q2 for B0 ->D- e+ nu", 50, 0.0, 12.0 );
     TH1F* Dme_elep = new TH1F( "h14", "Elep for B0 ->D- e+ nu", 50, 0.0, 2.5 );
     TH1F* D0e_q2 = new TH1F( "h15", "q2 for B- ->D0 e- nu", 50, 0.0, 12.0 );
     TH1F* D0e_elep = new TH1F( "h16", "Elep for B- ->D0 e- nu", 50, 0.0, 2.5 );
     TH1F* D0Be_q2 = new TH1F( "h17", "q2 for B+ ->D0B e+ nu", 50, 0.0, 12.0 );
     TH1F* D0Be_elep = new TH1F( "h18", "Elep for B+ ->D0B e+ nu", 50, 0.0, 2.5 );
 
     TH1F* Dstpe_q2 = new TH1F( "h21", "q2 for B0B ->D*+ e- nu", 50, 0.0, 12.0 );
     TH1F* Dstpe_elep = new TH1F( "h22", "Elep for B0B ->D*+ e- nu", 50, 0.0, 2.5 );
     TH1F* Dstme_q2 = new TH1F( "h23", "q2 for B0 ->D*- e+ nu", 50, 0.0, 12.0 );
     TH1F* Dstme_elep = new TH1F( "h24", "Elep for B0 ->D*- e+ nu", 50, 0.0, 2.5 );
     TH1F* Dst0e_q2 = new TH1F( "h25", "q2 for B- ->D*0 e- nu", 50, 0.0, 12.0 );
     TH1F* Dst0e_elep = new TH1F( "h26", "Elep for B*- ->D*0 e- nu", 50, 0.0, 2.5 );
     TH1F* Dst0Be_q2 = new TH1F( "h27", "q2 for B+ ->D*0B e+ nu", 50, 0.0, 12.0 );
     TH1F* Dst0Be_elep = new TH1F( "h28", "Elep for B+ ->D*0B e+ nu", 50, 0.0,
                                   2.5 );
 
     TH1F* D1P1pe_q2 = new TH1F( "h31", "q2 for B0B ->1P1+ e- nu", 50, 0.0, 12.0 );
     TH1F* D1P1pe_elep = new TH1F( "h32", "Elep for B0B ->1P1+ e- nu", 50, 0.0,
                                   2.5 );
     TH1F* D1P1me_q2 = new TH1F( "h33", "q2 for B0 ->1P1- e+ nu", 50, 0.0, 12.0 );
     TH1F* D1P1me_elep = new TH1F( "h34", "Elep for B0 ->1P1- e+ nu", 50, 0.0,
                                   2.5 );
     TH1F* D1P10e_q2 = new TH1F( "h35", "q2 for B- ->1P10 e- nu", 50, 0.0, 12.0 );
     TH1F* D1P10e_elep = new TH1F( "h36", "Elep for B*- ->1P10 e- nu", 50, 0.0,
                                   2.5 );
     TH1F* D1P10Be_q2 = new TH1F( "h37", "q2 for B+ ->1P1B e+ nu", 50, 0.0, 12.0 );
     TH1F* D1P10Be_elep = new TH1F( "h38", "Elep for B+ ->1P1B e+ nu", 50, 0.0,
                                    2.5 );
 
     TH1F* D3P0pe_q2 = new TH1F( "h41", "q2 for B0B ->3P0+ e- nu", 50, 0.0, 12.0 );
     TH1F* D3P0pe_elep = new TH1F( "h42", "Elep for B0B ->3P0+ e- nu", 50, 0.0,
                                   2.5 );
     TH1F* D3P0me_q2 = new TH1F( "h43", "q2 for B0 ->3P0- e+ nu", 50, 0.0, 12.0 );
     TH1F* D3P0me_elep = new TH1F( "h44", "Elep for B0 ->3P0- e+ nu", 50, 0.0,
                                   2.5 );
     TH1F* D3P00e_q2 = new TH1F( "h45", "q2 for B- ->3P00 e- nu", 50, 0.0, 12.0 );
     TH1F* D3P00e_elep = new TH1F( "h46", "Elep for B*- ->3P00 e- nu", 50, 0.0,
                                   2.5 );
     TH1F* D3P00Be_q2 = new TH1F( "h47", "q2 for B+ ->3P0B e+ nu", 50, 0.0, 12.0 );
     TH1F* D3P00Be_elep = new TH1F( "h48", "Elep for B+ ->3P0B e+ nu", 50, 0.0,
                                    2.5 );
 
     TH1F* D3P1pe_q2 = new TH1F( "h51", "q2 for B0B ->3P1+ e- nu", 50, 0.0, 12.0 );
     TH1F* D3P1pe_elep = new TH1F( "h52", "Elep for B0B ->3P1+ e- nu", 50, 0.0,
                                   2.5 );
     TH1F* D3P1me_q2 = new TH1F( "h53", "q2 for B0 ->3P1- e+ nu", 50, 0.0, 12.0 );
     TH1F* D3P1me_elep = new TH1F( "h54", "Elep for B0 ->3P1- e+ nu", 50, 0.0,
                                   2.5 );
     TH1F* D3P10e_q2 = new TH1F( "h55", "q2 for B- ->3P10 e- nu", 50, 0.0, 12.0 );
     TH1F* D3P10e_elep = new TH1F( "h56", "Elep for B*- ->3P10 e- nu", 50, 0.0,
                                   2.5 );
     TH1F* D3P10Be_q2 = new TH1F( "h57", "q2 for B+ ->3P1B e+ nu", 50, 0.0, 12.0 );
     TH1F* D3P10Be_elep = new TH1F( "h58", "Elep for B+ ->3P1B e+ nu", 50, 0.0,
                                    2.5 );
 
     TH1F* D3P2pe_q2 = new TH1F( "h61", "q2 for B0B ->3P2+ e- nu", 50, 0.0, 12.0 );
     TH1F* D3P2pe_elep = new TH1F( "h62", "Elep for B0B ->3P2+ e- nu", 50, 0.0,
                                   2.5 );
     TH1F* D3P2me_q2 = new TH1F( "h63", "q2 for B0 ->3P2- e+ nu", 50, 0.0, 12.0 );
     TH1F* D3P2me_elep = new TH1F( "h64", "Elep for B0 ->3P2- e+ nu", 50, 0.0,
                                   2.5 );
     TH1F* D3P20e_q2 = new TH1F( "h65", "q2 for B- ->3P20 e- nu", 50, 0.0, 12.0 );
     TH1F* D3P20e_elep = new TH1F( "h66", "Elep for B*- ->3P20 e- nu", 50, 0.0,
                                   2.5 );
     TH1F* D3P20Be_q2 = new TH1F( "h67", "q2 for B+ ->3P2B e+ nu", 50, 0.0, 12.0 );
     TH1F* D3P20Be_elep = new TH1F( "h68", "Elep for B+ ->3P2B e+ nu", 50, 0.0,
                                    2.5 );
 
     TH1F* phiL = new TH1F( "h69", "phi", 50, -3.1416, 3.1416 );
 
     int count;
 
     char udecay_name[100];
     strcpy( udecay_name, "exampleFiles/SEMIC.DEC" );
     //EvtGen myGenerator(decay_name,pdttable_name,myRandomEngine);
     myGenerator.readUDecay( udecay_name );
 
     count = 1;
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         int i;
 
         for ( i = 0; i < 2; i++ ) {
             EvtId meson = root_part->getDaug( i )->getDaug( 0 )->getId();
             EvtId lepton = root_part->getDaug( i )->getDaug( 1 )->getId();
             EvtVector4R lep = root_part->getDaug( i )->getDaug( 1 )->getP4Lab();
             phiL->Fill( atan2( lep.get( 1 ), lep.get( 2 ) ) );
             EvtVector4R nu = root_part->getDaug( i )->getDaug( 2 )->getP4Lab();
             double q2 = ( lep + nu ).mass2();
             double elep = root_part->getDaug( i )->getDaug( 1 )->getP4().get( 0 );
             if ( meson == DP && lepton == EM ) {
                 Dpe_q2->Fill( q2 );
                 Dpe_elep->Fill( elep );
             }
             if ( meson == DM && lepton == EP ) {
                 Dme_q2->Fill( q2 );
                 Dme_elep->Fill( elep );
             }
             if ( meson == D0 && lepton == EM ) {
                 D0e_q2->Fill( q2 );
                 D0e_elep->Fill( elep );
             }
             if ( meson == D0B && lepton == EP ) {
                 D0Be_q2->Fill( q2 );
                 D0Be_elep->Fill( elep );
             }
 
             if ( meson == DSTP && lepton == EM ) {
                 Dstpe_q2->Fill( q2 );
                 Dstpe_elep->Fill( elep );
             }
             if ( meson == DSTM && lepton == EP ) {
                 Dstme_q2->Fill( q2 );
                 Dstme_elep->Fill( elep );
             }
             if ( meson == DST0 && lepton == EM ) {
                 Dst0e_q2->Fill( q2 );
                 Dst0e_elep->Fill( elep );
             }
             if ( meson == DSTB && lepton == EP ) {
                 Dst0Be_q2->Fill( q2 );
                 Dst0Be_elep->Fill( elep );
             }
 
             if ( meson == D1P1P && lepton == EM ) {
                 D1P1pe_q2->Fill( q2 );
                 D1P1pe_elep->Fill( elep );
             }
             if ( meson == D1P1N && lepton == EP ) {
                 D1P1me_q2->Fill( q2 );
                 D1P1me_elep->Fill( elep );
             }
             if ( meson == D1P10 && lepton == EM ) {
                 D1P10e_q2->Fill( q2 );
                 D1P10e_elep->Fill( elep );
             }
             if ( meson == D1P1B && lepton == EP ) {
                 D1P10Be_q2->Fill( q2 );
                 D1P10Be_elep->Fill( elep );
             }
 
             if ( meson == D3P0P && lepton == EM ) {
                 D3P0pe_q2->Fill( q2 );
                 D3P0pe_elep->Fill( elep );
             }
             if ( meson == D3P0N && lepton == EP ) {
                 D3P0me_q2->Fill( q2 );
                 D3P0me_elep->Fill( elep );
             }
             if ( meson == D3P00 && lepton == EM ) {
                 D3P00e_q2->Fill( q2 );
                 D3P00e_elep->Fill( elep );
             }
             if ( meson == D3P0B && lepton == EP ) {
                 D3P00Be_q2->Fill( q2 );
                 D3P00Be_elep->Fill( elep );
             }
 
             if ( meson == D3P1P && lepton == EM ) {
                 D3P1pe_q2->Fill( q2 );
                 D3P1pe_elep->Fill( elep );
             }
             if ( meson == D3P1N && lepton == EP ) {
                 D3P1me_q2->Fill( q2 );
                 D3P1me_elep->Fill( elep );
             }
             if ( meson == D3P10 && lepton == EM ) {
                 D3P10e_q2->Fill( q2 );
                 D3P10e_elep->Fill( elep );
             }
             if ( meson == D3P1B && lepton == EP ) {
                 D3P10Be_q2->Fill( q2 );
                 D3P10Be_elep->Fill( elep );
             }
 
             if ( meson == D3P2P && lepton == EM ) {
                 D3P2pe_q2->Fill( q2 );
                 D3P2pe_elep->Fill( elep );
             }
             if ( meson == D3P2N && lepton == EP ) {
                 D3P2me_q2->Fill( q2 );
                 D3P2me_elep->Fill( elep );
             }
             if ( meson == D3P20 && lepton == EM ) {
                 D3P20e_q2->Fill( q2 );
                 D3P20e_elep->Fill( elep );
             }
             if ( meson == D3P2B && lepton == EP ) {
                 D3P20Be_q2->Fill( q2 );
                 D3P20Be_elep->Fill( elep );
             }
         }
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runKstarll( int nevent, EvtGen& myGenerator )
 {
     TFile* file = new TFile( "kstkmm.root", "RECREATE" );
 
     TH2F* _dalitz = new TH2F( "h1", "q^2! vs Elep", 70, 0.0, 3.5, 60, 0.0, 30.0 );
 
     TH1F* _ctl = new TH1F( "h2", "ctl", 50, -1.0, 1.0 );
 
     TH1F* _q2 = new TH1F( "h3", "q2", 50, 0.0, 25.0 );
 
     TH1F* _q2low = new TH1F( "h4", "q2 (low)", 50, 0.0, 1.0 );
     TH1F* _q2lowlow = new TH1F( "h5", "q2 (lowlow)", 50, 0.0, 0.00001 );
 
     TH1F* _phi = new TH1F( "h6", "phi", 50, -EvtConst::pi, EvtConst::pi );
 
     TH1F* _chi = new TH1F( "h7", "chi", 50, 0.0, EvtConst::twoPi );
 
     TH1F* _chictl = new TH1F( "h8", "chictl", 50, 0.0, EvtConst::twoPi );
 
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
 
     int count = 1;
 
     EvtVector4R kstar, l1, l2;
     EvtVector4R k, pi, b;
 
     char udecay_name[100];
     strcpy( udecay_name, "exampleFiles/KSTARLL.DEC" );
     //EvtGen myGenerator(decay_name,pdttable_name,myRandomEngine);
 
     myGenerator.readUDecay( udecay_name );
 
     std::vector<double> q2low( 5 );
     std::vector<double> q2high( 5 );
     std::vector<int> counts( 5 );
 
     //kee
     //int n=4;
     //q2low[0]=0.0;     q2high[0]=4.5;
     //q2low[1]=4.5;     q2high[1]=8.41;
     //q2low[2]=10.24;   q2high[2]=12.96;
     //q2low[3]=14.06;   q2high[3]=30.0;
 
     //kmm
     //int n=4;
     //q2low[0]=0.0;     q2high[0]=4.5;
     //q2low[1]=4.5;     q2high[1]=9.0;
     //q2low[2]=10.24;   q2high[2]=12.96;
     //q2low[3]=14.06;   q2high[3]=30.0;
 
     //K*ee
     int n = 5;
     q2low[0] = 0.0;
     q2high[0] = 0.1;
     q2low[1] = 0.1;
     q2high[1] = 4.5;
     q2low[2] = 4.5;
     q2high[2] = 8.41;
     q2low[3] = 10.24;
     q2high[3] = 12.96;
     q2low[4] = 14.06;
     q2high[4] = 30.0;
 
     //K*mm
     //int n=5;
     //q2low[0]=0.0;     q2high[0]=0.1;
     //q2low[1]=0.1;     q2high[1]=4.5;
     //q2low[2]=4.5;     q2high[2]=9.0;
     //q2low[3]=10.24;   q2high[3]=12.96;
     //q2low[4]=14.06;   q2high[4]=30.0;
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( B0 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( B0, p_init );
         root_part->setDiagonalSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         //    root_part->printTree();
         //root_part->getDaug(0)->printTree();
         //root_part->getDaug(1)->printTree();
         //root_part->getDaug(2)->printTree();
 
         kstar = root_part->getDaug( 0 )->getP4Lab();
         l1 = root_part->getDaug( 1 )->getP4Lab();
         l2 = root_part->getDaug( 2 )->getP4Lab();
 
         b = root_part->getP4();
         k = root_part->getDaug( 0 )->getDaug( 0 )->getP4Lab();
         pi = root_part->getDaug( 0 )->getDaug( 1 )->getP4Lab();
 
         double qsq = ( l1 + l2 ).mass2();
 
         for ( int j = 0; j < n; j++ ) {
             if ( qsq > q2low[j] && qsq < q2high[j] )
                 counts[j]++;
         }
 
         _q2->Fill( ( l1 + l2 ).mass2() );
         _q2low->Fill( ( l1 + l2 ).mass2() );
         _q2lowlow->Fill( ( l1 + l2 ).mass2() );
 
         _ctl->Fill( EvtDecayAngle( ( l1 + l2 + kstar ), ( l1 + l2 ), l1 ) );
 
         _dalitz->Fill( l1.get( 0 ), ( l1 + l2 ).mass2(), 1.0 );
 
         root_part->deleteTree();
 
         _phi->Fill( atan2( l1.get( 1 ), l1.get( 2 ) ) );
 
         _chi->Fill( EvtDecayAngleChi( b, k, pi, l1, l2 ) );
 
         if ( EvtDecayAngle( ( l1 + l2 + kstar ), ( l1 + l2 ), l1 ) > 0 ) {
             _chictl->Fill( EvtDecayAngleChi( b, k, pi, l1, l2 ) );
         }
         EvtGenReport( EVTGEN_INFO, "EvtGen" )
             << "count:" << count << " " << ( l1 + l2 ).mass2() << std::endl;
 
     } while ( count++ < nevent );
 
     for ( int j = 0; j < n; j++ ) {
         std::cout << "[" << q2low[j] << ".." << q2high[j] << "]=" << counts[j]
                   << std::endl;
     }
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runKll( int nevent, EvtGen& myGenerator )
 {
     TFile* file = new TFile( "ksem.root", "RECREATE" );
 
     TH2F* _dalitz = new TH2F( "h1", "q^2! vs Elep", 70, 0.0, 3.5, 60, 0.0, 30.0 );
 
     TH1F* _ctl = new TH1F( "h2", "ctl", 50, -1.0, 1.0 );
 
     TH1F* _q2 = new TH1F( "h3", "q2", 50, 0.0, 25.0 );
 
     TH1F* _q2low = new TH1F( "h4", "q2 (low)", 50, 0.0, 1.0 );
     TH1F* _q2lowlow = new TH1F( "h5", "q2 (lowlow)", 50, 0.0, 0.00001 );
 
     TH1F* _phi = new TH1F( "h6", "phi", 50, -EvtConst::pi, EvtConst::pi );
 
     //  TH1F* _chi  = new TH1F("h7","chi",50,0.0,EvtConst::twoPi);
 
     //  TH1F* _chictl  = new TH1F("h8","chictl",50,0.0,EvtConst::twoPi);
 
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
 
     int count = 1;
 
     EvtVector4R k, l1, l2;
 
     char udecay_name[100];
     strcpy( udecay_name, "exampleFiles/KLL.DEC" );
     //EvtGen myGenerator(decay_name,pdttable_name,myRandomEngine);
 
     myGenerator.readUDecay( udecay_name );
 
     std::vector<double> q2low( 5 );
     std::vector<double> q2high( 5 );
     std::vector<int> counts( 5 );
 
     //kee
     //  int n=4;
     //q2low[0]=0.0;     q2high[0]=4.5;
     //q2low[1]=4.5;     q2high[1]=8.41;
     //q2low[2]=10.24;   q2high[2]=12.96;
     //q2low[3]=14.06;   q2high[3]=30.0;
 
     //kmm
     int n = 4;
     q2low[0] = 0.0;
     q2high[0] = 4.5;
     q2low[1] = 4.5;
     q2high[1] = 9.0;
     q2low[2] = 10.24;
     q2high[2] = 12.96;
     q2low[3] = 14.06;
     q2high[3] = 30.0;
 
     //K*ee
     //int n=5;
     //q2low[0]=0.0;     q2high[0]=0.1;
     //q2low[1]=0.1;     q2high[1]=4.5;
     //q2low[2]=4.5;     q2high[2]=8.41;
     //q2low[3]=10.24;   q2high[3]=12.96;
     //q2low[4]=14.06;   q2high[4]=30.0;
 
     //K*mm
     //int n=5;
     //q2low[0]=0.0;     q2high[0]=0.1;
     //q2low[1]=0.1;     q2high[1]=4.5;
     //q2low[2]=4.5;     q2high[2]=9.0;
     //q2low[3]=10.24;   q2high[3]=12.96;
     //q2low[4]=14.06;   q2high[4]=30.0;
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( B0 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( B0, p_init );
         root_part->setDiagonalSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         //    root_part->printTree();
         //root_part->getDaug(0)->printTree();
         //root_part->getDaug(1)->printTree();
         //root_part->getDaug(2)->printTree();
 
         k = root_part->getDaug( 0 )->getP4Lab();
         l1 = root_part->getDaug( 1 )->getP4Lab();
         l2 = root_part->getDaug( 2 )->getP4Lab();
 
         //b=root_part->getP4();
         //    k=root_part->getDaug(0)->getDaug(0)->getP4Lab();
         //    pi=root_part->getDaug(0)->getDaug(1)->getP4Lab();
 
         double qsq = ( l1 + l2 ).mass2();
 
         for ( int j = 0; j < n; j++ ) {
             if ( qsq > q2low[j] && qsq < q2high[j] )
                 counts[j]++;
         }
 
         _q2->Fill( ( l1 + l2 ).mass2() );
         _q2low->Fill( ( l1 + l2 ).mass2() );
         _q2lowlow->Fill( ( l1 + l2 ).mass2() );
 
         _ctl->Fill( EvtDecayAngle( ( l1 + l2 + k ), ( l1 + l2 ), l1 ) );
 
         _dalitz->Fill( l1.get( 0 ), ( l1 + l2 ).mass2(), 1.0 );
 
         root_part->deleteTree();
 
         _phi->Fill( atan2( l1.get( 1 ), l1.get( 2 ) ) );
 
         //_chi->Fill(EvtDecayAngleChi(b,k,pi,l1,l2));
 
         //if (EvtDecayAngle((l1+l2+kstar),(l1+l2),l1)>0){
         //  _chictl->Fill(EvtDecayAngleChi(b,k,pi,l1,l2));
         // }
         EvtGenReport( EVTGEN_INFO, "EvtGen" )
             << "count:" << count << " " << ( l1 + l2 ).mass2() << std::endl;
 
     } while ( count++ < nevent );
 
     for ( int j = 0; j < n; j++ ) {
         std::cout << "[" << q2low[j] << ".." << q2high[j] << "]=" << counts[j]
                   << std::endl;
     }
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runHll( int nevent, EvtGen& myGenerator, char* mode )
 {
     TString modename = mode;
     TString filename;
     filename = modename;
     filename = filename + "_nnlo.root";
     TFile* file = new TFile( filename, "RECREATE" );
     TString decname;
     decname += modename;
     decname.ToUpper();
     decname = "exampleFiles/" + decname + ".DEC";
     char udecay_name[100];
     strcpy( udecay_name, decname );
 
     TH2F* _dalitz = new TH2F( "h1", "q^2! vs Elep", 70, 0.0, 3.5, 60, 0.0, 30.0 );
 
     TH1F* _ctl = new TH1F( "h2", "ctl", 50, -1.0, 1.0 );
 
     TH1F* _q2 = new TH1F( "h3", "q2", 50, 0.0, 25.0 );
 
     TH1F* _q2low = new TH1F( "h4", "q2 (low)", 50, 0.0, 1.0 );
     TH1F* _q2lowlow = new TH1F( "h5", "q2 (lowlow)", 50, 0.0, 0.00001 );
 
     TH1F* _phi = new TH1F( "h6", "phi", 50, -EvtConst::pi, EvtConst::pi );
 
     TH1F* _chi = new TH1F( "h7", "chi", 50, 0.0, EvtConst::twoPi );
 
     TH1F* _chictl = new TH1F( "h8", "chictl", 50, 0.0, EvtConst::twoPi );
 
     EvtId B;
     if ( modename == "kee" || modename == "kmm" || modename == "kstksee" ||
          modename == "kstksmm" || modename == "piee" || modename == "pimm" ||
          modename == "rhoee" || modename == "rhomm" ) {
         B = EvtPDL::getId( std::string( "B+" ) );
     } else {
         B = EvtPDL::getId( std::string( "B0" ) );
     }
     int count = 1;
 
     EvtVector4R b, h, l1, l2;
     EvtVector4R hdaug1, hdaug2;
 
     myGenerator.readUDecay( udecay_name );
 
     std::vector<double> q2low( 7 );
     std::vector<double> q2high( 7 );
     std::vector<int> counts( 7 );
     int n( 0 );
     if ( modename == "kee" || modename == "ksee" || modename == "piee" ||
          modename == "pi0ee" || modename == "etaee" || modename == "etapee" ) {
         //kee
         n = 6;
         q2low[0] = 0.0;
         q2high[0] = 4.5;
         q2low[1] = 4.5;
         q2high[1] = 8.41;
         q2low[2] = 8.41;
         q2high[2] = 10.24;
         q2low[3] = 10.24;
         q2high[3] = 12.96;
         q2low[4] = 12.96;
         q2high[4] = 14.06;
         q2low[5] = 14.06;
         q2high[5] = 30.0;
     } else if ( modename == "kmm" || modename == "ksmm" || modename == "pimm" ||
                 modename == "pi0mm" || modename == "etamm" ||
                 modename == "etapmm" ) {
         //kmm
         n = 6;
         q2low[0] = 0.0;
         q2high[0] = 4.5;
         q2low[1] = 4.5;
         q2high[1] = 9.0;
         q2low[2] = 9.0;
         q2high[2] = 10.24;
         q2low[3] = 10.24;
         q2high[3] = 12.96;
         q2low[4] = 12.96;
         q2high[4] = 14.06;
         q2low[5] = 14.06;
         q2high[5] = 30.0;
     } else if ( modename == "kstkee" || modename == "kstksee" ||
                 modename == "rhoee" || modename == "rho0ee" ||
                 modename == "omegaee" ) {
         //K*ee
         n = 7;
         q2low[0] = 0.0;
         q2high[0] = 0.1;
         q2low[1] = 0.1;
         q2high[1] = 4.5;
         q2low[2] = 4.5;
         q2high[2] = 8.41;
         q2low[3] = 8.41;
         q2high[3] = 10.24;
         q2low[4] = 10.24;
         q2high[4] = 12.96;
         q2low[5] = 12.96;
         q2high[5] = 14.06;
         q2low[6] = 14.06;
         q2high[6] = 30.0;
     } else if ( modename == "kstkmm" || modename == "kstksmm" ||
                 modename == "rhomm" || modename == "rho0mm" ||
                 modename == "omegamm" ) {
         //K*mm
         n = 7;
         q2low[0] = 0.0;
         q2high[0] = 0.1;
         q2low[1] = 0.1;
         q2high[1] = 4.5;
         q2low[2] = 4.5;
         q2high[2] = 9.0;
         q2low[3] = 9.0;
         q2high[3] = 10.24;
         q2low[4] = 10.24;
         q2high[4] = 12.96;
         q2low[5] = 12.96;
         q2high[5] = 14.06;
         q2low[6] = 14.06;
         q2high[6] = 30.0;
     }
     float q2binlow[n + 1];
     for ( int i = 0; i < n; i++ ) {
         q2binlow[i] = q2low[i];
     }
     q2binlow[n] = 30.0;
 
     TH1F* _q2var = new TH1F( "h9", "q2var", n, q2binlow );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( B ), 0.0, 0.0, 0.0 );
         EvtParticle* root_part = EvtParticleFactory::particleFactory( B, p_init );
         root_part->setDiagonalSpinDensity();
         myGenerator.generateDecay( root_part );
 
         //    root_part->printTree();
         //root_part->getDaug(0)->printTree();
         //root_part->getDaug(1)->printTree();
         //root_part->getDaug(2)->printTree();
 
         h = root_part->getDaug( 0 )->getP4Lab();
         l1 = root_part->getDaug( 1 )->getP4Lab();
         l2 = root_part->getDaug( 2 )->getP4Lab();
         double qsq = ( l1 + l2 ).mass2();
 
         for ( int j = 0; j < n; j++ ) {
             if ( qsq > q2low[j] && qsq < q2high[j] )
                 counts[j]++;
         }
 
         _q2->Fill( ( l1 + l2 ).mass2() );
         _q2var->Fill( ( l1 + l2 ).mass2() );
         _q2low->Fill( ( l1 + l2 ).mass2() );
         _q2lowlow->Fill( ( l1 + l2 ).mass2() );
 
         _ctl->Fill( EvtDecayAngle( ( l1 + l2 + h ), ( l1 + l2 ), l1 ) );
 
         _dalitz->Fill( l1.get( 0 ), ( l1 + l2 ).mass2(), 1.0 );
 
         _phi->Fill( atan2( l1.get( 1 ), l1.get( 2 ) ) );
 
         if ( modename == "kstkee" || modename == "kstkmm" ||
              modename == "kstksee" || modename == "kstksmm" ||
              modename == "rhoee" || modename == "rhomm" ||
              modename == "rho0ee" || modename == "rho0mm" ) {
             b = root_part->getP4();
             hdaug1 = root_part->getDaug( 0 )->getDaug( 0 )->getP4Lab();
             hdaug2 = root_part->getDaug( 0 )->getDaug( 1 )->getP4Lab();
             _chi->Fill( EvtDecayAngleChi( b, hdaug1, hdaug2, l1, l2 ) );
             if ( EvtDecayAngle( ( l1 + l2 + h ), ( l1 + l2 ), l1 ) > 0 ) {
                 _chictl->Fill( EvtDecayAngleChi( b, hdaug1, hdaug2, l1, l2 ) );
             }
         }
         if ( count % 1000 == 0 ) {
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << "count:" << count << " " << ( l1 + l2 ).mass2() << std::endl;
         }
         root_part->deleteTree();
     } while ( count++ < nevent );
 
     for ( int j = 0; j < n; j++ ) {
         std::cout << "[" << q2low[j] << ".." << q2high[j] << "] = " << counts[j]
                   << std::endl;
     }
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runVectorIsr( int nevent, EvtGen& myGenerator )
 {
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
     static EvtId VPHO = EvtPDL::getId( std::string( "vpho" ) );
 
     TFile* file = new TFile( "vectorisr.root", "RECREATE" );
 
     TH1F* cosv = new TH1F( "h1", "Cos vector in e+e- frame", 50, -1.0, 1.0 );
 
     TH1F* cosd1 = new TH1F( "h2", "Cos helang  1st dau of vector", 50, -1.0, 1.0 );
 
     TH1F* cosd1d1 = new TH1F( "h3", "Cos helang  1st dau of 1st dau", 50, -1.0,
                               1.0 );
 
     TH1F* cosd2d1 = new TH1F( "h4", "Cos helang  1st dau of 2nd dau", 50, -1.0,
                               1.0 );
 
     TH2F* d1vsd1d1 = new TH2F( "h5", "Cos helangs  d1 vs d1d1", 20, -1.0, 1.0,
                                20, -1.0, 1.0 );
 
     TH2F* d2vsd2d1 = new TH2F( "h6", "Cos helangs  d2 vs d2d1", 20, -1.0, 1.0,
                                20, -1.0, 1.0 );
 
     TH2F* d1d1vsd2d1 = new TH2F( "h7", "Cos helangs  d1d1 vs d2d1", 20, -1.0,
                                  1.0, 20, -1.0, 1.0 );
 
     TH1F* chidd = new TH1F( "h8", "Chi - angle between decay planes", 60, 0.,
                             360.0 );
 
     TH2F* chi12vsd1d1 = new TH2F( "h9", "Chi 1-2 vs d1d1", 30, 0., 360.0, 20,
                                   -1.0, 1.0 );
 
     TH2F* chi12vsd2d1 = new TH2F( "h10", "Chi 1-2 vs d2d1", 30, 0., 360.0, 20,
                                   -1.0, 1.0 );
 
     TH2F* chi21vsd1d1 = new TH2F( "h11", "Chi 2-1 vs d1d1", 30, 0., 360.0, 20,
                                   -1.0, 1.0 );
 
     TH2F* chi21vsd2d1 = new TH2F( "h12", "Chi 2-1 vs d2d1", 30, 0., 360.0, 20,
                                   -1.0, 1.0 );
 
     int count = 1;
     char udecay_name[100];
     EvtVector4R cm, v, d1, d2, d1d1, d1d2, d2d1, d2d2;
 
     strcpy( udecay_name, "exampleFiles/VECTORISR.DEC" );
     myGenerator.readUDecay( udecay_name );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( VPHO,
                                                                       p_init );
 
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
         cm = root_part->getP4Lab();
         v = root_part->getDaug( 0 )->getP4Lab();
 
         d1 = root_part->getDaug( 0 )->getDaug( 0 )->getP4Lab();
         d2 = root_part->getDaug( 0 )->getDaug( 1 )->getP4Lab();
 
         cosv->Fill( v.get( 3 ) / v.d3mag() );
 
         double cosdecayd1 = EvtDecayAngle( cm, v, d1 );
         double cosdecayd2 = EvtDecayAngle( cm, v, d2 );
         cosd1->Fill( cosdecayd1 );
 
         // now get daughters of the daughters
         //
         // first daughter of first daughter
         if ( root_part->getDaug( 0 )->getDaug( 0 )->getNDaug() >= 2 ) {
             d1d1 = root_part->getDaug( 0 )->getDaug( 0 )->getDaug( 0 )->getP4Lab();
             double cosdecayd1d1 = EvtDecayAngle( v, d1, d1d1 );
             cosd1d1->Fill( cosdecayd1d1 );
             d1vsd1d1->Fill( cosdecayd1, cosdecayd1d1, 1.0 );
         }
 
         // first daughter of second daughter
         if ( root_part->getDaug( 0 )->getDaug( 1 )->getNDaug() >= 2 ) {
             d2d1 = root_part->getDaug( 0 )->getDaug( 1 )->getDaug( 0 )->getP4Lab();
             double cosdecayd2d1 = EvtDecayAngle( v, d2, d2d1 );
             cosd2d1->Fill( cosdecayd2d1 );
             d2vsd2d1->Fill( cosdecayd2, cosdecayd2d1, 1.0 );
 
             if ( root_part->getDaug( 0 )->getDaug( 0 )->getNDaug() >= 2 ) {
                 d1d1 =
                     root_part->getDaug( 0 )->getDaug( 0 )->getDaug( 0 )->getP4Lab();
                 double cosdecayd1d1 = EvtDecayAngle( v, d1, d1d1 );
                 d1d1vsd2d1->Fill( cosdecayd1d1, cosdecayd2d1, 1.0 );
 
                 //second daughters of daughters 1 and 2
                 d1d2 =
                     root_part->getDaug( 0 )->getDaug( 0 )->getDaug( 1 )->getP4Lab();
                 d2d2 =
                     root_part->getDaug( 0 )->getDaug( 1 )->getDaug( 1 )->getP4Lab();
                 double chi21 = 57.29578 *
                                EvtDecayAngleChi( v, d2d1, d2d2, d1d1, d1d2 );
                 double chi12 = 57.29578 *
                                EvtDecayAngleChi( v, d1d1, d1d2, d2d1, d2d2 );
                 chidd->Fill( chi12 );
 
                 chi12vsd1d1->Fill( chi12, cosdecayd1d1, 1.0 );
                 chi12vsd2d1->Fill( chi12, cosdecayd2d1, 1.0 );
 
                 chi21vsd1d1->Fill( chi21, cosdecayd1d1, 1.0 );
                 chi21vsd2d1->Fill( chi21, cosdecayd2d1, 1.0 );
             }
         }
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runBsquark( int nevent, EvtGen& myGenerator )
 {
     static EvtId VPHO = EvtPDL::getId( std::string( "vpho" ) );
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
     static EvtId B0B = EvtPDL::getId( std::string( "anti-B0" ) );
 
     TFile* file = new TFile( "bsquark.root", "RECREATE" );
 
     TH1F* elep = new TH1F( "h1", "Elep", 50, 0.0, 1.5 );
 
     TH1F* q2 = new TH1F( "h2", "q2", 50, 0.0, 3.0 );
 
     TH2F* dalitz = new TH2F( "h3", "q2 vs. Elep", 50, 0.0, 1.5, 50, 0.0, 3.0 );
 
     TH1F* elepbar = new TH1F( "h11", "Elep bar", 50, 0.0, 1.5 );
 
     TH1F* q2bar = new TH1F( "h12", "q2 bar", 50, 0.0, 3.0 );
 
     TH2F* dalitzbar = new TH2F( "h13", "q2 vs. Elep bar", 50, 0.0, 1.5, 50, 0.0,
                                 3.0 );
 
     int count = 1;
     char udecay_name[100];
     EvtVector4R cm, v, d1, d2, d1d1, d1d2, d2d1, d2d2;
 
     strcpy( udecay_name, "exampleFiles/BSQUARK.DEC" );
     myGenerator.readUDecay( udecay_name );
 
     do {
         EvtVector4R p_init( 10.55, 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( VPHO,
                                                                       p_init );
 
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         EvtParticle* p = root_part->nextIter();
 
         while ( p ) {
             if ( p->getId() == B0 ) {
                 //EvtParticle *dstar=p->getDaug(0);
                 EvtParticle* lepton = p->getDaug( 1 );
                 EvtParticle* sneutrino = p->getDaug( 2 );
 
                 //EvtVector4R p4dstar=dstar->getP4();
                 EvtVector4R p4lepton = lepton->getP4();
                 EvtVector4R p4sneutrino = sneutrino->getP4();
 
                 elep->Fill( p4lepton.get( 0 ) );
                 q2->Fill( ( p4lepton + p4sneutrino ).mass2() );
 
                 dalitz->Fill( p4lepton.get( 0 ),
                               ( p4lepton + p4sneutrino ).mass2(), 1.0 );
             }
 
             if ( p->getId() == B0B ) {
                 //EvtParticle *dstar=p->getDaug(0);
                 EvtParticle* lepton = p->getDaug( 1 );
                 EvtParticle* sneutrino = p->getDaug( 2 );
 
                 //EvtVector4R p4dstar=dstar->getP4();
                 EvtVector4R p4lepton = lepton->getP4();
                 EvtVector4R p4sneutrino = sneutrino->getP4();
 
                 elepbar->Fill( p4lepton.get( 0 ) );
                 q2bar->Fill( ( p4lepton + p4sneutrino ).mass2() );
 
                 dalitzbar->Fill( p4lepton.get( 0 ),
                                  ( p4lepton + p4sneutrino ).mass2(), 1.0 );
             }
 
             p = p->nextIter();
         }
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runK3gamma( int nevent, EvtGen& myGenerator )
 {
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
 
     TFile* file = new TFile( "k3gamma.root", "RECREATE" );
 
     TH1F* costheta = new TH1F( "h1", "cosTheta", 100, -1.0, 1.0 );
 
     int count = 1;
     char udecay_name[100];
     EvtVector4R cm, v, d1, d2, d1d1, d1d2, d2d1, d2d2;
 
     strcpy( udecay_name, "exampleFiles/K3GAMMA.DEC" );
     myGenerator.readUDecay( udecay_name );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( B0 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( B0, p_init );
 
         root_part->setDiagonalSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         EvtParticle* k3 = root_part->getDaug( 0 );
         EvtParticle* k = k3->getDaug( 0 );
 
         EvtVector4R p4b = root_part->getP4Lab();
         EvtVector4R p4k3 = k3->getP4Lab();
         EvtVector4R p4k = k->getP4Lab();
 
         costheta->Fill( EvtDecayAngle( p4b, p4k3, p4k ) );
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runLambda( int nevent, EvtGen& myGenerator )
 {
     static EvtId LAMBDA = EvtPDL::getId( std::string( "Lambda0" ) );
 
     TFile* file = new TFile( "lambda.root", "RECREATE" );
 
     TH1F* costheta = new TH1F( "h1", "cosTheta", 100, -1.0, 1.0 );
 
     int count = 1;
     char udecay_name[100];
     EvtVector4R cm, v, d1, d2, d1d1, d1d2, d2d1, d2d2;
 
     strcpy( udecay_name, "exampleFiles/LAMBDA.DEC" );
     myGenerator.readUDecay( udecay_name );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( LAMBDA ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( LAMBDA,
                                                                       p_init );
 
         EvtSpinDensity rho;
 
         rho.setDim( 2 );
         rho.set( 0, 0, 1.0 );
         rho.set( 0, 1, 0.0 );
         rho.set( 1, 0, 0.0 );
         rho.set( 1, 1, 0.0 );
 
         root_part->setSpinDensityForwardHelicityBasis( rho );
 
         myGenerator.generateDecay( root_part );
 
         EvtParticle* p = root_part->getDaug( 0 );
 
         //EvtVector4R p4lambda=root_part->getP4Lab();
         EvtVector4R p4p = p->getP4Lab();
 
         costheta->Fill( p4p.get( 3 ) / p4p.d3mag() );
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runTauTauPiPi( int nevent, EvtGen& myGenerator )
 {
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
     static EvtId VPHO = EvtPDL::getId( std::string( "vpho" ) );
     TFile* file = new TFile( "tautaupipi.root", "RECREATE" );
 
     TH1F* cospi1 = new TH1F( "h1", "cos theta pi1", 50, -1.0, 1.0 );
     TH1F* cospi2 = new TH1F( "h2", "cos theta pi2", 50, -1.0, 1.0 );
     TH1F* costheta = new TH1F( "h3", "cos theta", 50, -1.0, 1.0 );
 
     std::ofstream outmix;
     outmix.open( "tautaupipi.dat" );
 
     int count = 1;
 
     EvtVector4R tau1, tau2, pi1, pi2;
     char udecay_name[100];
 
     strcpy( udecay_name, "exampleFiles/TAUTAUPIPI.DEC" );
     myGenerator.readUDecay( udecay_name );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( VPHO,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         tau1 = root_part->getDaug( 0 )->getP4Lab();
         tau2 = root_part->getDaug( 1 )->getP4Lab();
 
         pi1 = root_part->getDaug( 0 )->getDaug( 0 )->getP4Lab();
         pi2 = root_part->getDaug( 1 )->getDaug( 0 )->getP4Lab();
 
         cospi1->Fill( EvtDecayAngle( tau1 + tau2, tau1, pi1 ) );
         cospi2->Fill( EvtDecayAngle( tau1 + tau2, tau2, pi2 ) );
         costheta->Fill( tau1.get( 3 ) / tau1.d3mag() );
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
 
     outmix.close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runTauTauEE( int nevent, EvtGen& myGenerator )
 {
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
     static EvtId VPHO = EvtPDL::getId( std::string( "vpho" ) );
     TFile* file = new TFile( "tautauee.root", "RECREATE" );
 
     TH1F* e1 = new TH1F( "h1", "e1", 55, 0.0, 5.5 );
     TH1F* e2 = new TH1F( "h2", "e2", 55, 0.0, 5.5 );
     TH2F* e1vse2 = new TH2F( "h3", "e1 vs e2", 55, 0.0, 5.5, 55, 0.0, 5.5 );
 
     int count = 1;
     char udecay_name[100];
 
     strcpy( udecay_name, "exampleFiles/TAUTAUEE.DEC" );
     myGenerator.readUDecay( udecay_name );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( VPHO,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         e1->Fill( root_part->getDaug( 0 )->getDaug( 0 )->getP4Lab().get( 0 ) );
         e2->Fill( root_part->getDaug( 1 )->getDaug( 0 )->getP4Lab().get( 0 ) );
         e1vse2->Fill( root_part->getDaug( 0 )->getDaug( 0 )->getP4Lab().get( 0 ),
                       root_part->getDaug( 1 )->getDaug( 0 )->getP4Lab().get( 0 ),
                       1.0 );
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runTauTau2Pi2Pi( int nevent, EvtGen& myGenerator )
 {
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
     static EvtId VPHO = EvtPDL::getId( std::string( "vpho" ) );
     TFile* file = new TFile( "tautau2pi2pi.root", "RECREATE" );
 
     TH1F* e1 = new TH1F( "h1", "mrho", 200, 0.0, 2.0 );
     TH1F* e2 = new TH1F( "h2", "coshel", 200, -1.0, 1.0 );
 
     int count = 1;
     char udecay_name[100];
 
     strcpy( udecay_name, "exampleFiles/TAUTAU2PI2PI.DEC" );
     myGenerator.readUDecay( udecay_name );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( VPHO,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         EvtVector4R p4tau = root_part->getDaug( 0 )->getP4();
         EvtVector4R p4rho = root_part->getDaug( 0 )->getDaug( 0 )->getP4() +
                             root_part->getDaug( 0 )->getDaug( 1 )->getP4();
         EvtVector4R p4pi = root_part->getDaug( 0 )->getDaug( 0 )->getP4();
 
         e1->Fill( p4rho.mass() );
         double dcostheta = EvtDecayAngle( p4tau, p4rho, p4pi );
         e2->Fill( dcostheta );
 
         p4tau = root_part->getDaug( 1 )->getP4();
         p4rho = root_part->getDaug( 1 )->getDaug( 0 )->getP4() +
                 root_part->getDaug( 1 )->getDaug( 1 )->getP4();
         p4pi = root_part->getDaug( 1 )->getDaug( 0 )->getP4();
 
         e1->Fill( p4rho.mass() );
         dcostheta = EvtDecayAngle( p4tau, p4rho, p4pi );
         e2->Fill( dcostheta );
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runTauTau3Pi3Pi( int nevent, EvtGen& myGenerator )
 {
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
     static EvtId VPHO = EvtPDL::getId( std::string( "vpho" ) );
     TFile* file = new TFile( "tautau3pi3pi.root", "RECREATE" );
 
     TH1F* e1 = new TH1F( "h1", "a1", 200, 0.0, 2.0 );
 
     int count = 1;
     char udecay_name[100];
 
     strcpy( udecay_name, "exampleFiles/TAUTAU3PI3PI.DEC" );
     myGenerator.readUDecay( udecay_name );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( VPHO,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         EvtVector4R p4tau = root_part->getDaug( 0 )->getP4();
         EvtVector4R p4a1 = root_part->getDaug( 0 )->getDaug( 0 )->getP4() +
                            root_part->getDaug( 0 )->getDaug( 1 )->getP4() +
                            root_part->getDaug( 0 )->getDaug( 2 )->getP4();
 
         e1->Fill( p4a1.mass() );
 
         p4tau = root_part->getDaug( 1 )->getP4();
         p4a1 = root_part->getDaug( 1 )->getDaug( 0 )->getP4() +
                root_part->getDaug( 1 )->getDaug( 1 )->getP4() +
                root_part->getDaug( 1 )->getDaug( 2 )->getP4();
 
         e1->Fill( p4a1.mass() );
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runJPsiKstar( int nevent, EvtGen& myGenerator, int modeInt )
 {
     std::ofstream outmix;
     outmix.open( "jpsikstar.dat" );
 
     int count = 1;
 
     char udecay_name[100];
     if ( modeInt == 0 )
         strcpy( udecay_name, "exampleFiles/JPSIKSTAR.DEC" );
     if ( modeInt == 1 )
         strcpy( udecay_name, "exampleFiles/JPSIKSTAR1.DEC" );
     if ( modeInt == 2 )
         strcpy( udecay_name, "exampleFiles/JPSIKSTAR2.DEC" );
     if ( modeInt == 3 )
         strcpy( udecay_name, "exampleFiles/JPSIKSTAR3.DEC" );
     if ( modeInt == 4 )
         strcpy( udecay_name, "exampleFiles/JPSIKSTAR4.DEC" );
 
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
     static EvtId B0B = EvtPDL::getId( std::string( "anti-B0" ) );
 
     myGenerator.readUDecay( udecay_name );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         EvtParticle *btag, *bcp;
 
         if ( root_part->getDaug( 0 )->getNDaug() == 3 ) {
             btag = root_part->getDaug( 0 );
             bcp = root_part->getDaug( 1 );
         } else {
             bcp = root_part->getDaug( 0 );
             btag = root_part->getDaug( 1 );
         }
 
         EvtId tag;
 
         if ( btag->getId() == B0B ) {
             tag = B0;
         } else {
             tag = B0B;
         }
 
         EvtParticle *p_b, *p_psi, *p_kstar, *p_pi0, *p_kz, *p_ep, *p_em;
         EvtVector4R p4_b, p4_psi, p4_kstar, p4_pi0, p4_kz, p4_ep, p4_em;
 
         p_b = bcp;
 
         p_psi = p_b->getDaug( 0 );
         p_kstar = p_b->getDaug( 1 );
 
         p_pi0 = p_kstar->getDaug( 0 );
         p_kz = p_kstar->getDaug( 1 );
 
         p_ep = p_psi->getDaug( 0 );
         p_em = p_psi->getDaug( 1 );
 
         p4_b = p_b->getP4Lab();
         p4_psi = p_psi->getP4Lab();
         p4_kstar = p_kstar->getP4Lab();
         p4_pi0 = p_pi0->getP4Lab();
         p4_kz = p_kz->getP4Lab();
         p4_ep = p_ep->getP4Lab();
         p4_em = p_em->getP4Lab();
 
         outmix << tag.getId() << " ";
         outmix << root_part->getDaug( 0 )->getLifetime() << " ";
         outmix << root_part->getDaug( 1 )->getLifetime() << " ";
         outmix << EvtDecayAngle( p4_b, p4_ep + p4_em, p4_ep ) << " ";
         outmix << EvtDecayAngle( p4_b, p4_pi0 + p4_kz, p4_pi0 ) << " ";
         outmix << EvtDecayAngleChi( p4_b, p4_pi0, p4_kz, p4_ep, p4_em ) << "\n";
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     outmix.close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runSVVCPLH( int nevent, EvtGen& myGenerator )
 {
     TFile* file = new TFile( "svvcplh.root", "RECREATE" );
 
     TH1F* t = new TH1F( "h1", "t", 50, 0.0, 5.0 );
     TH1F* cospsi = new TH1F( "h2", "cos theta e+", 50, -1.0, 1.0 );
     TH1F* cosphi = new TH1F( "h3", "cos theta k+", 50, -1.0, 1.0 );
     TH1F* chi = new TH1F( "h4", "chi", 50, 0.0, 2.0 * EvtConst::pi );
 
     int count = 1;
 
     char udecay_name[100];
     strcpy( udecay_name, "exampleFiles/SVVCPLH.DEC" );
     myGenerator.readUDecay( udecay_name );
 
     static EvtId BS0 = EvtPDL::getId( std::string( "B_s0" ) );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( BS0 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( BS0,
                                                                       p_init );
         root_part->setDiagonalSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         EvtParticle *p_b, *p_psi, *p_phi, *p_kp, *p_km, *p_ep, *p_em;
         EvtVector4R p4_b, p4_psi, p4_phi, p4_kp, p4_km, p4_ep, p4_em;
 
         p_b = root_part;
 
         if ( p_b->getNDaug() == 1 )
             p_b = p_b->getDaug( 0 );
 
         p_psi = p_b->getDaug( 0 );
         p_phi = p_b->getDaug( 1 );
 
         p_kp = p_phi->getDaug( 0 );
         p_km = p_phi->getDaug( 1 );
 
         p_ep = p_psi->getDaug( 0 );
         p_em = p_psi->getDaug( 1 );
 
         p4_b = p_b->getP4Lab();
         p4_psi = p_psi->getP4Lab();
         p4_phi = p_phi->getP4Lab();
         p4_kp = p_kp->getP4Lab();
         p4_km = p_km->getP4Lab();
         p4_ep = p_ep->getP4Lab();
         p4_em = p_em->getP4Lab();
 
         t->Fill( root_part->getLifetime() );
         cospsi->Fill( EvtDecayAngle( p4_b, p4_ep + p4_em, p4_ep ) );
         cosphi->Fill( EvtDecayAngle( p4_b, p4_kp + p4_km, p4_kp ) );
         chi->Fill( EvtDecayAngleChi( p4_b, p4_kp, p4_km, p4_ep, p4_em ) );
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runSVSCPLH( int nevent, EvtGen& myGenerator )
 {
     TFile* file = new TFile( "svscplh.root", "RECREATE" );
 
     TH1F* t = new TH1F( "h1", "t", 200, -5.0, 5.0 );
     TH1F* tB0tag = new TH1F( "h2", "dt B0 tag (ps)", 200, -15.0, 15.0 );
     TH1F* tB0Btag = new TH1F( "h3", "dt B0B tag (ps)", 200, -15.0, 15.0 );
     TH1F* ctheta = new TH1F( "h4", "costheta", 50, -1.0, 1.0 );
 
     int count = 1;
 
     char udecay_name[100];
     strcpy( udecay_name, "exampleFiles/SVSCPLH.DEC" );
     myGenerator.readUDecay( udecay_name );
 
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
     static EvtId B0B = EvtPDL::getId( std::string( "anti-B0" ) );
 
     std::ofstream outmix;
     outmix.open( "svscplh.dat" );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         EvtParticle *p_tag, *p_cp, *p_jpsi, *p_ep;
         EvtVector4R p4_tag, p4_cp, p4_jpsi, p4_ep;
 
         p_tag = root_part->getDaug( 0 );
         p_cp = root_part->getDaug( 1 );
 
         p_jpsi = p_cp->getDaug( 0 );
         p_ep = p_jpsi->getDaug( 0 );
 
         p4_tag = p_tag->getP4Lab();
         p4_cp = p_cp->getP4Lab();
         p4_jpsi = p_jpsi->getP4Lab();
         p4_ep = p_ep->getP4Lab();
 
         double dt = p_cp->getLifetime() - p_tag->getLifetime();
         dt = dt / ( 1e-12 * 3e11 );
 
         t->Fill( dt );
 
         if ( p_tag->getId() == B0 ) {
             tB0tag->Fill( dt );
             outmix << dt << " 1" << std::endl;
         }
         if ( p_tag->getId() == B0B ) {
             tB0Btag->Fill( dt );
             outmix << dt << " -1" << std::endl;
         }
         ctheta->Fill( EvtDecayAngle( p4_cp, p4_jpsi, p4_ep ) );
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     outmix.close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runSSDCP( int nevent, EvtGen& myGenerator )
 {
     TFile* file = new TFile( "ssdcp.root", "RECREATE" );
 
     TH1F* t = new TH1F( "h1", "dt", 100, -15.0, 15.0 );
     TH1F* tB0tag = new TH1F( "h2", "dt B0 tag (ps)", 100, -15.0, 15.0 );
     TH1F* tB0Btag = new TH1F( "h3", "dt B0B tag (ps)", 100, -15.0, 15.0 );
 
     int count = 1;
 
     char udecay_name[100];
     strcpy( udecay_name, "exampleFiles/SSDCP.DEC" );
     myGenerator.readUDecay( udecay_name );
 
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
     static EvtId B0B = EvtPDL::getId( std::string( "anti-B0" ) );
 
     std::ofstream outmix;
 
     do {
         EvtVector4R pinit( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       pinit );
 
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         EvtParticle *p_tag, *p_cp, *p_jpsi;
         EvtVector4R p4_tag, p4_cp, p4_jpsi, p4_ep;
 
         p_tag = root_part->getDaug( 0 );
         p_cp = root_part->getDaug( 1 );
 
         p_jpsi = p_cp->getDaug( 0 );
         //p_ep=p_jpsi->getDaug(0);
 
         p4_tag = p_tag->getP4Lab();
         p4_cp = p_cp->getP4Lab();
         p4_jpsi = p_jpsi->getP4Lab();
         //p4_ep=p_ep->getP4Lab();
 
         double dt = p_cp->getLifetime() - p_tag->getLifetime();
         dt = dt / ( 1e-12 * EvtConst::c );
 
         t->Fill( dt );
 
         if ( p_tag->getId() == B0 ) {
             tB0tag->Fill( dt );
         }
         if ( p_tag->getId() == B0B ) {
             tB0Btag->Fill( dt );
         }
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runKstarstargamma( int nevent, EvtGen& myGenerator )
 {
     TFile* file = new TFile( "kstarstargamma.root", "RECREATE" );
 
     TH1F* m = new TH1F( "h1", "mkpi", 100, 0.5, 2.5 );
 
     TH1F* ctheta = new TH1F( "h2", "ctheta", 100, -1.0, 1.0 );
 
     int count = 1;
 
     myGenerator.readUDecay( "exampleFiles/KSTARSTARGAMMA.DEC" );
 
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
 
     std::ofstream outmix;
 
     do {
         EvtVector4R pinit( EvtPDL::getMass( B0 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( B0, pinit );
 
         root_part->setDiagonalSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         EvtParticle *p_kaon, *p_pion;
         EvtVector4R p4_kaon, p4_pion;
 
         p_kaon = root_part->getDaug( 0 );
         p_pion = root_part->getDaug( 1 );
 
         p4_kaon = p_kaon->getP4Lab();
         p4_pion = p_pion->getP4Lab();
 
         m->Fill( ( p4_kaon + p4_pion ).mass() );
 
         ctheta->Fill( EvtDecayAngle( pinit, p4_kaon + p4_pion, p4_kaon ) );
 
         //EvtGenReport(EVTGEN_INFO,"EvtGen") << "ctheta:"<<EvtDecayAngle(pinit,p4_kaon+p4_pion,p4_kaon)<<std::endl;
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runDSTARPI( int nevent, EvtGen& myGenerator )
 {
     TFile* file = new TFile( "dstarpi.root", "RECREATE" );
 
     TH1F* t = new TH1F( "h1", "dt", 100, -15.0, 15.0 );
     TH1F* tB0tagpip = new TH1F( "h2", "dt B0 tag pi+ (ps)", 100, -15.0, 15.0 );
     TH1F* tB0Btagpip = new TH1F( "h3", "dt B0B tag pi+(ps)", 100, -15.0, 15.0 );
     TH1F* tB0tagpim = new TH1F( "h4", "dt B0 tag pi- (ps)", 100, -15.0, 15.0 );
     TH1F* tB0Btagpim = new TH1F( "h5", "dt B0B tag pi- (ps)", 100, -15.0, 15.0 );
 
     int count = 1;
 
     myGenerator.readUDecay( "exampleFiles/DSTARPI.DEC" );
 
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
     static EvtId B0B = EvtPDL::getId( std::string( "anti-B0" ) );
     static EvtId PIP = EvtPDL::getId( std::string( "pi+" ) );
     static EvtId PIM = EvtPDL::getId( std::string( "pi-" ) );
 
     std::ofstream outmix;
 
     do {
         EvtVector4R pinit( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       pinit );
 
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         EvtParticle *p_tag, *p_cp, *p_pi;
 
         p_tag = root_part->getDaug( 0 );
         p_cp = root_part->getDaug( 1 );
 
         //p_dstar=p_cp->getDaug(1);
         p_pi = p_cp->getDaug( 0 );
 
         double dt = p_cp->getLifetime() - p_tag->getLifetime();
         dt = dt / ( 1e-12 * EvtConst::c );
 
         t->Fill( dt );
 
         if ( p_tag->getId() == B0 ) {
             if ( p_pi->getId() == PIP )
                 tB0tagpip->Fill( dt );
             if ( p_pi->getId() == PIM )
                 tB0tagpim->Fill( dt );
         }
         if ( p_tag->getId() == B0B ) {
             if ( p_pi->getId() == PIP )
                 tB0Btagpip->Fill( dt );
             if ( p_pi->getId() == PIM )
                 tB0Btagpim->Fill( dt );
         }
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runETACPHIPHI( int nevent, EvtGen& myGenerator )
 {
     TFile* file = new TFile( "etacphiphi.root", "RECREATE" );
 
     TH2F* cosphi12 = new TH2F( "h1", "cos phi1 vs phi2", 50, -1.0, 1.0, 50,
                                -1.0, 1.0 );
     TH1F* cosphi1 = new TH1F( "h2", "cos phi1", 50, -1.0, 1.0 );
     TH1F* cosphi2 = new TH1F( "h3", "cos phi2", 50, -1.0, 1.0 );
     TH1F* chi = new TH1F( "h4", "chi", 50, 0.0, 2.0 * EvtConst::pi );
 
     int count = 1;
 
     char udecay_name[100];
     strcpy( udecay_name, "exampleFiles/ETACPHIPHI.DEC" );
     myGenerator.readUDecay( udecay_name );
 
     static EvtId ETAC = EvtPDL::getId( std::string( "eta_c" ) );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( ETAC ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( ETAC,
                                                                       p_init );
         root_part->setDiagonalSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         EvtParticle *p_etac, *p_phi1, *p_phi2, *p_kp1, *p_km1, *p_kp2, *p_km2;
         EvtVector4R p4_etac, p4_phi1, p4_phi2, p4_kp1, p4_km1, p4_kp2, p4_km2;
 
         p_etac = root_part;
 
         p_phi1 = p_etac->getDaug( 0 );
         p_phi2 = p_etac->getDaug( 1 );
 
         p_kp1 = p_phi1->getDaug( 0 );
         p_km1 = p_phi1->getDaug( 1 );
 
         p_kp2 = p_phi2->getDaug( 0 );
         p_km2 = p_phi2->getDaug( 1 );
 
         p4_etac = p_etac->getP4Lab();
         p4_phi1 = p_phi1->getP4Lab();
         p4_phi2 = p_phi2->getP4Lab();
         p4_kp1 = p_kp1->getP4Lab();
         p4_km1 = p_km1->getP4Lab();
         p4_kp2 = p_kp2->getP4Lab();
         p4_km2 = p_km2->getP4Lab();
 
         cosphi12->Fill( EvtDecayAngle( p4_etac, p4_phi1, p4_kp1 ),
                         EvtDecayAngle( p4_etac, p4_phi2, p4_kp2 ), 1.0 );
 
         cosphi1->Fill( EvtDecayAngle( p4_etac, p4_phi1, p4_kp1 ) );
         cosphi2->Fill( EvtDecayAngle( p4_etac, p4_phi2, p4_kp2 ) );
         chi->Fill( EvtDecayAngleChi( p4_etac, p4_kp1, p4_km1, p4_kp2, p4_km2 ) );
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runVVPiPi( int nevent, EvtGen& myGenerator )
 {
     TFile* file = new TFile( "vvpipi.root", "RECREATE" );
 
     TH1F* cospsi = new TH1F( "h1", "cos theta J/psi ", 50, -1.0, 1.0 );
     TH1F* cose = new TH1F( "h2", "cos theta e+ ", 50, -1.0, 1.0 );
     TH1F* mpipi = new TH1F( "h3", "m pipi ", 50, 0.0, 1.0 );
     TH2F* cosevspsi = new TH2F( "h4", "cos theta e+vs cos thete J/psi ", 25,
                                 -1.0, 1.0, 25, -1.0, 1.0 );
     TH1F* cose1 = new TH1F( "h5", "cos theta e+ 1 ", 50, -1.0, 1.0 );
     TH1F* cose2 = new TH1F( "h6", "cos theta e+ 2 ", 50, -1.0, 1.0 );
 
     int count = 1;
 
     char udecay_name[100];
     strcpy( udecay_name, "exampleFiles/VVPIPI.DEC" );
     myGenerator.readUDecay( udecay_name );
 
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( B0 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( B0, p_init );
         root_part->setDiagonalSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         EvtParticle *p_b, *p_psip, *p_psi, *p_ep, *p_pi1, *p_pi2;
         EvtVector4R p4_b, p4_psip, p4_psi, p4_ep, p4_pi1, p4_pi2;
 
         p_b = root_part;
 
         p_psip = p_b->getDaug( 0 );
         p_psi = p_psip->getDaug( 0 );
         p_pi1 = p_psip->getDaug( 1 );
         p_pi2 = p_psip->getDaug( 2 );
         p_ep = p_psi->getDaug( 0 );
 
         p4_b = p_b->getP4Lab();
         p4_psip = p_psip->getP4Lab();
         p4_psi = p_psi->getP4Lab();
         p4_pi1 = p_pi1->getP4Lab();
         p4_pi2 = p_pi2->getP4Lab();
         p4_ep = p_ep->getP4Lab();
 
         cospsi->Fill( EvtDecayAngle( p4_b, p4_psip, p4_psi ) );
         cose->Fill( EvtDecayAngle( p4_psip, p4_psi, p4_ep ) );
         mpipi->Fill( ( p4_pi1 + p4_pi2 ).mass() );
         cosevspsi->Fill( EvtDecayAngle( p4_b, p4_psip, p4_psi ),
                          EvtDecayAngle( p4_psip, p4_psi, p4_ep ), 1.0 );
         if ( std::fabs( EvtDecayAngle( p4_b, p4_psip, p4_psi ) ) > 0.95 ) {
             cose1->Fill( EvtDecayAngle( p4_psip, p4_psi, p4_ep ) );
         }
         if ( std::fabs( EvtDecayAngle( p4_b, p4_psip, p4_psi ) ) < 0.05 ) {
             cose2->Fill( EvtDecayAngle( p4_psip, p4_psi, p4_ep ) );
         }
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runSVVHelAmp( int nevent, EvtGen& myGenerator )
 {
     TFile* file = new TFile( "svvhelamp.root", "RECREATE" );
 
     TH1F* cospip = new TH1F( "h1", "cos theta pi+", 50, -1.0, 1.0 );
     TH1F* cospim = new TH1F( "h2", "cos theta pi-", 50, -1.0, 1.0 );
     TH1F* chi = new TH1F( "h3", "chi pi+ to pi- in D+ direction", 50, 0.0,
                           EvtConst::twoPi );
     TH1F* chicospipp = new TH1F( "h4",
                                  "chi pi+ to pi- in D+ direction (cospip>0)",
                                  50, 0.0, EvtConst::twoPi );
     TH1F* chicospipn = new TH1F( "h5", "chi pi+ to pi- in D+ direction (cospip<0",
                                  50, 0.0, EvtConst::twoPi );
 
     TH1F* chipp = new TH1F( "h6",
                             "chi pi+ to pi- in D+ direction (cospip>0,cospim>0)",
                             50, 0.0, EvtConst::twoPi );
 
     TH1F* chipn = new TH1F( "h7",
                             "chi pi+ to pi- in D+ direction (cospip>0,cospim<0)",
                             50, 0.0, EvtConst::twoPi );
 
     TH1F* chinp = new TH1F( "h8",
                             "chi pi+ to pi- in D+ direction (cospip<0,cospim>0)",
                             50, 0.0, EvtConst::twoPi );
 
     TH1F* chinn = new TH1F( "h9",
                             "chi pi+ to pi- in D+ direction (cospip<0,cospim<0)",
                             50, 0.0, EvtConst::twoPi );
 
     TH1F* chinnnn = new TH1F(
         "h10", "chi pi+ to pi- in D+ direction (cospip<-0.5,cospim<-0.5)", 50,
         0.0, EvtConst::twoPi );
 
     int count = 1;
 
     char udecay_name[100];
     strcpy( udecay_name, "exampleFiles/SVVHELAMP.DEC" );
     myGenerator.readUDecay( udecay_name );
 
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( B0 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( B0, p_init );
         root_part->setDiagonalSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         EvtParticle *p_b, *p_dstp, *p_dstm, *p_pip, *p_pim, *p_d0, *p_d0b;
         EvtVector4R p4_b, p4_dstp, p4_dstm, p4_pip, p4_pim, p4_d0, p4_d0b;
 
         p_b = root_part;
 
         p_dstp = p_b->getDaug( 0 );
         p_dstm = p_b->getDaug( 1 );
 
         p_pip = p_dstp->getDaug( 1 );
         p_pim = p_dstm->getDaug( 1 );
 
         p_d0 = p_dstp->getDaug( 0 );
         p_d0b = p_dstm->getDaug( 0 );
 
         p4_b = p_b->getP4Lab();
         p4_dstp = p_dstp->getP4Lab();
         p4_dstm = p_dstm->getP4Lab();
         p4_pip = p_pip->getP4Lab();
         p4_pim = p_pim->getP4Lab();
         p4_d0 = p_d0->getP4Lab();
         p4_d0b = p_d0b->getP4Lab();
 
         double costhpip = EvtDecayAngle( p4_b, p4_pip + p4_d0, p4_pip );
         double costhpim = EvtDecayAngle( p4_b, p4_pim + p4_d0b, p4_pim );
         double chiang = EvtDecayAngleChi( p4_b, p4_pip, p4_d0, p4_pim, p4_d0b );
 
         cospip->Fill( costhpip );
         cospim->Fill( costhpim );
         chi->Fill( chiang );
         if ( costhpip > 0 )
             chicospipp->Fill( chiang );
         if ( costhpip < 0 )
             chicospipn->Fill( chiang );
 
         if ( costhpip > 0 && costhpim > 0 )
             chipp->Fill( chiang );
         if ( costhpip > 0 && costhpim < 0 )
             chipn->Fill( chiang );
         if ( costhpip < 0 && costhpim > 0 )
             chinp->Fill( chiang );
         if ( costhpip < 0 && costhpim < 0 )
             chinn->Fill( chiang );
         if ( costhpip < -0.5 && costhpim < -0.5 )
             chinnnn->Fill( chiang );
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runPartWave( int nevent, EvtGen& myGenerator )
 {
     TFile* file = new TFile( "partwave.root", "RECREATE" );
 
     TH1F* cospip = new TH1F( "h1", "cos theta pi+", 50, -1.0, 1.0 );
     TH1F* cospim = new TH1F( "h2", "cos theta pi-", 50, -1.0, 1.0 );
     TH1F* chi = new TH1F( "h3", "chi pi+ to pi- in D+ direction", 50, 0.0,
                           EvtConst::twoPi );
     TH1F* chicospipp = new TH1F( "h4",
                                  "chi pi+ to pi- in D+ direction (cospip>0)",
                                  50, 0.0, EvtConst::twoPi );
     TH1F* chicospipn = new TH1F( "h5", "chi pi+ to pi- in D+ direction (cospip<0",
                                  50, 0.0, EvtConst::twoPi );
 
     TH1F* chipp = new TH1F( "h6",
                             "chi pi+ to pi- in D+ direction (cospip>0,cospim>0)",
                             50, 0.0, EvtConst::twoPi );
 
     TH1F* chipn = new TH1F( "h7",
                             "chi pi+ to pi- in D+ direction (cospip>0,cospim<0)",
                             50, 0.0, EvtConst::twoPi );
 
     TH1F* chinp = new TH1F( "h8",
                             "chi pi+ to pi- in D+ direction (cospip<0,cospim>0)",
                             50, 0.0, EvtConst::twoPi );
 
     TH1F* chinn = new TH1F( "h9",
                             "chi pi+ to pi- in D+ direction (cospip<0,cospim<0)",
                             50, 0.0, EvtConst::twoPi );
 
     TH1F* chinnnn = new TH1F(
         "h10", "chi pi+ to pi- in D+ direction (cospip<-0.5,cospim<-0.5)", 50,
         0.0, EvtConst::twoPi );
 
     int count = 1;
 
     char udecay_name[100];
     strcpy( udecay_name, "exampleFiles/PARTWAVE.DEC" );
     myGenerator.readUDecay( udecay_name );
 
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( B0 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( B0, p_init );
         root_part->setDiagonalSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         EvtParticle *p_b, *p_dstp, *p_dstm, *p_pip, *p_pim, *p_d0, *p_d0b;
         EvtVector4R p4_b, p4_dstp, p4_dstm, p4_pip, p4_pim, p4_d0, p4_d0b;
 
         p_b = root_part;
 
         p_dstp = p_b->getDaug( 0 );
         p_dstm = p_b->getDaug( 1 );
 
         p_pip = p_dstp->getDaug( 1 );
         p_pim = p_dstm->getDaug( 1 );
 
         p_d0 = p_dstp->getDaug( 0 );
         p_d0b = p_dstm->getDaug( 0 );
 
         p4_b = p_b->getP4Lab();
         p4_dstp = p_dstp->getP4Lab();
         p4_dstm = p_dstm->getP4Lab();
         p4_pip = p_pip->getP4Lab();
         p4_pim = p_pim->getP4Lab();
         p4_d0 = p_d0->getP4Lab();
         p4_d0b = p_d0b->getP4Lab();
 
         double costhpip = EvtDecayAngle( p4_b, p4_pip + p4_d0, p4_pip );
         double costhpim = EvtDecayAngle( p4_b, p4_pim + p4_d0b, p4_pim );
         double chiang = EvtDecayAngleChi( p4_b, p4_pip, p4_d0, p4_pim, p4_d0b );
 
         cospip->Fill( costhpip );
         cospim->Fill( costhpim );
         chi->Fill( chiang );
         if ( costhpip > 0 )
             chicospipp->Fill( chiang );
         if ( costhpip < 0 )
             chicospipn->Fill( chiang );
 
         if ( costhpip > 0 && costhpim > 0 )
             chipp->Fill( chiang );
         if ( costhpip > 0 && costhpim < 0 )
             chipn->Fill( chiang );
         if ( costhpip < 0 && costhpim > 0 )
             chinp->Fill( chiang );
         if ( costhpip < 0 && costhpim < 0 )
             chinn->Fill( chiang );
         if ( costhpip < -0.5 && costhpim < -0.5 )
             chinnnn->Fill( chiang );
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runPartWave2( int nevent, EvtGen& myGenerator )
 {
     TFile file( "partwave2.root", "RECREATE" );
 
     TH1F* cthetapi = new TH1F( "h1", "cos theta pi", 50, -1.0, 1.0 );
 
     TH1F* cthetapi2 = new TH1F( "h2", "cos theta pi (|cosrho|<0.1)", 50, -1.0,
                                 1.0 );
 
     TH1F* cthetan = new TH1F( "h3", "cos thetan", 50, -1.0, 1.0 );
 
     //TH1F* cthetan2 = new TH1F("h4","cos thetan costhetapi>0 ",
     //					 50,-1.0,1.0);
 
     TH1F* cthetarho = new TH1F( "h4", "cos thetarho ", 50, -1.0, 1.0 );
     int count = 1;
 
     char udecay_name[100];
     strcpy( udecay_name, "exampleFiles/PARTWAVE2.DEC" );
     myGenerator.readUDecay( udecay_name );
 
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( B0 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( B0, p_init );
         root_part->setDiagonalSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         EvtParticle *p_b, *p_jpsi, *p_rho, *p_pi1, *p_pi2;
         EvtVector4R p4_b, p4_jpsi, p4_rho, p4_pi1, p4_pi2;
 
         p_b = root_part;
 
         p_jpsi = root_part->getDaug( 0 );
 
         p_rho = 0;
 
         if ( p_jpsi->getDaug( 0 )->getNDaug() == 2 ) {
             p_rho = p_jpsi->getDaug( 0 );
         }
 
         if ( p_jpsi->getDaug( 1 )->getNDaug() == 2 ) {
             p_rho = p_jpsi->getDaug( 1 );
         }
 
         assert( p_rho != 0 );
 
         p_pi1 = p_rho->getDaug( 0 );
         p_pi2 = p_rho->getDaug( 1 );
 
         p4_b = p_b->getP4Lab();
         p4_jpsi = p_jpsi->getP4Lab();
         p4_rho = p_rho->getP4Lab();
         p4_pi1 = p_pi1->getP4Lab();
         p4_pi2 = p_pi2->getP4Lab();
 
         double costhetan = EvtDecayPlaneNormalAngle( p4_b, p4_jpsi, p4_pi1,
                                                      p4_pi2 );
 
         //EvtGenReport(EVTGEN_INFO,"EvtGen") << "costhetan:"<<costhetan<<std::endl;
 
         cthetan->Fill( costhetan );
 
         double costhpi = EvtDecayAngle( p4_jpsi, p4_rho, p4_pi1 );
 
         double costhrho = EvtDecayAngle( p4_b, p4_jpsi, p4_rho );
 
         //EvtGenReport(EVTGEN_INFO,"EvtGen") << "costhetarho:"<<costhrho<<std::endl;
 
         cthetarho->Fill( costhrho );
 
         //if (((p4_rho.get(3)/p4_rho.d3mag()))<-0.95) cthetan2->Fill( costhetan );
 
         cthetapi->Fill( costhpi );
 
         if ( ( p4_rho.get( 3 ) / p4_rho.d3mag() ) > 0.9 ) {
             cthetapi2->Fill( costhpi );
         }
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file.Write();
     file.Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runTwoBody( int nevent, EvtGen& myGenerator, std::string decFile,
                  std::string rootFile )
 {
     TFile* file = new TFile( rootFile.c_str(), "RECREATE" );
 
     int count = 0;
 
     myGenerator.readUDecay( decFile.c_str() );
 
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
 
     vector<TH1F*> histograms;
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( B0 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( B0, p_init );
         root_part->setDiagonalSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         //root_part->printTree();
 
         myGenerator.generateDecay( root_part );
         int nhist = 0;
 
         EvtParticle* p = root_part;
 
         do {
             int nDaug = p->getNDaug();
 
             if ( !( nDaug == 0 || nDaug == 2 ) ) {
                 EvtGenReport( EVTGEN_INFO, "EvtGen" )
                     << "nDaug=" << nDaug << " but can only handle 0 or 2!"
                     << std::endl;
                 abort();
             }
 
             if ( nDaug == 2 ) {
                 if ( p->getParent() == 0 ) {
                     EvtVector4R p4 = p->getDaug( 0 )->getP4();
                     double ctheta = p4.get( 3 ) / p4.d3mag();
                     double phi = atan2( p4.get( 2 ), p4.get( 1 ) );
                     if ( count == 0 ) {
                         histograms.push_back(
                             new TH1F( "h1", "cos theta", 50, -1.0, 1.0 ) );
                         histograms.push_back( new TH1F(
                             "h2", "phi", 50, -EvtConst::pi, EvtConst::pi ) );
                     }
                     histograms[nhist++]->Fill( ctheta );
                     histograms[nhist++]->Fill( phi );
                 } else {
                     double ctheta = EvtDecayAngle( p->getParent()->getP4Lab(),
                                                    p->getP4Lab(),
                                                    p->getDaug( 0 )->getP4Lab() );
                     if ( count == 0 ) {
                         //	    char* tmp=new char[10];
                         //	    std::ostrstream strm(tmp,9);
                         //	    strm  << (nhist+1) << '\0'<< std::endl;
                         //	    histograms.push_back(new TH1F(TString("h")+tmp,TString("cos theta")+tmp,50,-1.0,1.0));
                         std::ostringstream strm;
                         strm << ( nhist + 1 );
                         histograms.push_back(
                             new TH1F( TString( "h" ) + strm.str().c_str(),
                                       TString( "cos theta" ) + strm.str().c_str(),
                                       50, -1.0, 1.0 ) );
                     }
                     histograms[nhist++]->Fill( ctheta );
                     if ( p->getDaug( 0 )->getNDaug() == 2 ) {
                         double costhetan = EvtDecayPlaneNormalAngle(
                             p->getParent()->getP4Lab(), p->getP4Lab(),
                             p->getDaug( 0 )->getDaug( 0 )->getP4Lab(),
                             p->getDaug( 0 )->getDaug( 1 )->getP4Lab() );
                         if ( count == 0 ) {
                             //	      char* tmp=new char[10];
                             //	      std::ostrstream strm(tmp,9);
                             //	      strm  << (nhist+1) << '\0'<< std::endl;
                             //	      histograms.push_back(new TH1F(TString("h")+tmp,TString("cos thetan")+tmp,50,-1.0,1.0));
                             std::ostringstream strm;
                             strm << ( nhist + 1 );
                             histograms.push_back( new TH1F(
                                 TString( "h" ) + strm.str().c_str(),
                                 TString( "cos theta" ) + strm.str().c_str(), 50,
                                 -1.0, 1.0 ) );
                         }
                         histograms[nhist++]->Fill( costhetan );
                     }
                     if ( p->getDaug( 1 )->getNDaug() == 2 ) {
                         double costhetan = EvtDecayPlaneNormalAngle(
                             p->getParent()->getP4Lab(), p->getP4Lab(),
                             p->getDaug( 1 )->getDaug( 0 )->getP4Lab(),
                             p->getDaug( 1 )->getDaug( 1 )->getP4Lab() );
                         if ( count == 0 ) {
                             //	      char* tmp=new char[10];
                             //	      std::ostrstream strm(tmp,9);
                             //	      strm  << (nhist+1) << '\0'<< std::endl;
                             //	      histograms.push_back(new TH1F(TString("h")+tmp,TString("cos thetan")+tmp,50,-1.0,1.0));
                             std::ostringstream strm;
                             strm << ( nhist + 1 );
                             histograms.push_back( new TH1F(
                                 TString( "h" ) + strm.str().c_str(),
                                 TString( "cos theta" ) + strm.str().c_str(), 50,
                                 -1.0, 1.0 ) );
                         }
                         histograms[nhist++]->Fill( costhetan );
                     }
                 }
             }
 
             p = p->nextIter( root_part );
 
         } while ( p != 0 );
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runPiPi( int nevent, EvtGen& myGenerator )
 {
     std::ofstream outmix;
     outmix.open( "pipi.dat" );
 
     TFile* file = new TFile( "pipi.root", "RECREATE" );
 
     TH1F* tB0Hist = new TH1F( "h1", "dt in B->pipi with B0 tag", 50, -5.0, 5.0 );
     TH1F* tB0BHist = new TH1F( "h2", "dt in B->pipi with B0B tag", 50, -5.0, 5.0 );
 
     TH1F* tB0 = new TH1F( "h3", "t in B->pipi for B0 tag", 25, 0.0, 5.0 );
     TH1F* tB0B = new TH1F( "h4", "t in B->pipi for B0B tag", 25, 0.0, 5.0 );
 
     char udecay_name[100];
     strcpy( udecay_name, "exampleFiles/PIPI.DEC" );
     //EvtGen myGenerator(decay_name,pdttable_name,myRandomEngine);
     myGenerator.readUDecay( udecay_name );
 
     EvtParticle *bcp, *btag;
 
     int count = 1;
 
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
     static EvtId B0B = EvtPDL::getId( std::string( "anti-B0" ) );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         if ( root_part->getDaug( 0 )->getNDaug() == 3 ) {
             btag = root_part->getDaug( 0 );
             bcp = root_part->getDaug( 1 );
         } else {
             bcp = root_part->getDaug( 0 );
             btag = root_part->getDaug( 1 );
         }
 
         EvtId tag;    //cp tag
 
         if ( btag->getId() == B0B ) {
             tag = B0;
         } else {
             tag = B0B;
         }
 
         //  int a1=bcp->getDaug(0)->getId();
 
         if ( tag == B0 )
             tB0Hist->Fill( bcp->getLifetime() - btag->getLifetime() );
         if ( tag == B0 )
             tB0->Fill( btag->getLifetime() );
         if ( tag == B0B )
             tB0BHist->Fill( bcp->getLifetime() - btag->getLifetime() );
         if ( tag == B0B )
             tB0B->Fill( btag->getLifetime() );
 
         outmix << bcp->getLifetime() << " " << btag->getLifetime() << " "
                << tag.getId() << std::endl;
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     outmix.close();
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runA1Pi( int nevent, EvtGen& myGenerator )
 {
     std::ofstream outmix;
     outmix.open( "a1pi.dat" );
 
     int count = 1;
 
     char udecay_name[100];
     strcpy( udecay_name, "exampleFiles/A1PI.DEC" );
     myGenerator.readUDecay( udecay_name );
 
     EvtParticle *bcp, *btag;
     EvtParticle *a1, *rho0, *pi1, *pi2, *pi3, *pi4;
     EvtVector4R p4bcp, p4a1, p4rho0, p4pi1, p4pi2, p4pi3, p4pi4;
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
     static EvtId B0B = EvtPDL::getId( std::string( "anti-B0" ) );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       p_init );
         root_part->setVectorSpinDensity();
         myGenerator.generateDecay( root_part );
 
         if ( root_part->getDaug( 0 )->getNDaug() == 3 ) {
             btag = root_part->getDaug( 0 );
             bcp = root_part->getDaug( 1 );
         } else {
             bcp = root_part->getDaug( 0 );
             btag = root_part->getDaug( 1 );
         }
 
         a1 = bcp->getDaug( 0 );
         pi1 = bcp->getDaug( 1 );
 
         rho0 = a1->getDaug( 0 );
         pi2 = a1->getDaug( 1 );
 
         pi3 = rho0->getDaug( 0 );
         pi4 = rho0->getDaug( 1 );
 
         p4bcp = bcp->getP4Lab();
         p4a1 = a1->getP4Lab();
         p4pi1 = pi1->getP4Lab();
 
         p4rho0 = rho0->getP4Lab();
         p4pi2 = pi2->getP4Lab();
 
         p4pi3 = pi3->getP4Lab();
         p4pi4 = pi4->getP4Lab();
 
         EvtId tag;    //cp tag
 
         if ( btag->getId() == B0B ) {
             tag = B0;
         } else {
             tag = B0B;
         }
 
         outmix << bcp->getLifetime() << " " << btag->getLifetime() << " "
                << EvtDecayAngle( p4bcp, p4rho0 + p4pi2, p4rho0 ) << " "
                << EvtDecayAngle( p4a1, p4pi3 + p4pi4, p4pi3 ) << " "
                << EvtPDL::getStdHep( tag ) << std::endl;
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     outmix.close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runCPTest( int nevent, EvtGen& myGenerator )
 {
     std::ofstream outmix;
     outmix.open( "cptest.dat" );
 
     int count = 1;
 
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
     static EvtId B0B = EvtPDL::getId( std::string( "anti-B0" ) );
 
     char udecay_name[100];
     strcpy( udecay_name, "exampleFiles/CPTEST.DEC" );
     //EvtGen myGenerator(decay_name,pdttable_name,myRandomEngine);
     myGenerator.readUDecay( udecay_name );
 
     EvtParticle *bcp, *btag;
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         if ( root_part->getDaug( 0 )->getNDaug() == 3 ) {
             btag = root_part->getDaug( 0 );
             bcp = root_part->getDaug( 1 );
         } else {
             bcp = root_part->getDaug( 0 );
             btag = root_part->getDaug( 1 );
         }
 
         EvtId tag;    //cp tag
 
         if ( btag->getId() == B0B ) {
             tag = B0;
         } else {
             tag = B0B;
         }
 
         outmix << bcp->getLifetime() << " " << btag->getLifetime() << " "
                << tag.getId() << std::endl;
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     outmix.close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runBtoXsgamma( int nevent, EvtGen& myGenerator )
 {
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
     TFile* file = new TFile( "BtoXsgamma.root", "RECREATE" );
 
     int count = 1;
 
     EvtParticle* root_part;
     EvtVectorParticle* vector_part;
 
     char udecay_name[100];
     strcpy( udecay_name, "exampleFiles/BTOXSGAMMA.DEC" );
 
     myGenerator.readUDecay( udecay_name );
 
     // Plot kinematics for b->s,gamma
     int strangeid, antistrangeid;
     int Bmulti, bId1a, bId1b, bId2a, bId2b, b1Id, b2Id;
     do {
         vector_part = new EvtVectorParticle;
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         vector_part->init( UPS4, p_init );
 
         root_part = (EvtParticle*)vector_part;
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         EvtParticle* B1 = root_part->getDaug( 0 );
         Bmulti = B1->getNDaug();
         if ( Bmulti == 1 )
             B1 = B1->getDaug( 0 );
         EvtId BId1a = B1->getDaug( 0 )->getId();
         bId1a = EvtPDL::getStdHep( BId1a );
         EvtId BId1b = B1->getDaug( 1 )->getId();
         bId1b = EvtPDL::getStdHep( BId1b );
 
         if ( Bmulti == 1 )
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << "B1"
                 << " bId1a=" << bId1a << " bId1b=" << bId1b
                 << " ndaug=" << B1->getNDaug()
                 << " Bid=" << EvtPDL::getStdHep( B1->getId() ) << std::endl;
 
         EvtParticle* B2 = root_part->getDaug( 1 );
         Bmulti = B2->getNDaug();
         if ( Bmulti == 1 )
             B2 = B2->getDaug( 0 );    // B has a daughter which is a string
         EvtId BId2a = B2->getDaug( 0 )->getId();
         bId2a = EvtPDL::getStdHep( BId2a );
         EvtId BId2b = B2->getDaug( 1 )->getId();
         bId2b = EvtPDL::getStdHep( BId2b );
 
         if ( Bmulti == 1 )
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << "B2"
                 << " bId2a=" << bId2a << " bId2b=" << bId2b
                 << " ndaug=" << B2->getNDaug()
                 << " Bid=" << EvtPDL::getStdHep( B2->getId() ) << std::endl;
 
         EvtId B1Id = B1->getId();
         b1Id = EvtPDL::getStdHep( B1Id );
         EvtId B2Id = B2->getId();
         b2Id = EvtPDL::getStdHep( B2Id );
 
         strangeid = 0;
         antistrangeid = 0;
         if ( ( b1Id == 511 ) || ( b1Id == -511 ) || ( b2Id == 511 ) ||
              ( b2Id == -511 ) ) {
             strangeid = 30343;
             antistrangeid = -30343;
         } else if ( ( b1Id == 521 ) || ( b1Id == -521 ) || ( b2Id == 521 ) ||
                     ( b2Id == -521 ) ) {
             strangeid = 30353;
             antistrangeid = -30353;
         } else if ( ( b1Id == 531 ) || ( b1Id == -531 ) || ( b2Id == 531 ) ||
                     ( b2Id == -531 ) ) {
             strangeid = 30363;
             antistrangeid = -30363;
         }
         EvtGenReport( EVTGEN_INFO, "EvtGen" )
             << "bId1a " << bId1a << " bId1b " << bId1b << " bId2a " << bId2a
             << " bId2b " << bId2b << " for event " << count << std::endl;
 
         EvtParticle* Bpeng = 0;
         //int bnum=0;
         int pengcount = 0;
         if ( ( ( bId1a == strangeid ) && ( bId1b == 22 ) ) ||
              ( ( bId1a == antistrangeid ) && ( bId1b == 22 ) ) ||
              ( ( bId1b == strangeid ) && ( bId1a == 22 ) ) ||
              ( ( bId1b == antistrangeid ) && ( bId1a == 22 ) ) ) {
             Bpeng = B1;
             //bnum=1;
             pengcount++;
         }
         if ( ( ( bId2a == strangeid ) && ( bId2b == 22 ) ) ||
              ( ( bId2a == antistrangeid ) && ( bId2b == 22 ) ) ||
              ( ( bId2b == strangeid ) && ( bId2a == 22 ) ) ||
              ( ( bId2b == antistrangeid ) && ( bId2a == 22 ) ) ) {
             Bpeng = B2;
             //bnum=2;
             pengcount++;
         }
         if ( pengcount == 0 ) {
             Bpeng = B1;
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << "No penguin decay for event " << count << std::endl;
             //bnum=0;
         } else if ( pengcount == 2 ) {
             Bpeng = B1;
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << "Two penguin decays in event " << count << std::endl;
             //bnum=0;
         }
         Bmulti = Bpeng->getNDaug();
         EvtParticle* Xs = Bpeng->getDaug( 0 );
         //EvtParticle *gam = Bpeng->getDaug(1);
 
         //EvtVector4R p4Xs = Xs->getP4Lab();
 
         //EvtId BId = Bpeng->getId();
 
         //EvtId XsId = Xs->getId();
         int Xsmulti = Xs->getNDaug();
         //EvtId gamId = gam->getId();
 
         //int bId = EvtPDL::getStdHep(BId);
         //int XId = EvtPDL::getStdHep(XsId);
         //int gId = EvtPDL::getStdHep(gamId);
 
         //float XsMass = p4Xs.mass();
         //double gmass = p4gam.mass();
         //double genergy = p4gam.get(0);
 
         // debug stuff:      EvtGenReport(EVTGEN_INFO,"EvtGen") << "bnum=" << bnum << " pengcount=" << pengcount << " bId=" << bId << " Bmulti=" << Bmulti << " XsId=" << XId << " gId=" << gId << std::endl;
 
         //need to change this to root...I don't have the energy now
         //tuple->column("bnum", bnum);
         //tuple->column("pengcount", pengcount);
         //tuple->column("bId", bId);
         //tuple->column("Bmulti", Bmulti);
         //tuple->column("XsId", XId);
         //tuple->column("gId", gId);
         //tuple->column("XsMass", XsMass);
         //tuple->column("Xsmulti", Xsmulti, 0,"Xs", HTRange<int>(0,200));
         //tuple->column("gmass", gmass);
         //tuple->column("genergy", genergy);
         //HTValOrderedVector<int> XDaugId, XDaugNephewId;
         //HTValOrderedVector<float> XsDaugMass, XsDaugNephewMass;
         int nTot( 0 );
         for ( int i = 0; i < Xsmulti; i++ ) {
             EvtParticle* XsDaug = Xs->getDaug( i );
             //EvtVector4R p4XsDaug = XsDaug->getP4Lab();
             EvtId XsDaugId = XsDaug->getId();
             //XDaugId.push_back(EvtPDL::getStdHep(XsDaugId));
             //XsDaugMass.push_back( p4XsDaug.mass());
 
             int Daumulti = XsDaug->getNDaug();
             if ( abs( EvtPDL::getStdHep( XsDaugId ) ) == 321 ||
                  EvtPDL::getStdHep( XsDaugId ) == 310 ||
                  EvtPDL::getStdHep( XsDaugId ) == 111 ||
                  abs( EvtPDL::getStdHep( XsDaugId ) ) == 211 || Daumulti == 0 ) {
                 nTot++;
                 //EvtVector4R p4XsDaugNephew = XsDaug->getP4Lab();
                 //EvtId XsDaugNephewId =XsDaug->getId() ;
                 //XDaugNephewId.push_back(EvtPDL::getStdHep(XsDaugId));
                 //XsDaugNephewMass.push_back( p4XsDaug.mass());
 
             } else if ( Daumulti != 0 ) {
                 for ( int k = 0; k < Daumulti; k++ ) {
                     EvtParticle* XsDaugNephew = XsDaug->getDaug( k );
                     EvtId XsDaugNephewId = XsDaugNephew->getId();
                     int Nephmulti = XsDaugNephew->getNDaug();
 
                     if ( Nephmulti == 0 ||
                          abs( EvtPDL::getStdHep( XsDaugNephewId ) ) == 321 ||
                          EvtPDL::getStdHep( XsDaugNephewId ) == 310 ||
                          EvtPDL::getStdHep( XsDaugNephewId ) == 111 ||
                          abs( EvtPDL::getStdHep( XsDaugNephewId ) ) == 211 ) {
                         nTot++;
                         //EvtVector4R p4XsDaugNephew = XsDaugNephew->getP4Lab();
                         //XDaugNephewId.push_back(EvtPDL::getStdHep(XsDaugNephewId));
                         //XsDaugNephewMass.push_back( p4XsDaugNephew.mass());
                     } else {
                         for ( int g = 0; g < Nephmulti; g++ ) {
                             nTot++;
                             //EvtParticle *XsDaugNephewNephew = XsDaugNephew->getDaug(g);
                             //EvtVector4R p4XsDaugNephewNephew = XsDaugNephewNephew->getP4Lab();
                             //EvtId XsDaugNephewNephewId = XsDaugNephewNephew->getId();
                             //XDaugNephewId.push_back(EvtPDL::getStdHep(XsDaugNephewNephewId));
                             //XsDaugNephewMass.push_back( p4XsDaugNephewNephew.mass());
                         }
                     }
                 }
             }
         }
         //tuple->column("XsDaugId", XDaugId,"Xsmulti", 0, "Xs");
         //tuple->column("XsDaugMass", XsDaugMass,"Xsmulti", 0, "Xs");
 
         //tuple->column("nTot", nTot, 0,"nTot", HTRange<int>(0,200));
         //tuple->column("XsDaugNephewId", XDaugNephewId,"nTot", 0, "nTot");
         //tuple->column("XsDaugNephewMass", XsDaugNephewMass,"nTot", 0, "nTot");
 
         //tuple->dumpData();
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
 
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "End EvtGen. Ran on " << nevent << " events." << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runBtoK1273gamma( int nevent, EvtGen& myGenerator )
 {
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
     TFile* file = new TFile( "BtoK1273gamma.root", "RECREATE" );
     //HepTuple *tuple = hfile.ntuple("BtoK1273gamma", 1);
 
     int count = 1;
 
     EvtParticle* root_part;
     EvtVectorParticle* vector_part;
 
     char udecay_name[100];
     strcpy( udecay_name, "exampleFiles/BTOK1273GAMMA.DEC" );
 
     myGenerator.readUDecay( udecay_name );
 
     // Plot kinematics for b->s,gamma
     int strangeid, antistrangeid;
     int Bmulti, bId1a, bId1b, bId2a, bId2b, b1Id, b2Id;
     do {
         vector_part = new EvtVectorParticle;
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         vector_part->init( UPS4, p_init );
 
         root_part = (EvtParticle*)vector_part;
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         EvtParticle* B1 = root_part->getDaug( 0 );
         Bmulti = B1->getNDaug();
         if ( Bmulti == 1 )
             B1 = B1->getDaug( 0 );
         EvtId BId1a = B1->getDaug( 0 )->getId();
         bId1a = EvtPDL::getStdHep( BId1a );
         EvtId BId1b = B1->getDaug( 1 )->getId();
         bId1b = EvtPDL::getStdHep( BId1b );
 
         if ( Bmulti == 1 )
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << "B1"
                 << " bId1a=" << bId1a << " bId1b=" << bId1b
                 << " ndaug=" << B1->getNDaug()
                 << " Bid=" << EvtPDL::getStdHep( B1->getId() ) << std::endl;
 
         EvtParticle* B2 = root_part->getDaug( 1 );
         Bmulti = B2->getNDaug();
         if ( Bmulti == 1 )
             B2 = B2->getDaug( 0 );    // B has a daughter which is a string
         EvtId BId2a = B2->getDaug( 0 )->getId();
         bId2a = EvtPDL::getStdHep( BId2a );
         EvtId BId2b = B2->getDaug( 1 )->getId();
         bId2b = EvtPDL::getStdHep( BId2b );
 
         if ( Bmulti == 1 )
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << "B2"
                 << " bId2a=" << bId2a << " bId2b=" << bId2b
                 << " ndaug=" << B2->getNDaug()
                 << " Bid=" << EvtPDL::getStdHep( B2->getId() ) << std::endl;
 
         EvtId B1Id = B1->getId();
         b1Id = EvtPDL::getStdHep( B1Id );
         EvtId B2Id = B2->getId();
         b2Id = EvtPDL::getStdHep( B2Id );
 
         strangeid = 0;
         antistrangeid = 0;
         if ( ( b1Id == 511 ) || ( b1Id == -511 ) || ( b2Id == 511 ) ||
              ( b2Id == -511 ) ) {
             strangeid = 10313;
             antistrangeid = -10313;
         } else if ( ( b1Id == 521 ) || ( b1Id == -521 ) || ( b2Id == 521 ) ||
                     ( b2Id == -521 ) ) {
             strangeid = 10323;
             antistrangeid = -10323;
         }
         EvtGenReport( EVTGEN_INFO, "EvtGen" )
             << "bId1a " << bId1a << " bId1b " << bId1b << " bId2a " << bId2a
             << " bId2b " << bId2b << " for event " << count << std::endl;
 
         EvtParticle* Bpeng = 0;
         //int bnum=0;
         int pengcount = 0;
         if ( ( ( bId1a == strangeid ) && ( bId1b == 22 ) ) ||
              ( ( bId1a == antistrangeid ) && ( bId1b == 22 ) ) ||
              ( ( bId1b == strangeid ) && ( bId1a == 22 ) ) ||
              ( ( bId1b == antistrangeid ) && ( bId1a == 22 ) ) ) {
             Bpeng = B1;
             //bnum=1;
             pengcount++;
         }
         if ( ( ( bId2a == strangeid ) && ( bId2b == 22 ) ) ||
              ( ( bId2a == antistrangeid ) && ( bId2b == 22 ) ) ||
              ( ( bId2b == strangeid ) && ( bId2a == 22 ) ) ||
              ( ( bId2b == antistrangeid ) && ( bId2a == 22 ) ) ) {
             Bpeng = B2;
             //bnum=2;
             pengcount++;
         }
         if ( pengcount == 0 ) {
             Bpeng = B1;
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << "No penguin decay for event " << count << std::endl;
             //bnum=0;
         } else if ( pengcount == 2 ) {
             Bpeng = B1;
             EvtGenReport( EVTGEN_INFO, "EvtGen" )
                 << "Two penguin decays in event " << count << std::endl;
             //bnum=0;
         }
         Bmulti = Bpeng->getNDaug();
         //EvtParticle *Ks = Bpeng->getDaug(0);
         //EvtParticle *gam = Bpeng->getDaug(1);
 
         //EvtVector4R p4Ks = Ks->getP4Lab();
         //const  EvtVector4R& p4gam = gam->getP4(); // gamma 4-mom in parent's rest frame
 
         //EvtId BId = Bpeng->getId();
 
         //EvtId KsId = Ks->getId();
         //int Ksmulti = Ks->getNDaug();
         //EvtId gamId = gam->getId();
 
         //int bId = EvtPDL::getStdHep(BId);
         //int XId = EvtPDL::getStdHep(KsId);
         //int gId = EvtPDL::getStdHep(gamId);
 
         //double KsMass = p4Ks.mass();
         //double gmass = p4gam.mass();
         //double genergy = p4gam.get(0);
 
         // debug stuff:      EvtGenReport(EVTGEN_INFO,"EvtGen") << "bnum=" << bnum << " pengcount=" << pengcount << " bId=" << bId << " Bmulti=" << Bmulti << " KsId=" << XId << " gId=" << gId << std::endl;
 
         //tuple->column("bnum", bnum);
         //tuple->column("pengcount", pengcount);
         //tuple->column("bId", bId);
         //tuple->column("Bmulti", Bmulti);
         //tuple->column("KsId", XId);
         //tuple->column("gId", gId);
         //tuple->column("KsMass", KsMass);
         //tuple->column("Ksmulti", Ksmulti);
         //tuple->column("gmass", gmass);
         //tuple->column("genergy", genergy);
 
         //for(int i=0;i<Ksmulti;i++){
         //EvtParticle *KsDaug = Ks->getDaug(i);
         //EvtVector4R p4KsDaug = KsDaug->getP4Lab();
         //EvtId KsDaugId = KsDaug->getId();
         //int XDaugId = EvtPDL::getStdHep(KsDaugId);
         //double KsDaugMass = p4KsDaug.mass();
         //tuple->column("KsDaugId", XDaugId);
         //tuple->column("KsDaugMass", KsDaugMass);
         //}
 
         //tuple->dumpData();
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
 
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "End EvtGen. Ran on " << nevent << " events." << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runCheckRotBoost()
 {
     EvtDiracSpinor sp1, sp2;
     //Generate ryd/lange random spinors.
     sp1.set( EvtComplex( 1.0, -2.0 ), EvtComplex( 3.0, 1.0 ),
              EvtComplex( -4.5, 0.5 ), EvtComplex( 0.2, -0.5 ) );
     sp2.set( EvtComplex( 0.1, -1.0 ), EvtComplex( 1.2, -0.5 ),
              EvtComplex( 3.6, 1.8 ), EvtComplex( -0.2, -0.6 ) );
 
     EvtComplex s = EvtLeptonSCurrent( sp1, sp2 );
     EvtComplex p = EvtLeptonPCurrent( sp1, sp2 );
     EvtVector4C a = EvtLeptonACurrent( sp1, sp2 );
     EvtVector4C v = EvtLeptonVCurrent( sp1, sp2 );
     EvtVector4C va = EvtLeptonVACurrent( sp1, sp2 );
     EvtTensor4C t = EvtLeptonTCurrent( sp1, sp2 );
 
     //start with boosts...
     EvtVector4R ranBoost( 2.0, 0.4, -0.8, 0.3 );
 
     EvtDiracSpinor sp1Boost = boostTo( sp1, ranBoost );
     EvtDiracSpinor sp2Boost = boostTo( sp2, ranBoost );
 
     EvtComplex sBoost = EvtLeptonSCurrent( sp1Boost, sp2Boost );
     EvtComplex pBoost = EvtLeptonPCurrent( sp1Boost, sp2Boost );
     EvtVector4C aBoost = EvtLeptonACurrent( sp1Boost, sp2Boost );
     EvtVector4C vBoost = EvtLeptonVCurrent( sp1Boost, sp2Boost );
     EvtVector4C vaBoost = EvtLeptonVACurrent( sp1Boost, sp2Boost );
     EvtTensor4C tBoost = EvtLeptonTCurrent( sp1Boost, sp2Boost );
 
     EvtVector4C aDirBoost = boostTo( a, ranBoost );
     EvtVector4C vDirBoost = boostTo( v, ranBoost );
     EvtVector4C vaDirBoost = boostTo( va, ranBoost );
     EvtTensor4C tDirBoost( t );
     tDirBoost.applyBoostTo( ranBoost );
 
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "Comparing after doing a random boost" << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "Scalar " << s << " " << sBoost << s - sBoost << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "PseudoScalar " << p << " " << pBoost << p - pBoost << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "AxialVector " << aDirBoost << " " << aBoost << aDirBoost - aBoost
         << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "Vector " << vDirBoost << " " << vBoost << vDirBoost - vBoost
         << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "V-A " << vaDirBoost << " " << vaBoost << vaDirBoost - vaBoost
         << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "Tensor " << tDirBoost << " " << tBoost << tDirBoost - tBoost
         << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "Done comparing after doing a random boost" << std::endl;
 
     //Now do rotations...
 
     //start with boosts...
     double alpha = 0.4;
     double beta = -0.61;
     double gamma = 3.0;
 
     EvtDiracSpinor sp1Rot = rotateEuler( sp1, alpha, beta, gamma );
     EvtDiracSpinor sp2Rot = rotateEuler( sp2, alpha, beta, gamma );
 
     EvtComplex sRot = EvtLeptonSCurrent( sp1Rot, sp2Rot );
     EvtComplex pRot = EvtLeptonPCurrent( sp1Rot, sp2Rot );
     EvtVector4C aRot = EvtLeptonACurrent( sp1Rot, sp2Rot );
     EvtVector4C vRot = EvtLeptonVCurrent( sp1Rot, sp2Rot );
     EvtVector4C vaRot = EvtLeptonVACurrent( sp1Rot, sp2Rot );
     EvtTensor4C tRot = EvtLeptonTCurrent( sp1Rot, sp2Rot );
 
     EvtVector4C aDirRot( a );
     EvtVector4C vDirRot( v );
     EvtVector4C vaDirRot( va );
     EvtTensor4C tDirRot( t );
     aDirRot.applyRotateEuler( alpha, beta, gamma );
     vDirRot.applyRotateEuler( alpha, beta, gamma );
     vaDirRot.applyRotateEuler( alpha, beta, gamma );
     tDirRot.applyRotateEuler( alpha, beta, gamma );
 
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "Comparing after doing a random rotation" << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "Scalar " << s << " " << sRot << s - sRot << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "PseudoScalar " << p << " " << pRot << p - pRot << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "AxialVector " << aDirRot << " "
                                           << aRot << aDirRot - aRot << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "Vector " << vDirRot << " " << vRot << vDirRot - vRot << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "V-A " << vaDirRot << " " << vaRot << vaDirRot - vaRot << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "Tensor " << tDirRot << " " << tRot << tDirRot - tRot << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" )
         << "Done comparing after doing a random rotation" << std::endl;
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 int countInclusive( std::string name, EvtParticle* root_part, TH1F* mom,
                     TH1F* mass )
 {
     EvtParticle* p = root_part;
     int temp = 0;
     EvtId searchFor = EvtPDL::getId( name );
 
     do {
         EvtId type = p->getId();
         if ( type == searchFor ) {
             temp += 1;
             if ( mom )
                 mom->Fill( p->getP4Lab().d3mag() );
             if ( mass )
                 mass->Fill( p->mass() );
             //if ( theBs.contains(p->getParent()->getId()) ) {
             //dirPsimom->Fill(p->getP4Lab().d3mag());
             //}
             //EvtGenReport(EVTGEN_INFO,"EvtGen") << "LANGE " << p->getP4Lab().d3mag() << " " << p->getP4Lab().get(3)/p->getP4Lab().d3mag() << std::endl;
         }
 
         p = p->nextIter( root_part );
 
     } while ( p != 0 );
 
     return temp;
 }
 
 int countInclusiveSubTree( std::string name, EvtParticle* root_part,
                            EvtIdSet setIds, TH1F* /*mom*/ )
 {
     int temp = 0;
     EvtParticle* p = root_part;
     do {
         if ( setIds.contains( p->getId() ) ) {
             temp += countInclusive( name, p );
         }
 
         //p->printTree();
         p = p->nextIter( root_part );
 
     } while ( p != 0 );
     //EvtGenReport(EVTGEN_INFO,"EvtGen") << "done"<<std::endl;
     return temp;
 }
 
 int countInclusiveParent( std::string name, EvtParticle* root_part,
                           EvtIdSet setIds, TH1F* mom )
 {
     EvtParticle* p = root_part;
     int temp = 0;
 
     EvtId searchFor = EvtPDL::getId( name );
 
     do {
         EvtId type = p->getId();
         if ( type == searchFor ) {
             if ( p->getParent() ) {
                 if ( setIds.contains( p->getParent()->getId() ) ) {
                     temp += 1;
                     if ( mom )
                         mom->Fill( p->getP4Lab().d3mag() );
                 }
             }
         }
 
         p = p->nextIter( root_part );
     } while ( p != 0 );
 
     return temp;
 }
 
 void runBMix( int nevent, EvtGen& myGenerator, std::string userFile,
               std::string rootFile )
 {
     TFile* file = new TFile( rootFile.c_str(), "RECREATE" );
 
     TH1F* b0_b0 = new TH1F( "h1", "dt B0-B0", 100, -15.0, 15.0 );
     TH1F* b0b_b0b = new TH1F( "h2", "dt B0B-B0B", 100, -15.0, 15.0 );
     TH1F* b0b_b0 = new TH1F( "h3", "dt B0B-B0", 100, -15.0, 15.0 );
     TH1F* b0_b0b = new TH1F( "h4", "dt B0-B0B", 100, -15.0, 15.0 );
 
     int count = 1;
 
     myGenerator.readUDecay( userFile.c_str() );
 
     EvtId b0 = EvtPDL::getId( "B0" );
     EvtId b0b = EvtPDL::getId( "anti-B0" );
 
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
 
     std::ofstream outmix;
     TString outFileName( rootFile.c_str() );
     outFileName.ReplaceAll( ".root", ".dat" );
     outmix.open( outFileName.Data() );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         EvtId id1 = root_part->getDaug( 0 )->getId();
         EvtId id2 = root_part->getDaug( 1 )->getId();
 
         double t1 = root_part->getDaug( 0 )->getLifetime();
         double t2 = root_part->getDaug( 1 )->getLifetime();
 
         double dt = ( t1 - t2 ) / ( 1e-12 * 3e11 );
 
         if ( id1 == b0 && id2 == b0 ) {
             b0_b0->Fill( dt );
             outmix << dt << " 1" << std::endl;
         }
         if ( id1 == b0b && id2 == b0b ) {
             b0b_b0b->Fill( dt );
             outmix << dt << " 2" << std::endl;
         }
         if ( id1 == b0b && id2 == b0 ) {
             b0b_b0->Fill( dt );
             outmix << dt << " 0" << std::endl;
         }
         if ( id1 == b0 && id2 == b0b ) {
             b0_b0b->Fill( dt );
             outmix << dt << " 0" << std::endl;
         }
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     outmix.close();
 
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runDDalitz( int nevent, EvtGen& myGenerator )
 {
     TFile* file = new TFile( "ddalitz.root", "RECREATE" );
 
     TH2F* dalitz = new TH2F( "h1", "m^2!?[K-[p]+! vs m^2!?[K-[p]0!", 70, 0.0,
                              3.5, 70, 0.0, 3.5 );
     TH2F* dalitz2 = new TH2F( "h5", "m^2!([p]^-![p]^0!) vs m^2!([K-[p]+!", 100,
                               0.0, 3.5, 100, 0.0, 2.0 );
 
     TH1F* m12 = new TH1F( "h2", "m?[K-[p]+!", 100, 0.0, 3.0 );
     TH1F* m13 = new TH1F( "h3", "m?[K-[p]0!", 100, 0.0, 3.0 );
     TH1F* m23 = new TH1F( "h4", "m?[[p]+[p]0!", 100, 0.0, 2.0 );
 
     int count;
 
     myGenerator.readUDecay( "exampleFiles/DDALITZ.DEC" );
     count = 1;
 
     static EvtId D0 = EvtPDL::getId( std::string( "D0" ) );
 
     std::ofstream outmix;
     outmix.open( "ddalitz.dat" );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( D0 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( D0, p_init );
         root_part->setDiagonalSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         EvtVector4R p1 = root_part->getDaug( 0 )->getP4Lab();
         EvtVector4R p2 = root_part->getDaug( 1 )->getP4Lab();
         EvtVector4R p3 = root_part->getDaug( 2 )->getP4Lab();
 
         dalitz->Fill( ( p1 + p2 ).mass2(), ( p1 + p3 ).mass2(), 1.0 );
         dalitz2->Fill( ( p1 + p2 ).mass2(), ( p2 + p3 ).mass2(), 1.0 );
 
         m12->Fill( ( p1 + p2 ).mass2() );
         m13->Fill( ( p1 + p3 ).mass2() );
         m23->Fill( ( p2 + p3 ).mass2() );
         outmix << ( p1 + p2 ).mass2() << " " << ( p2 + p3 ).mass2() << " "
                << ( p1 + p3 ).mass2() << std::endl;
         root_part->deleteTree();
 
         if ( count == nevent - 1 ) {
             std::ofstream testi( "testi.dat" );
             double val = m12->GetMean();
             double errval = m12->GetMeanError();
             testi << "evtgenlhc_test1  1   " << val << "   " << errval
                   << std::endl;
 
             val = m23->GetMean();
             errval = m23->GetMeanError();
             testi << "evtgenlhc_test1  2   " << val << "   " << errval
                   << std::endl;
         }
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     outmix.close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runPiPiPi( int nevent, EvtGen& myGenerator )
 {
     std::ofstream outmix;
     outmix.open( "pipipi.dat" );
 
     int count;
     EvtVector4R p4pip, p4pim, p4pi0;
 
     myGenerator.readUDecay( "exampleFiles/PIPIPI.DEC" );
 
     count = 1;
 
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         p4pip = root_part->getDaug( 0 )->getDaug( 0 )->getP4Lab();
         p4pim = root_part->getDaug( 0 )->getDaug( 1 )->getP4Lab();
         p4pi0 = root_part->getDaug( 0 )->getDaug( 2 )->getP4Lab();
 
         outmix << root_part->getDaug( 0 )->getLifetime() << " "
                << root_part->getDaug( 1 )->getLifetime() << " ";
         outmix << ( p4pip + p4pim ).mass2() << " " << ( p4pip + p4pi0 ).mass2()
                << std::endl;
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     outmix.close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runBHadronic( int nevent, EvtGen& myGenerator )
 {
     std::ofstream outmix;
     outmix.open( "bhadronic.dat" );
 
     int count;
 
     myGenerator.readUDecay( "exampleFiles/BHADRONIC.DEC" );
 
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
 
     count = 1;
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( B0 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( B0, p_init );
         root_part->setDiagonalSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         EvtParticle* p;
 
         //    root_part->printTree();
 
         p = root_part;
 
         do {
             outmix << p->getId().getId() << " " << p->getP4Lab().d3mag()
                    << std::endl;
             p = p->nextIter();
 
         } while ( p != 0 );
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     outmix.close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runSingleB( int nevent, EvtGen& myGenerator )
 {
     int count;
 
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
 
     count = 1;
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( B0 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( B0, p_init );
         root_part->setDiagonalSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runPiPiPiPi( int nevent, EvtGen& myGenerator )
 {
     std::ofstream outmix;
     outmix.open( "pipipipi.dat" );
 
     int count;
 
     EvtVector4R p4pi1, p4pi2, p4pi3, p4pi4;
 
     myGenerator.readUDecay( "exampleFiles/PIPIPIPI.DEC" );
 
     count = 1;
 
     EvtParticle *bcp, *btag;
 
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
     static EvtId B0B = EvtPDL::getId( std::string( "anti-B0" ) );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         if ( root_part->getDaug( 0 )->getNDaug() == 3 ) {
             btag = root_part->getDaug( 0 );
             bcp = root_part->getDaug( 1 );
         } else {
             bcp = root_part->getDaug( 0 );
             btag = root_part->getDaug( 1 );
         }
 
         EvtId tag;    //cp tag
 
         if ( btag->getId() == B0B ) {
             tag = B0;
         } else {
             tag = B0B;
         }
 
         p4pi1 = bcp->getDaug( 0 )->getP4Lab();
         p4pi2 = bcp->getDaug( 1 )->getP4Lab();
         p4pi3 = bcp->getDaug( 2 )->getP4Lab();
         p4pi4 = bcp->getDaug( 3 )->getP4Lab();
 
         EvtVector4R p4bcp, p4rho0, p4a2;
 
         p4rho0 = p4pi1 + p4pi2;
         p4a2 = p4rho0 + p4pi3;
         p4bcp = p4a2 + p4pi4;
 
         outmix << bcp->getLifetime() << " " << btag->getLifetime() << " "
                << tag.getId() << " " << ( p4pi1 + p4pi2 + p4pi3 ).mass() << " "
                << ( p4pi1 + p4pi2 ).mass() << " "
                << EvtDecayAngle( p4bcp, p4rho0 + p4pi3, p4rho0 ) << " "
                << EvtDecayAngle( p4a2, p4pi1 + p4pi2, p4pi1 ) << std::endl;
 
         root_part->deleteTree();
 
         EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "count:" << count << std::endl;
 
     } while ( count++ < nevent );
 
     outmix.close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runA2Pi( int nevent, EvtGen& myGenerator )
 {
     std::ofstream outmix;
     outmix.open( "a2pi.dat" );
 
     int count;
 
     myGenerator.readUDecay( "exampleFiles/A2PI.DEC" );
 
     EvtParticle *bcp, *btag;
     EvtParticle *a2, *rho0, *pi1, *pi2, *pi3, *pi4;
     EvtVector4R p4bcp, p4a2, p4rho0, p4pi1, p4pi2, p4pi3, p4pi4;
 
     count = 1;
 
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
     static EvtId B0B = EvtPDL::getId( std::string( "anti-B0" ) );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         if ( root_part->getDaug( 0 )->getNDaug() == 3 ) {
             btag = root_part->getDaug( 0 );
             bcp = root_part->getDaug( 1 );
         } else {
             bcp = root_part->getDaug( 0 );
             btag = root_part->getDaug( 1 );
         }
 
         a2 = bcp->getDaug( 0 );
         pi1 = bcp->getDaug( 1 );
 
         rho0 = a2->getDaug( 0 );
         pi2 = a2->getDaug( 1 );
 
         pi3 = rho0->getDaug( 0 );
         pi4 = rho0->getDaug( 1 );
 
         p4bcp = bcp->getP4Lab();
         p4a2 = a2->getP4Lab();
         p4pi1 = pi1->getP4Lab();
 
         p4rho0 = rho0->getP4Lab();
         p4pi2 = pi2->getP4Lab();
 
         p4pi3 = pi3->getP4Lab();
         p4pi4 = pi4->getP4Lab();
 
         EvtId tag;    //cp tag
 
         if ( btag->getId() == B0B ) {
             tag = B0;
         } else {
             tag = B0B;
         }
 
         outmix << bcp->getLifetime() << " " << btag->getLifetime() << " "
                << EvtDecayAngle( p4bcp, p4rho0 + p4pi2, p4rho0 ) << " "
                << EvtDecayAngle( p4a2, p4pi3 + p4pi4, p4pi3 ) << " "
                << EvtPDL::getStdHep( tag ) << std::endl;
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     outmix.close();
 
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runHelAmp( int nevent, EvtGen& myGenerator, std::string userFile,
                 std::string rootFile )
 {
     TFile* file = new TFile( rootFile.c_str(), "RECREATE" );
 
     TH1F* costheta = new TH1F( "h1", "costheta", 100, -1.0, 1.0 );
     TH1F* costheta2 = new TH1F( "h2", "costheta2", 100, -1.0, 1.0 );
 
     int count;
 
     myGenerator.readUDecay( userFile.c_str() );
 
     count = 1;
 
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         EvtVector4R d14 = root_part->getDaug( 0 )->getP4Lab();
         double c = d14.get( 3 ) / d14.d3mag();
         costheta->Fill( c );
 
         EvtVector4R p = root_part->getP4Lab();
         EvtVector4R q = root_part->getDaug( 0 )->getP4Lab();
         EvtVector4R d = root_part->getDaug( 0 )->getDaug( 0 )->getP4Lab();
 
         costheta2->Fill( EvtDecayAngle( p, q, d ) );
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runHelAmp2( int nevent, EvtGen& myGenerator )
 {
     TFile* file = new TFile( "helamp2.root", "RECREATE" );
 
     TH1F* costheta = new TH1F( "h1", "costheta", 100, -1.0, 1.0 );
 
     int count;
 
     myGenerator.readUDecay( "exampleFiles/HELAMP2.DEC" );
 
     count = 1;
 
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         EvtVector4R p = root_part->getDaug( 0 )->getDaug( 0 )->getP4Lab();
         EvtVector4R q =
             root_part->getDaug( 0 )->getDaug( 0 )->getDaug( 0 )->getP4Lab();
         EvtVector4R d = root_part->getDaug( 0 )
                             ->getDaug( 0 )
                             ->getDaug( 0 )
                             ->getDaug( 0 )
                             ->getP4Lab();
 
         costheta->Fill( EvtDecayAngle( p, q, d ) );
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runD2Pi( int nevent, EvtGen& myGenerator )
 {
     TFile* file = new TFile( "d2pi.root", "RECREATE" );
 
     TH1F* cospi = new TH1F( "h1", "cos[Q]?[p]!", 50, -1.0, 1.0 );
     TH1F* ptpi = new TH1F( "h2", "Pt of pion", 50, 0.0, 1.5 );
     TH1F* ppi = new TH1F( "h3", "P?[p]! in [Y](4S) rest frame", 50, 0.0, 1.5 );
 
     int count;
 
     myGenerator.readUDecay( "exampleFiles/D2PI.DEC" );
 
     EvtParticle* b;
     EvtParticle *d2, *pi;
 
     EvtVector4R p4b, p4d2, p4pi;
 
     count = 1;
 
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         b = root_part->getDaug( 0 );
 
         d2 = b->getDaug( 0 );
 
         pi = d2->getDaug( 1 );
 
         p4b = b->getP4Lab();
         p4d2 = d2->getP4Lab();
         p4pi = pi->getP4Lab();
 
         cospi->Fill( EvtDecayAngle( p4b, p4d2, p4pi ) );
         ptpi->Fill( sqrt( p4pi.get( 2 ) * p4pi.get( 2 ) +
                           p4pi.get( 3 ) * p4pi.get( 3 ) ) );
         ppi->Fill( p4pi.d3mag() );
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runPiPiCPT( int nevent, EvtGen& myGenerator )
 {
     std::ofstream outmix;
     outmix.open( "pipicpt.dat" );
 
     int count;
 
     myGenerator.readUDecay( "exampleFiles/PIPICPT.DEC" );
 
     EvtParticle *bcp, *btag;
 
     count = 1;
 
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
     static EvtId B0B = EvtPDL::getId( std::string( "anti-B0" ) );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         if ( root_part->getDaug( 0 )->getNDaug() == 3 ) {
             btag = root_part->getDaug( 0 );
             bcp = root_part->getDaug( 1 );
         } else {
             bcp = root_part->getDaug( 0 );
             btag = root_part->getDaug( 1 );
         }
 
         EvtId tag;    //cp tag
 
         if ( btag->getId() == B0B ) {
             tag = B0;
         } else {
             tag = B0B;
         }
 
         outmix << bcp->getLifetime() << " " << btag->getLifetime() << " "
                << tag.getId() << std::endl;
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     outmix.close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runJpsiKs( int nevent, EvtGen& myGenerator )
 {
     std::ofstream outmix;
     outmix.open( "jpsiks.dat" );
 
     int count;
 
     myGenerator.readUDecay( "exampleFiles/JPSIKS.DEC" );
 
     EvtParticle *bcp, *btag;
 
     count = 1;
 
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
     static EvtId B0 = EvtPDL::getId( std::string( "B0" ) );
     static EvtId B0B = EvtPDL::getId( std::string( "anti-B0" ) );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         if ( root_part->getDaug( 0 )->getNDaug() == 3 ) {
             btag = root_part->getDaug( 0 );
             bcp = root_part->getDaug( 1 );
         } else {
             bcp = root_part->getDaug( 0 );
             btag = root_part->getDaug( 1 );
         }
 
         EvtId tag;    //cp tag
 
         if ( btag->getId() == B0B ) {
             tag = B0;
         } else {
             tag = B0B;
         }
 
         outmix << bcp->getLifetime() << " " << btag->getLifetime() << " "
                << tag.getId() << std::endl;
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     outmix.close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runDump( int nevent, EvtGen& myGenerator )
 {
     int count;
 
     std::ofstream outmix;
     outmix.open( "dump.dat" );
 
     EvtParticle* p;
 
     myGenerator.readUDecay( "exampleFiles/DUMP.DEC" );
 
     count = 1;
 
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
 
     static EvtId PIP = EvtPDL::getId( std::string( "pi+" ) );
     static EvtId PIM = EvtPDL::getId( std::string( "pi-" ) );
 
     static EvtId EP = EvtPDL::getId( std::string( "e+" ) );
     static EvtId KP = EvtPDL::getId( std::string( "K+" ) );
     static EvtId MUP = EvtPDL::getId( std::string( "mu+" ) );
     static EvtId EM = EvtPDL::getId( std::string( "e-" ) );
     static EvtId KM = EvtPDL::getId( std::string( "K-" ) );
     static EvtId MUM = EvtPDL::getId( std::string( "mu-" ) );
     static EvtId GAMM = EvtPDL::getId( std::string( "gamma" ) );
     static EvtId K0L = EvtPDL::getId( std::string( "K_L0" ) );
 
     do {
         if ( count == 100 * ( count / 100 ) ) {
             EvtGenReport( EVTGEN_INFO, "EvtGen" ) << count << std::endl;
         }
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         p = root_part;
 
         EvtParticle* otherb = root_part->getDaug( 1 );
 
         EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "Event:" << count << std::endl;
         root_part->printTree();
 
         outmix << "B"
                << " " << otherb->getP4Lab().get( 0 ) << " "
                << otherb->getP4Lab().get( 1 ) << " "
                << otherb->getP4Lab().get( 2 ) << " "
                << otherb->getP4Lab().get( 3 ) << std::endl;
 
         do {
             if ( p->getId() == PIP || p->getId() == EP || p->getId() == KP ||
                  p->getId() == MUP ) {
                 outmix << "chg +1"
                        << " " << p->getP4Lab().get( 1 ) << " "
                        << p->getP4Lab().get( 2 ) << " "
                        << p->getP4Lab().get( 3 ) << std::endl;
             }
 
             if ( p->getId() == PIM || p->getId() == EM || p->getId() == KM ||
                  p->getId() == MUM ) {
                 outmix << "chg -1"
                        << " " << p->getP4Lab().get( 1 ) << " "
                        << p->getP4Lab().get( 2 ) << " "
                        << p->getP4Lab().get( 3 ) << std::endl;
             }
 
             if ( p->getId() == GAMM || p->getId() == K0L ) {
                 outmix << "neu"
                        << " " << p->getP4Lab().get( 1 ) << " "
                        << p->getP4Lab().get( 2 ) << " "
                        << p->getP4Lab().get( 3 ) << std::endl;
             }
 
             p = p->nextIter();
 
         } while ( p != 0 );
 
         outmix << "event" << std::endl;
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     outmix.close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runGenericCont( int nevent, EvtGen& myGenerator )
 {
     int count;
 
     std::ofstream outmix;
     outmix.open( "genericcont.dat" );
 
     EvtParticle* p;
 
     myGenerator.readUDecay( "exampleFiles/GENERIC.DEC" );
 
     count = 1;
 
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
     static EvtId VPHO = EvtPDL::getId( std::string( "vpho" ) );
 
     do {
         if ( count == 1000 * ( count / 1000 ) ) {
             EvtGenReport( EVTGEN_DEBUG, "EvtGen" ) << count << std::endl;
         }
 
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( VPHO,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         p = root_part;
 
         do {
             outmix << p->getId().getId() << " " << p->getP4Lab().d3mag()
                    << std::endl;
 
             p = p->nextIter();
 
         } while ( p != 0 );
 
         //root_part->printTree();
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     outmix.close();
 
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runD1( int nevent, EvtGen& myGenerator )
 {
     std::ofstream outmix;
     outmix.open( "d1.dat" );
 
     int count = 1;
 
     myGenerator.readUDecay( "exampleFiles/D1.DEC" );
 
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         EvtParticle *p_b, *p_d1, *p_e, *p_nu, *p_pi1, *p_dstar, *p_pi2, *p_d;
         EvtVector4R p4_b, p4_d1, p4_e, p4_nu, p4_pi1, p4_dstar, p4_pi2, p4_d;
 
         // code for analyzing B->D1 e nu ; D1 -> D* pi ; D* -> D pi
 
         p_b = root_part->getDaug( 1 );
 
         p_d1 = p_b->getDaug( 0 );
         p_e = p_b->getDaug( 1 );
         p_nu = p_b->getDaug( 2 );
 
         p_dstar = p_d1->getDaug( 0 );
         p_pi1 = p_d1->getDaug( 1 );
 
         p_d = p_dstar->getDaug( 0 );
         p_pi2 = p_dstar->getDaug( 1 );
 
         p4_b = p_b->getP4Lab();
         p4_d1 = p_d1->getP4Lab();
         p4_e = p_e->getP4Lab();
         p4_nu = p_nu->getP4Lab();
         p4_dstar = p_dstar->getP4Lab();
         p4_pi1 = p_pi1->getP4Lab();
         p4_pi2 = p_pi2->getP4Lab();
         p4_d = p_d->getP4Lab();
 
         outmix << p4_e.get( 0 ) << " ";
         outmix << ( p4_e + p4_nu ) * ( p4_e + p4_nu ) << " ";
         outmix << EvtDecayAngle( p4_b, p4_e + p4_nu, p4_e ) << " ";
         outmix << EvtDecayAngle( p4_b, p4_dstar + p4_pi1, p4_dstar ) << " ";
         outmix << EvtDecayAngle( p4_d1, p4_d + p4_pi2, p4_d ) << " ";
         outmix << EvtDecayAngleChi( p4_b, p4_e, p4_nu, p4_dstar, p4_pi1 ) << "\n";
 
         root_part->deleteTree();
 
         EvtGenReport( EVTGEN_DEBUG, "EvtGen" ) << "count:" << count << std::endl;
 
     } while ( count++ < nevent );
 
     outmix.close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runMix( int nevent, EvtGen& myGenerator )
 {
     std::ofstream outmix;
     outmix.open( "mix.dat" );
 
     int count = 1;
 
     myGenerator.readUDecay( "exampleFiles/MIX.DEC" );
 
     static EvtId UPS4 = EvtPDL::getId( std::string( "Upsilon(4S)" ) );
 
     do {
         EvtVector4R p_init( EvtPDL::getMass( UPS4 ), 0.0, 0.0, 0.0 );
         EvtParticle* root_part = EvtParticleFactory::particleFactory( UPS4,
                                                                       p_init );
         root_part->setVectorSpinDensity();
 
         myGenerator.generateDecay( root_part );
 
         outmix << root_part->getDaug( 0 )->getId().getId() << " ";
         outmix << root_part->getDaug( 0 )->getLifetime() << " ";
         outmix << root_part->getDaug( 1 )->getId().getId() << " ";
         outmix << root_part->getDaug( 1 )->getLifetime() << "\n";
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     outmix.close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runBaryonic( int nEvent, EvtGen& myGenerator )
 {
     TFile* f = new TFile( "baryonic.root", "RECREATE" );
     TH1D* q2Hist = new TH1D( "q2Hist", "q square", 50, 0.0, 25.00 );
 
     EvtId BMINUS = EvtPDL::getId( "B-" );
     EvtVector4R p_init( EvtPDL::getMass( BMINUS ), 0.0, 0.0, 0.0 );
     EvtParticle* root_part;
     myGenerator.readUDecay( "exampleFiles/BARYONIC.DEC" );
 
     EvtVector4R l;
     EvtVector4R p;
     EvtVector4R g;
     EvtVector4R sum;
 
     for ( int i = 0; i < nEvent; ++i ) {
         root_part = EvtParticleFactory::particleFactory( BMINUS, p_init );
         root_part->setDiagonalSpinDensity();
         myGenerator.generateDecay( root_part );
         l = root_part->getDaug( 0 )->getP4Lab();    // lambda momentum
         p = root_part->getDaug( 1 )->getP4Lab();    // pBar momentum
         g = root_part->getDaug( 2 )->getP4Lab();    // gamma momentum
         sum = p + g;
         q2Hist->Fill( sum.mass2() );
         root_part->deleteTree();
     }
     f->Write();
     f->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void runPhspDecaytimeCut( int nevent, EvtGen& myGenerator )
 {
     TFile* file = new TFile( "phspdecaytimecut.root", "RECREATE" );
 
     TH1F* thist = new TH1F( "h1", "t [ps]", 100, 0.0, 10.0 );
 
     int count = 1;
 
     char udecay_name[100];
     strcpy( udecay_name, "exampleFiles/PhspDecaytimeCut.DEC" );
     myGenerator.readUDecay( udecay_name );
 
     static EvtId B = EvtPDL::getId( std::string( "B+" ) );
 
     std::ofstream outmix;
 
     do {
         EvtVector4R pinit( EvtPDL::getMass( B ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( B, pinit );
 
         myGenerator.generateDecay( root_part );
 
         double t = root_part->getLifetime() / ( 1e-12 * EvtConst::c );
         thist->Fill( t );
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
 void run3BPhspRegion( int nevent, EvtGen& myGenerator )
 {
     TFile* file = new TFile( "3BodyPhspRegion.root", "RECREATE" );
 
     TH1F* pxhist = new TH1F( "h1", "p_x ", 100, -3.0, 3.0 );
     TH1F* pyhist = new TH1F( "h2", "p_y ", 100, -3.0, 3.0 );
     TH1F* pzhist = new TH1F( "h3", "p_z ", 100, -3.0, 3.0 );
     TH2F* dalitz = new TH2F( "h4", "Dalitz", 50, 12.5, 27., 50, 0.35, 4.8 );
     TH2F* pxpyhist = new TH2F( "h5", "px-py", 50, -1.8, 1.8, 50, -1.8, 1.8 );
     TH2F* pxpzhist = new TH2F( "h6", "px-pz", 50, -1.8, 1.8, 50, -1.8, 1.8 );
     TH2F* pypzhist = new TH2F( "h7", "py-pz", 50, -1.8, 1.8, 50, -1.8, 1.8 );
 
     int count = 1;
 
     char udecay_name[100];
     strcpy( udecay_name, "exampleFiles/3BodyPhspRegion.DEC" );
     myGenerator.readUDecay( udecay_name );
 
     static EvtId B = EvtPDL::getId( std::string( "B+" ) );
 
     std::ofstream outmix;
 
     do {
         EvtVector4R pinit( EvtPDL::getMass( B ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( B, pinit );
 
         myGenerator.generateDecay( root_part );
 
         EvtParticle* daug1 = root_part->getDaug( 0 );
         EvtParticle* daug2 = root_part->getDaug( 1 );
         EvtParticle* daug3 = root_part->getDaug( 2 );
         pxhist->Fill( daug1->getP4().get( 1 ) );
         pyhist->Fill( daug1->getP4().get( 2 ) );
         pzhist->Fill( daug1->getP4().get( 3 ) );
         pxpyhist->Fill( daug1->getP4().get( 1 ), daug1->getP4().get( 2 ) );
         pxpzhist->Fill( daug1->getP4().get( 1 ), daug1->getP4().get( 3 ) );
         pypzhist->Fill( daug1->getP4().get( 2 ), daug1->getP4().get( 3 ) );
         double m12 = ( daug1->getP4() + daug2->getP4() ).mass();
         double m23 = ( daug2->getP4() + daug3->getP4() ).mass();
         dalitz->Fill( m12 * m12, m23 * m23 );
 
         root_part->deleteTree();
 
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
 
-void runFlatSqDalitz( int nevent, EvtGen& myGenerator )
-{
-    TFile* file = new TFile( "flatSqDalitz.root", "RECREATE" );
-
-    TH2F* dalitz = new TH2F( "h4", "Dalitz", 50, 0.0, 1.0, 50, 0.0, 1.0 );
-
-    int count = 1;
-
-    char udecay_name[100];
-    strcpy( udecay_name, "exampleFiles/flatSqDalitz.dec" );
-    myGenerator.readUDecay( udecay_name );
-
-    static EvtId B = EvtPDL::getId( std::string( "Lambda_b0" ) );
-
-    do {
-        EvtVector4R pinit( EvtPDL::getMass( B ), 0.0, 0.0, 0.0 );
-
-        EvtParticle* root_part = EvtParticleFactory::particleFactory( B, pinit );
-
-        myGenerator.generateDecay( root_part );
-
-        double mB = root_part->mass();
-        double m1 = root_part->getDaug( 0 )->mass();
-        double m2 = root_part->getDaug( 1 )->mass();
-        double m3 = root_part->getDaug( 2 )->mass();
-        double mBSq{ mB * mB };
-        double m1Sq{ m1 * m1 };
-        double m2Sq{ m2 * m2 };
-        double m3Sq{ m3 * m3 };
-
-        EvtParticle* daug1 = root_part->getDaug( 0 );
-        EvtParticle* daug2 = root_part->getDaug( 1 );
-        EvtParticle* daug3 = root_part->getDaug( 2 );
-        double m12 = ( daug1->getP4() + daug2->getP4() ).mass();
-        double m13 = ( daug1->getP4() + daug3->getP4() ).mass();
-        double m12Sq{ m12 * m12 };
-        double m13Sq{ m13 * m13 };
-
-        double m12norm =
-            2 * ( ( m12 - ( m1 + m2 ) ) / ( mB - ( m1 + m2 + m3 ) ) ) - 1;
-        double mPrime = acos( m12norm ) / EvtConst::pi;
-        double en1 = ( m12Sq - m2Sq + m1Sq ) / ( 2.0 * m12 );
-        double en3 = ( mBSq - m12Sq - m3Sq ) / ( 2.0 * m12 );
-        double p1 = std::sqrt( en1 * en1 - m1Sq );
-        double p3 = std::sqrt( en3 * en3 - m3Sq );
-        double cosTheta = ( -m13Sq + m1Sq + m3Sq + 2. * en1 * en3 ) /
-                          ( 2. * p1 * p3 );
-        double thPrime = acos( cosTheta ) / EvtConst::pi;
-
-        dalitz->Fill( mPrime, thPrime );
-
-        root_part->deleteTree();
-    } while ( count++ < nevent );
-
-    file->Write();
-    file->Close();
-    EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
-}
-
 void runFourBody( int nevent, EvtGen& myGenerator )
 {
     TFile* file = new TFile( "fourBody.root", "RECREATE" );
 
     double m12, m13, m14, m23, m24, m34, m123, m124, m234;
     double mB, m1, m2, m3, m4;
     double pBe, pBx, pBy, pBz;
     double p1e, p1x, p1y, p1z;
     double p2e, p2x, p2y, p2z;
     double p3e, p3x, p3y, p3z;
     double p4e, p4x, p4y, p4z;
     double theta1, theta3, chi;
-    TTree* tree = new TTree( "tree", "");
-    tree->Branch("m12", &m12, "m12/D");
-    tree->Branch("m13", &m13, "m13/D");
-    tree->Branch("m14", &m14, "m14/D");
-    tree->Branch("m23", &m23, "m23/D");
-    tree->Branch("m24", &m24, "m24/D");
-    tree->Branch("m34", &m34, "m34/D");
-    tree->Branch("m123", &m123, "m123/D");
-    tree->Branch("m124", &m124, "m124/D");
-    tree->Branch("m234", &m234, "m234/D");
-    tree->Branch("mB", &mB, "mB/D");
-    tree->Branch("m1", &m1, "m1/D");
-    tree->Branch("m2", &m2, "m2/D");
-    tree->Branch("m3", &m3, "m3/D");
-    tree->Branch("m4", &m4, "m4/D");
-    tree->Branch("pBe", &pBe, "pBe/D");
-    tree->Branch("pBx", &pBx, "pBx/D");
-    tree->Branch("pBy", &pBy, "pBy/D");
-    tree->Branch("pBz", &pBz, "pBz/D");
-    tree->Branch("p1e", &p1e, "p1e/D");
-    tree->Branch("p1x", &p1x, "p1x/D");
-    tree->Branch("p1y", &p1y, "p1y/D");
-    tree->Branch("p1z", &p1z, "p1z/D");
-    tree->Branch("p2e", &p2e, "p2e/D");
-    tree->Branch("p2x", &p2x, "p2x/D");
-    tree->Branch("p2y", &p2y, "p2y/D");
-    tree->Branch("p2z", &p2z, "p2z/D");
-    tree->Branch("p3e", &p3e, "p3e/D");
-    tree->Branch("p3x", &p3x, "p3x/D");
-    tree->Branch("p3y", &p3y, "p3y/D");
-    tree->Branch("p3z", &p3z, "p3z/D");
-    tree->Branch("p4e", &p4e, "p4e/D");
-    tree->Branch("p4x", &p4x, "p4x/D");
-    tree->Branch("p4y", &p4y, "p4y/D");
-    tree->Branch("p4z", &p4z, "p4z/D");
-    tree->Branch("theta1", &theta1, "theta1/D");
-    tree->Branch("theta3", &theta3, "theta3/D");
-    tree->Branch("chi", &chi, "chi/D");
+    TTree* tree = new TTree( "tree", "" );
+    tree->Branch( "m12", &m12, "m12/D" );
+    tree->Branch( "m13", &m13, "m13/D" );
+    tree->Branch( "m14", &m14, "m14/D" );
+    tree->Branch( "m23", &m23, "m23/D" );
+    tree->Branch( "m24", &m24, "m24/D" );
+    tree->Branch( "m34", &m34, "m34/D" );
+    tree->Branch( "m123", &m123, "m123/D" );
+    tree->Branch( "m124", &m124, "m124/D" );
+    tree->Branch( "m234", &m234, "m234/D" );
+    tree->Branch( "mB", &mB, "mB/D" );
+    tree->Branch( "m1", &m1, "m1/D" );
+    tree->Branch( "m2", &m2, "m2/D" );
+    tree->Branch( "m3", &m3, "m3/D" );
+    tree->Branch( "m4", &m4, "m4/D" );
+    tree->Branch( "pBe", &pBe, "pBe/D" );
+    tree->Branch( "pBx", &pBx, "pBx/D" );
+    tree->Branch( "pBy", &pBy, "pBy/D" );
+    tree->Branch( "pBz", &pBz, "pBz/D" );
+    tree->Branch( "p1e", &p1e, "p1e/D" );
+    tree->Branch( "p1x", &p1x, "p1x/D" );
+    tree->Branch( "p1y", &p1y, "p1y/D" );
+    tree->Branch( "p1z", &p1z, "p1z/D" );
+    tree->Branch( "p2e", &p2e, "p2e/D" );
+    tree->Branch( "p2x", &p2x, "p2x/D" );
+    tree->Branch( "p2y", &p2y, "p2y/D" );
+    tree->Branch( "p2z", &p2z, "p2z/D" );
+    tree->Branch( "p3e", &p3e, "p3e/D" );
+    tree->Branch( "p3x", &p3x, "p3x/D" );
+    tree->Branch( "p3y", &p3y, "p3y/D" );
+    tree->Branch( "p3z", &p3z, "p3z/D" );
+    tree->Branch( "p4e", &p4e, "p4e/D" );
+    tree->Branch( "p4x", &p4x, "p4x/D" );
+    tree->Branch( "p4y", &p4y, "p4y/D" );
+    tree->Branch( "p4z", &p4z, "p4z/D" );
+    tree->Branch( "theta1", &theta1, "theta1/D" );
+    tree->Branch( "theta3", &theta3, "theta3/D" );
+    tree->Branch( "chi", &chi, "chi/D" );
 
     int count = 1;
 
     char udecay_name[100];
     strcpy( udecay_name, "exampleFiles/4BodyPhsp.DEC" );
     myGenerator.readUDecay( udecay_name );
 
     static EvtId B = EvtPDL::getId( std::string( "B+" ) );
 
     do {
         EvtVector4R pinit( EvtPDL::getMass( B ), 0.0, 0.0, 0.0 );
 
         EvtParticle* root_part = EvtParticleFactory::particleFactory( B, pinit );
 
         myGenerator.generateDecay( root_part );
 
         mB = root_part->mass();
         m1 = root_part->getDaug( 0 )->mass();
         m2 = root_part->getDaug( 1 )->mass();
         m3 = root_part->getDaug( 2 )->mass();
         m4 = root_part->getDaug( 3 )->mass();
 
         EvtParticle* daug1 = root_part->getDaug( 0 );
         EvtParticle* daug2 = root_part->getDaug( 1 );
         EvtParticle* daug3 = root_part->getDaug( 2 );
         EvtParticle* daug4 = root_part->getDaug( 3 );
         m12 = ( daug1->getP4() + daug2->getP4() ).mass();
         m13 = ( daug1->getP4() + daug3->getP4() ).mass();
         m14 = ( daug1->getP4() + daug4->getP4() ).mass();
         m23 = ( daug2->getP4() + daug3->getP4() ).mass();
         m24 = ( daug2->getP4() + daug4->getP4() ).mass();
         m34 = ( daug3->getP4() + daug4->getP4() ).mass();
         m123 = ( daug1->getP4() + daug2->getP4() + daug3->getP4() ).mass();
         m124 = ( daug1->getP4() + daug2->getP4() + daug4->getP4() ).mass();
         m234 = ( daug2->getP4() + daug3->getP4() + daug4->getP4() ).mass();
         pBe = root_part->getP4().get( 0 );
         pBx = root_part->getP4().get( 1 );
         pBy = root_part->getP4().get( 2 );
         pBz = root_part->getP4().get( 3 );
         p1e = daug1->getP4().get( 0 );
         p1x = daug1->getP4().get( 1 );
         p1y = daug1->getP4().get( 2 );
         p1z = daug1->getP4().get( 3 );
         p2e = daug2->getP4().get( 0 );
         p2x = daug2->getP4().get( 1 );
         p2y = daug2->getP4().get( 2 );
         p2z = daug2->getP4().get( 3 );
         p3e = daug3->getP4().get( 0 );
         p3x = daug3->getP4().get( 1 );
         p3y = daug3->getP4().get( 2 );
         p3z = daug3->getP4().get( 3 );
         p4e = daug4->getP4().get( 0 );
         p4x = daug4->getP4().get( 1 );
         p4y = daug4->getP4().get( 2 );
         p4z = daug4->getP4().get( 3 );
 
         theta1 = EvtDecayAngle( root_part->getP4(),
-                              daug1->getP4() + daug2->getP4(), daug1->getP4() );
+                                daug1->getP4() + daug2->getP4(), daug1->getP4() );
         theta3 = EvtDecayAngle( root_part->getP4(),
-                              daug3->getP4() + daug4->getP4(), daug3->getP4() );
+                                daug3->getP4() + daug4->getP4(), daug3->getP4() );
         chi = EvtDecayAngleChi( root_part->getP4(), daug1->getP4(),
                                 daug2->getP4(), daug3->getP4(), daug4->getP4() );
         tree->Fill();
 
         root_part->deleteTree();
     } while ( count++ < nevent );
 
     file->Write();
     file->Close();
     EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "SUCCESS\n";
 }
diff --git a/test/jsonFiles/BC_BSSTAR_NPI__Bc_Bs0star3pi.json b/test/jsonFiles/BC_BSSTAR_NPI__Bc_Bs0star3pi.json
new file mode 100644
index 0000000..407b61f
--- /dev/null
+++ b/test/jsonFiles/BC_BSSTAR_NPI__Bc_Bs0star3pi.json
@@ -0,0 +1,17 @@
+{
+    "parent" : "B_c+",
+    "daughters" : ["B_s*0", "pi+", "pi-", "pi+"],
+    "models" : ["BC_BSSTAR_NPI", "", "", "", ""],
+    "parameters" : [[], [], [], [], []],
+    "do_conjugate_decay" : [true, false, false, false, false],
+    "extras" : ["Define dm_incohMix_B_s0 0"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(BC_BSSTAR_NPI)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "parMass", "title" : "m(B_{c}^{+})", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 6.2, "xmax" : 6.3},
+	{"variable" : "mass", "title" : "m(B_{s}^{*0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 5.4, "xmax" : 5.5},
+	{"variable" : "mass3", "title" : "m(#pi^{+}#pi^{-}#pi^{+})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0}
+    ],
+    "outfile" : "BC_BSSTAR_NPI__Bc_Bs0star3pi.root",
+    "reference" : "RefBC_BSSTAR_NPI__Bc_Bs0star3pi.root"
+}
diff --git a/test/jsonFiles/BC_BS_NPI__Bc_Bs03pi.json b/test/jsonFiles/BC_BS_NPI__Bc_Bs03pi.json
new file mode 100644
index 0000000..4099e53
--- /dev/null
+++ b/test/jsonFiles/BC_BS_NPI__Bc_Bs03pi.json
@@ -0,0 +1,17 @@
+{
+    "parent" : "B_c+",
+    "daughters" : ["B_s0", "pi+", "pi-", "pi+"],
+    "models" : ["BC_BS_NPI", "", "", "", ""],
+    "parameters" : [[], [], [], [], []],
+    "do_conjugate_decay" : [true, false, false, false, false],
+    "extras" : ["Define dm_incohMix_B_s0 0"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(BC_BS_NPI)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "parMass", "title" : "m(B_{c}^{+})", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 6.2, "xmax" : 6.3},
+	{"variable" : "mass", "title" : "m(B_{s}^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 5.3, "xmax" : 5.4},
+	{"variable" : "mass3", "title" : "m(#pi^{+}#pi^{-}#pi^{+})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0}
+    ],
+    "outfile" : "BC_BS_NPI__Bc_Bs03pi.root",
+    "reference" : "RefBC_BS_NPI__Bc_Bs03pi.root"
+}
diff --git a/test/jsonFiles/BC_PSI_NPI=VLL__Bc_Jpsi3pi,ee.json b/test/jsonFiles/BC_PSI_NPI=VLL__Bc_Jpsi3pi,ee.json
new file mode 100644
index 0000000..5b58bab
--- /dev/null
+++ b/test/jsonFiles/BC_PSI_NPI=VLL__Bc_Jpsi3pi,ee.json
@@ -0,0 +1,20 @@
+{
+    "parent" : "B_c+",
+    "daughters" : ["J/psi", "pi+", "pi-", "pi+"],
+    "grand_daughters" : [["e+", "e-"], [], [], []],
+    "models" : ["BC_PSI_NPI", "VLL", "", "", ""],
+    "parameters" : [[], [], [], [], []],
+    "do_conjugate_decay" : [true, false, false, false, false],
+    "extras" : ["Define dm_incohMix_B_s0 0"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(BC_PSI_NPI)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug1", "title" : "Prob(VLL)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "parMass", "title" : "m(B_{c}^{+})", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 6.2, "xmax" : 6.3},
+	{"variable" : "mass", "title" : "m(J/#psi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 3.0, "xmax" : 3.2},
+	{"variable" : "mass3", "title" : "m(#pi^{+}#pi^{-}#pi^{+})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.5},
+	{"variable" : "cosHel", "title" : "cosHel(e^{+}, J/#psi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "BC_PSI_NPI=VLL__Bc_Jpsi3pi,ee.root",
+    "reference" : "RefBC_PSI_NPI=VLL__Bc_Jpsi3pi,ee.root"
+}
diff --git a/test/jsonFiles/BC_SMN=SVP__Bc_D0munu,Kst0gamma.json b/test/jsonFiles/BC_SMN=SVP__Bc_D0munu,Kst0gamma.json
new file mode 100644
index 0000000..38cd418
--- /dev/null
+++ b/test/jsonFiles/BC_SMN=SVP__Bc_D0munu,Kst0gamma.json
@@ -0,0 +1,35 @@
+{
+    "parent" : "B_c+",
+    "daughters" : ["D0", "mu+", "nu_mu"],
+    "grand_daughters" : [["gamma", "K*0"], [], []],
+    "models" : ["BC_SMN", "SVP", ""],
+    "parameters" : [["1"], [], []],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob", "d1" : 0, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(D0)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 1.8, "xmax" : 1.9},
+	{"variable" : "mass", "title" : "m(D0 mu)", "d1" : 1, "d2" : 2, "nbins": 100, "xmin" : 3.0, "xmax" : 7.0},
+	{"variable" : "mass", "title" : "m(mu nu)", "d1" : 2, "d2" : 3, "nbins": 100, "xmin" : 0.0, "xmax" : 5.0},
+	{"variable" : "pSumSq", "title" : "qSq(mu nu)", "d1" : 2, "d2" : 3, "nbins": 100, "xmin" : 0.0, "xmax" : 20.0},
+	{"variable" : "p", "title" : "p(D0)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 3.5},
+	{"variable" : "pSq", "title" : "pSq(D0)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 10.0},
+	{"variable" : "pz", "title" : "pz(D0)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -3.0, "xmax" : 3.0},
+	{"variable" : "cosHel", "title" : "cosHel(D0,mu)", "d1" : 1, "d2" : 2, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel_daug1", "title" : "cosHel(gamma)", "d1" : 1, "d2" : 2, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel_daug1", "title" : "cosHel(K*0)", "d1" : 2, "d2" : 1, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(D0)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "E", "title" : "E(D0)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 1.5, "xmax" : 4.0},
+	{"variable" : "phi", "title" : "phi(D0)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "E_daug1", "title" : "E(gamma)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "pLab_daug1", "title" : "pLab(K*0)", "d1" : 2, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 4.0},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(gamma)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug1", "title" : "phi(gamma)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(K*0)", "d1" : 2, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug1", "title" : "phi(K*0)", "d1" : 2, "d2" : 0, "nbins": 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "BC_SMN=SVP__Bc_D0munu,Kst0gamma.root",
+    "reference" : "RefBC_SMN=SVP__Bc_D0munu,Kst0gamma.root"
+}
diff --git a/test/jsonFiles/BC_TMN=TVP__Bc_chic2munu,Jpsigamma.json b/test/jsonFiles/BC_TMN=TVP__Bc_chic2munu,Jpsigamma.json
new file mode 100644
index 0000000..b670989
--- /dev/null
+++ b/test/jsonFiles/BC_TMN=TVP__Bc_chic2munu,Jpsigamma.json
@@ -0,0 +1,36 @@
+{
+    "parent" : "B_c+",
+    "daughters" : ["chi_c2", "mu+", "nu_mu"],
+    "grand_daughters" : [["gamma", "J/psi"], [], []],
+    "models" : ["BC_TMN", "TVP", ""],
+    "parameters" : [["3"], [], []],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob", "d1" : 0, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(chi_c2)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 3.52, "xmax" : 3.6},
+	{"variable" : "mass", "title" : "m(chi_c2 mu)", "d1" : 1, "d2" : 2, "nbins": 100, "xmin" : 3.0, "xmax" : 7.0},
+	{"variable" : "mass", "title" : "m(mu nu)", "d1" : 2, "d2" : 3, "nbins": 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "pSumSq", "title" : "qSq(mu nu)", "d1" : 2, "d2" : 3, "nbins": 100, "xmin" : 0.0, "xmax" : 9.0},
+	{"variable" : "p", "title" : "p(chi_c2)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "pSq", "title" : "pSq(chi_c2)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 5.0},
+	{"variable" : "pz", "title" : "pz(chi_c2)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -2.5, "xmax" : 2.5},
+	{"variable" : "cosHel", "title" : "cosHel(chi_c2,mu)", "d1" : 1, "d2" : 2, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel(mu,chi_c2)", "d1" : 2, "d2" : 1, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel_daug1", "title" : "cosHel(gamma)", "d1" : 1, "d2" : 2, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel_daug1", "title" : "cosHel(J/psi)", "d1" : 2, "d2" : 1, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(chi_c2)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "E", "title" : "E(chi_c2)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 3.5, "xmax" : 4.3},
+	{"variable" : "phi", "title" : "phi(chi_c2)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "E_daug1", "title" : "E(gamma)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "pLab_daug1", "title" : "pLab(J/psi)", "d1" : 2, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(gamma)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug1", "title" : "phi(gamma)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(J/psi)", "d1" : 2, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug1", "title" : "phi(J/psi)", "d1" : 2, "d2" : 0, "nbins": 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "BC_TMN=TVP__Bc_chic2munu,Jpsigamma.root",
+    "reference" : "RefBC_TMN=TVP__Bc_chic2munu,Jpsigamma.root"
+}
diff --git a/test/jsonFiles/BC_VHAD=VLL__Bc_psi2SKKpi,mm.json b/test/jsonFiles/BC_VHAD=VLL__Bc_psi2SKKpi,mm.json
new file mode 100644
index 0000000..399299c
--- /dev/null
+++ b/test/jsonFiles/BC_VHAD=VLL__Bc_psi2SKKpi,mm.json
@@ -0,0 +1,41 @@
+{
+    "parent" : "B_c+",
+    "daughters" : ["psi(2S)", "K+", "K-", "pi+"],
+    "grand_daughters" : [["mu+", "mu-"], [], [], []],
+    "models" : ["BC_VHAD", "VLL", "", "", ""],
+    "parameters" : [["1"], [], [], [], []],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(psi2S)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 3.68, "xmax" : 3.695},
+        {"variable" : "mass", "title" : "m(psi2S K+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 4.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(psi2S K-)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 4.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(K+K-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.5, "xmax" : 3.0},
+        {"variable" : "mass", "title" : "m(K-pi+)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.5, "xmax" : 1.6},
+        {"variable" : "mass", "title" : "m(psi2S pi+)", "d1" : 1, "d2" : 4, "nbins" : 100, "xmin" : 3.5, "xmax" : 5.5},
+        {"variable" : "pSumSq", "title" : "qSq(K+ K-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 7.0},
+        {"variable" : "p", "title" : "p(psi2S)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0},
+        {"variable" : "pSq", "title" : "pSq(psi2S)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.5},
+        {"variable" : "pz", "title" : "pz(psi2S)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.0, "xmax" : 2.0},
+        {"variable" : "cosHel", "title" : "cosHel(psi2S,K+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(K-,pi+)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(K+,K-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(psi2S,K-)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel_daug1", "title" : "cosHel(mu+,psi2S)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel_daug1", "title" : "cosHel(mu-,psi2S)", "d1" : 2, "d2" : 1, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(psi2S)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "E", "title" : "E(psi2S)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 3.5, "xmax" : 4.2},
+	{"variable" : "phi", "title" : "phi(psi2S)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "pLab_daug1", "title" : "pLab(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 3.5},
+	{"variable" : "pLab_daug1", "title" : "pLab(mu-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 3.5},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug1", "title" : "phi(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(mu-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug1", "title" : "phi(mu-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "BC_VHAD=VLL__Bc_psi2SKKpi,mm.root",
+    "reference" : "RefBC_VHAD=VLL__Bc_psi2SKKpi,mm.root"
+}
diff --git a/test/jsonFiles/BC_VMN=VVPIPI_WEIGHTED__Bc_psi2Smunu,Jpsipipi.json b/test/jsonFiles/BC_VMN=VVPIPI_WEIGHTED__Bc_psi2Smunu,Jpsipipi.json
new file mode 100644
index 0000000..1647f2d
--- /dev/null
+++ b/test/jsonFiles/BC_VMN=VVPIPI_WEIGHTED__Bc_psi2Smunu,Jpsipipi.json
@@ -0,0 +1,40 @@
+{
+    "parent" : "B_c+",
+    "daughters" : ["psi(2S)", "mu+", "nu_mu"],
+    "grand_daughters" : [["J/psi", "pi+", "pi-"], [], []],
+    "models" : ["BC_VMN", "VVPIPI_WEIGHTED", ""],
+    "parameters" : [["1"], [], []],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob", "d1" : 0, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(psi2S)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 3.68, "xmax" : 3.695},
+	{"variable" : "mass", "title" : "m(psi2S mu)", "d1" : 1, "d2" : 2, "nbins": 100, "xmin" : 3.0, "xmax" : 7.0},
+	{"variable" : "mass", "title" : "m(mu nu)", "d1" : 2, "d2" : 3, "nbins": 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "pSumSq", "title" : "qSq(mu nu)", "d1" : 2, "d2" : 3, "nbins": 100, "xmin" : 0.0, "xmax" : 8.0},
+	{"variable" : "p", "title" : "p(psi2S)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "pSq", "title" : "pSq(psi2S)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 5.0},
+	{"variable" : "pz", "title" : "pz(psi2S)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -2.5, "xmax" : 2.5},
+	{"variable" : "cosHel", "title" : "cosHel(psi2S,mu)", "d1" : 1, "d2" : 2, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel(mu,psi2S)", "d1" : 2, "d2" : 1, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel_daug1", "title" : "cosHel(J/psi)", "d1" : 1, "d2" : 2, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel_daug1", "title" : "cosHel(pi+)", "d1" : 2, "d2" : 1, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(psi2S)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(mu+)", "d1" : 2, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "E", "title" : "E(psi2S)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 3.6, "xmax" : 4.4},
+	{"variable" : "phi", "title" : "phi(psi2S)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "pLab_daug1", "title" : "pLab(J/psi)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "pLab_daug1", "title" : "pLab(pi+)", "d1" : 2, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 0.7},
+	{"variable" : "pLab_daug1", "title" : "pLab(pi-)", "d1" : 3, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 0.7},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(J/psi)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug1", "title" : "phi(J/psi)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(pi+)", "d1" : 2, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug1", "title" : "phi(pi+)", "d1" : 2, "d2" : 0, "nbins": 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(pi-)", "d1" : 3, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug1", "title" : "phi(pi-)", "d1" : 3, "d2" : 0, "nbins": 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "BC_VMN=VVPIPI_WEIGHTED__Bc_psi2Smunu,Jpsipipi.root",
+    "reference" : "RefBC_VMN=VVPIPI_WEIGHTED__Bc_psi2Smunu,Jpsipipi.root"
+}
diff --git a/test/jsonFiles/BC_VMN=VVPIPI__Bc_psi2Smunu,Jpsipipi.json b/test/jsonFiles/BC_VMN=VVPIPI__Bc_psi2Smunu,Jpsipipi.json
new file mode 100644
index 0000000..31cb697
--- /dev/null
+++ b/test/jsonFiles/BC_VMN=VVPIPI__Bc_psi2Smunu,Jpsipipi.json
@@ -0,0 +1,40 @@
+{
+    "parent" : "B_c+",
+    "daughters" : ["psi(2S)", "mu+", "nu_mu"],
+    "grand_daughters" : [["J/psi", "pi+", "pi-"], [], []],
+    "models" : ["BC_VMN", "VVPIPI", ""],
+    "parameters" : [["1"], [], []],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob", "d1" : 0, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(psi2S)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 3.68, "xmax" : 3.695},
+	{"variable" : "mass", "title" : "m(psi2S mu)", "d1" : 1, "d2" : 2, "nbins": 100, "xmin" : 3.0, "xmax" : 7.0},
+	{"variable" : "mass", "title" : "m(mu nu)", "d1" : 2, "d2" : 3, "nbins": 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "pSumSq", "title" : "qSq(mu nu)", "d1" : 2, "d2" : 3, "nbins": 100, "xmin" : 0.0, "xmax" : 8.0},
+	{"variable" : "p", "title" : "p(psi2S)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "pSq", "title" : "pSq(psi2S)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 5.0},
+	{"variable" : "pz", "title" : "pz(psi2S)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -2.5, "xmax" : 2.5},
+	{"variable" : "cosHel", "title" : "cosHel(psi2S,mu)", "d1" : 1, "d2" : 2, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel(mu,psi2S)", "d1" : 2, "d2" : 1, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel_daug1", "title" : "cosHel(J/psi)", "d1" : 1, "d2" : 2, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel_daug1", "title" : "cosHel(pi+)", "d1" : 2, "d2" : 1, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(psi2S)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(mu+)", "d1" : 2, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "E", "title" : "E(psi2S)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 3.6, "xmax" : 4.4},
+	{"variable" : "phi", "title" : "phi(psi2S)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "pLab_daug1", "title" : "pLab(J/psi)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "pLab_daug1", "title" : "pLab(pi+)", "d1" : 2, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 0.7},
+	{"variable" : "pLab_daug1", "title" : "pLab(pi-)", "d1" : 3, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 0.7},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(J/psi)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug1", "title" : "phi(J/psi)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(pi+)", "d1" : 2, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug1", "title" : "phi(pi+)", "d1" : 2, "d2" : 0, "nbins": 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(pi-)", "d1" : 3, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug1", "title" : "phi(pi-)", "d1" : 3, "d2" : 0, "nbins": 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "BC_VMN=VVPIPI__Bc_psi2Smunu,Jpsipipi.root",
+    "reference" : "RefBC_VMN=VVPIPI__Bc_psi2Smunu,Jpsipipi.root"
+}
diff --git a/test/jsonFiles/BC_VMN=VVP__Bc_psi2Smunu,chi_c1gamma.json b/test/jsonFiles/BC_VMN=VVP__Bc_psi2Smunu,chi_c1gamma.json
new file mode 100644
index 0000000..89cac72
--- /dev/null
+++ b/test/jsonFiles/BC_VMN=VVP__Bc_psi2Smunu,chi_c1gamma.json
@@ -0,0 +1,36 @@
+{
+    "parent" : "B_c+",
+    "daughters" : ["psi(2S)", "mu+", "nu_mu"],
+    "grand_daughters" : [["chi_c1", "gamma"], [], []],
+    "models" : ["BC_VMN", "VVP", ""],
+    "parameters" : [["1"], ["1.0", "0.0", "0.0", "0.0", "0.0", "0.0", "0.0", "0.0"], []],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob", "d1" : 0, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 1.0},
+ 	{"variable" : "mass", "title" : "m(psi2S)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 3.68, "xmax" : 3.695},
+	{"variable" : "mass", "title" : "m(psi2S mu)", "d1" : 1, "d2" : 2, "nbins": 100, "xmin" : 3.0, "xmax" : 7.0},
+	{"variable" : "mass", "title" : "m(mu nu)", "d1" : 2, "d2" : 3, "nbins": 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "pSumSq", "title" : "qSq(mu nu)", "d1" : 2, "d2" : 3, "nbins": 100, "xmin" : 0.0, "xmax" : 8.0},
+	{"variable" : "p", "title" : "p(psi2S)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "pSq", "title" : "pSq(psi2S)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 5.0},
+	{"variable" : "pz", "title" : "pz(psi2S)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -2.5, "xmax" : 2.5},
+	{"variable" : "cosHel", "title" : "cosHel(psi2S,mu)", "d1" : 1, "d2" : 2, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel(mu,psi2S)", "d1" : 2, "d2" : 1, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel_daug1", "title" : "cosHel(chi_c1)", "d1" : 1, "d2" : 2, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel_daug1", "title" : "cosHel(gamma)", "d1" : 2, "d2" : 1, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(psi2S)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "E", "title" : "E(psi2S)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 3.6, "xmax" : 4.4},
+	{"variable" : "phi", "title" : "phi(psi2S)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "pLab_daug1", "title" : "pLab(chi_c1)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "E_daug1", "title" : "E(gamma)", "d1" : 2, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 0.4},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(chi_c1)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug1", "title" : "phi(chi_c1)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(gamma)", "d1" : 2, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug1", "title" : "phi(gamma)", "d1" : 2, "d2" : 0, "nbins": 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "BC_VMN=VVP__Bc_psi2Smunu,chi_c1gamma.root",
+    "reference" : "RefBC_VMN=VVP__Bc_psi2Smunu,chi_c1gamma.root"
+}
diff --git a/test/jsonFiles/BC_VNPI=VLL__Bc_psi2Spipipi,mm.json b/test/jsonFiles/BC_VNPI=VLL__Bc_psi2Spipipi,mm.json
new file mode 100644
index 0000000..402e20d
--- /dev/null
+++ b/test/jsonFiles/BC_VNPI=VLL__Bc_psi2Spipipi,mm.json
@@ -0,0 +1,41 @@
+{
+    "parent" : "B_c+",
+    "daughters" : ["psi(2S)", "pi+", "pi-", "pi+"],
+    "grand_daughters" : [["mu+", "mu-"], [], [], []],
+    "models" : ["BC_VNPI", "VLL", "", "", ""],
+    "parameters" : [["1"], [], [], [], []],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(psi2S)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 3.684, "xmax" : 3.69},
+        {"variable" : "mass", "title" : "m(psi2S pi+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 3.5, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(psi2S pi-)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 3.5, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(pi+pi-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0, "xmax" : 3.0},
+        {"variable" : "mass", "title" : "m(pi-pi+)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0, "xmax" : 3.0},
+        {"variable" : "mass", "title" : "m(psi2S pi+)", "d1" : 1, "d2" : 4, "nbins" : 100, "xmin" : 3.5, "xmax" : 6.5},
+        {"variable" : "pSumSq", "title" : "qSq(pi+ pi-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "p", "title" : "p(psi2S)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0},
+        {"variable" : "pSq", "title" : "pSq(psi2S)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 4.0},
+        {"variable" : "pz", "title" : "pz(psi2S)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.0, "xmax" : 2.0},
+        {"variable" : "cosHel", "title" : "cosHel(psi2S,K+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(pi-,pi+)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(pi+,K-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(psi2S,K-)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel_daug1", "title" : "cosHel(mu+,psi2S)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel_daug1", "title" : "cosHel(mu-,psi2S)", "d1" : 2, "d2" : 1, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(psi2S)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "E", "title" : "E(psi2S)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 3.5, "xmax" : 4.2},
+	{"variable" : "phi", "title" : "phi(psi2S)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "pLab_daug1", "title" : "pLab(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 3.5},
+	{"variable" : "pLab_daug1", "title" : "pLab(mu-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 3.5},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug1", "title" : "phi(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(mu-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug1", "title" : "phi(mu-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "BC_VNPI=VLL__Bc_psi2Spipipi,mm.root",
+    "reference" : "RefBC_VNPI=VLL__Bc_psi2Spipipi,mm.root"
+}
diff --git a/test/jsonFiles/BHADRONIC__Bd_D0pi0.json b/test/jsonFiles/BHADRONIC__Bd_D0pi0.json
new file mode 100644
index 0000000..2224ce8
--- /dev/null
+++ b/test/jsonFiles/BHADRONIC__Bd_D0pi0.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "B0",
+    "daughters" : ["anti-D0", "pi0"],
+    "models" : ["BHADRONIC", "", ""],
+    "parameters" : [["1", "1"], [], []],
+    "do_conjugate_decay" : [ true, false, false ],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "parMass", "title" : "m(B0)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 5.25, "xmax" : 5.3},
+        {"variable" : "mass", "title" : "m(D0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.8, "xmax" : 1.9},
+        {"variable" : "mass", "title" : "m(pi0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.12, "xmax" : 0.15},
+	{"variable" : "p", "title" : "p(D0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.0, "xmax" : 2.5},
+	{"variable" : "phi", "title" : "phi(D0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(D0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "p", "title" : "p(pi0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 2.0, "xmax" : 2.5},
+	{"variable" : "phi", "title" : "phi(pi0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(pi0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "BHADRONIC__Bd_D0pi0.root",
+    "reference" : "RefBHADRONIC__Bd_D0pi0.root"
+}
diff --git a/test/jsonFiles/BHADRONIC__Bd_D0rho0.json b/test/jsonFiles/BHADRONIC__Bd_D0rho0.json
new file mode 100644
index 0000000..55b5d9f
--- /dev/null
+++ b/test/jsonFiles/BHADRONIC__Bd_D0rho0.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "B0",
+    "daughters" : ["anti-D0", "rho0"],
+    "models" : ["BHADRONIC", "", ""],
+    "parameters" : [["1", "2"], [], []],
+    "do_conjugate_decay" : [ true, false, false ],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "parMass", "title" : "m(B0)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 5.25, "xmax" : 5.3},
+        {"variable" : "mass", "title" : "m(D0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.8, "xmax" : 1.9},
+        {"variable" : "mass", "title" : "m(rho0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0},
+	{"variable" : "p", "title" : "p(D0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.5, "xmax" : 2.5},
+	{"variable" : "phi", "title" : "phi(D0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(D0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "p", "title" : "p(rho0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 1.5, "xmax" : 2.5},
+	{"variable" : "phi", "title" : "phi(rho0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(rho0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "BHADRONIC__Bd_D0rho0.root",
+    "reference" : "RefBHADRONIC__Bd_D0rho0.root"
+}
diff --git a/test/jsonFiles/BHADRONIC__Bd_D2star0pi0.json b/test/jsonFiles/BHADRONIC__Bd_D2star0pi0.json
new file mode 100644
index 0000000..96e1e0f
--- /dev/null
+++ b/test/jsonFiles/BHADRONIC__Bd_D2star0pi0.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "B0",
+    "daughters" : ["anti-D_2*0", "pi0"],
+    "models" : ["BHADRONIC", "", ""],
+    "parameters" : [["4", "1"], [], []],
+    "do_conjugate_decay" : [ true, false, false ],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "parMass", "title" : "m(B0)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 5.25, "xmax" : 5.3},
+        {"variable" : "mass", "title" : "m(D_2*0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.2, "xmax" : 3.0},
+        {"variable" : "mass", "title" : "m(pi0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.12, "xmax" : 0.15},
+	{"variable" : "p", "title" : "p(D_2*0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.6, "xmax" : 2.2},
+	{"variable" : "phi", "title" : "phi(D_2*0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(D_2*0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "p", "title" : "p(pi0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 1.6, "xmax" : 2.2},
+	{"variable" : "phi", "title" : "phi(pi0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(pi0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "BHADRONIC__Bd_D2star0pi0.root",
+    "reference" : "RefBHADRONIC__Bd_D2star0pi0.root"
+}
diff --git a/test/jsonFiles/BHADRONIC__Bd_D2star0rho0.json b/test/jsonFiles/BHADRONIC__Bd_D2star0rho0.json
new file mode 100644
index 0000000..465cac8
--- /dev/null
+++ b/test/jsonFiles/BHADRONIC__Bd_D2star0rho0.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "B0",
+    "daughters" : ["anti-D_2*0", "rho0"],
+    "models" : ["BHADRONIC", "", ""],
+    "parameters" : [["4", "2"], [], []],
+    "do_conjugate_decay" : [ true, false, false ],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "parMass", "title" : "m(B0)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 5.25, "xmax" : 5.3},
+        {"variable" : "mass", "title" : "m(D_2*0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.2, "xmax" : 3.0},
+        {"variable" : "mass", "title" : "m(rho0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0},
+	{"variable" : "p", "title" : "p(D_2*0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.2, "xmax" : 2.2},
+	{"variable" : "phi", "title" : "phi(D_2*0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(D_2*0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "p", "title" : "p(rho0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 1.2, "xmax" : 2.2},
+	{"variable" : "phi", "title" : "phi(rho0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(rho0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "BHADRONIC__Bd_D2star0rho0.root",
+    "reference" : "RefBHADRONIC__Bd_D2star0rho0.root"
+}
diff --git a/test/jsonFiles/BHADRONIC__Bd_Dstar0pi0.json b/test/jsonFiles/BHADRONIC__Bd_Dstar0pi0.json
new file mode 100644
index 0000000..0d962fe
--- /dev/null
+++ b/test/jsonFiles/BHADRONIC__Bd_Dstar0pi0.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "B0",
+    "daughters" : ["anti-D*0", "pi0"],
+    "models" : ["BHADRONIC", "", ""],
+    "parameters" : [["2", "1"], [], []],
+    "do_conjugate_decay" : [ true, false, false ],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "parMass", "title" : "m(B0)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 5.25, "xmax" : 5.3},
+        {"variable" : "mass", "title" : "m(D*0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.9, "xmax" : 2.1},
+        {"variable" : "mass", "title" : "m(pi0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.12, "xmax" : 0.15},
+	{"variable" : "p", "title" : "p(D*0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.0, "xmax" : 2.5},
+	{"variable" : "phi", "title" : "phi(D*0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(D*0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "p", "title" : "p(pi0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 2.0, "xmax" : 2.5},
+	{"variable" : "phi", "title" : "phi(pi0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(pi0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "BHADRONIC__Bd_Dstar0pi0.root",
+    "reference" : "RefBHADRONIC__Bd_Dstar0pi0.root"
+}
diff --git a/test/jsonFiles/BHADRONIC__Bd_Dstar0rho0.json b/test/jsonFiles/BHADRONIC__Bd_Dstar0rho0.json
new file mode 100644
index 0000000..79291b4
--- /dev/null
+++ b/test/jsonFiles/BHADRONIC__Bd_Dstar0rho0.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "B0",
+    "daughters" : ["anti-D*0", "rho0"],
+    "models" : ["BHADRONIC", "", ""],
+    "parameters" : [["2", "2"], [], []],
+    "do_conjugate_decay" : [ true, false, false ],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "parMass", "title" : "m(B0)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 5.25, "xmax" : 5.3},
+        {"variable" : "mass", "title" : "m(D*0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.9, "xmax" : 2.1},
+        {"variable" : "mass", "title" : "m(rho0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0},
+	{"variable" : "p", "title" : "p(D*0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.5, "xmax" : 2.5},
+	{"variable" : "phi", "title" : "phi(D*0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(D*0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "p", "title" : "p(rho0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 1.5, "xmax" : 2.5},
+	{"variable" : "phi", "title" : "phi(rho0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(rho0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "BHADRONIC__Bd_Dstar0rho0.root",
+    "reference" : "RefBHADRONIC__Bd_Dstar0rho0.root"
+}
diff --git a/test/jsonFiles/BLLNUL__Bu_eenumu.json b/test/jsonFiles/BLLNUL__Bu_eenumu.json
new file mode 100644
index 0000000..e9b1106
--- /dev/null
+++ b/test/jsonFiles/BLLNUL__Bu_eenumu.json
@@ -0,0 +1,39 @@
+{
+    "parent" : "B+",
+    "daughters" : ["e-", "e+", "nu_mu", "mu+"],
+    "models" : ["BLLNUL"],
+    "parameters" : [[]],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(e-e+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.1, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(e- nu_mu)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "mass", "title" : "m(e+ nu_mu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "mass", "title" : "m(nu_mu mu+)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "pSumSq", "title" : "qSq(e-e+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "pSumSq", "title" : "qSq(nu_mu mu+)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.0, "xmax" : 25.0},
+        {"variable" : "p", "title" : "p(e-)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(e-)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(e+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(e+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(nu_mu)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(nu_mu)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(mu+)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(mu+)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(e-,e+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(nu_mu,mu+)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(e+,nu_mu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(e-,nu_mu)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(e-)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(e+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(nu_mu)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu+)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(e-)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(e+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(nu_mu)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(mu+)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180}
+    ],
+    "outfile" : "BLLNUL__Bu_eenumu.root",
+    "reference" : "RefBLLNUL__Bu_eenumu.root"
+}
diff --git a/test/jsonFiles/BQTOLLLLHYPERCP__Bd_4mu.json b/test/jsonFiles/BQTOLLLLHYPERCP__Bd_4mu.json
new file mode 100644
index 0000000..757ccc0
--- /dev/null
+++ b/test/jsonFiles/BQTOLLLLHYPERCP__Bd_4mu.json
@@ -0,0 +1,39 @@
+{
+    "parent" : "anti-B0",
+    "daughters" : ["mu+", "mu-", "mu+", "mu-"],
+    "models" : ["BQTOLLLLHYPERCP"],
+    "parameters" : [["2.5", "0.214", "0.01", "0.01", "1.0", "1.0", "450.0", "0.0", "450.0", "0.0", "380.0", "0.0", "380.0", "0.0"]],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 100.0},
+	{"variable" : "mass", "title" : "m(mu1+mu1-)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.1, "xmax" : 5.0},
+        {"variable" : "mass", "title" : "m(mu1+mu2+)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "mass", "title" : "m(mu1- mu2+)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "mass", "title" : "m(mu2+ mu2-)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "pSumSq", "title" : "qSq(mu1+mu1-)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 25.0},
+        {"variable" : "pSumSq", "title" : "qSq(mu2+mu2-)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.0, "xmax" : 25.0},
+        {"variable" : "p", "title" : "p(mu1+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(mu1+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(mu1-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(mu1-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(mu2+)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(mu2+)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(mu2-)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(mu2-)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu1+,mu1-)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu2+,mu2-)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu1-,mu2+)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu1+,mu2+)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu1+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu1-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu2+)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu2-)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(mu1+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(mu1-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(mu2+)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(mu2-)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180}
+    ],
+    "outfile" : "BQTOLLLLHYPERCP__Bd_4mu.root",
+    "reference" : "RefBQTOLLLLHYPERCP__Bd_4mu.root"
+}
diff --git a/test/jsonFiles/BQTOLLLL__Bs_4mu.json b/test/jsonFiles/BQTOLLLL__Bs_4mu.json
new file mode 100644
index 0000000..ebbcc08
--- /dev/null
+++ b/test/jsonFiles/BQTOLLLL__Bs_4mu.json
@@ -0,0 +1,40 @@
+{
+    "parent" : "anti-B_s0",
+    "daughters" : ["mu+", "mu-", "mu+", "mu-"],
+    "models" : ["BQTOLLLL"],
+    "parameters" : [["5.0", "5", "0", "1", "0.88", "0.227", "0.22", "0.34"]],
+    "do_conjugate_decay" : [true],
+    "extras" : ["Define dm_incohMix_B_s0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 10.0},
+	{"variable" : "mass", "title" : "m(mu1+mu1-)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.1, "xmax" : 5.0},
+        {"variable" : "mass", "title" : "m(mu1+mu2+)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "mass", "title" : "m(mu1- mu2+)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "mass", "title" : "m(mu2+ mu2-)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "pSumSq", "title" : "qSq(mu1+mu1-)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 25.0},
+        {"variable" : "pSumSq", "title" : "qSq(mu2+mu2-)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.0, "xmax" : 25.0},
+        {"variable" : "p", "title" : "p(mu1+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(mu1+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(mu1-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(mu1-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(mu2+)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(mu2+)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(mu2-)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(mu2-)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu1+,mu1-)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu2+,mu2-)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu1-,mu2+)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu1+,mu2+)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu1+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu1-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu2+)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu2-)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(mu1+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(mu1-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(mu2+)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(mu2-)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180}
+    ],
+    "outfile" : "BQTOLLLL__Bs_4mu.root",
+    "reference" : "RefBQTOLLLL__Bs_4mu.root"
+}
diff --git a/test/jsonFiles/BSQUARK__Bu_Dstenue.json b/test/jsonFiles/BSQUARK__Bu_Dstenue.json
new file mode 100644
index 0000000..33b443b
--- /dev/null
+++ b/test/jsonFiles/BSQUARK__Bu_Dstenue.json
@@ -0,0 +1,26 @@
+{
+    "parent" : "B-",
+    "daughters" : ["D*0", "e-", "anti-nu_e"],
+    "models" : ["BSQUARK", "", ""],
+    "parameters" : [["1.14", "2.0", "1000.0", "100.0", "100.0"], [], []],
+    "do_conjugate_decay" : [ true, false, false ],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "parMass", "title" : "m(B-)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 5.25, "xmax" : 5.3},
+        {"variable" : "mass", "title" : "m(D*0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.9, "xmax" : 2.1},
+	{"variable" : "pSumSq", "title" : "qSq(e,nue)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+	{"variable" : "p", "title" : "p(D*0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "phi", "title" : "phi(D*0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(D*0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "p", "title" : "p(e-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "phi", "title" : "phi(e-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(e-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "p", "title" : "p(nue)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "phi", "title" : "phi(nue)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(nue)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "E", "title" : "Dalitz qSq(e,nue) vs E(e)", "d1" : 2, "d2" : 0, "nbins" : 50, "xmin" : 0.0, "xmax" : 2.5, "variableY" : "pSumSq", "d1Y" : 2, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 12.0}
+    ],
+    "outfile" : "BSQUARK__Bu_Dstenue.root",
+    "reference" : "RefBSQUARK__Bu_Dstenue.root"
+}
diff --git a/test/jsonFiles/BSTOGLLISRFSR__Bs_gammamumu.json b/test/jsonFiles/BSTOGLLISRFSR__Bs_gammamumu.json
new file mode 100644
index 0000000..3649520
--- /dev/null
+++ b/test/jsonFiles/BSTOGLLISRFSR__Bs_gammamumu.json
@@ -0,0 +1,34 @@
+{
+    "parent" : "B_s0",
+    "daughters" : ["gamma", "mu+", "mu-"],
+    "models" : ["BSTOGLLISRFSR"],
+    "parameters" : [["5.0", "5", "1", "1", "1", "0.02", "0.814", "0.2254", "0.117", "0.353"]],
+    "do_conjugate_decay" : [true],
+    "extras" : ["Define dm_incohMix_B_s0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.02},
+        {"variable" : "mass", "title" : "m(gamma mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(gamma mu-)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(mu+ mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "pSumSq", "title" : "qSq(gamma mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 40.0},
+        {"variable" : "pSumSq", "title" : "qSq(mu+mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 40.0},
+        {"variable" : "p", "title" : "p(gamma)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(gamma)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(gamma,mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(gamma,mu-)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu+,mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(gamma)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(gamma)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180}
+    ],
+    "outfile" : "BSTOGLLISRFSR__Bs_gammamumu.root",
+    "reference" : "RefBSTOGLLISRFSR__Bs_gammamumu.root"
+}
diff --git a/test/jsonFiles/BSTOGLLMNT__Bs_gammamumu.json b/test/jsonFiles/BSTOGLLMNT__Bs_gammamumu.json
new file mode 100644
index 0000000..46ebc6d
--- /dev/null
+++ b/test/jsonFiles/BSTOGLLMNT__Bs_gammamumu.json
@@ -0,0 +1,34 @@
+{
+    "parent" : "B_s0",
+    "daughters" : ["gamma", "mu+", "mu-"],
+    "models" : ["BSTOGLLMNT"],
+    "parameters" : [["5.0", "5", "1", "1", "0.02", "0.88", "0.227", "0.22", "0.34"]],
+    "do_conjugate_decay" : [true],
+    "extras" : ["Define dm_incohMix_B_s0 0", "noPhotos"],
+    "events" : 2000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.5},
+        {"variable" : "mass", "title" : "m(gamma mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.1, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(gamma mu-)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(mu+ mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "pSumSq", "title" : "qSq(gamma mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 30.0},
+        {"variable" : "pSumSq", "title" : "qSq(mu+ mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "E", "title" : "E(gamma)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 4.0},
+        {"variable" : "pz", "title" : "pz(gamma)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(gamma,mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(gamma,mu-)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu+,mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(gamma)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(gamma)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180}
+    ],
+    "outfile" : "BSTOGLLMNT__Bs_gammamumu.root",
+    "reference" : "RefBSTOGLLMNT__Bs_gammamumu.root"
+}
diff --git a/test/jsonFiles/BS_MUMUKK__Bs_mumuKK.json b/test/jsonFiles/BS_MUMUKK__Bs_mumuKK.json
new file mode 100644
index 0000000..11b963c
--- /dev/null
+++ b/test/jsonFiles/BS_MUMUKK__Bs_mumuKK.json
@@ -0,0 +1,40 @@
+{
+    "parent" : "B_s0",
+    "daughters" : ["mu+", "mu-", "K+", "K-"],
+    "models" : ["BS_MUMUKK"],
+    "parameters" : [["0.0", "0.0", "-0.03", "1.0", "0.07", "3.315", "-0.03", "1.0", "0.93", "0.5242", "0.0", "-0.03", "1.0", "0.25", "3.08", "-0.03", "1.0", "3.26", "-0.03", "1.0", "0.0", "0.0", "-0.03", "1.0", "0.0", "0.0", "-0.03", "1.0", "0.0", "-0.03", "1.0", "0.6614", "0.08543", "17.8", "0.9499", "0.988", "1.2"]],
+    "do_conjugate_decay" : [true],
+    "extras" : ["Define dm_incohMix_B_s0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.3},
+	{"variable" : "mass", "title" : "m(mu+mu-)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 3.0, "xmax" : 3.2},
+        {"variable" : "mass", "title" : "m(mu+K+)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 4.0},
+        {"variable" : "mass", "title" : "m(mu- K+)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 4.0},
+        {"variable" : "mass", "title" : "m(K+ K-)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.9, "xmax" : 1.3},
+        {"variable" : "pSumSq", "title" : "qSq(mu+mu-)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 9.5, "xmax" : 9.7},
+        {"variable" : "pSumSq", "title" : "qSq(K+K-)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.9, "xmax" : 1.5},
+        {"variable" : "p", "title" : "p(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(mu-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(mu-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(K+)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.5},
+        {"variable" : "pz", "title" : "pz(K+)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.5, "xmax" : 1.5},
+        {"variable" : "p", "title" : "p(K-)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.5},
+        {"variable" : "pz", "title" : "pz(K-)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : -1.5, "xmax" : 1.5},
+        {"variable" : "cosHel", "title" : "cosHel(mu+,mu-)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(K+,K-)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu-,K+)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu+,K+)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(K+)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(K-)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(mu-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(K+)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(K-)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180}
+    ],
+    "outfile" : "BS_MUMUKK__Bs_mumuKK.root",
+    "reference" : "RefBS_MUMUKK__Bs_mumuKK.root"
+}
diff --git a/test/jsonFiles/BTO3PI_CP=VSS=ISGW2__Upsilon4S_Bd_pipipi0_Deanti-nu_e.json b/test/jsonFiles/BTO3PI_CP=VSS=ISGW2__Upsilon4S_Bd_pipipi0_Deanti-nu_e.json
new file mode 100644
index 0000000..4f6cb9e
--- /dev/null
+++ b/test/jsonFiles/BTO3PI_CP=VSS=ISGW2__Upsilon4S_Bd_pipipi0_Deanti-nu_e.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "Upsilon(4S)",
+    "daughters" : ["B0", "anti-B0"],
+    "grand_daughters" : [["pi+","pi-","pi0"], ["D+","e-","anti-nu_e"]],
+    "models" : ["VSS", "BTO3PI_CP", "ISGW2"],
+    "parameters" : [[], ["0.51e12", "0.4"], []],
+    "do_conjugate_decay" : [false, true, true],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob_daug1", "title" : "Prob(BTO3PI_CP)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass_daug1", "title" : "m(#pi^{+} #pi^{-})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass_daug1", "title" : "m(#pi^{-} #pi^{0})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass_daug1", "title" : "m(#pi^{+} #pi^{0})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+	{"variable" : "massSq_daug1", "title" : "Dalitz m^{2}(#pi^{+} #pi^{-}) vs m^{2}(#pi^{+} #pi^{0})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.0, "xmax" : 30.0, "variableY" : "massSq_daug1", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 30.0},
+        {"variable" : "massSq_daug1", "title" : "Dalitz m^{2}(#pi^{-} #pi^{0}) vs m^{2}(#pi^{+} #pi^{+})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.0, "xmax" : 30.0, "variableY" : "massSq_daug1", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 30.0},
+        {"variable" : "mPrime_daug1", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime_daug1", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+        {"variable" : "lifetime_daug1", "title" : "tau(#pi^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 200000.0},
+        {"variable" : "lifetime_daug1", "title" : "tau(#pi^{-})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 200000.0}
+    ],
+    "outfile" :"BTO3PI_CP=VSS=ISGW2__Upsilon4S_Bd_pipipi0_Deanti-nu_e.root",
+    "reference" : "RefBTO3PI_CP=VSS=ISGW2__Upsilon4S_Bd_pipipi0_Deanti-nu_e.root"
+}
diff --git a/test/jsonFiles/BTO4PI_CP=VSS=ISGW2__Upsilon4S_Bd_pipipipi_D+enu.json b/test/jsonFiles/BTO4PI_CP=VSS=ISGW2__Upsilon4S_Bd_pipipipi_D+enu.json
new file mode 100644
index 0000000..6c3c0a1
--- /dev/null
+++ b/test/jsonFiles/BTO4PI_CP=VSS=ISGW2__Upsilon4S_Bd_pipipipi_D+enu.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "Upsilon(4S)",
+    "daughters" : ["B0", "anti-B0"],
+    "grand_daughters" : [["pi+","pi-","pi+","pi-"], ["D+","e-","anti-nu_e"]],
+    "models" : ["VSS", "BTO4PI_CP", "ISGW2"],
+    "parameters" : [[], ["0.4", "0.51e12", "1.0", "0.0", "1.0", "0.0", "1.0", "0.0", "1.0", "0.0", "1.0", "0.0", "1.0", "0.0", "1.0", "0.0", "1.0", "0.0"], []],
+    "do_conjugate_decay" : [false, true, true],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob_daug1", "title" : "Prob(BTO4PI_CP)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "lifetime", "title" : "tau1", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+        {"variable" : "lifetime", "title" : "tau2", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+        {"variable" : "id", "title" : "ID1", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1000.0, "xmax" : 1000.0},
+        {"variable" : "id", "title" : "ID2", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1000.0, "xmax" : 1000.0},
+        {"variable" : "mass_daug1", "title" : "mass(pi1pi2)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass3_daug1", "title" : "mass(pi1pi2pi3)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "decayangle3_daug1", "title" : "theta(rho+=pi1+pi2,pi3) B0 as parent", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 200.0},
+        {"variable" : "decayangle_BTO4PI_daug1", "title" : "theta(pi1,pi2) a2=pi1+pi2+pi3 as parent", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 200.0}
+    ],
+    "outfile" :"BTO4PI_CP=VSS=ISGW2__Upsilon4S_Bd_pipipipi_D+enu.root",
+    "reference" : "RefBTO4PI_CP=VSS=ISGW2__Upsilon4S_Bd_pipipipi_D+enu.root"
+}
diff --git a/test/jsonFiles/BTODDALITZCPK=D0GAMMADALITZ__Bu_D0K,KsKK.json b/test/jsonFiles/BTODDALITZCPK=D0GAMMADALITZ__Bu_D0K,KsKK.json
new file mode 100644
index 0000000..3b162a6
--- /dev/null
+++ b/test/jsonFiles/BTODDALITZCPK=D0GAMMADALITZ__Bu_D0K,KsKK.json
@@ -0,0 +1,26 @@
+{
+    "parent" : "B-",
+    "daughters" : ["D0", "K-"],
+    "grand_daughters" : [["K_S0", "K+", "K-"], []],
+    "models" : ["BTODDALITZCPK", "D0GAMMADALITZ", ""],
+    "parameters" : [["1.15", "2.27", "0.10"], [], []],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob_daug1", "title" : "Prob(D0GAMMADALITZ)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "parMass", "title" : "m(B^{0})", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 5.25, "xmax" : 5.3},
+	{"variable" : "cosTheta", "title" : "cosTheta(D^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(K)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "mass_daug1", "title" : "m(K^{0}_{S} K^{+})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.95, "xmax" : 1.4},
+        {"variable" : "mass_daug1", "title" : "m(K^{0}_{S} K^{-})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.95, "xmax" : 1.4},
+        {"variable" : "mass_daug1", "title" : "m(K^{+} K^{-})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.95, "xmax" : 1.4},
+        {"variable" : "massSq_daug1", "title" : "Dalitz m^{2}(K^{0}_{S} K^{+}) vs m^{2}(K^{0}_{S} K^{-})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.8, "xmax" : 2.0, "variableY" : "massSq_daug1", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.8, "ymax" : 2.0},
+        {"variable" : "massSq_daug1", "title" : "Dalitz m^{2}(K^{+} K^{-}) vs m^{2}(K^{0}_{S} K^{+})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.8, "xmax" : 2.0, "variableY" : "massSq_daug1", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.8, "ymax" : 2.0},
+        {"variable" : "mPrime_daug1", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime_daug1", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel(K^{0}_{S},D^{0})", "d1" : 1, "d2" : 0, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel_daug1", "title" : "cosHel12", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel_daug1", "title" : "cosHel23", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel_daug1", "title" : "cosHel13", "d1" : 1, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "BTODDALITZCPK=D0GAMMADALITZ__Bu_D0K,KsKK.root",
+    "reference" : "RefBTODDALITZCPK=D0GAMMADALITZ__Bu_D0K,KsKK.root"
+}
diff --git a/test/jsonFiles/BTOKD3P=PTO3P__Bu_KD0D0b,K0spipi.json b/test/jsonFiles/BTOKD3P=PTO3P__Bu_KD0D0b,K0spipi.json
new file mode 100644
index 0000000..f18323f
--- /dev/null
+++ b/test/jsonFiles/BTOKD3P=PTO3P__Bu_KD0D0b,K0spipi.json
@@ -0,0 +1,45 @@
+{
+    "parent" : "B-",
+    "daughters" : ["K-", "D0", "anti-D0"],
+    "grand_daughters" : [[], ["K_S0", "pi+", "pi-"], ["K_S0", "pi+", "pi-"]],
+    "models" : ["BTOKD3P", "", "PTO3P", "PTO3P"],
+    "do_conjugate_decay" : [false, false, false],
+    "parameters" : [["0.10", "3.04"], [],
+		    ["MAXPDF 2.4",
+		     "AMPLITUDE RESONANCE AC K*- ANGULAR BC TYPE RBW_ZEMACH COEFFICIENT POLAR_DEG 1.74 139.0",
+		     "AMPLITUDE RESONANCE AC K_0*- ANGULAR BC TYPE RBW_ZEMACH COEFFICIENT POLAR_DEG 0.8 153.0",
+		     "AMPLITUDE RESONANCE AC K_2*- ANGULAR BC TYPE RBW_ZEMACH COEFFICIENT POLAR_DEG 1.41 138.4",
+		     "AMPLITUDE RESONANCE AB K*+ ANGULAR CA TYPE RBW_ZEMACH COEFFICIENT POLAR_DEG 0.16 -42.7",
+		     "AMPLITUDE RESONANCE BC rho0 ANGULAR AB TYPE RBW_ZEMACH COEFFICIENT POLAR_DEG 1.0 0.0",
+		     "AMPLITUDE RESONANCE BC omega ANGULAR AB TYPE RBW_ZEMACH COEFFICIENT POLAR_DEG 0.053 126.5",
+		     "AMPLITUDE RESONANCE BC f_2 ANGULAR AB TYPE RBW_ZEMACH COEFFICIENT POLAR_DEG 0.61 157.4",
+		     "AMPLITUDE PHASESPACE COEFFICIENT POLAR_DEG 0.3 0.0"],
+		    ["MAXPDF 2.4",
+		     "AMPLITUDE RESONANCE AC K*- ANGULAR BC TYPE RBW_ZEMACH COEFFICIENT POLAR_DEG 1.74 139.0",
+		     "AMPLITUDE RESONANCE AC K_0*- ANGULAR BC TYPE RBW_ZEMACH COEFFICIENT POLAR_DEG 0.8 153.0",
+		     "AMPLITUDE RESONANCE AC K_2*- ANGULAR BC TYPE RBW_ZEMACH COEFFICIENT POLAR_DEG 1.41 138.4",
+		     "AMPLITUDE RESONANCE AB K*+ ANGULAR CA TYPE RBW_ZEMACH COEFFICIENT POLAR_DEG 0.16 -42.7",
+		     "AMPLITUDE RESONANCE BC rho0 ANGULAR AB TYPE RBW_ZEMACH COEFFICIENT POLAR_DEG 1.0 0.0",
+		     "AMPLITUDE RESONANCE BC omega ANGULAR AB TYPE RBW_ZEMACH COEFFICIENT POLAR_DEG 0.053 126.5",
+		     "AMPLITUDE RESONANCE BC f_2 ANGULAR AB TYPE RBW_ZEMACH COEFFICIENT POLAR_DEG 0.61 157.4",
+		     "AMPLITUDE PHASESPACE COEFFICIENT POLAR_DEG 0.3 0.0"]],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob(BTOKD3P)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(K^{-} D^{0})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 5.27, "xmax" : 5.29},
+	{"variable" : "mass_daug2", "title" : "m(K^{0}_{S} #pi^{+})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.5, "xmax" : 1.8},
+        {"variable" : "mass_daug2", "title" : "m(K^{0}_{S} #pi^{-})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.5, "xmax" : 1.8},
+        {"variable" : "mass_daug2", "title" : "m(#pi^{-} #pi^{+})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.2, "xmax" : 1.5},
+	{"variable" : "massSq_daug2", "title" : "m^{2}(K^{0}_{S} #pi^{+})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.5},
+        {"variable" : "massSq_daug2", "title" : "m^{2}(K^{0}_{S} #pi^{-})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.5},
+        {"variable" : "massSq_daug2", "title" : "m^{2}(#pi^{-} #pi^{+})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0},
+        {"variable" : "massSq_daug2", "title" : "Dalitz m^{2}(K^{0}_{S} #pi^{-}) vs m^{2}(K^{0}_{S} #pi^{+})", "d1" : 1, "d2" : 3, "nbins" : 50, "xmin" : 0.0, "xmax" : 3.5, "variableY" : "massSq_daug2", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 3.5},
+        {"variable" : "massSq_daug2", "title" : "Dalitz m^{2}(#pi^{+} #pi^{-}) vs m^{2}(K^{0}_{S} #pi^{+})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.0, "xmax" : 2.1, "variableY" : "massSq_daug2", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 3.5},
+        {"variable" : "mPrime_daug2", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime_daug2", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+	{"variable" : "cosHel_daug2", "title" : "cosHel12", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel_daug2", "title" : "cosHel23", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel_daug2", "title" : "cosHel13", "d1" : 1, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "BTOKD3P=PTO3P__Bu_KD0D0b,K0spipi.root",
+    "reference" : "RefBTOKD3P=PTO3P__Bu_KD0D0b,K0spipi.root"
+}
diff --git a/test/jsonFiles/BTOKPIPI_CP=VSS=ISGW2__Upsilon4S_Bd_Kpipi0_Deanti-nu_e.json b/test/jsonFiles/BTOKPIPI_CP=VSS=ISGW2__Upsilon4S_Bd_Kpipi0_Deanti-nu_e.json
new file mode 100644
index 0000000..2be5927
--- /dev/null
+++ b/test/jsonFiles/BTOKPIPI_CP=VSS=ISGW2__Upsilon4S_Bd_Kpipi0_Deanti-nu_e.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "Upsilon(4S)",
+    "daughters" : ["B0", "anti-B0"],
+    "grand_daughters" : [["K+","pi-","pi0"], ["D+","e-","anti-nu_e"]],
+    "models" : ["VSS", "BTOKPIPI_CP", "ISGW2"],
+    "parameters" : [[], ["0.51e12", "1.5", "0.4"], []],
+    "do_conjugate_decay" : [false, true, true],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob_daug1", "title" : "Prob(BTOKPIPI_CP)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass_daug1", "title" : "m(K^{+} #pi^{-})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass_daug1", "title" : "m(#pi^{-} #pi^{0})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass_daug1", "title" : "m(K^{+} #pi^{0})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+	{"variable" : "massSq_daug1", "title" : "Dalitz m^{2}(K^{+} #pi^{-}) vs m^{2}(K^{+} #pi^{0})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.0, "xmax" : 30.0, "variableY" : "massSq_daug1", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 30.0},
+        {"variable" : "massSq_daug1", "title" : "Dalitz m^{2}(#pi^{-} #pi^{0}) vs m^{2}(K^{+} K^{+})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.0, "xmax" : 30.0, "variableY" : "massSq_daug1", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 30.0},
+        {"variable" : "mPrime_daug1", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime_daug1", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+        {"variable" : "lifetime_daug1", "title" : "tau(K^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 200000.0},
+        {"variable" : "lifetime_daug1", "title" : "tau(#pi^{-})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 200000.0}
+    ],
+    "outfile" :"BTOKPIPI_CP=VSS=ISGW2__Upsilon4S_Bd_Kpipi0_Deanti-nu_e.root",
+    "reference" : "RefBTOKPIPI_CP=VSS=ISGW2__Upsilon4S_Bd_Kpipi0_Deanti-nu_e.root"
+}
diff --git a/test/jsonFiles/BTOPLNUBK__Bu_pienu.json b/test/jsonFiles/BTOPLNUBK__Bu_pienu.json
new file mode 100644
index 0000000..5133c43
--- /dev/null
+++ b/test/jsonFiles/BTOPLNUBK__Bu_pienu.json
@@ -0,0 +1,26 @@
+{
+    "parent" : "B+",
+    "daughters" : ["pi0", "e+", "nu_e"],
+    "models" : ["BTOPLNUBK"],
+    "parameters" : [["0.54", "1.4"]],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "pSumSq", "title" : "q^{2}(e #nu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 28.0},
+        {"variable" : "mass", "title" : "m(#pi^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.12, "xmax" : 0.15},
+        {"variable" : "mass", "title" : "m(#pi^{0} e)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.5},
+        {"variable" : "mass", "title" : "m(e #nu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.5},
+        {"variable" : "mass", "title" : "m(#pi^{0} #nu)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.5},
+	{"variable" : "p", "title" : "p(#pi^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(e)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(#nu)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "cosHel", "title" : "cosHel(#pi^{0},e)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(e,#nu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(#pi^{0},#nu)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#pi^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(e)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#nu)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "BTOPLNUBK__Bu_pienu.root",
+    "reference" : "RefBTOPLNUBK__Bu_pienu.root"
+}
diff --git a/test/jsonFiles/BTOSLLALI=VSS__Bs_phimumu,KK.json b/test/jsonFiles/BTOSLLALI=VSS__Bs_phimumu,KK.json
new file mode 100644
index 0000000..cd9e92b
--- /dev/null
+++ b/test/jsonFiles/BTOSLLALI=VSS__Bs_phimumu,KK.json
@@ -0,0 +1,32 @@
+{
+    "parent" : "B_s0",
+    "daughters" : ["phi", "mu+", "mu-"],
+    "grand_daughters" : [["K+", "K-"], [], []],
+    "models" : ["BTOSLLALI", "VSS", ""],
+    "parameters" : [[], [], []],
+    "do_conjugate_decay" : [true, false, false],
+    "extras" : ["Define dm_incohMix_B_s0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(BTOSLLALI)", "d1" : 0, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug1", "title" : "Prob(VSS)", "d1" : 0, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(phi)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 0.95, "xmax" : 1.1},
+        {"variable" : "mass", "title" : "m(phi mu+)", "d1" : 1, "d2" : 2, "nbins": 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(mu+ mu-)", "d1" : 2, "d2" : 3, "nbins": 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "pSumSq", "title" : "qSq(mu+ mu-)", "d1" : 2, "d2" : 3, "nbins": 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "p", "title" : "p(phi)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pSq", "title" : "pSq(phi)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 8.0},
+        {"variable" : "pz", "title" : "pz(phi)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu+,phi)", "d1" : 2, "d2" : 1, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(K+)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(phi)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(K+)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 2.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(K+)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(K+)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(K-)", "d1" : 2, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 2.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(K-)", "d1" : 2, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(K-)", "d1" : 2, "d2" : 0, "nbins": 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "BTOSLLALI=VSS__Bs_phimu+mu+,KK.root",
+    "reference" : "RefBTOSLLALI=VSS__Bs_phimu+mu+,KK.root"
+}
diff --git a/test/jsonFiles/BTOSLLBALL=PHSP__Bd_Ksmumu,pipi.json b/test/jsonFiles/BTOSLLBALL=PHSP__Bd_Ksmumu,pipi.json
new file mode 100644
index 0000000..9da26fb
--- /dev/null
+++ b/test/jsonFiles/BTOSLLBALL=PHSP__Bd_Ksmumu,pipi.json
@@ -0,0 +1,37 @@
+{
+    "parent" : "B0",
+    "daughters" : ["K_S0", "mu+", "mu-"],
+    "grand_daughters" : [["pi+", "pi-"], [], []],
+    "models" : ["BTOSLLBALL", "PHSP", ""],
+    "parameters" : [[], [], []],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(Ks)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.4, "xmax" : 0.6},
+        {"variable" : "mass", "title" : "m(Ks mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(Ks mu-)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(mu+mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "pSumSq", "title" : "qSq(mu+ mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 25.0},
+        {"variable" : "p", "title" : "p(Ks)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pSq", "title" : "pSq(Ks)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 8.0},
+        {"variable" : "pz", "title" : "pz(Ks)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(Ks,mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu+,mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(Ks)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(Ks)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 3.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(pi-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 3.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(pi-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "BTOSLLBALL=PHSP__Bd_Ksmumu,pipi.root",
+    "reference" : "RefBTOSLLBALL=PHSP__Bd_Ksmumu,pipi.root"
+}
diff --git a/test/jsonFiles/BTOSLLBALL=VSS__Bd_Kst0mumu,KK.json b/test/jsonFiles/BTOSLLBALL=VSS__Bd_Kst0mumu,KK.json
new file mode 100644
index 0000000..c6c5785
--- /dev/null
+++ b/test/jsonFiles/BTOSLLBALL=VSS__Bd_Kst0mumu,KK.json
@@ -0,0 +1,37 @@
+{
+    "parent" : "B0",
+    "daughters" : ["K*0", "mu+", "mu-"],
+    "grand_daughters" : [["K+", "pi-"], [], []],
+    "models" : ["BTOSLLBALL", "VSS", ""],
+    "parameters" : [["6"], [], []],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(Kst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0},
+        {"variable" : "mass", "title" : "m(Kst mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(Kst mu-)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(mu+mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "pSumSq", "title" : "qSq(mu+ mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 25.0},
+        {"variable" : "p", "title" : "p(Kst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pSq", "title" : "pSq(Kst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 8.0},
+        {"variable" : "pz", "title" : "pz(Kst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(Kst,mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu+,mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(K+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(Kst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(Kst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(K+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 3.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(pi-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 3.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(K+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(K+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(pi-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "BTOSLLBALL=VSS__Bd_Kst0mumu,Kpi.root",
+    "reference" : "RefBTOSLLBALL=VSS__Bd_Kst0mumu,Kpi.root"
+}
diff --git a/test/jsonFiles/BTOSLLBALL=VSS__Bs_phimumu,KK.json b/test/jsonFiles/BTOSLLBALL=VSS__Bs_phimumu,KK.json
new file mode 100644
index 0000000..123fa24
--- /dev/null
+++ b/test/jsonFiles/BTOSLLBALL=VSS__Bs_phimumu,KK.json
@@ -0,0 +1,38 @@
+{
+    "parent" : "B_s0",
+    "daughters" : ["phi", "mu+", "mu-"],
+    "grand_daughters" : [["K+", "K-"], [], []],
+    "models" : ["BTOSLLBALL", "VSS", ""],
+    "parameters" : [["6"], [], []],
+    "do_conjugate_decay" : [true, false, false, false],
+    "extras" : ["Define dm_incohMix_B_s0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(phi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.95, "xmax" : 1.1},
+        {"variable" : "mass", "title" : "m(phi mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(phi mu-)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(mu+mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "pSumSq", "title" : "qSq(mu+ mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "p", "title" : "p(phi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pSq", "title" : "pSq(phi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 8.0},
+        {"variable" : "pz", "title" : "pz(phi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(phi,mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu+,mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(K+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(phi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(phi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(K+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 2.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(K-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 2.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(K+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(K+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(K-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(K-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "BTOSLLBALL=VSS__Bs_phimumu,KK.root",
+    "reference" : "RefBTOSLLBALL=VSS__Bs_phimumu,KK.root"
+}
diff --git a/test/jsonFiles/BTOSLLBALL=VSS__Bu_rhomumu,pipi0.json b/test/jsonFiles/BTOSLLBALL=VSS__Bu_rhomumu,pipi0.json
new file mode 100644
index 0000000..42d9be0
--- /dev/null
+++ b/test/jsonFiles/BTOSLLBALL=VSS__Bu_rhomumu,pipi0.json
@@ -0,0 +1,37 @@
+{
+    "parent" : "B+",
+    "daughters" : ["rho+", "mu+", "mu-"],
+    "grand_daughters" : [["pi+", "pi0"], [], []],
+    "models" : ["BTOSLLBALL", "VSS", ""],
+    "parameters" : [["6"], [], []],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(rho)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0},
+        {"variable" : "mass", "title" : "m(rho mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(rho mu-)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(mu+mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "pSumSq", "title" : "qSq(mu+ mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 25.0},
+        {"variable" : "p", "title" : "p(rho)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pSq", "title" : "pSq(rho)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 8.0},
+        {"variable" : "pz", "title" : "pz(rho)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(rho,mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu+,mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(rho)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(rho)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 3.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(pi0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 3.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(pi0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+      ],
+    "outfile" : "BTOSLLBALL=VSS__Bu_rhomumu,pipi0.root",
+    "reference" : "RefBTOSLLBALL=VSS__Bu_rhomumu,pipi0.root"
+}
diff --git a/test/jsonFiles/BTOSLLBALL__Bu_Kmumu.json b/test/jsonFiles/BTOSLLBALL__Bu_Kmumu.json
new file mode 100644
index 0000000..9b4b3d0
--- /dev/null
+++ b/test/jsonFiles/BTOSLLBALL__Bu_Kmumu.json
@@ -0,0 +1,33 @@
+{
+    "parent" : "B+",
+    "daughters" : ["K+", "mu+", "mu-"],
+    "models" : ["BTOSLLBALL"],
+    "parameters" : [["6"]],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(K+ mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.1, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(K+ mu-)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(mu+ mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "pSumSq", "title" : "qSq(K+ mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 30.0},
+        {"variable" : "pSumSq", "title" : "qSq(mu+ mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 30.0},
+        {"variable" : "p", "title" : "p(K+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(K+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(K+,mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(K+,mu-)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu+,mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(K+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(K+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180}
+    ],
+    "outfile" : "BTOSLLBALL__Bu_Kmumu.root",
+    "reference" : "RefBTOSLLBALL__Bu_Kmumu.root"
+}
diff --git a/test/jsonFiles/BTOSLLBALL__Bu_pimumu.json b/test/jsonFiles/BTOSLLBALL__Bu_pimumu.json
new file mode 100644
index 0000000..e32780b
--- /dev/null
+++ b/test/jsonFiles/BTOSLLBALL__Bu_pimumu.json
@@ -0,0 +1,33 @@
+{
+    "parent" : "B+",
+    "daughters" : ["pi+", "mu+", "mu-"],
+    "models" : ["BTOSLLBALL"],
+    "parameters" : [["6"]],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(pi+ mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.1, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(pi+ mu-)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(mu+ mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "pSumSq", "title" : "qSq(pi+ mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 30.0},
+        {"variable" : "pSumSq", "title" : "qSq(mu+ mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 30.0},
+        {"variable" : "p", "title" : "p(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(pi+,mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(pi+,mu-)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu+,mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180}
+    ],
+    "outfile" : "BTOSLLBALL__Bu_pimumu.root",
+    "reference" : "RefBTOSLLBALL__Bu_pimumu.root"
+}
diff --git a/test/jsonFiles/BTOSLLMS=VSS__Bu_rhomumu,pipi0.json b/test/jsonFiles/BTOSLLMS=VSS__Bu_rhomumu,pipi0.json
new file mode 100644
index 0000000..9b71f13
--- /dev/null
+++ b/test/jsonFiles/BTOSLLMS=VSS__Bu_rhomumu,pipi0.json
@@ -0,0 +1,37 @@
+{
+    "parent" : "B+",
+    "daughters" : ["rho+", "mu+", "mu-"],
+    "grand_daughters" : [["pi+", "pi0"], [], []],
+    "models" : ["BTOSLLMS", "VSS", ""],
+    "parameters" : [["5.0", "5", "0", "1", "0.88", "0.227", "0.22", "0.34"], [], []],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(rho)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "mass", "title" : "m(rho mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(rho mu-)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(mu+mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "pSumSq", "title" : "qSq(mu+ mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 25.0},
+        {"variable" : "p", "title" : "p(rho)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pSq", "title" : "pSq(rho)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 8.0},
+        {"variable" : "pz", "title" : "pz(rho)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(rho,mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu+,mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(rho)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(rho)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 3.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(pi0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 3.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(pi0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "BTOSLLMS=VSS__Bu_rhomumu,pipi0.root",
+    "reference" : "RefBTOSLLMS=VSS__Bu_rhomumu,pipi0.root"
+}
diff --git a/test/jsonFiles/BTOSLLMSEXT=VVS_PWAVE__Bu_K1mumu,rho0K.json b/test/jsonFiles/BTOSLLMSEXT=VVS_PWAVE__Bu_K1mumu,rho0K.json
new file mode 100644
index 0000000..b6a04fb
--- /dev/null
+++ b/test/jsonFiles/BTOSLLMSEXT=VVS_PWAVE__Bu_K1mumu,rho0K.json
@@ -0,0 +1,38 @@
+{
+    "parent" : "B+",
+    "daughters" : ["K_1+", "mu+", "mu-"],
+    "grand_daughters" : [["rho0", "K+"], [], []],
+    "models" : ["BTOSLLMSEXT", "VVS_PWAVE", ""],
+    "parameters" : [["5.0", "5", "0", "1", "0.88", "0.227", "0.22", "0.34", "1.0", "0.0", "-1.0", "0.0"], 
+                    ["1.0", "0.0", "0.0", "0.0", "0.0", "0.0"], []],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(K_1)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "mass", "title" : "m(K_1 mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(K_1 mu-)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(mu+mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "pSumSq", "title" : "qSq(mu+ mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "p", "title" : "p(K_1)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pSq", "title" : "pSq(K_1)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 8.0},
+        {"variable" : "pz", "title" : "pz(K_1)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(K_1,mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu+,mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(rho0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(K_1)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(K_1)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(rho0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 3.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(K+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 3.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(rho0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(rho0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(K+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(K+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "BTOSLLMSEXT=VSS__Bu_K1mumu,rho0K.root",
+    "reference" : "RefBTOSLLMSEXT=VSS__Bu_K1mumu,rho0K.root"
+}
diff --git a/test/jsonFiles/BTOVLNUBALL__Bd_Kstarenu.json b/test/jsonFiles/BTOVLNUBALL__Bd_Kstarenu.json
new file mode 100644
index 0000000..3c2d3ac
--- /dev/null
+++ b/test/jsonFiles/BTOVLNUBALL__Bd_Kstarenu.json
@@ -0,0 +1,26 @@
+{
+    "parent" : "B0",
+    "daughters" : ["K*+", "e-", "anti-nu_e"],
+    "models" : ["BTOVLNUBALL"],
+    "parameters" : [["0.290", "40.38", "-0.084", "0.342", "52.0", "0.923", "-0.511", "49.40"]],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(K^{*+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 1.8},
+        {"variable" : "mass", "title" : "m(K^{*+} e)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.5, "xmax" : 5.5},
+        {"variable" : "mass", "title" : "m(e #nu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "mass", "title" : "m(K^{*+} #nu)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.5, "xmax" : 5.5},
+        {"variable" : "pSumSq", "title" : "q^{2}(e #nu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 21.0},
+        {"variable" : "p", "title" : "p(K^{*+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(e)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(#nu)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(K^{*+},e)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(e,#nu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(K^{*+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(e)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#nu)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "BTOVLNUBALL__Bd_Kstarenu.root",
+    "reference" : "RefBTOVLNUBALL__Bd_Kstarenu.root"
+}
diff --git a/test/jsonFiles/BTOXELNU=VSS__Bu_rho0munu,pipi.json b/test/jsonFiles/BTOXELNU=VSS__Bu_rho0munu,pipi.json
new file mode 100644
index 0000000..c232402
--- /dev/null
+++ b/test/jsonFiles/BTOXELNU=VSS__Bu_rho0munu,pipi.json
@@ -0,0 +1,38 @@
+{
+    "parent" : "B+",
+    "daughters" : ["rho0", "mu+", "nu_mu"],
+    "grand_daughters" : [["pi+", "pi-"], [], []],
+    "models" : ["BTOXELNU", "VSS", ""],
+    "parameters" : [["BCL", "-0.861", "1.444", "0.266", "0.378", "0.165", "0.291",
+		     "0.718", "0.384", "0.331", "-0.876", "1.907"], [], []],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(BTOXELNU)",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug1", "title" : "Prob(VSS)",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(#rho^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.2, "xmax" : 2.0},
+        {"variable" : "mass", "title" : "m(#rho^{0} #mu)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(#rho^{0} #nu)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(#mu #nu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "pSumSq", "title" : "q^{2}(#mu #nu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 25.0},
+        {"variable" : "p", "title" : "p(#rho^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(#rho^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(#pi^{+},#rho^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#rho^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#mu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#nu)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(#rho^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi", "title" : "phi(#mu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi", "title" : "phi(#nu)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "p_daug1", "title" : "p(#pi^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.5},
+        {"variable" : "p_daug1", "title" : "p(#pi^{-})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.5},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(#pi^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(#pi^{-})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(#pi^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi_daug1", "title" : "phi(#pi^{-})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "BTOXELNU=VSS__Bu_rho0munu,pipi.root",
+    "reference" : "RefBTOXELNU=VSS__Bu_rho0munu,pipi.root"
+}
diff --git a/test/jsonFiles/BTOXSETAP=SVP_HELAMP__Bu_Xsuetap,rho0gamma.json b/test/jsonFiles/BTOXSETAP=SVP_HELAMP__Bu_Xsuetap,rho0gamma.json
new file mode 100644
index 0000000..8cf4d66
--- /dev/null
+++ b/test/jsonFiles/BTOXSETAP=SVP_HELAMP__Bu_Xsuetap,rho0gamma.json
@@ -0,0 +1,31 @@
+{
+    "parent" : "B+",
+    "daughters" : ["Xsu", "eta'"],
+    "grand_daughters" : [[], ["rho0", "gamma"], []],
+    "models" : ["BTOXSETAP", "", "SVP_HELAMP"],
+    "parameters" : [[], [], ["1.0", "0.0", "1.0", "0.0"]],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob", "d1" : 0, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 2.0},
+        {"variable" : "mass", "title" : "m(Xsu)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "mass", "title" : "m(eta')", "d1" : 2, "d2" : 0, "nbins": 100, "xmin" : 0.8, "xmax" : 1.1},
+        {"variable" : "p", "title" : "p(Xsu)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pSq", "title" : "pSq(Xsu)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 8.0},
+        {"variable" : "pz", "title" : "pz(Xsu)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel_daug2", "title" : "cosHel(rho0)", "d1" : 1, "d2" : 2, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel_daug2", "title" : "cosHel(gamma)", "d1" : 2, "d2" : 1, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(Xsu)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+        {"variable" : "phi", "title" : "phi(Xsu)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug2", "title" : "pLab(rho0)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "cosTheta_daug2", "title" : "cosTheta(rho0)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug2", "title" : "phi(rho0)", "d1" : 1, "d2" : 0, "nbins": 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "E_daug2", "title" : "E(gamma)", "d1" : 2, "d2" : 0, "nbins": 100, "xmin" : 0.0, "xmax" : 2.0},
+        {"variable" : "cosTheta_daug2", "title" : "cosTheta(gamma)", "d1" : 2, "d2" : 0, "nbins": 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug2", "title" : "phi(gamma)", "d1" : 2, "d2" : 0, "nbins": 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" :"BTOXSETAP=SVP_HELAMP__Bu_Xsuetap,rho0gamma.root",
+    "reference" : "RefBTOXSETAP=SVP_HELAMP__Bu_Xsuetap,rho0gamma.root"
+}
diff --git a/test/jsonFiles/BTOXSGAMMA__Bd_Xsdgamma.json b/test/jsonFiles/BTOXSGAMMA__Bd_Xsdgamma.json
new file mode 100644
index 0000000..da410fc
--- /dev/null
+++ b/test/jsonFiles/BTOXSGAMMA__Bd_Xsdgamma.json
@@ -0,0 +1,21 @@
+{
+    "parent" : "B0",
+    "daughters" : ["Xsd", "gamma"],
+    "models" : ["BTOXSGAMMA", "", ""],
+    "parameters" : [["1"], [], []],
+    "do_conjugate_decay" : [ true, false, false ],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "parMass", "title" : "m(B0)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 5.25, "xmax" : 5.3},
+        {"variable" : "mass", "title" : "m(Xsd)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+	{"variable" : "p", "title" : "p(Xsd)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "phi", "title" : "phi(Xsd)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(Xsd)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "p", "title" : "p(gamma)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 1.0, "xmax" : 3.0},
+	{"variable" : "phi", "title" : "phi(gamma)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(gamma)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "BTOXSGAMMA__Bd_Xsdgamma.root",
+    "reference" : "RefBTOXSGAMMA__Bd_Xsdgamma.root"
+}
diff --git a/test/jsonFiles/BTOXSLL__Bu_Xsumumu.json b/test/jsonFiles/BTOXSLL__Bu_Xsumumu.json
new file mode 100644
index 0000000..4398df3
--- /dev/null
+++ b/test/jsonFiles/BTOXSLL__Bu_Xsumumu.json
@@ -0,0 +1,35 @@
+{
+    "parent" : "B+",
+    "daughters" : ["Xsu", "mu+", "mu-"],
+    "grand_daughters" : [[], [], []],
+    "models" : ["BTOXSLL", "", ""],
+    "parameters" : [["4.8", "0.2", "0.0", "0.41"], 
+                    [], []],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0},
+        {"variable" : "mass", "title" : "m(Xsu mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.1, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(Xsu mu-)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(mu+ mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "pSumSq", "title" : "qSq(Xsu mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 30.0},
+        {"variable" : "pSumSq", "title" : "qSq(mu+ mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "p", "title" : "p(Xsu)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(Xsu)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(Xsu,mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(Xsu,mu-)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu+,mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(Xsu)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(Xsu)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180}
+    ],
+    "outfile" :"BTOXSLL__Bu_Xsumumu.root",
+    "reference" : "RefBTOXSLL__Bu_Xsumumu.root"
+}
diff --git a/test/jsonFiles/BToDiBaryonlnupQCD__Bu_Deltapmunu.json b/test/jsonFiles/BToDiBaryonlnupQCD__Bu_Deltapmunu.json
new file mode 100644
index 0000000..11f7d10
--- /dev/null
+++ b/test/jsonFiles/BToDiBaryonlnupQCD__Bu_Deltapmunu.json
@@ -0,0 +1,17 @@
+{
+    "parent" : "B-",
+    "daughters" : ["Delta+", "anti-p-", "mu-", "anti-nu_mu"],
+    "models" : ["BToDiBaryonlnupQCD"],
+    "parameters" : [["67.7", "-280.0", "-187.3", "-840.1", "-10.1", "-157.0", "7.0e6"]],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "mPP", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 1.5, "xmax" : 3.5},
+	{"variable" : "mass", "title" : "mMuNu", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.5},
+	{"variable" : "pSumSq", "title" : "qSqMuNu", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+	{"variable" : "cosHel", "title" : "cosThetaB", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosThetaL", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "BToDiBaryonlnupQCD__Bu_Deltapmunu.root",
+    "reference" : "RefBToDiBaryonlnupQCD__Bu_Deltapmunu.root"
+}
diff --git a/test/jsonFiles/BToDiBaryonlnupQCD__Bu_ppmunu.json b/test/jsonFiles/BToDiBaryonlnupQCD__Bu_ppmunu.json
new file mode 100644
index 0000000..60608bf
--- /dev/null
+++ b/test/jsonFiles/BToDiBaryonlnupQCD__Bu_ppmunu.json
@@ -0,0 +1,17 @@
+{
+    "parent" : "B-",
+    "daughters" : ["p+", "anti-p-", "mu-", "anti-nu_mu"],
+    "models" : ["BToDiBaryonlnupQCD"],
+    "parameters" : [["67.7", "-280.0", "-187.3", "-840.1", "-10.1", "-157.0", "3.0e6"]],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "mPP", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 1.5, "xmax" : 3.5},
+	{"variable" : "mass", "title" : "mMuNu", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.5},
+	{"variable" : "pSumSq", "title" : "qSqMuNu", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+	{"variable" : "cosHel", "title" : "cosThetaB", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosThetaL", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "BToDiBaryonlnupQCD__Bu_ppmunu.root",
+    "reference" : "RefBToDiBaryonlnupQCD__Bu_ppmunu.root"
+}
diff --git a/test/jsonFiles/B_TO_2BARYON_SCALAR__Bu_Lambda0pbarpi0.json b/test/jsonFiles/B_TO_2BARYON_SCALAR__Bu_Lambda0pbarpi0.json
new file mode 100644
index 0000000..4e88412
--- /dev/null
+++ b/test/jsonFiles/B_TO_2BARYON_SCALAR__Bu_Lambda0pbarpi0.json
@@ -0,0 +1,19 @@
+{
+    "parent" : "B-",
+    "daughters" : ["Lambda0", "anti-p-", "pi0"],
+    "models" : ["B_TO_2BARYON_SCALAR"],
+    "parameters" : [[]],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "M(#it{#Lambda}#bar{#it{p}})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 1.5, "xmax" : 5.5},
+	{"variable" : "mass", "title" : "M(#bar{#it{p}}#it{#pi}^{0})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 1.0, "xmax" : 5.0},
+	{"variable" : "mass", "title" : "M(#it{#Lambda}#it{#pi}^{0})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 1.0, "xmax" : 5.0},
+	{"variable" : "cosHel", "title" : "cosHel(#it{#Lambda},#bar{#it{p}})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel(#bar{#it{p}},#it{#pi}^{0})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel(#it{#Lambda},#it{#pi}^{0})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "B_TO_2BARYON_SCALAR__Bu_Lambda0pbarpi0.root",
+    "reference" : "RefB_TO_2BARYON_SCALAR__Bu_Lambda0pbarpi0.root"
+}
diff --git a/test/jsonFiles/B_TO_LAMBDA_PBAR_GAMMA__Bu_Lambda0pbargamma.json b/test/jsonFiles/B_TO_LAMBDA_PBAR_GAMMA__Bu_Lambda0pbargamma.json
new file mode 100644
index 0000000..d843e20
--- /dev/null
+++ b/test/jsonFiles/B_TO_LAMBDA_PBAR_GAMMA__Bu_Lambda0pbargamma.json
@@ -0,0 +1,20 @@
+{
+    "parent" : "B-",
+    "daughters" : ["Lambda0", "anti-p-", "gamma"],
+    "models" : ["B_TO_LAMBDA_PBAR_GAMMA"],
+    "parameters" : [[]],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "pSumSq", "title" : "qSq(pbar,gamma)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+	{"variable" : "mass", "title" : "m(Lambda,pbar)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 1.5, "xmax" : 5.5},
+	{"variable" : "mass", "title" : "m(pbar,gamma)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 1.0, "xmax" : 5.0},
+	{"variable" : "mass", "title" : "m(Lambda,gamma)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 1.0, "xmax" : 5.0},
+	{"variable" : "cosHel", "title" : "cosHel(Lambda0,pbar)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel(pbar,gamma)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel(Lambda0,gamma)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "B_TO_LAMBDA_PBAR_GAMMA__BuLambdapbargamma.root",
+    "reference" : "RefB_TO_LAMBDA_PBAR_GAMMA__BuLambdapbargamma.root"
+}
diff --git a/test/jsonFiles/BaryonPCR=PHSP__Lambdab0_Lambdacmunu,Lambda0pi.json b/test/jsonFiles/BaryonPCR=PHSP__Lambdab0_Lambdacmunu,Lambda0pi.json
new file mode 100644
index 0000000..e769082
--- /dev/null
+++ b/test/jsonFiles/BaryonPCR=PHSP__Lambdab0_Lambdacmunu,Lambda0pi.json
@@ -0,0 +1,20 @@
+{
+    "parent" : "Lambda_b0",
+    "daughters" : ["Lambda_c+", "mu-", "anti-nu_mu"],
+    "grand_daughters" : [["Lambda0", "pi+"], [], []],
+    "models" : ["BaryonPCR", "PHSP", ""],
+    "parameters" : [["1", "1", "1", "1"], [], []],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(BaryonPCR)",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "parMass", "title" : "m(#Lambda^{0}_{b})", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 5.5, "xmax" : 5.7},
+        {"variable" : "mass", "title" : "m(#Lambda^{+}_{c})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.0, "xmax" : 2.5},
+        {"variable" : "mass", "title" : "m(#Lambda^{+}_{c},#mu^{-})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 2.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(#mu^{-},anti-#nu_{#mu})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 4.0},
+        {"variable" : "mass", "title" : "m(#Lambda^{+}_{c},anti-#nu_{#mu})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 2.0, "xmax" : 6.0},
+        {"variable" : "pSumSq", "title" : "qSq(#mu^{-},anti-#nu_{#mu})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+        {"variable" : "cosHel", "title" : "cosHel(#Lambda^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "BaryonPCR=PHSP__Lambdab0_Lambdacmunu,Lambda0pi.root",
+    "reference" : "RefBaryonPCR=PHSP__Lambdab0_Lambdacmunu,Lambda0pi.root"
+}
diff --git a/test/jsonFiles/CB3PI-MPP__Bu_3pi.json b/test/jsonFiles/CB3PI-MPP__Bu_3pi.json
new file mode 100644
index 0000000..1cfd937
--- /dev/null
+++ b/test/jsonFiles/CB3PI-MPP__Bu_3pi.json
@@ -0,0 +1,17 @@
+{
+    "parent" : "B+",
+    "daughters" : ["pi+","pi+","pi-"],
+    "models" : ["CB3PI-MPP"],
+    "parameters" : [["1.5"]],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(#pi^{+} #pi^{+})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(#pi^{+} #pi^{-})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(#pi^{+} #pi^{-})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+	{"variable" : "massSq", "title" : "Dalitz m^{2}(#pi^{+} #pi^{-}) vs m^{2}(#pi^{+} #pi^{-})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.0, "xmax" : 30.0, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 30.0},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0}
+    ],
+    "outfile" :"CB3PI-MPP__Bu_3pi.root",
+    "reference" : "RefCB3PI-MPP__Bu_3pi.root"
+}
diff --git a/test/jsonFiles/CB3PI-P00__Bu_pi2pi0.json b/test/jsonFiles/CB3PI-P00__Bu_pi2pi0.json
new file mode 100644
index 0000000..d52e242
--- /dev/null
+++ b/test/jsonFiles/CB3PI-P00__Bu_pi2pi0.json
@@ -0,0 +1,17 @@
+{
+    "parent" : "B+",
+    "daughters" : ["pi+","pi0","pi0"],
+    "models" : ["CB3PI-P00"],
+    "parameters" : [["1.5"]],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(#pi^{+} #pi^{0})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(#pi^{+} #pi^{0})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(#pi^{0} #pi^{0})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+	{"variable" : "massSq", "title" : "Dalitz m^{2}(#pi^{+} #pi^{0}) vs m^{2}(#pi^{+} #pi^{0})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.0, "xmax" : 30.0, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 30.0},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0}
+    ],
+    "outfile" :"CB3PI-P00__Bu_pi2pi0.root",
+    "reference" : "RefCB3PI-P00__Bu_pi2pi0.root"
+}
diff --git a/test/jsonFiles/D0MIXDALITZ__D0_KsKK.json b/test/jsonFiles/D0MIXDALITZ__D0_KsKK.json
new file mode 100644
index 0000000..62a0baf
--- /dev/null
+++ b/test/jsonFiles/D0MIXDALITZ__D0_KsKK.json
@@ -0,0 +1,21 @@
+{
+    "parent" : "D0",
+    "daughters" : ["K_S0", "K+", "K-"],
+    "models" : ["D0MIXDALITZ"],
+    "parameters" : [["0.01", "0.01", "1.0", "0.0"]],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(K^{0}_{S} K^{+})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.95, "xmax" : 1.4},
+        {"variable" : "mass", "title" : "m(K^{0}_{S} K^{-})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.95, "xmax" : 1.4},
+        {"variable" : "mass", "title" : "m(K^{+} K^{-})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.95, "xmax" : 1.4},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(K^{0}_{S} K^{+}) vs m^{2}(K^{0}_{S} K^{-})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.8, "xmax" : 2.0, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.8, "ymax" : 2.0},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(K^{+} K^{-}) vs m^{2}(K^{0}_{S} K^{+})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.8, "xmax" : 2.0, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.8, "ymax" : 2.0},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel12", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel23", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel13", "d1" : 1, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "D0MIXDALITZ__D0_KsKK.root",
+    "reference" : "RefD_DALITZ__D0_KsKK.root"
+}
diff --git a/test/jsonFiles/DMIX=VSS__psi3770_D0antiD0,Kpi.json b/test/jsonFiles/DMIX=VSS__psi3770_D0antiD0,Kpi.json
new file mode 100644
index 0000000..028c52b
--- /dev/null
+++ b/test/jsonFiles/DMIX=VSS__psi3770_D0antiD0,Kpi.json
@@ -0,0 +1,30 @@
+{
+    "parent" : "psi(3770)",
+    "daughters" : ["D0", "anti-D0"],
+    "grand_daughters" : [["K+", "pi-"], ["K-", "pi+"]],
+    "models" : ["VSS", "DMIX", "DMIX"],
+    "parameters" : [[], ["3.4e-3", "0.1e-3", "1.0e-3"], ["3.4e-3", "0.1e-3", "1.0e-3"]],
+    "extras" : ["noPhotos"],
+    "events" : 20000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob(VSS)",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug1", "title" : "Prob(DMIX)",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.1},
+        {"variable" : "prob_daug2", "title" : "Prob(DMIX)",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.1},
+        {"variable" : "parMass", "title" : "m(#psi(3770))", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 3.7, "xmax" : 4.0},
+        {"variable" : "mass", "title" : "m(D^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.8, "xmax" : 1.9},
+        {"variable" : "mass", "title" : "m(anti-D^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 1.8, "xmax" : 1.9},
+        {"variable" : "cosHel", "title" : "cosHel(K^{+},D^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(K^{-},anti-D^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "decayangle_daug1", "title" : "DecayAngle(K^{+},#pi^{-})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+        {"variable" : "decayangle_daug2", "title" : "DecayAngle(K^{-},#pi^{+})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "lifetime", "title" : "#tau(D^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 4.0},
+	{"variable" : "lifetime", "title" : "#tau(anti-D^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 4.0},
+        {"variable" : "deltaT", "title" : "#Delta #tau", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -4.0, "xmax" : 4.0},
+	{"variable" : "pLab_daug1", "title" : "p(K^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.4, "xmax" : 1.5},
+	{"variable" : "pLab_daug1", "title" : "p(#pi^{-})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.4, "xmax" : 1.5},
+	{"variable" : "pLab_daug2", "title" : "p(K^{-})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.4, "xmax" : 1.5},
+	{"variable" : "pLab_daug2", "title" : "p(#pi^{+})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.4, "xmax" : 1.5}
+    ],
+    "outfile" : "DMIX=VSS__psi3770_D0antiD0,Kpi.root",
+    "reference" : "RefDMIX=VSS__psi3770_D0antiD0,Kpi.root"
+}
diff --git a/test/jsonFiles/DToKpienu__D+_Kpimunu.json b/test/jsonFiles/DToKpienu__D+_Kpimunu.json
new file mode 100644
index 0000000..82b1d0c
--- /dev/null
+++ b/test/jsonFiles/DToKpienu__D+_Kpimunu.json
@@ -0,0 +1,39 @@
+{
+    "parent" : "D+",
+    "daughters" : ["K-", "pi+", "mu+", "nu_mu"],
+    "models" : ["DToKpienu"],
+    "parameters" : [[]],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(K pi)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.5, "xmax" : 1.5},
+        {"variable" : "mass", "title" : "m(K mu)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0},
+        {"variable" : "mass", "title" : "m(pi mu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.5},
+        {"variable" : "mass", "title" : "m(mu mu)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.5},
+        {"variable" : "pSumSq", "title" : "qSq(K pi)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0},
+        {"variable" : "pSumSq", "title" : "qSq(mu mu)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0},
+        {"variable" : "p", "title" : "p(K)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "pz", "title" : "pz(K)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "p", "title" : "p(pi)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "pz", "title" : "pz(pi)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "p", "title" : "p(mu)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "pz", "title" : "pz(mu)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "p", "title" : "p(nu)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "pz", "title" : "pz(nu)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(K,pi)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu,nu)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(pi,mu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(K,mu)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(K)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(pi)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(nu)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(K)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(pi)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(mu)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(nu)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180}
+    ],
+    "outfile" : "DToKpiemu__D+_Kpimunu.root",
+    "reference" : "RefDToKpiemu__D+_Kpimunu.root"
+}
diff --git a/test/jsonFiles/D_DALITZ__D+_K+pipi.json b/test/jsonFiles/D_DALITZ__D+_K+pipi.json
new file mode 100644
index 0000000..656e846
--- /dev/null
+++ b/test/jsonFiles/D_DALITZ__D+_K+pipi.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "D+",
+    "daughters" : ["K+", "pi-", "pi+"],
+    "models" : ["D_DALITZ"],
+    "parameters" : [[]],
+    "do_conjugate_decay" : [true],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(K^{+} #pi^{-})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.5, "xmax" : 1.8},
+        {"variable" : "mass", "title" : "m(K^{+} #pi^{+})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.5, "xmax" : 1.8},
+        {"variable" : "mass", "title" : "m(#pi^{-} #pi^{+})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.2, "xmax" : 1.5},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(K^{+} #pi^{-}) vs m^{2}(K^{+} #pi^{+})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.05, "xmax" : 3.5, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 3.5},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(#pi^{-} #pi^{+}) vs m^{2}(K^{+} #pi^{-})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.05, "xmax" : 2.0, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.05, "ymax" : 3.5},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel12", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel23", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel13", "d1" : 1, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "D_DALITZ__D+_K+pipi.root",
+    "reference" : "RefD_DALITZ__D+_K+pipi.root"
+}
diff --git a/test/jsonFiles/D_DALITZ__D+_K0pipi0.json b/test/jsonFiles/D_DALITZ__D+_K0pipi0.json
new file mode 100644
index 0000000..78157a8
--- /dev/null
+++ b/test/jsonFiles/D_DALITZ__D+_K0pipi0.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "D+",
+    "daughters" : ["K0", "pi+", "pi0"],
+    "models" : ["D_DALITZ"],
+    "parameters" : [[]],
+    "do_conjugate_decay" : [true],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(K^{0} #pi^{+})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.5, "xmax" : 1.8},
+        {"variable" : "mass", "title" : "m(K^{0} #pi^{0})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.5, "xmax" : 1.8},
+        {"variable" : "mass", "title" : "m(#pi^{+} #pi^{0})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.2, "xmax" : 1.5},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(K^{0} #pi^{+}) vs m^{2}(K^{0} #pi^{0})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.3, "xmax" : 3.2, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.3, "ymax" : 3.2},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(#pi^{+} #pi^{0}) vs m^{2}(K^{0} #pi^{+})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.0, "xmax" : 2.0, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.3, "ymax" : 3.2},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel12", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel23", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel13", "d1" : 1, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "D_DALITZ__D+_K0pipi0.root",
+    "reference" : "RefD_DALITZ__D+_K0pipi0.root"
+}
diff --git a/test/jsonFiles/D_DALITZ__D+_KKpi+.json b/test/jsonFiles/D_DALITZ__D+_KKpi+.json
new file mode 100644
index 0000000..ce272ec
--- /dev/null
+++ b/test/jsonFiles/D_DALITZ__D+_KKpi+.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "D+",
+    "daughters" : ["K-", "K+", "pi+"],
+    "models" : ["D_DALITZ"],
+    "parameters" : [[]],
+    "do_conjugate_decay" : [true],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(K^{-} K^{+})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.9, "xmax" : 1.8},
+        {"variable" : "mass", "title" : "m(K^{-} #pi^{+})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.5, "xmax" : 1.5},
+        {"variable" : "mass", "title" : "m(K^{+} #pi^{+})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.5, "xmax" : 1.5},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(K^{-} K^{+}) vs m^{2}(K^{-} #pi^{+})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.8, "xmax" : 3.2, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.3, "ymax" : 2.0},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(K^{+} #pi^{+}) vs m^{2}(K^{-} K^{+})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.3, "xmax" : 2.0, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.7, "ymax" : 3.2},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel12", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel23", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel13", "d1" : 1, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "D_DALITZ__D+_KKpi+.root",
+    "reference" : "RefD_DALITZ__D+_KKpi+.root"
+}
diff --git a/test/jsonFiles/D_DALITZ__D+_Kpipi+.json b/test/jsonFiles/D_DALITZ__D+_Kpipi+.json
new file mode 100644
index 0000000..e56c302
--- /dev/null
+++ b/test/jsonFiles/D_DALITZ__D+_Kpipi+.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "D+",
+    "daughters" : ["K-", "pi+", "pi+"],
+    "models" : ["D_DALITZ"],
+    "parameters" : [[]],
+    "do_conjugate_decay" : [true],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(K^{-} #pi^{+})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.5, "xmax" : 1.8},
+        {"variable" : "mass", "title" : "m(K^{-} #pi^{+})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.5, "xmax" : 1.8},
+        {"variable" : "mass", "title" : "m(#pi^{+} #pi^{+})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.2, "xmax" : 1.5},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(K^{-} #pi^{+}) vs m^{2}(K^{-} #pi^{+})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.3, "xmax" : 3.2, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.3, "ymax" : 3.2},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(#pi^{+} #pi^{+}) vs m^{2}(K^{-} #pi^{+})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.0, "xmax" : 2.0, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.3, "ymax" : 3.2},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel12", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel23", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel13", "d1" : 1, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "D_DALITZ__D+_Kpipi+.root",
+    "reference" : "RefD_DALITZ__D+_Kpipi+.root"
+}
diff --git a/test/jsonFiles/D_DALITZ__D+_pipipi+.json b/test/jsonFiles/D_DALITZ__D+_pipipi+.json
new file mode 100644
index 0000000..04a355e
--- /dev/null
+++ b/test/jsonFiles/D_DALITZ__D+_pipipi+.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "D+",
+    "daughters" : ["pi-", "pi+", "pi+"],
+    "models" : ["D_DALITZ"],
+    "parameters" : [[]],
+    "do_conjugate_decay" : [true],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(#pi^{-} #pi^{+})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.2, "xmax" : 1.8},
+        {"variable" : "mass", "title" : "m(#pi^{-} #pi^{+})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.2, "xmax" : 1.8},
+        {"variable" : "mass", "title" : "m(#pi^{+} #pi^{+})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.2, "xmax" : 1.8},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(#pi^{-} #pi^{+}) vs m^{2}(#pi^{-} #pi^{+})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.0, "xmax" : 3.2, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 3.2},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(#pi^{+} #pi^{+}) vs m^{2}(#pi^{-} #pi^{+})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.0, "xmax" : 3.2, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 3.2},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel12", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel23", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel13", "d1" : 1, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "D_DALITZ__D+_pipipi+.root",
+    "reference" : "RefD_DALITZ__D+_pipipi+.root"
+}
diff --git a/test/jsonFiles/D_DALITZ__D0_KKK_S0.json b/test/jsonFiles/D_DALITZ__D0_KKK_S0.json
new file mode 100644
index 0000000..70512f0
--- /dev/null
+++ b/test/jsonFiles/D_DALITZ__D0_KKK_S0.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "D0",
+    "daughters" : ["K-", "K+", "K_S0"],
+    "models" : ["D_DALITZ"],
+    "parameters" : [[]],
+    "do_conjugate_decay" : [true],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(K^{-} K^{+})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.95, "xmax" : 1.4},
+        {"variable" : "mass", "title" : "m(K^{-} K^{0}_{S})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.95, "xmax" : 1.4},
+        {"variable" : "mass", "title" : "m(K^{+} K^{0}_{S})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.95, "xmax" : 1.4},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(K^{-} K^{+}) vs m^{2}(K^{-} K^{0}_{S})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.8, "xmax" : 2.0, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.8, "ymax" : 2.0},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(K^{+} K^{0}_{S}) vs m^{2}(K^{-} K^{+})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.8, "xmax" : 2.0, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.8, "ymax" : 2.0},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel12", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel23", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel13", "d1" : 1, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "D_DALITZ__D0_KKK_S0.root",
+    "reference" : "RefD_DALITZ__D0_KKK_S0.root"
+}
diff --git a/test/jsonFiles/D_DALITZ__D0_KKanti-K0.json b/test/jsonFiles/D_DALITZ__D0_KKanti-K0.json
new file mode 100644
index 0000000..a2f44f4
--- /dev/null
+++ b/test/jsonFiles/D_DALITZ__D0_KKanti-K0.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "D0",
+    "daughters" : ["K-", "K+", "anti-K0"],
+    "models" : ["D_DALITZ"],
+    "parameters" : [[]],
+    "do_conjugate_decay" : [true],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(K^{-} K^{+})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.95, "xmax" : 1.4},
+        {"variable" : "mass", "title" : "m(K^{-} anti-K^{0})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.95, "xmax" : 1.4},
+        {"variable" : "mass", "title" : "m(K^{+} anti-K^{0})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.95, "xmax" : 1.4},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(K^{-} K^{+}) vs m^{2}(K^{-} anti-K^{0})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.8, "xmax" : 2.0, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.8, "ymax" : 2.0},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(K^{+} anti-K^{0}) vs m^{2}(K^{-} K^{+})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.8, "xmax" : 2.0, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.8, "ymax" : 2.0},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel12", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel23", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel13", "d1" : 1, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "D_DALITZ__D0_KKanti-K0.root",
+    "reference" : "RefD_DALITZ__D0_KKanti-K0.root"
+}
diff --git a/test/jsonFiles/D_DALITZ__D0_Kpipi0.json b/test/jsonFiles/D_DALITZ__D0_Kpipi0.json
new file mode 100644
index 0000000..1713726
--- /dev/null
+++ b/test/jsonFiles/D_DALITZ__D0_Kpipi0.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "D0",
+    "daughters" : ["K-", "pi+", "pi0"],
+    "models" : ["D_DALITZ"],
+    "parameters" : [[]],
+    "do_conjugate_decay" : [true],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(K^{-} #pi^{+})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.5, "xmax" : 1.8},
+        {"variable" : "mass", "title" : "m(K^{-} #pi^{0})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.5, "xmax" : 1.8},
+        {"variable" : "mass", "title" : "m(#pi^{+} #pi^{0})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.2, "xmax" : 1.5},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(K^{-} #pi^{+}) vs m^{2}(K^{-} #pi^{0})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.3, "xmax" : 3.2, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.3, "ymax" : 3.2},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(#pi^{+} #pi^{0}) vs m^{2}(K^{-} #pi^{+})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.0, "xmax" : 2.0, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 3.2},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel12", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel23", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel13", "d1" : 1, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "D_DALITZ__D0_Kpipi0.root",
+    "reference" : "RefD_DALITZ__D0_Kpipi0.root"
+}
diff --git a/test/jsonFiles/D_DALITZ__D0_anti-K0pipi.json b/test/jsonFiles/D_DALITZ__D0_anti-K0pipi.json
new file mode 100644
index 0000000..d9172c4
--- /dev/null
+++ b/test/jsonFiles/D_DALITZ__D0_anti-K0pipi.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "D0",
+    "daughters" : ["anti-K0", "pi+", "pi-"],
+    "models" : ["D_DALITZ"],
+    "parameters" : [[]],
+    "do_conjugate_decay" : [true],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(anti-K^{0} #pi^{+})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.6, "xmax" : 1.8},
+        {"variable" : "mass", "title" : "m(anti-K^{0} #pi^{-})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.6, "xmax" : 1.8},
+        {"variable" : "mass", "title" : "m(#pi^{+} #pi^{-})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.2, "xmax" : 1.5},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(anti-K^{0} #pi^{+}) vs m^{2}(anti-K^{0} #pi^{-})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.05, "xmax" : 3.5, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 3.5},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(#pi^{+} #pi^{-}) vs m^{2}(anti-K^{0} #pi^{+})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.05, "xmax" : 2.0, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.05, "ymax" : 3.5},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel12", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel23", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel13", "d1" : 1, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "D_DALITZ__D0_anti-K0pipi.root",
+    "reference" : "RefD_DALITZ__D0_anti-K0pipi.root"
+}
diff --git a/test/jsonFiles/D_DALITZ__D0_pipiK_S0.json b/test/jsonFiles/D_DALITZ__D0_pipiK_S0.json
new file mode 100644
index 0000000..56aff45
--- /dev/null
+++ b/test/jsonFiles/D_DALITZ__D0_pipiK_S0.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "D0",
+    "daughters" : ["pi-", "pi+", "K_S0"],
+    "models" : ["D_DALITZ"],
+    "parameters" : [[]],
+    "do_conjugate_decay" : [true],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(#pi^{-} #pi^{+})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.2, "xmax" : 1.5},
+        {"variable" : "mass", "title" : "m(#pi^{-} K^{0}_{S})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.6, "xmax" : 1.8},
+        {"variable" : "mass", "title" : "m(#pi^{+} K^{0}_{S})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.6, "xmax" : 1.8},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(#pi^{-} #pi^{+}) vs m^{2}(#pi^{-} K^{0}_{S})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.0, "xmax" : 2.0, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 3.2},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(#pi^{+} K^{0}_{S}) vs m^{2}(#pi^{-} #pi^{+})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.3, "xmax" : 3.2, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 2.0},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel12", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel23", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel13", "d1" : 1, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "D_DALITZ__D0_pipiK_S0.root",
+    "reference" : "RefD_DALITZ__D0_pipiK_S0.root"
+}
diff --git a/test/jsonFiles/D_DALITZ__D0_pipipi0.json b/test/jsonFiles/D_DALITZ__D0_pipipi0.json
new file mode 100644
index 0000000..4ec1c90
--- /dev/null
+++ b/test/jsonFiles/D_DALITZ__D0_pipipi0.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "D0",
+    "daughters" : ["pi-", "pi+", "pi0"],
+    "models" : ["D_DALITZ"],
+    "parameters" : [[]],
+    "do_conjugate_decay" : [true],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(#pi^{-} #pi^{+})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.2, "xmax" : 1.8},
+        {"variable" : "mass", "title" : "m(#pi^{-} #pi^{0})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.2, "xmax" : 1.8},
+        {"variable" : "mass", "title" : "m(#pi^{+} #pi^{0})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.2, "xmax" : 1.8},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(#pi^{-} #pi^{+}) vs m^{2}(#pi^{-} #pi^{0})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.0, "xmax" : 3.2, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 3.2},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(#pi^{+} #pi^{0}) vs m^{2}(#pi^{-} #pi^{+})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.0, "xmax" : 3.2, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 3.2},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel12", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel23", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel13", "d1" : 1, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "D_DALITZ__D0_pipipi0.root",
+    "reference" : "RefD_DALITZ__D0_pipipi0.root"
+}
diff --git a/test/jsonFiles/D_DALITZ__Ds+_KKpi.json b/test/jsonFiles/D_DALITZ__Ds+_KKpi.json
new file mode 100644
index 0000000..ca93b4c
--- /dev/null
+++ b/test/jsonFiles/D_DALITZ__Ds+_KKpi.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "D_s+",
+    "daughters" : ["K-", "K+", "pi+"],
+    "models" : ["D_DALITZ"],
+    "parameters" : [[]],
+    "do_conjugate_decay" : [true],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(K^{-} K^{+})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.9, "xmax" : 1.9},
+        {"variable" : "mass", "title" : "m(K^{-} #pi^{+})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.5, "xmax" : 1.6},
+        {"variable" : "mass", "title" : "m(K^{+} #pi^{+})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.5, "xmax" : 1.6},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(K^{-} K^{+}) vs m^{2}(K^{-} #pi^{+})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.8, "xmax" : 3.5, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.2, "ymax" : 2.5},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(K^{+} #pi^{+}) vs m^{2}(K^{-} K^{+})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.2, "xmax" : 2.5, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.7, "ymax" : 3.5},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel12", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel23", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel13", "d1" : 1, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "D_DALITZ__Ds+_KKpi.root",
+    "reference" : "RefD_DALITZ__Ds+_KKpi.root"
+}
diff --git a/test/jsonFiles/D_DALITZ__Ds+_pipipi.json b/test/jsonFiles/D_DALITZ__Ds+_pipipi.json
new file mode 100644
index 0000000..f0cf311
--- /dev/null
+++ b/test/jsonFiles/D_DALITZ__Ds+_pipipi.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "D_s+",
+    "daughters" : ["pi-", "pi+", "pi+"],
+    "models" : ["D_DALITZ"],
+    "parameters" : [[]],
+    "do_conjugate_decay" : [true],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(#pi^{-} #pi^{+})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.2, "xmax" : 1.9},
+        {"variable" : "mass", "title" : "m(#pi^{-} #pi^{+})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.2, "xmax" : 1.9},
+        {"variable" : "mass", "title" : "m(#pi^{+} #pi^{+})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.2, "xmax" : 1.9},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(#pi^{-} #pi^{+}) vs m^{2}(#pi^{-} #pi^{+})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.0, "xmax" : 3.5, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 3.5},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(#pi^{+} #pi^{+}) vs m^{2}(#pi^{-} #pi^{+})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.0, "xmax" : 3.5, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 3.5},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel12", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel23", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel13", "d1" : 1, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "D_DALITZ__Ds+_pipipi.root",
+    "reference" : "RefD_DALITZ__Ds+_pipipi.root"
+}
diff --git a/test/jsonFiles/D_MULTIBODY__D0_K0sKK.json b/test/jsonFiles/D_MULTIBODY__D0_K0sKK.json
new file mode 100644
index 0000000..aefc26f
--- /dev/null
+++ b/test/jsonFiles/D_MULTIBODY__D0_K0sKK.json
@@ -0,0 +1,24 @@
+{
+    "parent" : "D0",
+    "daughters" : ["K_S0", "K-", "K+"],
+    "models" : ["D_MULTIBODY"],
+    "parameters" : [["RESONANCE", "a_00(BREITWIGNER,HELAMP,[1.0,0.0],[K+,K-])",
+		     "RESONANCE", "a_0+(BREITWIGNER,HELAMP,[0.460,3.59],[K_S0,K+])",
+		     "RESONANCE", "f'_0(BREITWIGNER,HELAMP,[0.435,-2.65],[K+,K-])"]],
+    "do_conjugate_decay" : [false],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(K^{0}_{S} K^{+})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.9, "xmax" : 1.5},
+        {"variable" : "mass", "title" : "m(K^{0}_{S} K^{-})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.9, "xmax" : 1.5},
+        {"variable" : "mass", "title" : "m(K^{-} K^{+})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.9, "xmax" : 1.5},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(K^{0}_{S} K^{+}) vs m^{2}(K^{0}_{S} K^{-})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.8, "xmax" : 2.0, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.8, "ymax" : 2.0},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(K^{+} K^{-}) vs m^{2}(K^{0}_{S} K^{+})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.8, "xmax" : 2.0, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.8, "ymax" : 2.0},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel12", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel23", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel13", "d1" : 1, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "D_MULTIBODY__D0_K0sKK.root",
+    "reference" : "RefD_MULTIBODY__D0_K0sKK.root"
+}
diff --git a/test/jsonFiles/ETA_DALITZ__eta_pipipi0.json b/test/jsonFiles/ETA_DALITZ__eta_pipipi0.json
new file mode 100644
index 0000000..37de921
--- /dev/null
+++ b/test/jsonFiles/ETA_DALITZ__eta_pipipi0.json
@@ -0,0 +1,21 @@
+{
+    "parent" : "eta",
+    "daughters" : ["pi+", "pi-", "pi0"],
+    "models" : ["ETA_DALITZ"],
+    "parameters" : [[]],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(#pi^{+} #pi^{-})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.25, "xmax" : 0.45},
+        {"variable" : "mass", "title" : "m(#pi^{+} #pi^{0})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.25, "xmax" : 0.45},
+        {"variable" : "mass", "title" : "m(#pi^{-} #pi^{0})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.25, "xmax" : 0.45},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(#pi^{+} #pi^{-}) vs m^{2}(#pi^{+} #pi^{0})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.06, "xmax" : 0.18, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.06, "ymax" : 0.18},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(#pi^{-} #pi^{0}) vs m^{2}(#pi^{+} #pi^{-})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.06, "xmax" : 0.18, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.06, "ymax" : 0.18},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel12", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel23", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel13", "d1" : 1, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "ETA_DALITZ__eta_pipipi0.root",
+    "reference" : "RefETA_DALITZ__eta_pipipi0.root"
+}
diff --git a/test/jsonFiles/ETA_LLPIPI__etap_eepipi.json b/test/jsonFiles/ETA_LLPIPI__etap_eepipi.json
new file mode 100644
index 0000000..8c0fe5f
--- /dev/null
+++ b/test/jsonFiles/ETA_LLPIPI__etap_eepipi.json
@@ -0,0 +1,18 @@
+{
+    "parent" : "eta'",
+    "daughters" : ["e+", "e-", "pi+", "pi-"],
+    "models" : ["ETA_LLPIPI"],
+    "parameters" : [[]],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "mPiPi", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "mLL"  , "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.5},
+	{"variable" : "mass", "title" : "mPiL1", "d1" : 1, "d2" : 4, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.85},
+	{"variable" : "mass", "title" : "mPiL2", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.85},
+	{"variable" : "cosHel", "title" : "cosL", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosPi", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "ETA_LLPIPI__etap_eepipi.root",
+    "reference" : "RefETA_LLPIPI__etap_eepipi.root"
+}
diff --git a/test/jsonFiles/ETA_LLPIPI__etap_mumupipi.json b/test/jsonFiles/ETA_LLPIPI__etap_mumupipi.json
new file mode 100644
index 0000000..07b6272
--- /dev/null
+++ b/test/jsonFiles/ETA_LLPIPI__etap_mumupipi.json
@@ -0,0 +1,18 @@
+{
+    "parent" : "eta'",
+    "daughters" : ["mu+", "mu-", "pi+", "pi-"],
+    "models" : ["ETA_LLPIPI"],
+    "parameters" : [[]],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "mPiPi", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "mLL"  , "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.1, "xmax" : 0.75},
+	{"variable" : "mass", "title" : "mPiL1", "d1" : 1, "d2" : 4, "nbins" : 100, "xmin" : 0.1, "xmax" : 0.8},
+	{"variable" : "mass", "title" : "mPiL2", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.1, "xmax" : 0.8},
+	{"variable" : "cosHel", "title" : "cosL", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosPi", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "ETA_LLPIPI__etap_mumupipi.root",
+    "reference" : "RefETA_LLPIPI__etap_mumupipi.root"
+}
diff --git a/test/jsonFiles/EvtBcToNPi=VLL__Bc_Jpsi3pi,ee.json b/test/jsonFiles/EvtBcToNPi=VLL__Bc_Jpsi3pi,ee.json
new file mode 100644
index 0000000..94e3be4
--- /dev/null
+++ b/test/jsonFiles/EvtBcToNPi=VLL__Bc_Jpsi3pi,ee.json
@@ -0,0 +1,20 @@
+{
+    "parent" : "B_c+",
+    "daughters" : ["J/psi", "pi+", "pi-", "pi+"],
+    "grand_daughters" : [["e+", "e-"], [], [], []],
+    "models" : ["EvtBcToNPi", "VLL", "", "", ""],
+    "parameters" : [["0.9e5", "5.9", "0.049", "0.0015", "0.0", "0.0", "0.0", "-0.074", "0.049", "0.0015"], [], [], [], []],
+    "do_conjugate_decay" : [true, false, false, false, false],
+    "extras" : ["Define dm_incohMix_B_s0 0"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(EvtBcToNPi)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug1", "title" : "Prob(VLL)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "parMass", "title" : "m(B_{c}^{+})", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 6.2, "xmax" : 6.3},
+	{"variable" : "mass", "title" : "m(J/#psi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 3.0, "xmax" : 3.2},
+	{"variable" : "mass3", "title" : "m(#pi^{+}#pi^{-}#pi^{+})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.5},
+	{"variable" : "cosHel", "title" : "cosHel(e^{+}, J/#psi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "EvtBcToNPi=VLL__Bc_Jpsi3pi,ee.root",
+    "reference" : "RefEvtBcToNPi=VLL__Bc_Jpsi3pi,ee.root"
+}
diff --git a/test/jsonFiles/FLATQ2=VSS__Bs_phimumu,KK.json b/test/jsonFiles/FLATQ2=VSS__Bs_phimumu,KK.json
new file mode 100644
index 0000000..311117b
--- /dev/null
+++ b/test/jsonFiles/FLATQ2=VSS__Bs_phimumu,KK.json
@@ -0,0 +1,38 @@
+{
+    "parent" : "B_s0",
+    "daughters" : ["phi", "mu+", "mu-"],
+    "grand_daughters" : [["K+", "K-"], [], []],
+    "models" : ["FLATQ2", "VSS", ""],
+    "parameters" : [["1"], [], []],
+    "do_conjugate_decay" : [true, false, false, false],
+    "extras" : ["Define dm_incohMix_B_s0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(phi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.95, "xmax" : 1.1},
+        {"variable" : "mass", "title" : "m(phi mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(phi mu-)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(mu+mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "pSumSq", "title" : "qSq(mu+ mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "p", "title" : "p(phi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pSq", "title" : "pSq(phi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 8.0},
+        {"variable" : "pz", "title" : "pz(phi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(phi,mu+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu+,mu-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(K+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(phi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(phi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(K+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 2.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(K-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 2.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(K+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(K+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(K-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(K-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "FLATQ2=VSS__Bs_phimumu,KK.root",
+    "reference" : "RefFLATQ2=VSS__Bs_phimumu,KK.root"
+}
diff --git a/test/jsonFiles/FLATSQDALITZ__Lb_LzKK.json b/test/jsonFiles/FLATSQDALITZ__Lb_LzKK.json
new file mode 100644
index 0000000..1a9771c
--- /dev/null
+++ b/test/jsonFiles/FLATSQDALITZ__Lb_LzKK.json
@@ -0,0 +1,20 @@
+{
+    "parent" : "Lambda_b0",
+    "daughters" : ["K+", "K-", "Lambda0"],
+    "do_conjugate_decay" : [ true, true, true, true ],
+    "models" : ["FLATSQDALITZ"],
+    "parameters" : [[]],
+    "extras" : ["noPhotos"],
+    "events" : 1000000,
+    "histograms" : [
+	{"variable" : "mass", "title" : "mKPi", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.6, "xmax" : 2.25},
+	{"variable" : "mass", "title" : "mJpsiPi", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 3.2, "xmax" : 4.8},
+	{"variable" : "mass", "title" : "mJpsiK", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 3.5, "xmax" : 5.2},
+	{"variable" : "cosHel", "title" : "cosTheta1", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosTheta2", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosTheta3", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0}
+    ],
+    "outfile" : "FLATSQDALITZ__Lb_LzKK.root",
+    "reference" : "RefFLATSQDALITZ__Lb_LzKK.root"
+}
diff --git a/test/jsonFiles/FLATSQDALITZ__Lb_LzKK_cuts.json b/test/jsonFiles/FLATSQDALITZ__Lb_LzKK_cuts.json
new file mode 100644
index 0000000..ce8fd6e
--- /dev/null
+++ b/test/jsonFiles/FLATSQDALITZ__Lb_LzKK_cuts.json
@@ -0,0 +1,20 @@
+{
+    "parent" : "Lambda_b0",
+    "daughters" : ["K+", "K-", "Lambda0"],
+    "do_conjugate_decay" : [ true, true, true, true ],
+    "models" : ["FLATSQDALITZ"],
+    "parameters" : [["0.2", "0.7", "0.3", "0.8"]],
+    "extras" : ["noPhotos"],
+    "events" : 1000000,
+    "histograms" : [
+	{"variable" : "mass", "title" : "mKPi", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.6, "xmax" : 2.25},
+	{"variable" : "mass", "title" : "mJpsiPi", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 3.2, "xmax" : 4.8},
+	{"variable" : "mass", "title" : "mJpsiK", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 3.5, "xmax" : 5.2},
+	{"variable" : "cosHel", "title" : "cosTheta1", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosTheta2", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosTheta3", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 20, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 20, "ymin" : 0.0, "ymax" : 1.0}
+    ],
+    "outfile" : "FLATSQDALITZ__Lb_LzKK_cuts.root",
+    "reference" : "RefFLATSQDALITZ__Lb_LzKK_cuts.root"
+}
diff --git a/test/jsonFiles/FOURBODYPHSP__Bu_mumuKrho0.json b/test/jsonFiles/FOURBODYPHSP__Bu_mumuKrho0.json
new file mode 100644
index 0000000..c5fb107
--- /dev/null
+++ b/test/jsonFiles/FOURBODYPHSP__Bu_mumuKrho0.json
@@ -0,0 +1,49 @@
+{
+    "parent" : "B+",
+    "daughters" : ["mu+", "mu-", "K+", "rho0"],
+    "do_conjugate_decay" : [true,false,false,true,false],
+    "models" : ["FOURBODYPHSP"],
+    "parameters" : [["1.0", "2.0", "1.0", "2.0"]],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "parMass", "title" : "M(B+)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 5.0, "xmax" : 5.5},
+        {"variable" : "px", "title" : "px(B+)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "py", "title" : "py(B+)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(B+)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "E", "title" : "E(B+)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "mass", "title" : "M(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.2},
+        {"variable" : "px", "title" : "px(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "py", "title" : "py(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(mu+", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "E", "title" : "E(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "mass", "title" : "M(mu-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.2},
+        {"variable" : "px", "title" : "px(mu-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "py", "title" : "py(mu-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(mu-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "E", "title" : "E(mu-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "mass", "title" : "M(K+)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "px", "title" : "px(K+)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "py", "title" : "py(K+)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(K+)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "E", "title" : "E(K+)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "mass", "title" : "M(rho0)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.5},
+        {"variable" : "px", "title" : "px(rho0)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "py", "title" : "py(rho0)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(rho0)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "E", "title" : "E(rho0)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "mass", "title" : "m1m2(mu+ + mu-)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.8, "xmax" : 1.2},
+        {"variable" : "mass", "title" : "m1m3(mu+ + K+)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "mass", "title" : "m1m4(mu+ + rho0)", "d1" : 1, "d2" : 4, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "mass", "title" : "m2m3(mu- + K+)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "mass", "title" : "m2m4(mu- + rho0)", "d1" : 2, "d2" : 4, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "mass", "title" : "m3m4(K+ + rho0)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.8, "xmax" : 1.2},
+        {"variable" : "mass3_specified", "title" : "m1m2m3(mu+, mu-, K+)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass3_specified", "title" : "m1m2m3(mu+, mu-, rho0)", "d1" : 1, "d2" : 4, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "mass3_specified", "title" : "m2m3m4(mu-, K+, rho0)", "d1" : 2, "d2" : 4, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "decayangle", "title" : "theta1(mu+,mu-)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 200.0},
+        {"variable" : "decayangle", "title" : "theta3(K+,rho0)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.0, "xmax" : 200.0},
+        {"variable" : "chi", "title" : "chi(mu+,mu-,K+,rho0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 360.0}
+    ],
+    "outfile" : "FOURBODYPHSP__Bu_mumuKrho0.root",
+    "reference" : "RefFOURBODYPHSP__Bu_mumuKrho0.root"
+}
diff --git a/test/jsonFiles/GENERIC_DALITZ__D0_KsKK.json b/test/jsonFiles/GENERIC_DALITZ__D0_KsKK.json
new file mode 100644
index 0000000..31f8f82
--- /dev/null
+++ b/test/jsonFiles/GENERIC_DALITZ__D0_KsKK.json
@@ -0,0 +1,21 @@
+{
+    "parent" : "D0",
+    "daughters" : ["K_S0", "K+", "K-"],
+    "models" : ["GENERIC_DALITZ"],
+    "parameters" : [["../validation/DalitzFiles/DalitzDecays.xml"]],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(K^{0}_{S} K^{+})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.9, "xmax" : 1.5},
+        {"variable" : "mass", "title" : "m(K^{0}_{S} K^{-})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.9, "xmax" : 1.5},
+        {"variable" : "mass", "title" : "m(K^{-} K^{+})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.9, "xmax" : 1.5},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(K^{0}_{S} K^{+}) vs m^{2}(K^{0}_{S} K^{-})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.8, "xmax" : 2.0, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.8, "ymax" : 2.0},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(K^{+} K^{-}) vs m^{2}(K^{0}_{S} K^{+})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.8, "xmax" : 2.0, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.8, "ymax" : 2.0},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel12", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel23", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel13", "d1" : 1, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "GENERIC_DALITZ__D0_K0sKK.root",
+    "reference" : "RefGENERIC_DALIZT__D0_K0sKK.root"
+}
diff --git a/test/jsonFiles/GOITY_ROBERTS=VSS__Bd_Dst0pienu,D0pi0.json b/test/jsonFiles/GOITY_ROBERTS=VSS__Bd_Dst0pienu,D0pi0.json
new file mode 100644
index 0000000..f8103ba
--- /dev/null
+++ b/test/jsonFiles/GOITY_ROBERTS=VSS__Bd_Dst0pienu,D0pi0.json
@@ -0,0 +1,42 @@
+{
+    "parent" : "B0",
+    "daughters" : ["anti-D*0", "pi-", "e+", "nu_e"],
+    "grand_daughters" : [["anti-D0", "pi0"], [], []],
+    "models" : ["GOITY_ROBERTS", "VSS", ""],
+    "parameters" : [[], [], []],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "M(#it{D}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.9, "xmax" : 2.1},
+        {"variable" : "mass", "title" : "M(#it{D}*^{0}#it{#pi})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 1.5, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "M(#it{D}*^{0}#it{e})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 1.5, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "M(#it{D}*^{0}#it{#nu})", "d1" : 1, "d2" : 4, "nbins" : 100, "xmin" : 1.5, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "M(#it{e}#it{#nu})", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.0, "xmax" : 4.0},
+        {"variable" : "mass3", "title" : "M(#it{D}*^{0}#it{#pi}#it{e})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 1.5, "xmax" : 6.0},
+        {"variable" : "pSumSq", "title" : "q^{2}(#it{e}#it{#nu})", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+        {"variable" : "p", "title" : "p(#it{D}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pSq", "title" : "p^{2}(#it{D}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "pz", "title" : "pz(#it{D}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 2.5},
+        {"variable" : "decayangle", "title" : "#theta(#it{D}*^{0},#it{e})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0, "xmax" : 200.0},
+        {"variable" : "cosHel", "title" : "cosHel(#it{D}*^{0},#it{#pi})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(#it{D}*^{0},#it{e})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(#it{e}#it{#nu})", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(#it{D}^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{D}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{#pi})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{e})", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{#nu})", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(#it{D}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(#it{D}^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 2.5},
+        {"variable" : "pLab_daug1", "title" : "pLab(#it{pi}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.25},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(#it{D}^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(#it{D}^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(#it{pi}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(#it{pi}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "GOITY_ROBERTS=VSS__Bd_Dst0enu,D0pi0.root",
+    "reference" : "RefGOITY_ROBERTS=VSS__Bd_Dst0enu,D0pi0.root"
+}
diff --git a/test/jsonFiles/HELAMP=VSS__Bu_psi2SKstar_Jpsigamma,K0pi.json b/test/jsonFiles/HELAMP=VSS__Bu_psi2SKstar_Jpsigamma,K0pi.json
new file mode 100644
index 0000000..ec4885e
--- /dev/null
+++ b/test/jsonFiles/HELAMP=VSS__Bu_psi2SKstar_Jpsigamma,K0pi.json
@@ -0,0 +1,45 @@
+{
+    "parent" : "B+",
+    "daughters" : ["psi(2S)", "K*+"],
+    "grand_daughters" : [["J/psi", "gamma"], ["K0", "pi+"]],
+    "models" : ["HELAMP", "HELAMP", "VSS"],
+    "parameters" : [["0.0", "0.0", "0.0", "0.0", "1.0", "0.0"], ["1.0", "0.0", "1.0", "0.0", "0.0", "0.0", "0.0", "0.0"], []],
+    "do_conjugate_decay" : [true, true, true],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(HELAMP,B)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug1", "title" : "Prob(HELAMP,psi2S)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug2", "title" : "Prob(VSS)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "parMass", "title" : "m(B+)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 5.27, "xmax" : 5.29},
+        {"variable" : "mass", "title" : "m(psi2S)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 3.6, "xmax" : 3.8},
+        {"variable" : "mass", "title" : "m(K*+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.6, "xmax" : 1.6},
+        {"variable" : "mass_daug1", "title" : "m(J/psi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 3.0, "xmax" : 3.2},
+        {"variable" : "mass_daug2", "title" : "m(K0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.4, "xmax" : 0.6},
+        {"variable" : "mass_daug2", "title" : "m(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.13, "xmax" : 0.15},
+	{"variable" : "cosHel", "title" : "cosHel(J/psi,psi2S)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel(K0,K*+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+	{"variable" : "decayangle", "title" : "decayAngle(psi2S,K*+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "decayangle_daug1", "title" : "decayAngle(J/psi,gamma)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "decayangle_daug2", "title" : "decayAngle(K0,pi+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(psi2S)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(K*+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(J/psi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(gamma)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosTheta_daug2", "title" : "cosTheta(K0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosTheta_daug2", "title" : "cosTheta(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(J/psi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi_daug1", "title" : "phi(gamma)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi_daug2", "title" : "phi(K0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi_daug2", "title" : "phi(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "p", "title" : "p(psi2S)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.4, "xmax" : 1.3},
+	{"variable" : "p", "title" : "p(K*+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.4, "xmax" : 1.3},
+	{"variable" : "p_daug1", "title" : "p(J/psi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 0.6},
+	{"variable" : "p_daug1", "title" : "p(gamma)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 0.6},
+	{"variable" : "p_daug2", "title" : "p(K0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.8},
+	{"variable" : "p_daug2", "title" : "p(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.8}
+    ],
+    "outfile" : "HELAMP=VSS__Bu_psi2SKstar_Jpsigamma,K0pi.root",
+    "reference" : "RefHELAMP=VSS__Bu_psi2SKstar_Jpsigamma,K0pi.root"
+}
diff --git a/test/jsonFiles/HQET2=VSS__Bd_Dstenu,D0pi.json b/test/jsonFiles/HQET2=VSS__Bd_Dstenu,D0pi.json
new file mode 100644
index 0000000..658452c
--- /dev/null
+++ b/test/jsonFiles/HQET2=VSS__Bd_Dstenu,D0pi.json
@@ -0,0 +1,37 @@
+{
+    "parent" : "B0",
+    "daughters" : ["D*-", "e+", "nu_e"],
+    "grand_daughters" : [["anti-D0", "pi-"], [], []],
+    "models" : ["HQET2", "VSS", ""],
+    "parameters" : [["1.122", "0.921", "1.270", "0.852"], [], []],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "M(#it{D}*)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.9, "xmax" : 2.1},
+        {"variable" : "mass", "title" : "M(#it{D}*#it{e})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 1.5, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "M(#it{D}*#it{#nu})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 1.5, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "M(#it{e}#it{#nu})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 4.0},
+        {"variable" : "pSumSq", "title" : "q^{2}(#it{e}#it{#nu})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+        {"variable" : "p", "title" : "p(#it{D}*)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pSq", "title" : "p^{2}(#it{D}*)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "pz", "title" : "pz(#it{D}*)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 2.5},
+        {"variable" : "cosHel", "title" : "cosHel(#it{D}*,#it{e})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(#it{e}#it{#nu})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(#it{D}^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{D}*)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{e})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{#nu})", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(#it{D}*)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(#it{D}^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 2.5},
+        {"variable" : "pLab_daug1", "title" : "pLab(#it{#pi})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.25},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(#it{D}^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(#it{D}^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(#it{#pi})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(#it{#pi})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "HQET2=VSS__Bd_Dstenu,D0pi.root",
+    "reference" : "RefHQET2=VSS__Bd_Dstenu,D0pi.root"
+}
diff --git a/test/jsonFiles/HQET=VSS__Bd_Dstenu,D0pi.json b/test/jsonFiles/HQET=VSS__Bd_Dstenu,D0pi.json
new file mode 100644
index 0000000..5c62a6f
--- /dev/null
+++ b/test/jsonFiles/HQET=VSS__Bd_Dstenu,D0pi.json
@@ -0,0 +1,37 @@
+{
+    "parent" : "B0",
+    "daughters" : ["D*-", "e+", "nu_e"],
+    "grand_daughters" : [["anti-D0", "pi-"], [], []],
+    "models" : ["HQET", "VSS", ""],
+    "parameters" : [["0.92", "1.18", "0.72"], [], []],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(Dst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.9, "xmax" : 2.1},
+        {"variable" : "mass", "title" : "m(Dst e)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 1.5, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(Dst nu)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 1.5, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(e nu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 4.0},
+        {"variable" : "pSumSq", "title" : "qSq(e nu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+        {"variable" : "p", "title" : "p(Dst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pSq", "title" : "pSq(Dst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "pz", "title" : "pz(Dst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 2.5},
+        {"variable" : "cosHel", "title" : "cosHel(Dst,e)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(e,nu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(Dst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(e)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(nu)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(Dst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 2.5},
+        {"variable" : "pLab_daug1", "title" : "pLab(pi)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.25},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(pi)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "HQET=VSS__Bd_Dstenu,D0pi.root",
+    "reference" : "RefHQET=VSS__Bd_Dstenu,D0pi.root"
+}
diff --git a/test/jsonFiles/HypNonLepton__Lambda0_ppi.json b/test/jsonFiles/HypNonLepton__Lambda0_ppi.json
new file mode 100644
index 0000000..1c6cb20
--- /dev/null
+++ b/test/jsonFiles/HypNonLepton__Lambda0_ppi.json
@@ -0,0 +1,19 @@
+{
+    "parent" : "Lambda0",
+    "daughters" : ["p+", "pi-"],
+    "models" : ["HypNonLepton"],
+    "parameters" : [["0.642", "-6.5"]],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "parMass", "title" : "m(#Lambda^{0})", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 1.0, "xmax" : 1.2},
+	{"variable" : "mass", "title" : "m(p #pi)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 1.0, "xmax" : 1.2},
+	{"variable" : "cosTheta", "title" : "cosTheta(p)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(#pi)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi", "title" : "phi(p)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "phi", "title" : "phi(#pi)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "HypNonLepton__Lambda0_ppi.root",
+    "reference" : "RefHypNonLepton__Lambda0_ppi.root"
+}
diff --git a/test/jsonFiles/ISGW2=PHSP=TAUSCALARNU__Bu_D0taunu,Kpi,pinu.json b/test/jsonFiles/ISGW2=PHSP=TAUSCALARNU__Bu_D0taunu,Kpi,pinu.json
new file mode 100644
index 0000000..e7f4a61
--- /dev/null
+++ b/test/jsonFiles/ISGW2=PHSP=TAUSCALARNU__Bu_D0taunu,Kpi,pinu.json
@@ -0,0 +1,36 @@
+{
+    "parent" : "B+",
+    "daughters" : ["anti-D0", "tau+", "nu_tau"],
+    "grand_daughters" : [["K+", "pi-"], ["pi+", "anti-nu_tau"], []],
+    "models" : ["ISGW2", "PHSP", "TAUSCALARNU"],
+    "parameters" : [[], [], []],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(D0 tau)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 3.0, "xmax" : 6.0},
+	{"variable" : "pSumSq", "title" : "qSq(tau nu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 3.0, "xmax" : 15.0},
+	{"variable" : "p", "title" : "p(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0},
+	{"variable" : "pSq", "title" : "pSq(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 4.0},
+	{"variable" : "pz", "title" : "pz(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.0, "xmax" : 2.0},
+	{"variable" : "cosHel", "title" : "cosHel(tau,D0)", "d1" : 2, "d2" : 1, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(tau)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHelTau", "title" : "cosHelTau(pi2)", "d1" : 2, "d2" : 1, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel(K+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi", "title" : "phi(tau)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+	{"variable" : "pLab_daug1", "title" : "pLab(K+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(K+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug1", "title" : "phi(K+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+	{"variable" : "pLab_daug1", "title" : "pLab(pi1)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(pi1)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug1", "title" : "phi(pi1)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+	{"variable" : "pLab_daug2", "title" : "pLab(pi2)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "cosTheta_daug2", "title" : "cosTheta(pi2)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug2", "title" : "phi(pi2)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+	{"variable" : "pLab_daug2", "title" : "pLab(nu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "cosTheta_daug2", "title" : "cosTheta(nu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug2", "title" : "phi(nu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180}
+    ],
+    "outfile" : "ISGW2=PHSP=TAUSCALARNU__Bu_D0taunu,Kpi,pinu.root",
+    "reference" : "RefISGW2=PHSP=TAUSCALARNU__Bu_D0taunu,Kpi,pinu.root"
+}
diff --git a/test/jsonFiles/ISGW2=VSS=TAUSCALARNU__Bd_Dsttaunu,D0pi,pinu.json b/test/jsonFiles/ISGW2=VSS=TAUSCALARNU__Bd_Dsttaunu,D0pi,pinu.json
new file mode 100644
index 0000000..7beeffd
--- /dev/null
+++ b/test/jsonFiles/ISGW2=VSS=TAUSCALARNU__Bd_Dsttaunu,D0pi,pinu.json
@@ -0,0 +1,36 @@
+{
+    "parent" : "B0",
+    "daughters" : ["D*-", "tau+", "nu_tau"],
+    "grand_daughters" : [["anti-D0", "pi-"], ["pi+", "anti-nu_tau"], []],
+    "models" : ["ISGW2", "VSS", "TAUSCALARNU"],
+    "parameters" : [[], [], []],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(Dst tau)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 3.0, "xmax" : 6.0},
+        {"variable" : "pSumSq", "title" : "qSq(tau nu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 3.0, "xmax" : 12.0},
+        {"variable" : "p", "title" : "p(Dst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0},
+        {"variable" : "pSq", "title" : "pSq(Dst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 4.0},
+        {"variable" : "pz", "title" : "pz(Dst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.0, "xmax" : 2.0},
+        {"variable" : "cosHel", "title" : "cosHel(tau,Dst)", "d1" : 2, "d2" : 1, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(tau)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelTau", "title" : "cosHelTau(pi2)", "d1" : 2, "d2" : 1, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(tau)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "pLab_daug1", "title" : "pLab(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "pLab_daug1", "title" : "pLab(pi1)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.2},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi1)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(pi1)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "pLab_daug2", "title" : "pLab(pi2)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+        {"variable" : "cosTheta_daug2", "title" : "cosTheta(pi2)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug2", "title" : "phi(pi2)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "pLab_daug2", "title" : "pLab(nu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+        {"variable" : "cosTheta_daug2", "title" : "cosTheta(nu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug2", "title" : "phi(nu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180}
+    ],
+    "outfile" : "ISGW2=VSS=TAUSCALARNU__Bd_Dsttaunu,D0pi,pinu.root",
+    "reference" : "RefISGW2=VSS=TAUSCALARNU__Bd_Dsttaunu,D0pi,pinu.root"
+}
diff --git a/test/jsonFiles/ISGW2=VSS__Bd_Dstmunu,D0pi.json b/test/jsonFiles/ISGW2=VSS__Bd_Dstmunu,D0pi.json
new file mode 100644
index 0000000..24a4e18
--- /dev/null
+++ b/test/jsonFiles/ISGW2=VSS__Bd_Dstmunu,D0pi.json
@@ -0,0 +1,37 @@
+{
+    "parent" : "B0",
+    "daughters" : ["D*-", "mu+", "nu_mu"],
+    "grand_daughters" : [["anti-D0", "pi-"], [], []],
+    "models" : ["ISGW2", "VSS", ""],
+    "parameters" : [[], [], []],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(Dst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.9, "xmax" : 2.1},
+        {"variable" : "mass", "title" : "m(Dst mu)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 1.5, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(Dst nu)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 1.5, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(mu nu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 4.0},
+        {"variable" : "pSumSq", "title" : "qSq(mu nu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+        {"variable" : "p", "title" : "p(Dst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pSq", "title" : "pSq(Dst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "pz", "title" : "pz(Dst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 2.5},
+        {"variable" : "cosHel", "title" : "cosHel(Dst,mu)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu,nu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(Dst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(nu)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(Dst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 2.5},
+        {"variable" : "pLab_daug1", "title" : "pLab(pi)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.3},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(pi)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "ISGW2=VSS__Bd_Dstmunu,D0pi.root",
+    "reference" : "RefISGW2=VSS__Bd_Dstmunu,D0pi.root"
+}
diff --git a/test/jsonFiles/ISGW=VSS__Bd_Dstmunu,D0pi.json b/test/jsonFiles/ISGW=VSS__Bd_Dstmunu,D0pi.json
new file mode 100644
index 0000000..b406483
--- /dev/null
+++ b/test/jsonFiles/ISGW=VSS__Bd_Dstmunu,D0pi.json
@@ -0,0 +1,37 @@
+{
+    "parent" : "B0",
+    "daughters" : ["D*-", "mu+", "nu_mu"],
+    "grand_daughters" : [["anti-D0", "pi-"], [], []],
+    "models" : ["ISGW", "VSS", ""],
+    "parameters" : [[], [], []],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(Dst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.9, "xmax" : 2.1},
+        {"variable" : "mass", "title" : "m(Dst mu)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 1.5, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(Dst nu)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 1.5, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "m(mu nu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 4.0},
+        {"variable" : "pSumSq", "title" : "qSq(mu nu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+        {"variable" : "p", "title" : "p(Dst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pSq", "title" : "pSq(Dst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "pz", "title" : "pz(Dst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 2.5},
+        {"variable" : "cosHel", "title" : "cosHel(Dst,mu)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu,nu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(Dst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(nu)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(Dst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 2.5},
+        {"variable" : "pLab_daug1", "title" : "pLab(pi)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.3},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(pi)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "ISGW=VSS__Bd_Dstmunu,D0pi.root",
+    "reference" : "RefISGW=VSS__Bd_Dstmunu,D0pi.root"
+}
diff --git a/test/jsonFiles/KK_LAMBDAC_SL=HELAMP__Lambdac_Lambda0munu.json b/test/jsonFiles/KK_LAMBDAC_SL=HELAMP__Lambdac_Lambda0munu.json
new file mode 100644
index 0000000..c1470c4
--- /dev/null
+++ b/test/jsonFiles/KK_LAMBDAC_SL=HELAMP__Lambdac_Lambda0munu.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "Lambda_c+",
+    "daughters" : ["Lambda0", "mu+", "nu_mu"],
+    "grand_daughters" : [["p+","pi-"], [], []],
+    "models" : ["KK_LAMBDAC_SL", "HELAMP", ""],
+    "parameters" : [["1.0", "2.0"], ["0.936", "0.0", "0.351", "0.0"]],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob(KK_LAMBDAC_SL)",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug1", "title" : "Prob(HELAMP)",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "parMass", "title" : "m(#Lambda^{+}_{c})", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 2.2, "xmax" : 2.4},
+        {"variable" : "mass", "title" : "m(#Lambda^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.0, "xmax" : 1.2},
+        {"variable" : "mass", "title" : "m(#Lambda^{0} #mu^{+})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 1.0, "xmax" : 2.5},
+        {"variable" : "mass", "title" : "m(#Lambda^{0} #nu_{#mu})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 1.0, "xmax" : 2.5},
+        {"variable" : "pSumSq", "title" : "q^{2}(#mu^{+} #nu_{#mu})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0},
+        {"variable" : "cosHel", "title" : "cosHel(p,#Lambda^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "decayangle_daug1", "title" : "decayAngle(#Lambda^{0},p,#pi^{-})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0}
+    ],
+    "outfile" : "KK_LAMBDAC_SL=HELAMP__Lambdac_Lambda0munu.root",
+    "reference" : "RefKK_LAMBDAC_SL=HELAMP__Lambdac_Lambda0munu.root"
+}
diff --git a/test/jsonFiles/KSTARNUNU__Bd_Kstr0nunu.json b/test/jsonFiles/KSTARNUNU__Bd_Kstr0nunu.json
new file mode 100644
index 0000000..fe83720
--- /dev/null
+++ b/test/jsonFiles/KSTARNUNU__Bd_Kstr0nunu.json
@@ -0,0 +1,16 @@
+{
+    "parent" : "B0",
+    "daughters" : ["K*0","nu_e","anti-nu_e"],
+    "models" : ["KSTARNUNU"],
+    "parameters" : [[]],
+    "extras" : ["Define dm_incohMix_B0 0.0"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "prob", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "massSq", "title" : "q2", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 25.0},
+        {"variable" : "E", "title" : "E(nu_e)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "totE_over_Mparent", "title" : "E(nu_e + anti-nu_e)/M(B)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.4, "xmax" : 0.9}
+    ],
+    "outfile" : "KSTARNUNU__Bd_Kstr0nunu.root",
+    "reference" : "RefKSTARNUNU__Bd_Kstr0nunu.root"
+}
diff --git a/test/jsonFiles/KSTARSTARGAMMA__Bd_Kpigamma.json b/test/jsonFiles/KSTARSTARGAMMA__Bd_Kpigamma.json
new file mode 100644
index 0000000..d98febc
--- /dev/null
+++ b/test/jsonFiles/KSTARSTARGAMMA__Bd_Kpigamma.json
@@ -0,0 +1,14 @@
+{
+    "parent" : "B0",
+    "daughters" : ["K+", "pi-", "gamma"],
+    "models" : ["KSTARSTARGAMMA"],
+    "parameters" : [[]],
+    "extras" : ["Define dm_incohMix_B0 0.0"],
+    "events" : 10000,
+    "histograms" : [
+    {"variable" : "mass", "title" : "m(K,pi)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.5, "xmax" : 2.5},
+    {"variable" : "cosHel", "title" : "cosHel(K,pi)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "KSTARSTARGAMMA__Bd_Kpigamma.root",
+    "reference" : "RefKSTARSTARGAMMA__Bd_Kpigamma.root"
+}
diff --git a/test/jsonFiles/KS_PI0MUMU__Ks_pi0mumu.json b/test/jsonFiles/KS_PI0MUMU__Ks_pi0mumu.json
new file mode 100644
index 0000000..31f7e07
--- /dev/null
+++ b/test/jsonFiles/KS_PI0MUMU__Ks_pi0mumu.json
@@ -0,0 +1,21 @@
+{
+    "parent" : "K_S0",
+    "daughters" : ["pi0", "mu+", "mu-"],
+    "models" : ["KS_PI0MUMU"],
+    "parameters" : [["1.2", "0.49", "-3.9", "0.2", "2.5"]],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.02},
+	{"variable" : "mass", "title" : "m(#pi^{0} #mu^{+})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.2, "xmax" : 0.4},
+        {"variable" : "mass", "title" : "m(#mu^{+} #mu^{-})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.2, "xmax" : 0.4},
+        {"variable" : "mass", "title" : "m(#pi^{0} #mu^{-})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.2, "xmax" : 0.4},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(#pi^{0} #mu^{+}) vs m^{2}(#pi^{0} #mu^{-})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.05, "xmax" : 0.16, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.05, "ymax" : 0.16},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(#mu^{+} #mu^{-}) vs m^{2}(#pi^{0} #mu^{+})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.03, "xmax" : 0.14, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.05, "ymax" : 0.16},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel12", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel23", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel13", "d1" : 1, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "KS_PI0MUMU__Ks_pi0mumu.root",
+    "reference" : "RefKS_PI0MUMU__Ks_pi0mumu.root"
+}
diff --git a/test/jsonFiles/LAMBDAB2LAMBDAV=LAMBDA2PPIFORLAMBDAB2LAMBDAV=V2VPVMFORLAMBDAB2LAMBDAV__Lambdab0_Lambda0Jpsi,ppi,mumu.json b/test/jsonFiles/LAMBDAB2LAMBDAV=LAMBDA2PPIFORLAMBDAB2LAMBDAV=V2VPVMFORLAMBDAB2LAMBDAV__Lambdab0_Lambda0Jpsi,ppi,mumu.json
new file mode 100644
index 0000000..c30ed8d
--- /dev/null
+++ b/test/jsonFiles/LAMBDAB2LAMBDAV=LAMBDA2PPIFORLAMBDAB2LAMBDAV=V2VPVMFORLAMBDAB2LAMBDAV__Lambdab0_Lambda0Jpsi,ppi,mumu.json
@@ -0,0 +1,23 @@
+{
+    "parent" : "Lambda_b0",
+    "daughters" : ["Lambda0", "J/psi"],
+    "grand_daughters" : [["p+", "pi-"], ["mu+", "mu-"]],
+    "models" : ["LAMBDAB2LAMBDAV", "LAMBDA2PPIFORLAMBDAB2LAMBDAV", "V2VPVMFORLAMBDAB2LAMBDAV"],
+    "parameters" : [["0.5", "1"], ["0.5", "1"], ["0.5", "1"]],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob(LAMBDAB2LAMBDAV)",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "prob_daug1", "title" : "Prob(LAMBDA2PPIFORLAMBDAB2LAMBDAV)",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "prob_daug2", "title" : "Prob(V2VPVMFORLAMBDAB2LAMBDAV)",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "parMass", "title" : "m(#Lambda^{0}_{b})", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 5.0, "xmax" : 6.0},
+	{"variable" : "mass", "title" : "m(#Lambda^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.0, "xmax" : 2.5},
+	{"variable" : "mass", "title" : "m(J/#psi)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 3.0, "xmax" : 4.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(#Lambda^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi", "title" : "phi(#Lambda^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "cosHel", "title" : "cosHel(p,#Lambda^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "cosHel", "title" : "cosHel(#mu^{_},J/#psi)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0}
+    ],
+    "outfile" : "LAMBDAB2LAMBDADAV__Lambdab0_Lambda0Jpsi,ppi,mumu.root",
+    "reference" : "RefLAMBDAB2LAMBDADAV__Lambdab0_Lambda0Jpsi,ppi,mumu.root"
+}
diff --git a/test/jsonFiles/LAMBDAC_PHH__Lc_pKpi.json b/test/jsonFiles/LAMBDAC_PHH__Lc_pKpi.json
new file mode 100644
index 0000000..ba9a8a1
--- /dev/null
+++ b/test/jsonFiles/LAMBDAC_PHH__Lc_pKpi.json
@@ -0,0 +1,20 @@
+{
+    "parent" : "Lambda_c+",
+    "daughters" : ["p+", "K-", "pi+"],
+    "do_conjugate_decay" : [ true, true, true, true ],
+    "models" : ["LAMBDAC_PHH"],
+    "parameters" : [[]],
+    "extras" : ["noPhotos"],
+    "events" : 100000,
+    "histograms" : [
+	{"variable" : "mass", "title" : "mPK", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 1.4, "xmax" : 2.2},
+	{"variable" : "mass", "title" : "mPPi", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 1.05, "xmax" : 1.85},
+	{"variable" : "mass", "title" : "mKpi", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.6, "xmax" : 1.4},
+	{"variable" : "cosHel", "title" : "cosTheta1", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosTheta2", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosTheta3", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "massSq", "title" : "Dalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 1.9, "xmax" : 4.8, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 25, "ymin" : 1.0, "ymax" : 3.4}
+    ],
+    "outfile" : "LAMBDAC_PHH__Lc_pKpi.root",
+    "reference" : "RefLAMBDAC_PHH__Lc_pKpi.root"
+}
diff --git a/test/jsonFiles/LNUGAMMA__Bu_enugamma.json b/test/jsonFiles/LNUGAMMA__Bu_enugamma.json
new file mode 100644
index 0000000..ce7352d
--- /dev/null
+++ b/test/jsonFiles/LNUGAMMA__Bu_enugamma.json
@@ -0,0 +1,25 @@
+{
+    "parent" : "B+",
+    "daughters" : ["e+", "nu_e", "gamma"],
+    "models" : ["LNUGAMMA"],
+    "parameters" : [["0.35", "3.0", "5.0", "0.0"]],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "parMass", "title" : "m(B^{+})", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 5.27, "xmax" : 5.29},
+        {"variable" : "mass", "title" : "m(e^{+},#nu_{e})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.3},
+	{"variable" : "pSumSq", "title" : "q^{2}(e^{+},nue)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 25.0},
+	{"variable" : "p", "title" : "p(e^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "phi", "title" : "phi(e^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(e^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "p", "title" : "p(#nu_{e})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "phi", "title" : "phi(#nu_{e})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(#nu_{e})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "p", "title" : "p(#gamma)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "phi", "title" : "phi(#gamma)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(#gamma)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "E", "title" : "Dalitz q^{2}(e^{+},#nu_{e}) vs E(#gamma)", "d1" : 3, "d2" : 0, "nbins" : 50, "xmin" : 0.0, "xmax" : 3.0, "variableY" : "pSumSq", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 27.0}
+    ],
+    "outfile" : "LNUGAMMA__Bd_enugamma.root",
+    "reference" : "RefLNUGAMMA__Bd_enugamma.root"
+}
diff --git a/test/jsonFiles/Lb2Baryonlnu__Lb_Lc2593munu.json b/test/jsonFiles/Lb2Baryonlnu__Lb_Lc2593munu.json
new file mode 100644
index 0000000..38f9e7d
--- /dev/null
+++ b/test/jsonFiles/Lb2Baryonlnu__Lb_Lc2593munu.json
@@ -0,0 +1,15 @@
+{
+    "parent" : "Lambda_b0",
+    "daughters" : ["Lambda_c(2593)+", "mu-", "anti-nu_mu"],
+    "do_conjugate_decay" : [ true, true, true, true ],
+    "models" : ["Lb2Baryonlnu"],
+    "parameters" : [["1.0", "1.0", "1.0", "1.0"]],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "massSq", "title" : "q2", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 9.5},
+	{"variable" : "cosHel", "title" : "cosTheta", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "Lb2Baryonlnu__Lb_Lc2593munu.root",
+    "reference" : "RefLb2Baryonlnu__Lb_Lc2593munu.root"
+}
diff --git a/test/jsonFiles/Lb2Baryonlnu__Lb_Lc2625munu.json b/test/jsonFiles/Lb2Baryonlnu__Lb_Lc2625munu.json
new file mode 100644
index 0000000..02b0abe
--- /dev/null
+++ b/test/jsonFiles/Lb2Baryonlnu__Lb_Lc2625munu.json
@@ -0,0 +1,15 @@
+{
+    "parent" : "Lambda_b0",
+    "daughters" : ["Lambda_c(2625)+", "mu-", "anti-nu_mu"],
+    "do_conjugate_decay" : [ true, true, true, true ],
+    "models" : ["Lb2Baryonlnu"],
+    "parameters" : [["1.0", "1.0", "1.0", "1.0"]],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "massSq", "title" : "q2", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 9.5},
+	{"variable" : "cosHel", "title" : "cosTheta", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "Lb2Baryonlnu__Lb_Lc2625munu.root",
+    "reference" : "RefLb2Baryonlnu__Lb_Lc2625munu.root"
+}
diff --git a/test/jsonFiles/Lb2Baryonlnu__Lb_Lcmunu.json b/test/jsonFiles/Lb2Baryonlnu__Lb_Lcmunu.json
new file mode 100644
index 0000000..98585a2
--- /dev/null
+++ b/test/jsonFiles/Lb2Baryonlnu__Lb_Lcmunu.json
@@ -0,0 +1,15 @@
+{
+    "parent" : "Lambda_b0",
+    "daughters" : ["Lambda_c+", "mu-", "anti-nu_mu"],
+    "do_conjugate_decay" : [ true, true, true, true ],
+    "models" : ["Lb2Baryonlnu"],
+    "parameters" : [["1.0", "1.0", "1.0", "1.0"]],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "massSq", "title" : "q2", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 11.5},
+	{"variable" : "cosHel", "title" : "cosTheta", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "Lb2Baryonlnu__Lb_Lcmunu.root",
+    "reference" : "RefLb2Baryonlnu__Lb_Lcmunu.root"
+}
diff --git a/test/jsonFiles/Lb2Baryonlnu__Lb_pmunu.json b/test/jsonFiles/Lb2Baryonlnu__Lb_pmunu.json
new file mode 100644
index 0000000..fa61ba3
--- /dev/null
+++ b/test/jsonFiles/Lb2Baryonlnu__Lb_pmunu.json
@@ -0,0 +1,15 @@
+{
+    "parent" : "Lambda_b0",
+    "daughters" : ["p+", "mu-", "anti-nu_mu"],
+    "do_conjugate_decay" : [ true, true, true, true ],
+    "models" : ["Lb2Baryonlnu"],
+    "parameters" : [["1.0", "1.0", "1.0", "1.0"]],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "massSq", "title" : "q2", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 22.0},
+	{"variable" : "cosHel", "title" : "cosTheta", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "Lb2Baryonlnu__Lb_pmunu.root",
+    "reference" : "RefLb2Baryonlnu__Lb_pmunu.root"
+}
diff --git a/test/jsonFiles/Lb2Lll=HELAMP__Lambdab0_Lambda0mumu,pipi.json b/test/jsonFiles/Lb2Lll=HELAMP__Lambdab0_Lambda0mumu,pipi.json
new file mode 100644
index 0000000..48f9e13
--- /dev/null
+++ b/test/jsonFiles/Lb2Lll=HELAMP__Lambdab0_Lambda0mumu,pipi.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "Lambda_b0",
+    "daughters" : ["Lambda0", "mu-", "mu+"],
+    "grand_daughters" : [["p+","pi-"], [], []],
+    "models" : ["Lb2Lll", "HELAMP", ""],
+    "parameters" : [[], ["0.936", "0.0", "0.351", "0.0"]],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob(Lb2Lll)",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "prob_daug1", "title" : "Prob(HELAMP)",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "parMass", "title" : "m(#Lambda^{0}_{b})", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 5.0, "xmax" : 6.0},
+	{"variable" : "mass", "title" : "m(#Lambda^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.0, "xmax" : 1.2},
+	{"variable" : "mass", "title" : "m(#Lambda^{0} #mu^{-})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+	{"variable" : "mass", "title" : "m(#Lambda^{0} #mu^{+})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+	{"variable" : "pSumSq", "title" : "q^{2}(#mu^{-} #mu^{+})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 21.0},
+	{"variable" : "cosHel", "title" : "cosHel(p,#Lambda^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "decayangle_daug1", "title" : "decayAngle(#Lambda^{0},p,#pi^{-})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0}
+    ],
+    "outfile" : "Lb2Lll=HELAMP__Lambdab0_Lambda0mumu,ppi.root",
+    "reference" : "RefLb2Lll=HELAMP__Lambdab0_Lambda0mumu,ppi.root"
+}
diff --git a/test/jsonFiles/Lb2plnuLCSR__Lb_pmunu.json b/test/jsonFiles/Lb2plnuLCSR__Lb_pmunu.json
new file mode 100644
index 0000000..1257d1d
--- /dev/null
+++ b/test/jsonFiles/Lb2plnuLCSR__Lb_pmunu.json
@@ -0,0 +1,15 @@
+{
+    "parent" : "Lambda_b0",
+    "daughters" : ["p+", "mu-", "anti-nu_mu"],
+    "do_conjugate_decay" : [ true, true, true, true ],
+    "models" : ["Lb2plnuLCSR"],
+    "parameters" : [["1.0", "1.0", "1.0", "1.0"]],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "massSq", "title" : "q2", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 22.0},
+	{"variable" : "cosHel", "title" : "cosTheta", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "Lb2plnuLCSR__Lb_pmunu.root",
+    "reference" : "RefLb2plnuLCSR__Lb_pmunu.root"
+}
diff --git a/test/jsonFiles/Lb2plnuLQCD__Lb_pmunu.json b/test/jsonFiles/Lb2plnuLQCD__Lb_pmunu.json
new file mode 100644
index 0000000..6584538
--- /dev/null
+++ b/test/jsonFiles/Lb2plnuLQCD__Lb_pmunu.json
@@ -0,0 +1,15 @@
+{
+    "parent" : "Lambda_b0",
+    "daughters" : ["p+", "mu-", "anti-nu_mu"],
+    "do_conjugate_decay" : [ true, true, true, true ],
+    "models" : ["Lb2plnuLQCD"],
+    "parameters" : [["1.0", "1.0", "1.0", "1.0"]],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "massSq", "title" : "q2", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 22.0},
+	{"variable" : "cosHel", "title" : "cosTheta", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "Lb2plnuLQCD__Lb_pmunu.root",
+    "reference" : "RefLb2plnuLQCD__Lb_pmunu.root"
+}
diff --git a/test/jsonFiles/MELIKHOV=VSS__Bd_rhomunu,pipi0.json b/test/jsonFiles/MELIKHOV=VSS__Bd_rhomunu,pipi0.json
new file mode 100644
index 0000000..50ed734
--- /dev/null
+++ b/test/jsonFiles/MELIKHOV=VSS__Bd_rhomunu,pipi0.json
@@ -0,0 +1,37 @@
+{
+    "parent" : "B0",
+    "daughters" : ["rho-", "mu+", "nu_mu"],
+    "grand_daughters" : [["pi-", "pi0"], [], []],
+    "models" : ["MELIKHOV", "VSS", ""],
+    "parameters" : [["1"], [], []],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(MELIKHOV)",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug1", "title" : "Prob(VSS)",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "M(#rho)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.4, "xmax" : 1.5},
+        {"variable" : "mass", "title" : "M(#rho#mu)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 1.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "M(#rho#nu)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 1.0, "xmax" : 6.0},
+        {"variable" : "mass", "title" : "M(#mu#nu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+        {"variable" : "pSumSq", "title" : "q^{2}(#mu#nu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "p", "title" : "p(#rho)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(#rho)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 2.5},
+        {"variable" : "cosHel", "title" : "cosHel(#rho,#mu)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(#mu#nu)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(#pi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#rho)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#mu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#nu)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(#rho)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(#pi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(#pi^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(#pi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(#pi^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(#pi^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "MELIKHOV=VSS__Bd_rhomunu,pipi0.root",
+    "reference" : "RefMELIKHOV=VSS__Bd_rhomunu,pipi0.root"
+}
diff --git a/test/jsonFiles/OMEGA_DALITZ__omega_pipipi0.json b/test/jsonFiles/OMEGA_DALITZ__omega_pipipi0.json
new file mode 100644
index 0000000..7b1f1f4
--- /dev/null
+++ b/test/jsonFiles/OMEGA_DALITZ__omega_pipipi0.json
@@ -0,0 +1,21 @@
+{
+    "parent" : "omega",
+    "daughters" : ["pi+", "pi-", "pi0"],
+    "models" : ["OMEGA_DALITZ"],
+    "parameters" : [[]],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(#pi^{+} #pi^{-})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.25, "xmax" : 0.75},
+        {"variable" : "mass", "title" : "m(#pi^{+} #pi^{0})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.25, "xmax" : 0.75},
+        {"variable" : "mass", "title" : "m(#pi^{-} #pi^{0})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.25, "xmax" : 0.75},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(#pi^{+} #pi^{-}) vs m^{2}(#pi^{+} #pi^{0})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.05, "xmax" : 0.55, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.05, "ymax" : 0.55},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(#pi^{-} #pi^{0}) vs m^{2}(#pi^{+} #pi^{-})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.05, "xmax" : 0.55, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.05, "ymax" : 0.55},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel12", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel23", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel13", "d1" : 1, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "OMEGA_DALITZ__omega_pipipi0.root",
+    "reference" : "RefOMEGA_DALITZ__omega_pipipi0.root"
+}
diff --git a/test/jsonFiles/PARTWAVE=VSS__Bd_DstarDstar,D0piD0pi.json b/test/jsonFiles/PARTWAVE=VSS__Bd_DstarDstar,D0piD0pi.json
new file mode 100644
index 0000000..47efaae
--- /dev/null
+++ b/test/jsonFiles/PARTWAVE=VSS__Bd_DstarDstar,D0piD0pi.json
@@ -0,0 +1,46 @@
+{
+    "parent" : "B0",
+    "daughters" : ["D*+", "D*-"],
+    "grand_daughters" : [["D0", "pi+"], ["anti-D0", "pi-"]],
+    "models" : ["PARTWAVE", "VSS", "VSS"],
+    "parameters" : [["1.0", "0.0", "0.0", "0.0", "0.0", "0.0"], [], []],
+    "extras" : ["Define dm_incohMix_B0 0"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(PARTWAVE,B)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug1", "title" : "Prob(VSS,D*+)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug2", "title" : "Prob(VSS,D*-)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.1},
+        {"variable" : "parMass", "title" : "m(B0)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 5.27, "xmax" : 5.29},
+        {"variable" : "mass", "title" : "m(D*+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.95, "xmax" : 2.05},
+        {"variable" : "mass", "title" : "m(D*-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 1.95, "xmax" : 2.05},
+        {"variable" : "mass_daug1", "title" : "m(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.85, "xmax" : 1.9},
+        {"variable" : "mass_daug1", "title" : "m(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.13, "xmax" : 0.15},
+        {"variable" : "mass_daug2", "title" : "m(D0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.85, "xmax" : 1.9},
+        {"variable" : "mass_daug2", "title" : "m(pi-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.13, "xmax" : 0.15},
+	{"variable" : "cosHel", "title" : "cosHel(D0,D*+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel(D0bar,D*-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+ 	{"variable" : "decayangle", "title" : "decayAngle(D*+,D*-)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "decayangle_daug1", "title" : "decayAngle(D0,pi+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "decayangle_daug2", "title" : "decayAngle(D0bar,pi-)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(D*+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(D*-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosTheta_daug2", "title" : "cosTheta(D0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosTheta_daug2", "title" : "cosTheta(pi-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi_daug1", "title" : "phi(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi_daug2", "title" : "phi(D0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi_daug2", "title" : "phi(pi-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "p", "title" : "p(D*+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.65, "xmax" : 1.75},
+	{"variable" : "p", "title" : "p(D*-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 1.65, "xmax" : 1.75},
+	{"variable" : "p_daug1", "title" : "p(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.1},
+	{"variable" : "p_daug1", "title" : "p(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.1},
+	{"variable" : "p_daug2", "title" : "p(D0bar)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.1},
+	{"variable" : "p_daug2", "title" : "p(pi-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.1}
+    ],
+    "outfile" : "PARTWAVE=VSS__Bd_DstarDstar,D0piD0pi.root",
+    "reference" : "RefPARTWAVE=VSS__Bd_DstarDstar,D0piD0pi.root"
+}
diff --git a/test/jsonFiles/PHI_DALITZ__phi_pipipi0.json b/test/jsonFiles/PHI_DALITZ__phi_pipipi0.json
new file mode 100644
index 0000000..086c085
--- /dev/null
+++ b/test/jsonFiles/PHI_DALITZ__phi_pipipi0.json
@@ -0,0 +1,21 @@
+{
+    "parent" : "phi",
+    "daughters" : ["pi+", "pi-", "pi0"],
+    "models" : ["PHI_DALITZ"],
+    "parameters" : [[]],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(#pi^{+} #pi^{-})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.2, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(#pi^{+} #pi^{0})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.2, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(#pi^{-} #pi^{0})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.2, "xmax" : 1.0},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(#pi^{+} #pi^{-}) vs m^{2}(#pi^{+} #pi^{0})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.0, "xmax" : 0.8, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 0.8},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(#pi^{-} #pi^{0}) vs m^{2}(#pi^{+} #pi^{-})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.0, "xmax" : 0.8, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 0.8},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel12", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel23", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel13", "d1" : 1, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "PHI_DALITZ__eta_pipipi0.root",
+    "reference" : "RefPHI_DALITZ__eta_pipipi0.root"
+}
diff --git a/test/jsonFiles/PHSP=TAUSCALARNU__Bd_tautau,pinu,pinu.json b/test/jsonFiles/PHSP=TAUSCALARNU__Bd_tautau,pinu,pinu.json
new file mode 100644
index 0000000..79ec758
--- /dev/null
+++ b/test/jsonFiles/PHSP=TAUSCALARNU__Bd_tautau,pinu,pinu.json
@@ -0,0 +1,53 @@
+{
+    "parent" : "B0",
+    "daughters" : ["tau+", "tau-"],
+    "grand_daughters" : [["pi+", "anti-nu_tau"], ["pi-", "nu_tau"]],
+    "models" : ["PHSP", "TAUSCALARNU", "TAUSCALARNU"],
+    "parameters" : [[], [], []],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0},
+	{"variable" : "mass", "title" : "m(tau+tau-)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 5.1, "xmax" : 5.4},
+	{"variable" : "pSumSq", "title" : "qSq(tau+tau-)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 25.0, "xmax" : 30.0},
+	{"variable" : "p", "title" : "p(tau+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.5, "xmax" : 2.5},
+	{"variable" : "pSq", "title" : "pSq(tau+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 3.5, "xmax" : 4.5},
+	{"variable" : "pz", "title" : "pz(tau+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 2.5},
+	{"variable" : "cosTheta", "title" : "cosTheta(tau+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(tau-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelDiTau", "title" : "cosHelTau1(pi+)", "d1" : 1, "d2" : 1, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelDiTau", "title" : "cosHelTau2(pi-)", "d1" : 2, "d2" : 1, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelDiTau_over05", "title" : "cosHelTau1(pi+)", "d1" : 1, "d2" : 1, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelDiTau_over05", "title" : "cosHelTau2(pi-)", "d1" : 2, "d2" : 1, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelDiTau_under05", "title" : "cosHelTau1(pi+)", "d1" : 1, "d2" : 1, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelDiTau_under05", "title" : "cosHelTau2(pi-)", "d1" : 2, "d2" : 1, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+	{"variable" : "E_daug1", "title" : "E(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(pi+)/E(tau+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "pLab_daug1", "title" : "pLab(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "pzLab_daug1", "title" : "pzLab(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 2.5},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug1", "title" : "phi(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+	{"variable" : "E_daug1", "title" : "E(nubar)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(nubar)/E(tau+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "pLab_daug1", "title" : "pLab(nubar)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "pzLab_daug1", "title" : "pzLab(nubar)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 2.5},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(nubar)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug1", "title" : "phi(nubar)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+	{"variable" : "E_daug2", "title" : "E(pi-)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+        {"variable" : "E_over_Eparent_daug2", "title" : "E(pi-)/E(tau+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "pLab_daug2", "title" : "pLab(pi-)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "pzLab_daug2", "title" : "pzLab(pi-)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 2.5},
+	{"variable" : "cosTheta_daug2", "title" : "cosTheta(pi-)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug2", "title" : "phi(pi-)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+	{"variable" : "E_daug2", "title" : "E(nu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+        {"variable" : "E_over_Eparent_daug2", "title" : "E(nu)/E(tau+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "pLab_daug2", "title" : "pLab(nu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "pzLab_daug2", "title" : "pzLab(nu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 2.5},
+	{"variable" : "cosTheta_daug2", "title" : "cosTheta(nu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug2", "title" : "phi(nu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180}
+    ],
+    "outfile" : "PHSP=TAUSCALARNU__Bd_tautau,pinu,pinu.root",
+    "reference" : "RefPHSP=TAUSCALARNU__Bd_tautau,pinu,pinu.root"
+}
diff --git a/test/jsonFiles/PHSPDECAYTIMECUT__Bu_JpsiK+.json b/test/jsonFiles/PHSPDECAYTIMECUT__Bu_JpsiK+.json
new file mode 100644
index 0000000..9edd9b9
--- /dev/null
+++ b/test/jsonFiles/PHSPDECAYTIMECUT__Bu_JpsiK+.json
@@ -0,0 +1,13 @@
+{
+    "parent" : "B+",
+    "daughters" : ["J/psi", "K+"],
+    "do_conjugate_decay" : [ true, false, true ],
+    "models" : ["PHSPDECAYTIMECUT"],
+    "parameters" : [["0.4"]],
+    "events" : 10000,
+    "histograms" : [
+  {"variable" : "lifetime", "title" : "tau", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 10.0}
+    ],
+    "outfile" : "PhspDecaytimeCut__Bu_JpsiK+.root",
+    "reference" : "RefPhspDecaytimeCut__Bu_JpsiK+.root"
+}
diff --git a/test/jsonFiles/PHSPFLATLIFETIME__Bu_JpsiKpi.json b/test/jsonFiles/PHSPFLATLIFETIME__Bu_JpsiKpi.json
new file mode 100644
index 0000000..8b80dd6
--- /dev/null
+++ b/test/jsonFiles/PHSPFLATLIFETIME__Bu_JpsiKpi.json
@@ -0,0 +1,20 @@
+{
+    "parent" : "B+",
+    "daughters" : ["J/psi", "K+", "pi0"],
+    "do_conjugate_decay" : [ true, false, true, false ],
+    "models" : ["PHSPFLATLIFETIME"],
+    "parameters" : [["5.0"]],
+    "events" : 20000,
+    "histograms" : [
+  {"variable" : "lifetime", "title" : "tau", "d1" : 0, "d2" : 0, "nbins" : 110, "xmin" : 0.0, "xmax" : 5.5},
+	{"variable" : "mass", "title" : "mKPi", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.6, "xmax" : 2.25},
+	{"variable" : "mass", "title" : "mJpsiPi", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 3.2, "xmax" : 4.8},
+	{"variable" : "mass", "title" : "mJpsiK", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 3.5, "xmax" : 5.2},
+	{"variable" : "cosHel", "title" : "cosTheta1", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosTheta2", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosTheta3", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "massSq", "title" : "dalitz", "d1" : 2, "d2" : 3, "nbins" : 25, "xmin" : 0.30, "xmax" : 5.30, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 25, "ymin" : 10.2, "ymax" : 23.2}
+    ],
+    "outfile" : "PHSPFLATLIFETIME__Bu_JpsiKpi.root",
+    "reference" : "RefPHSPFLATLIFETIME__Bu_JpsiKpi.root"
+}
diff --git a/test/jsonFiles/PHSP__Bd_4pi.json b/test/jsonFiles/PHSP__Bd_4pi.json
new file mode 100644
index 0000000..a7fae53
--- /dev/null
+++ b/test/jsonFiles/PHSP__Bd_4pi.json
@@ -0,0 +1,39 @@
+{
+    "parent" : "B0",
+    "daughters" : ["pi+", "pi-", "pi+", "pi-"],
+    "models" : ["PHSP"],
+    "parameters" : [[]],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0},
+        {"variable" : "mass", "title" : "m(pi1+pi1-)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.1, "xmax" : 5.0},
+        {"variable" : "mass", "title" : "m(pi1+pi2+)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "mass", "title" : "m(pi1- pi2+)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "mass", "title" : "m(pi2+ pi2-)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "pSumSq", "title" : "qSq(pi1+pi1-)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 25.0},
+        {"variable" : "pSumSq", "title" : "qSq(pi2+pi2-)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.0, "xmax" : 25.0},
+        {"variable" : "p", "title" : "p(pi1+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(pi1+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(pi1-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(pi1-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(pi2+)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(pi2+)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(pi2-)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(pi2-)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(pi1+,pi1-)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(pi2+,pi2-)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(pi1-,pi2+)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(pi1+,pi2+)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(pi1+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(pi1-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(pi2+)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(pi2-)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(pi1+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(pi1-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(pi2+)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "phi", "title" : "phi(pi2-)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180}
+    ],
+    "outfile" : "PHSP__Bd_4pi.root",
+    "reference" : "RefPHSP__Bd_4pi.root"
+}
diff --git a/test/jsonFiles/PI0_DALITZ__pi0_eegamma.json b/test/jsonFiles/PI0_DALITZ__pi0_eegamma.json
new file mode 100644
index 0000000..da439de
--- /dev/null
+++ b/test/jsonFiles/PI0_DALITZ__pi0_eegamma.json
@@ -0,0 +1,21 @@
+{
+    "parent" : "pi0",
+    "daughters" : ["e+", "e-", "gamma"],
+    "models" : ["PI0_DALITZ"],
+    "parameters" : [[], [], []],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(e+ e-)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.15},
+        {"variable" : "mass", "title" : "m(e+ #gamma)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.15},
+        {"variable" : "mass", "title" : "m(e- #gamma)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.15},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(e+ e-) vs m^{2}(e+ #gamma)", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.0, "xmax" : 0.02, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 0.02},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(e- #gamma) vs m^{2}(e+ e-)", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.0, "xmax" : 0.02, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 0.02},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel12", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel23", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel13", "d1" : 1, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "PI0DALITZ__pi0_eegamma.root",
+    "reference" : "RefPI0DALITZ__pi0_eegamma.root"
+}
diff --git a/test/jsonFiles/PROPSLPOLE=VSS__D+_Kst0enu,Kpi.json b/test/jsonFiles/PROPSLPOLE=VSS__D+_Kst0enu,Kpi.json
new file mode 100644
index 0000000..40aa32e
--- /dev/null
+++ b/test/jsonFiles/PROPSLPOLE=VSS__D+_Kst0enu,Kpi.json
@@ -0,0 +1,38 @@
+{
+    "parent" : "D+",
+    "daughters" : ["anti-K*0", "e+", "nu_e"],
+    "grand_daughters" : [["K-", "pi+"], [], []],
+    "models" : ["PROPSLPOLE", "VSS", ""],
+    "parameters" : [["1.00", "-0.558", "0.0", "1.0", "0.85", "-0.558", "0.0", "1.0", "1.50", "-0.790", "0.0", "1.0", "0.00", "-0.558", "0.0", "1.0"], [], []],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "M(#it{K}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.6, "xmax" : 1.4},
+        {"variable" : "mass", "title" : "M(#it{K}*^{0}#it{e})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.5, "xmax" : 2.0},
+        {"variable" : "mass", "title" : "M(#it{K}*^{0}#it{#nu})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.5, "xmax" : 2.0},
+        {"variable" : "mass", "title" : "M(#it{e}#it{#nu})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0},
+        {"variable" : "pSumSq", "title" : "q^{2}(#it{e}#it{#nu})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.5},
+        {"variable" : "p", "title" : "p(#it{K}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "pSq", "title" : "p^{2}(#it{K}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "pz", "title" : "pz(#it{K}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(#it{K}*^{0},#it{e})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(#it{e}#it{#nu})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(#it{K})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+        {"variable" : "decayangle", "title" : "#theta(#it{K}*^{0},#it{e})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 200.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{K}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{e})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{#nu})", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(#it{K}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(#it{K})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(#it{#pi})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(#it{K})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(#it{K})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(#it{#pi})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(#it{#pi})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "PROPSLPOLE=VSS__D+_Kst0enu,Kpi.root",
+    "reference" : "RefPROPSLPOLE=VSS__D+_Kst0enu,Kpi.root"
+}
diff --git a/test/jsonFiles/PSI2JPSIPIPI__psi2S_Jpsipipi_nlo.json b/test/jsonFiles/PSI2JPSIPIPI__psi2S_Jpsipipi_nlo.json
new file mode 100644
index 0000000..cfee186
--- /dev/null
+++ b/test/jsonFiles/PSI2JPSIPIPI__psi2S_Jpsipipi_nlo.json
@@ -0,0 +1,15 @@
+{
+    "parent" : "X_2(3872)",
+    "daughters" : ["J/psi", "pi+", "pi-"],
+    "models" : ["PSI2JPSIPIPI"],
+    "parameters" : [["0.78539816"]],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "mPiPi", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.25, "xmax" : 0.85},
+	{"variable" : "cosHel", "title" : "cosTheta1", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosTheta2", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "PSI2JPSIPIPI__psi2S_Jpsipipi_nlo.root",
+    "reference" : "RefPSI2JPSIPIPI__psi2S_Jpsipipi_nlo.root"
+}
diff --git a/test/jsonFiles/PSI2JPSIPIPI__psi2S_Jpsipipi_tree.json b/test/jsonFiles/PSI2JPSIPIPI__psi2S_Jpsipipi_tree.json
new file mode 100644
index 0000000..f03ace4
--- /dev/null
+++ b/test/jsonFiles/PSI2JPSIPIPI__psi2S_Jpsipipi_tree.json
@@ -0,0 +1,15 @@
+{
+    "parent" : "X_2(3872)",
+    "daughters" : ["J/psi", "pi+", "pi-"],
+    "models" : ["PSI2JPSIPIPI"],
+    "parameters" : [[]],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "mPiPi", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.25, "xmax" : 0.85},
+	{"variable" : "cosHel", "title" : "cosTheta1", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosTheta2", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "PSI2JPSIPIPI__psi2S_Jpsipipi_tree.root",
+    "reference" : "RefPSI2JPSIPIPI__psi2S_Jpsipipi_tree.root"
+}
diff --git a/test/jsonFiles/PTO3P__D0_K0sKK.json b/test/jsonFiles/PTO3P__D0_K0sKK.json
new file mode 100644
index 0000000..da5328d
--- /dev/null
+++ b/test/jsonFiles/PTO3P__D0_K0sKK.json
@@ -0,0 +1,25 @@
+{
+    "parent" : "D0",
+    "daughters" : ["K_S0", "K+", "K-"],
+    "models" : ["PTO3P"],
+    "parameters" : [["MAXPDF 6.0",
+		     "AMPLITUDE RESONANCE BC a_00 ANGULAR AC TYPE NBW COEFFICIENT POLAR_RAD 1.0 0.0",
+		     "AMPLITUDE RESONANCE BC phi ANGULAR AC TYPE RBW_ZEMACH COEFFICIENT POLAR_RAD 0.437 1.91",
+		     "AMPLITUDE RESONANCE AB a_0+ ANGULAR CA TYPE NBW COEFFICIENT POLAR_RAD 0.460 3.59",
+		     "AMPLITUDE RESONANCE BC f'_0 ANGULAR AC TYPE RBW_ZEMACH COEFFICIENT POLAR_RAD 0.435 -2.65"]],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(K^{0}_{S} K^{+})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.9, "xmax" : 1.5},
+        {"variable" : "mass", "title" : "m(K^{0}_{S} K^{-})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.9, "xmax" : 1.5},
+        {"variable" : "mass", "title" : "m(K^{-} K^{+})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.9, "xmax" : 1.5},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(K^{0}_{S} K^{+}) vs m^{2}(K^{0}_{S} K^{-})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.8, "xmax" : 2.0, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.8, "ymax" : 2.0},
+        {"variable" : "massSq", "title" : "Dalitz m^{2}(K^{+} K^{-}) vs m^{2}(K^{0}_{S} K^{+})", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : 0.8, "xmax" : 2.0, "variableY" : "massSq", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 50, "ymin" : 0.8, "ymax" : 2.0},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel12", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel23", "d1" : 2, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel13", "d1" : 1, "d2" : 3, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "PTO3P__D0_K0sKK.root",
+    "reference" : "RefPTO3P__D0_K0sKK.root"
+}
diff --git a/test/jsonFiles/PVV_CPLH=VLL=VSS__B0s_Jpsiphi,ee,KK.json b/test/jsonFiles/PVV_CPLH=VLL=VSS__B0s_Jpsiphi,ee,KK.json
new file mode 100644
index 0000000..7ec49fd
--- /dev/null
+++ b/test/jsonFiles/PVV_CPLH=VLL=VSS__B0s_Jpsiphi,ee,KK.json
@@ -0,0 +1,26 @@
+{
+    "parent" : "B_s0",
+    "daughters" : ["J/psi", "phi"],
+    "grand_daughters" : [["e+", "e-"], ["K+", "K-"]],
+    "models" : ["PVV_CPLH", "VLL", "VSS"],
+    "parameters" : [["-0.035", "1", "0.480", "3.30", "0.722", "0.0", "0.499", "3.07"], [], []],
+    "do_conjugate_decay" : [true, false, false],
+    "extras" : ["Define dm_incohMix_B_s0 0"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(PVV_CPLH)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug1", "title" : "Prob(VLL)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug2", "title" : "Prob(VSS)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "parMass", "title" : "m(B0s)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 5.2, "xmax" : 5.5},
+        {"variable" : "mass", "title" : "m(J/psi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.5, "xmax" : 3.5},
+        {"variable" : "mass", "title" : "m(phi)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.8, "xmax" : 1.2},
+	{"variable" : "cosHel", "title" : "cosHel(e)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel(K)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "decayangle_daug1", "title" : "DecayAngle(e)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "decayangle_daug2", "title" : "DecayAngle(K)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "p_daug1", "title" : "p(e)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.0, "xmax" : 1.8},
+	{"variable" : "p_daug2", "title" : "p(K)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.3}
+    ],
+    "outfile" : "PVV_CPLH=VLL=VSS__Bs0_Jpsiphi,ee,KK.root",
+    "reference" : "RefPVV_CPLH=VLL=VSS__Bs0_Jpsiphi,ee,KK.root"
+}
diff --git a/test/jsonFiles/RareLbToLll=HELAMP__Lambdab0_Lambda0mumu,pipi.json b/test/jsonFiles/RareLbToLll=HELAMP__Lambdab0_Lambda0mumu,pipi.json
new file mode 100644
index 0000000..bf86f62
--- /dev/null
+++ b/test/jsonFiles/RareLbToLll=HELAMP__Lambdab0_Lambda0mumu,pipi.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "Lambda_b0",
+    "daughters" : ["Lambda0", "mu-", "mu+"],
+    "grand_daughters" : [["p+","pi-"], [], []],
+    "models" : ["RareLbToLll", "HELAMP", ""],
+    "parameters" : [[], ["0.936", "0.0", "0.351", "0.0"]],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob(RareLbToLll)",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "prob_daug1", "title" : "Prob(HELAMP)",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "parMass", "title" : "m(#Lambda^{0}_{b})", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 5.0, "xmax" : 6.0},
+	{"variable" : "mass", "title" : "m(#Lambda^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.0, "xmax" : 1.2},
+	{"variable" : "mass", "title" : "m(#Lambda^{0} #mu^{-})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+	{"variable" : "mass", "title" : "m(#Lambda^{0} #mu^{+})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 6.0},
+	{"variable" : "pSumSq", "title" : "q^{2}(#mu^{-} #mu^{+})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 21.0},
+	{"variable" : "cosHel", "title" : "cosHel(p,#Lambda^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "decayangle_daug1", "title" : "decayAngle(#Lambda^{0},p,#pi^{-})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0}
+    ],
+    "outfile" : "RareLbToLll=HELAMP__Lambdab0_Lambda0mumu,ppi.root",
+    "reference" : "RefRareLbToLll=HELAMP__Lambdab0_Lambda0mumu,ppi.root"
+}
diff --git a/test/jsonFiles/SINGLE__Upsilon4S_mu.json b/test/jsonFiles/SINGLE__Upsilon4S_mu.json
new file mode 100644
index 0000000..ca0ed5f
--- /dev/null
+++ b/test/jsonFiles/SINGLE__Upsilon4S_mu.json
@@ -0,0 +1,17 @@
+{
+    "parent" : "Upsilon(4S)",
+    "daughters" : ["mu+"],
+    "models" : ["SINGLE"],
+    "parameters" : [["0.5", "1.0", "-0.8", "0.5", "0.0", "6.2832"]],
+    "extras" : ["noPhotos"],
+    "events" : 100000,
+    "histograms" : [
+        {"variable" : "parMass", "title" : "m(Upsilon4S)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 10.0, "xmax" : 11.0},
+	{"variable" : "mass", "title" : "m(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.05, "xmax" : 0.15},
+        {"variable" : "p", "title" : "p(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.4, "xmax" : 1.1},
+        {"variable" : "cosTheta", "title" : "cosTheta(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "SINGLE__Upsilon4S_mu.root",
+    "reference" : "RefSINGLE__Upsilon4S_mu.root"
+}
diff --git a/test/jsonFiles/SLBKPOLE=PHSP__D+_Ksenu,pipi.json b/test/jsonFiles/SLBKPOLE=PHSP__D+_Ksenu,pipi.json
new file mode 100644
index 0000000..e049468
--- /dev/null
+++ b/test/jsonFiles/SLBKPOLE=PHSP__D+_Ksenu,pipi.json
@@ -0,0 +1,38 @@
+{
+    "parent" : "D+",
+    "daughters" : ["anti-K0", "e+", "nu_e"],
+    "grand_daughters" : [["pi+", "pi-"], [], []],
+    "models" : ["SLBKPOLE", "PHSP", ""],
+    "parameters" : [["1.0", "0.303", "1.0", "2.112"], [], []],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "M(#it{K}_{S}^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.6, "xmax" : 1.4},
+        {"variable" : "mass", "title" : "M(#it{K}_{S}^{0}#it{e})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.5, "xmax" : 2.0},
+        {"variable" : "mass", "title" : "M(#it{K}_{S}^{0}#it{#nu})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.5, "xmax" : 2.0},
+        {"variable" : "mass", "title" : "M(#it{e}#it{#nu})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0},
+        {"variable" : "pSumSq", "title" : "q^{2}(#it{e}#it{#nu})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.5},
+        {"variable" : "p", "title" : "p(#it{K}_{S}^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "pSq", "title" : "p^{2}(#it{K}_{S}^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "pz", "title" : "pz(#it{K}_{S}^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(#it{K}_{S}^{0},#it{e})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(#it{e}#it{#nu})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(#it{K}_{S}^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+        {"variable" : "decayangle", "title" : "#theta(#it{K}_{S}^{0},#it{e})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 200.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{K}_{S}^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{e})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{#nu})", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(#it{K}_{S}^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(#it{#pi})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(#it{#pi})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(#it{#pi})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(#it{#pi})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(#it{#pi})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(#it{#pi})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "SLBKPOLE=PHSP__D+_Ksenu,pipi.root",
+    "reference" : "RefSLBKPOLE=PHSP__D+_Ksenu,pipi.root"
+}
diff --git a/test/jsonFiles/SLL=TAUSCALARNU__Bd_tautau,pinu,pinu.json b/test/jsonFiles/SLL=TAUSCALARNU__Bd_tautau,pinu,pinu.json
new file mode 100644
index 0000000..611faba
--- /dev/null
+++ b/test/jsonFiles/SLL=TAUSCALARNU__Bd_tautau,pinu,pinu.json
@@ -0,0 +1,53 @@
+{
+    "parent" : "B0",
+    "daughters" : ["tau+", "tau-"],
+    "grand_daughters" : [["pi+", "anti-nu_tau"], ["pi-", "nu_tau"]],
+    "models" : ["SLL", "TAUSCALARNU", "TAUSCALARNU"],
+    "parameters" : [[], [], []],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob(SLL)",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "prob_daug1", "title" : "Prob_{1}(TAUSCALARNU)",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "prob_daug2", "title" : "Prob_{2}(TAUSCALARNU)",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(#tau^{+}#tau^{-})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 5.1, "xmax" : 5.4},
+	{"variable" : "p", "title" : "p(#tau^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.5, "xmax" : 2.5},
+	{"variable" : "pz", "title" : "pz(#tau^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 2.5},
+	{"variable" : "cosTheta", "title" : "cosTheta(#tau^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(#tau^{-})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelDiTau", "title" : "cosHelTau1(#pi^{+})", "d1" : 1, "d2" : 1, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelDiTau", "title" : "cosHelTau2(#pi^{-})", "d1" : 2, "d2" : 1, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelDiTau_over05", "title" : "cosHelTau1(#pi^{+})", "d1" : 1, "d2" : 1, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelDiTau_over05", "title" : "cosHelTau2(#pi^{-})", "d1" : 2, "d2" : 1, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelDiTau_under05", "title" : "cosHelTau1(#pi^{+})", "d1" : 1, "d2" : 1, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelDiTau_under05", "title" : "cosHelTau2(#pi^{-})", "d1" : 2, "d2" : 1, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+	{"variable" : "E_daug1", "title" : "E(#pi^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(#pi^{+})/E(#tau^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "pLab_daug1", "title" : "pLab(#pi^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "pzLab_daug1", "title" : "pzLab(#pi^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 2.5},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(#pi^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug1", "title" : "phi(#pi^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+	{"variable" : "E_daug1", "title" : "E(#bar{#nu})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(#bar{#nu})/E(#tau^{+})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "pLab_daug1", "title" : "pLab(#bar{#nu})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "pzLab_daug1", "title" : "pzLab(#bar{#nu})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 2.5},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(#bar{#nu})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug1", "title" : "phi(#bar{#nu})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+	{"variable" : "E_daug2", "title" : "E(#pi^{-})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+        {"variable" : "E_over_Eparent_daug2", "title" : "E(#pi^{-})/E(#tau^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "pLab_daug2", "title" : "pLab(#pi^{-})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "pzLab_daug2", "title" : "pzLab(#pi^{-})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 2.5},
+	{"variable" : "cosTheta_daug2", "title" : "cosTheta(#pi^{-})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug2", "title" : "phi(#pi^{-})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+	{"variable" : "E_daug2", "title" : "E(#nu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+        {"variable" : "E_over_Eparent_daug2", "title" : "E(#nu)/E(#tau^{+})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "pLab_daug2", "title" : "pLab(#nu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "pzLab_daug2", "title" : "pzLab(#nu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 2.5},
+	{"variable" : "cosTheta_daug2", "title" : "cosTheta(#nu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug2", "title" : "phi(#nu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180}
+    ],
+    "outfile" : "SLL=TAUSCALARNU__Bd_tautau,pinu,pinu.root",
+    "reference" : "RefSLL=TAUSCALARNU__Bd_tautau,pinu,pinu.root"
+}
diff --git a/test/jsonFiles/SLN=TAUHADNU__Bu_taunu,pi0pi0pinu.json b/test/jsonFiles/SLN=TAUHADNU__Bu_taunu,pi0pi0pinu.json
new file mode 100644
index 0000000..b1536d2
--- /dev/null
+++ b/test/jsonFiles/SLN=TAUHADNU__Bu_taunu,pi0pi0pinu.json
@@ -0,0 +1,42 @@
+{
+    "parent" : "B+",
+    "daughters" : ["tau+", "nu_tau"],
+    "grand_daughters" : [["pi0", "pi0", "pi+", "anti-nu_tau"], []],
+    "models" : ["SLN", "TAUHADNU", ""],
+    "parameters" : [[], ["-0.108", "0.775", "0.149", "1.364", "0.400", "1.23", "0.4"], []],
+    "extras" : ["Define TauolaBR1 1.0",
+                "Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.8, "xmax" : 1.2},
+	{"variable" : "p", "title" : "p(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.2, "xmax" : 2.6},
+	{"variable" : "pz", "title" : "pz(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 2.5},
+	{"variable" : "cosTheta", "title" : "cosTheta(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi", "title" : "phi(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+	{"variable" : "E", "title" : "E(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.5, "xmax" : 3.5},
+        {"variable" : "E_over_Eparent", "title" : "E(tau)/E(B)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(pi0_{1})/E(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(pi0_{2})/E(tau)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(pi+)/E(tau)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(nu)/E(tau)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi0_{1})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi0_{2})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi+)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(nu)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(pi0_{1})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelTau", "title" : "cosHelTau(pi0_{1})", "d1" : 1, "d2" : 1, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelTau", "title" : "cosHelTau(pi0_{2})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelTau", "title" : "cosHelTau(pi+)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelTau", "title" : "cosHelTau(nu)", "d1" : 1, "d2" : 4, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "mass_daug1", "title" : "m(pi0_{1} pi0_{2})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.25, "xmax" : 2.0},
+	{"variable" : "mass_daug1", "title" : "m(pi0_{1} pi+)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.25, "xmax" : 2.0},
+	{"variable" : "mass_daug1", "title" : "m(pi0_{1} nu)", "d1" : 1, "d2" : 4, "nbins" : 100, "xmin" : 0.25, "xmax" : 2.0},
+	{"variable" : "mass_daug1", "title" : "m(pi0_{2} pi+)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.25, "xmax" : 2.0},
+	{"variable" : "mass_daug1", "title" : "m(pi0_{2} nu)", "d1" : 2, "d2" : 4, "nbins" : 100, "xmin" : 0.25, "xmax" : 2.0},
+	{"variable" : "mass_daug1", "title" : "m(pi+ nu)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.25, "xmax" : 2.0},
+	{"variable" : "mass3_daug1", "title" : "m(pi0_{1} pi0_{2} pi+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.2, "xmax" : 1.8},
+	{"variable" : "cosTheta3_daug1", "title" : "cosTheta3", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "SLN=TAUHADNU__Bu_taunu,pi0pi0pinu.root",
+    "reference" : "RefSLN=TAUHADNU__Bu_taunu,pi0pi0pinu.root"
+}
diff --git a/test/jsonFiles/SLN=TAULNUNU__Bu_taunu,enu.json b/test/jsonFiles/SLN=TAULNUNU__Bu_taunu,enu.json
new file mode 100644
index 0000000..85b4942
--- /dev/null
+++ b/test/jsonFiles/SLN=TAULNUNU__Bu_taunu,enu.json
@@ -0,0 +1,33 @@
+{
+    "parent" : "B+",
+    "daughters" : ["tau+", "nu_tau"],
+    "grand_daughters" : [["e+", "nu_e", "anti-nu_tau"], []],
+    "models" : ["SLN", "TAULNUNU", ""],
+    "parameters" : [[], [], []],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.8, "xmax" : 1.2},
+        {"variable" : "p", "title" : "p(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.2, "xmax" : 2.6},
+        {"variable" : "pz", "title" : "pz(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 2.5},
+        {"variable" : "cosTheta", "title" : "cosTheta(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "E", "title" : "E(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.5, "xmax" : 3.5},
+        {"variable" : "E_over_Eparent", "title" : "E(tau)/E(B)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(e)/E(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(nue)/E(tau)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(nutau_{2})/E(tau)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(e)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(nue)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(nutau_{2})", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(e)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelTau", "title" : "cosHelTau(e)", "d1" : 1, "d2" : 1, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelTau", "title" : "cosHelTau(nue)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelTau", "title" : "cosHelTau(nutau_{2})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "mass_daug1", "title" : "m(e nue)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.25, "xmax" : 2.0},
+        {"variable" : "mass_daug1", "title" : "m(e nutau_{2})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.25, "xmax" : 2.0},
+        {"variable" : "mass_daug1", "title" : "m(nue nutau_{2})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.25, "xmax" : 2.0}
+    ],
+    "outfile" : "SLN=TAULNUNU__Bu_taunu,enu.root",
+    "reference" : "RefSLN=TAULNUNU__Bu_taunu,enu.root"
+}
diff --git a/test/jsonFiles/SLN=TAULNUNU__Bu_taunu,munu.json b/test/jsonFiles/SLN=TAULNUNU__Bu_taunu,munu.json
new file mode 100644
index 0000000..7b781d6
--- /dev/null
+++ b/test/jsonFiles/SLN=TAULNUNU__Bu_taunu,munu.json
@@ -0,0 +1,33 @@
+{
+    "parent" : "B+",
+    "daughters" : ["tau+", "nu_tau"],
+    "grand_daughters" : [["mu+", "nu_mu", "anti-nu_tau"], []],
+    "models" : ["SLN", "TAULNUNU", ""],
+    "parameters" : [[], [], []],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.8, "xmax" : 1.2},
+        {"variable" : "p", "title" : "p(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.2, "xmax" : 2.6},
+        {"variable" : "pz", "title" : "pz(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 2.5},
+        {"variable" : "cosTheta", "title" : "cosTheta(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "E", "title" : "E(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.5, "xmax" : 3.5},
+        {"variable" : "E_over_Eparent", "title" : "E(tau)/E(B)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(mu)/E(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(numu)/E(tau)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(nutau)/E(tau)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(mu)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(numu)", "d1" : 2, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(nutau)", "d1" : 3, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelTau", "title" : "cosHelTau(mu)", "d1" : 1, "d2" : 1, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelTau", "title" : "cosHelTau(numu)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelTau", "title" : "cosHelTau(nutau)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "mass_daug1", "title" : "m(mu numu)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.25, "xmax" : 2.0},
+        {"variable" : "mass_daug1", "title" : "m(mu nutau)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.25, "xmax" : 2.0},
+        {"variable" : "mass_daug1", "title" : "m(numu nutau)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.25, "xmax" : 2.0}
+    ],
+    "outfile" : "SLN=TAULNUNU__Bu_taunu,munu.root",
+    "reference" : "RefSLN=TAULNUNU__Bu_taunu,munu.root"
+}
diff --git a/test/jsonFiles/SLN=TAUOLA__Bu_taunu,pipipinu,BaBar.json b/test/jsonFiles/SLN=TAUOLA__Bu_taunu,pipipinu,BaBar.json
new file mode 100644
index 0000000..11d1f66
--- /dev/null
+++ b/test/jsonFiles/SLN=TAUOLA__Bu_taunu,pipipinu,BaBar.json
@@ -0,0 +1,43 @@
+{
+    "parent" : "B+",
+    "daughters" : ["tau+", "nu_tau"],
+    "grand_daughters" : [[" "], []],
+    "models" : ["SLN", "TAUOLA", ""],
+    "parameters" : [[], ["5"], []],
+    "extras" : ["Define TauolaCurrentOption 1", 
+                "Define TauolaBR1 1.0",
+                "Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.8, "xmax" : 1.2},
+        {"variable" : "p", "title" : "p(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.2, "xmax" : 2.6},
+        {"variable" : "pz", "title" : "pz(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 2.5},
+        {"variable" : "cosTheta", "title" : "cosTheta(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "E", "title" : "E(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.5, "xmax" : 3.5},
+        {"variable" : "E_over_Eparent", "title" : "E(tau)/E(B)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(nutau_{2})/E(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(pi+_{1})/E(tau)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(pi+_{2})/E(tau)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(pi-)/E(tau)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(nutau_{2})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi+_{1})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi+_{2})", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi-)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(nutau_{2})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelTau", "title" : "cosHelTau(nutau_{2})", "d1" : 1, "d2" : 1, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelTau", "title" : "cosHelTau(pi+_{1})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelTau", "title" : "cosHelTau(pi+_{2})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelTau", "title" : "cosHelTau(pi-)", "d1" : 1, "d2" : 4, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "mass_daug1", "title" : "m(nutau_{2} pi+_{1})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.25, "xmax" : 2.0},
+        {"variable" : "mass_daug1", "title" : "m(nutau_{2} pi+_{2})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.25, "xmax" : 2.0},
+        {"variable" : "mass_daug1", "title" : "m(nutau_{2} pi-)", "d1" : 1, "d2" : 4, "nbins" : 100, "xmin" : 0.25, "xmax" : 2.0},
+        {"variable" : "mass_daug1", "title" : "m(pi+_{1} pi+_{2})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.25, "xmax" : 2.0},
+        {"variable" : "mass_daug1", "title" : "m(pi+_{1} pi-)", "d1" : 2, "d2" : 4, "nbins" : 100, "xmin" : 0.25, "xmax" : 2.0},
+        {"variable" : "mass_daug1", "title" : "m(pi+_{2} pi-)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.25, "xmax" : 2.0},
+        {"variable" : "mass3_daug1", "title" : "m(pi+_{1} pi+_{2} pi-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.2, "xmax" : 1.8},
+        {"variable" : "cosTheta3_daug1", "title" : "cosTheta3pi", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "SLN=TAUOLA__Bu_taunu,pipipinu,BaBar.root",
+    "reference" : "RefSLN=TAUOLA__Bu_taunu,pipipinu,BaBar.root"
+}
diff --git a/test/jsonFiles/SLN=TAUOLA__Bu_taunu,pipipinu,CLEO.json b/test/jsonFiles/SLN=TAUOLA__Bu_taunu,pipipinu,CLEO.json
new file mode 100644
index 0000000..9129857
--- /dev/null
+++ b/test/jsonFiles/SLN=TAUOLA__Bu_taunu,pipipinu,CLEO.json
@@ -0,0 +1,43 @@
+{
+    "parent" : "B+",
+    "daughters" : ["tau+", "nu_tau"],
+    "grand_daughters" : [[" "], []],
+    "models" : ["SLN", "TAUOLA", ""],
+    "parameters" : [[], ["5"], []],
+    "extras" : ["Define TauolaCurrentOption 0", 
+                "Define TauolaBR1 1.0",
+                "Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.8, "xmax" : 1.2},
+        {"variable" : "p", "title" : "p(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.2, "xmax" : 2.6},
+        {"variable" : "pz", "title" : "pz(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 2.5},
+        {"variable" : "cosTheta", "title" : "cosTheta(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "E", "title" : "E(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.5, "xmax" : 3.5},
+        {"variable" : "E_over_Eparent", "title" : "E(tau)/E(B)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(nutau_{2})/E(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(pi+_{1})/E(tau)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(pi+_{2})/E(tau)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(pi-)/E(tau)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(nutau_{2})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi+_{1})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi+_{2})", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi-)", "d1" : 4, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(nutau_{2})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelTau", "title" : "cosHelTau(nutau_{2})", "d1" : 1, "d2" : 1, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelTau", "title" : "cosHelTau(pi+_{1})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelTau", "title" : "cosHelTau(pi+_{2})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelTau", "title" : "cosHelTau(pi-)", "d1" : 1, "d2" : 4, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "mass_daug1", "title" : "m(nutau_{2} pi+_{1})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.25, "xmax" : 2.0},
+        {"variable" : "mass_daug1", "title" : "m(nutau_{2} pi+_{2})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.25, "xmax" : 2.0},
+        {"variable" : "mass_daug1", "title" : "m(nutau_{2} pi-)", "d1" : 1, "d2" : 4, "nbins" : 100, "xmin" : 0.25, "xmax" : 2.0},
+        {"variable" : "mass_daug1", "title" : "m(pi+_{1} pi+_{2})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.25, "xmax" : 2.0},
+        {"variable" : "mass_daug1", "title" : "m(pi+_{1} pi-)", "d1" : 2, "d2" : 4, "nbins" : 100, "xmin" : 0.25, "xmax" : 2.0},
+        {"variable" : "mass_daug1", "title" : "m(pi+_{2} pi-)", "d1" : 3, "d2" : 4, "nbins" : 100, "xmin" : 0.25, "xmax" : 2.0},
+        {"variable" : "mass3_daug1", "title" : "m(pi+_{1} pi+_{2} pi-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.2, "xmax" : 1.8},
+        {"variable" : "cosTheta3_daug1", "title" : "cosTheta3pi", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "SLN=TAUOLA__Bu_taunu,pipipinu,CLEO.root",
+    "reference" : "RefSLN=TAUOLA__Bu_taunu,pipipinu,CLEO.root"
+}
diff --git a/test/jsonFiles/SLN=TAUSCALARNU__Bu_taunu,pinu.json b/test/jsonFiles/SLN=TAUSCALARNU__Bu_taunu,pinu.json
new file mode 100644
index 0000000..33c6460
--- /dev/null
+++ b/test/jsonFiles/SLN=TAUSCALARNU__Bu_taunu,pinu.json
@@ -0,0 +1,28 @@
+{
+    "parent" : "B+",
+    "daughters" : ["tau+", "nu_tau"],
+    "grand_daughters" : [["pi+", "anti-nu_tau"], []],
+    "models" : ["SLN", "TAUSCALARNU", ""],
+    "parameters" : [[], [], []],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.8, "xmax" : 1.2},
+        {"variable" : "p", "title" : "p(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.2, "xmax" : 2.6},
+        {"variable" : "pz", "title" : "pz(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 2.5},
+        {"variable" : "cosTheta", "title" : "cosTheta(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "E", "title" : "E(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.5, "xmax" : 3.5},
+        {"variable" : "E_over_Eparent", "title" : "E(tau)/E(B)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(pi)/E(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(nutau_{2})/E(tau)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(nutau_{2})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(pi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelTau", "title" : "cosHelTau(pi)", "d1" : 1, "d2" : 1, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelTau", "title" : "cosHelTau(nutau_{2})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "mass_daug1", "title" : "m(pi nutau_{2})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 1.7, "xmax" : 1.9}
+    ],
+    "outfile" : "SLN=TAUSCALARNU__Bu_taunu,pinu.root",
+    "reference" : "RefSLN=TAUSCALARNU__Bu_taunu,pinu.root"
+}
diff --git a/test/jsonFiles/SLN=TAUVECTORNU__Bu_taunu,rhonu.json b/test/jsonFiles/SLN=TAUVECTORNU__Bu_taunu,rhonu.json
new file mode 100644
index 0000000..8ddf3f8
--- /dev/null
+++ b/test/jsonFiles/SLN=TAUVECTORNU__Bu_taunu,rhonu.json
@@ -0,0 +1,29 @@
+{
+    "parent" : "B+",
+    "daughters" : ["tau+", "nu_tau"],
+    "grand_daughters" : [["rho+", "anti-nu_tau"], []],
+    "models" : ["SLN", "TAUVECTORNU", ""],
+    "parameters" : [[], [], []],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.8, "xmax" : 1.2},
+        {"variable" : "p", "title" : "p(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.2, "xmax" : 2.6},
+        {"variable" : "pz", "title" : "pz(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 2.5},
+        {"variable" : "cosTheta", "title" : "cosTheta(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+        {"variable" : "E", "title" : "E(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.5, "xmax" : 3.5},
+        {"variable" : "E_over_Eparent", "title" : "E(tau)/E(B)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(rho)/E(tau)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "E_over_Eparent_daug1", "title" : "E(nutau_{2})/E(tau)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(rho)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(nutau_{2})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(rho)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelTau", "title" : "cosHelTau(rho)", "d1" : 1, "d2" : 1, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelTau", "title" : "cosHelTau(nutau_{2})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "mass_daug1", "title" : "m(rho nutau_{2})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 1.7, "xmax" : 1.9},
+        {"variable" : "mass_daug1", "title" : "m(rho)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0}
+    ],
+    "outfile" : "SLN=TAUVECTORNU__Bu_taunu,rhonu.root",
+    "reference" : "RefSLN=TAUVECTORNU__Bu_taunu,rhonu.root"
+}
diff --git a/test/jsonFiles/SLPOLE=VSS__D+_Kst0enu,Kpi.json b/test/jsonFiles/SLPOLE=VSS__D+_Kst0enu,Kpi.json
new file mode 100644
index 0000000..f9bff06
--- /dev/null
+++ b/test/jsonFiles/SLPOLE=VSS__D+_Kst0enu,Kpi.json
@@ -0,0 +1,38 @@
+{
+    "parent" : "D+",
+    "daughters" : ["anti-K*0", "e+", "nu_e"],
+    "grand_daughters" : [["K-", "pi+"], [], []],
+    "models" : ["SLPOLE", "VSS", ""],
+    "parameters" : [["1.00", "-0.558", "0.0", "1.0", "0.85", "-0.558", "0.0", "1.0", "1.50", "-0.790", "0.0", "1.0", "0.00", "-0.558", "0.0", "1.0"], [], []],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "M(#it{K}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.6, "xmax" : 1.4},
+        {"variable" : "mass", "title" : "M(#it{K}*^{0}#it{e})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.5, "xmax" : 2.0},
+        {"variable" : "mass", "title" : "M(#it{K}*^{0}#it{#nu})", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 0.5, "xmax" : 2.0},
+        {"variable" : "mass", "title" : "M(#it{e}#it{#nu})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0},
+        {"variable" : "pSumSq", "title" : "q^{2}(#it{e}#it{#nu})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.5},
+        {"variable" : "p", "title" : "p(#it{K}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "pSq", "title" : "p^{2}(#it{K}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "pz", "title" : "pz(#it{K}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(#it{K}*^{0},#it{e})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(#it{e}#it{#nu})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(#it{K})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+        {"variable" : "decayangle", "title" : "#theta(#it{K}*^{0},#it{e})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 200.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{K}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{e})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{#nu})", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(#it{K}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(#it{K})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(#it{#pi})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(#it{K})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(#it{K})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(#it{#pi})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(#it{#pi})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "SLPOLE=VSS__D+_Kst0enu,Kpi.root",
+    "reference" : "RefSLPOLE=VSS__D+_Kst0enu,Kpi.root"
+}
diff --git a/test/jsonFiles/SSD_DirectCP=TSS__Bu_f2pi+,pi+pi-.json b/test/jsonFiles/SSD_DirectCP=TSS__Bu_f2pi+,pi+pi-.json
new file mode 100644
index 0000000..debae4f
--- /dev/null
+++ b/test/jsonFiles/SSD_DirectCP=TSS__Bu_f2pi+,pi+pi-.json
@@ -0,0 +1,19 @@
+{
+    "parent" : "B+",
+    "daughters" : ["f_2", "pi+"],
+    "grand_daughters" : [["pi+", "pi-"], []],
+    "models" : ["SSD_DirectCP", "TSS", ""],
+    "parameters" : [["0.40"], [], []],
+    "do_conjugate_decay" : [ true, false, false ],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "id", "title" : "StdHep ID", "d1" : 0, "d2" : 0, "nbins" : 2, "xmin" : -600.0, "xmax" : 600.0},
+	{"variable" : "p", "title" : "f_2 Mtm",  "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.0, "xmax" : 3.0},
+	{"variable" : "p", "title" : "pi Mtm",  "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 1.0, "xmax" : 3.0},
+	{"variable" : "mass", "title" : "f_2 Mass",  "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "cosHel", "title" : "f_2 Helicity Angle",  "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0}
+    ],
+    "outfile" : "SSD_DirectCP=TSS__Bu_f2pi+,pi+pi-.root",
+    "reference" : "RefSSD_DirectCP=TSS__Bu_f2pi+,pi+pi-.root"
+}
diff --git a/test/jsonFiles/SSD_DirectCP=VSS__Bu_Kst0pi+,K+pi-.json b/test/jsonFiles/SSD_DirectCP=VSS__Bu_Kst0pi+,K+pi-.json
new file mode 100644
index 0000000..b303551
--- /dev/null
+++ b/test/jsonFiles/SSD_DirectCP=VSS__Bu_Kst0pi+,K+pi-.json
@@ -0,0 +1,19 @@
+{
+    "parent" : "B+",
+    "daughters" : ["K*0", "pi+"],
+    "grand_daughters" : [["K+", "pi-"], []],
+    "models" : ["SSD_DirectCP", "VSS", ""],
+    "parameters" : [["0.032"], [], []],
+    "do_conjugate_decay" : [ true, true, false ],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "id", "title" : "StdHep ID", "d1" : 0, "d2" : 0, "nbins" : 2, "xmin" : -600.0, "xmax" : 600.0},
+	{"variable" : "p", "title" : "Kst Mtm",  "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.0, "xmax" : 3.0},
+	{"variable" : "p", "title" : "pi Mtm",  "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 2.0, "xmax" : 3.0},
+	{"variable" : "mass", "title" : "Kst Mass",  "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 1.5},
+	{"variable" : "cosHel", "title" : "Kst Helicity Angle",  "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0}
+    ],
+    "outfile" : "SSD_DirectCP=VSS__Bu_Kst0pi+,K+pi-.root",
+    "reference" : "RefSSD_DirectCP=VSS__Bu_Kst0pi+,K+pi-.root"
+}
diff --git a/test/jsonFiles/SSD_DirectCP__Bd_K+pi-.json b/test/jsonFiles/SSD_DirectCP__Bd_K+pi-.json
new file mode 100644
index 0000000..a4ce5fe
--- /dev/null
+++ b/test/jsonFiles/SSD_DirectCP__Bd_K+pi-.json
@@ -0,0 +1,16 @@
+{
+    "parent" : "B0",
+    "daughters" : ["K+", "pi-"],
+    "models" : ["SSD_DirectCP"],
+    "parameters" : [["-0.083"]],
+    "do_conjugate_decay" : [ true ],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "id", "title" : "StdHep ID", "d1" : 0, "d2" : 0, "nbins" : 2, "xmin" : -600.0, "xmax" : 600.0},
+	{"variable" : "p", "title" : "K Mtm",  "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.0, "xmax" : 3.0},
+	{"variable" : "p", "title" : "pi Mtm",  "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 2.0, "xmax" : 3.0},
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0}
+    ],
+    "outfile" : "SSD_DirectCP__Bd_K+pi-.root",
+    "reference" : "RefSSD_DirectCP__Bd_K+pi-.root"
+}
diff --git a/test/jsonFiles/STS=TSS__Bu_D2st0pi,Dpi.json b/test/jsonFiles/STS=TSS__Bu_D2st0pi,Dpi.json
new file mode 100644
index 0000000..17e66a3
--- /dev/null
+++ b/test/jsonFiles/STS=TSS__Bu_D2st0pi,Dpi.json
@@ -0,0 +1,29 @@
+{
+    "parent" : "B+",
+    "daughters" : ["D_2*0", "pi+"],
+    "grand_daughters" : [["D+", "pi-"], [], []],
+    "models" : ["STS", "TSS", ""],
+    "parameters" : [[], [], []],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0},
+        {"variable" : "mass", "title" : "m(D2st)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.0, "xmax" : 3.5},
+        {"variable" : "mass", "title" : "m(D2st pi+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 5.0, "xmax" : 5.5},
+        {"variable" : "p", "title" : "p(D2st)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.6, "xmax" : 2.3},
+        {"variable" : "pSq", "title" : "pSq(D2st)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.5, "xmax" : 5.0},
+        {"variable" : "pz", "title" : "pz(D2st)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -2.5, "xmax" : 2.5},
+        {"variable" : "cosHel", "title" : "cosHel(D+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(Dst)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(D2st)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(D+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+        {"variable" : "pLab_daug1", "title" : "pLab(pi-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.8},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(pi-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "STS=TSS__Bu_D2st0pi,Dpi.root",
+    "reference" : "RefSTS=TSS__Bu_D2st0pi,Dpi.root"
+}
diff --git a/test/jsonFiles/STS_CP=TVS_PWAVE__Bd_a2pi,rhopi.json b/test/jsonFiles/STS_CP=TVS_PWAVE__Bd_a2pi,rhopi.json
new file mode 100644
index 0000000..8c185b5
--- /dev/null
+++ b/test/jsonFiles/STS_CP=TVS_PWAVE__Bd_a2pi,rhopi.json
@@ -0,0 +1,30 @@
+{
+    "parent" : "B0",
+    "daughters" : ["a_2+", "pi-"],
+    "grand_daughters" : [["rho0", "pi+"], []],
+    "models" : ["STS_CP", "TVS_PWAVE"],
+    "parameters" : [["0.4", "0.51e12", "1.0", "1.0", "0.0", "1.0", "0.0"], ["0.0", "0.0", "1.0", "0.0", "0.0", "0.0"]],
+    "do_conjugate_decay" : [true, true],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "m(a2)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 3.0},
+        {"variable" : "mass", "title" : "m(a2pi1)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 5.2, "xmax" : 5.4},
+	{"variable" : "lifetime", "title" : "B0 lifetime", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+        {"variable" : "p", "title" : "p(a2)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.8, "xmax" : 2.8},
+        {"variable" : "pSq", "title" : "pSq(a2)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 3.5, "xmax" : 7.0},
+        {"variable" : "pz", "title" : "pz(a2)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(rho0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(a2)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(pi1)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(rho)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(pi2)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(rho)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi2)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(rho)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi_daug1", "title" : "phi(pi2)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "STS_CP=TVS_PWAVE__Bd_a2pi,rhopi.root",
+    "reference" : "RefSTS_CP=TVS_PWAVE__Bd_a2pi,rhopi.root"
+}
diff --git a/test/jsonFiles/SVPHELCPMIX=VSS=ISGW2__Upsilon5S_Bs_phigamma,Dsenue.json b/test/jsonFiles/SVPHELCPMIX=VSS=ISGW2__Upsilon5S_Bs_phigamma,Dsenue.json
new file mode 100644
index 0000000..6082e2d
--- /dev/null
+++ b/test/jsonFiles/SVPHELCPMIX=VSS=ISGW2__Upsilon5S_Bs_phigamma,Dsenue.json
@@ -0,0 +1,33 @@
+{
+    "parent" : "Upsilon(5S)",
+    "daughters" : ["B_s0", "anti-B_s0"],
+    "grand_daughters" : [["phi", "gamma"], ["D_s+","e-","anti-nu_e"]],
+    "models" : ["VSS", "SVPHELCPMIX", "ISGW2"],
+    "parameters" : [[], ["1.0", "0.0", "1.0", "0.0", "0.025"], []],
+    "do_conjugate_decay" : [false, true, true],
+    "extras" : ["Define dm_incohMix_B_s0 17.8e12", "Define qoverp_incohMix_B_s0 1.0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(VSS)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug1", "title" : "Prob(SVPHELCPMIX)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug2", "title" : "Prob(ISGW2)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "lifetime", "title" : "tau(B_{s})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "lifetime", "title" : "tau(anti-B_{s})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "deltaT", "title" : "deltaT", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -12.0, "xmax" : 12.0},
+        {"variable" : "mass", "title" : "m(B_{s})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 5.3, "xmax" : 5.4},
+        {"variable" : "mass", "title" : "m(anti-B_{s})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 5.3, "xmax" : 5.4},
+        {"variable" : "mass_daug1", "title" : "m(#phi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.95, "xmax" : 1.15},
+	{"variable" : "E_daug1", "title" : "E_{Lab}(#gamma)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 1.5, "xmax" : 4.0},
+        {"variable" : "mass_daug2", "title" : "m(D_{s}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.9, "xmax" : 2.1},
+        {"variable" : "pSumSq_daug2", "title" : "qSq(e^{-} anti-#nu_{e})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+	{"variable" : "cosHel_daug2", "title" : "cosHel(D_{s}^{+},e^{-})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "decayangle_daug1", "title" : "decayAngle(#phi,#gamma)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "p_daug1", "title" : "p(#phi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.5, "xmax" : 2.7},
+	{"variable" : "p_daug1", "title" : "p(#gamma)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 2.5, "xmax" : 2.7},
+	{"variable" : "p_daug2", "title" : "p(D_s^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "p_daug2", "title" : "p(e^{-})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "p_daug2", "title" : "p(anti-#nu_{e})", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5}
+    ],
+    "outfile" : "SVPHELCPMIX=VSS=ISGW2__Upsilon5S_Bs_phigamma,Dsenue.root",
+    "reference" : "RefSVPHELCPMIX=VSS=ISGW2__Upsilon5S_Bs_phigamma,Dsenue.root"
+}
diff --git a/test/jsonFiles/SVP_CP=VSS__Bd_Kst0gamma,Kpi.json b/test/jsonFiles/SVP_CP=VSS__Bd_Kst0gamma,Kpi.json
new file mode 100644
index 0000000..1694b4e
--- /dev/null
+++ b/test/jsonFiles/SVP_CP=VSS__Bd_Kst0gamma,Kpi.json
@@ -0,0 +1,35 @@
+{
+    "parent" : "B0",
+    "daughters" : ["K*0", "gamma"],
+    "grand_daughters" : [["K+", "pi-"], []],
+    "models" : ["SVP_CP", "VSS"],
+    "parameters" : [["0.0", "0.472e12", "1.0", "1.0", "0.0", "1.0", "0.0"], [], []],
+    "do_conjugate_decay" : [true, true],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "M(#it{K}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.6, "xmax" : 1.5},
+        {"variable" : "mass", "title" : "M(#it{#gamma})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0, "xmax" : 0.01},
+        {"variable" : "p", "title" : "p(#it{K}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.3, "xmax" : 2.7},
+        {"variable" : "pSq", "title" : "p^{2}(#it{K}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 5.5, "xmax" : 7.0},
+        {"variable" : "pz", "title" : "pz(#it{K}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(#it{#gamma})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 2.3, "xmax" : 2.7},
+        {"variable" : "pSq", "title" : "p^{2}(#it{#gamma})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 5.5, "xmax" : 7.0},
+        {"variable" : "pz", "title" : "pz(#it{#gamma})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(#it{K}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelDiTau", "title" : "cosHel(#it{K}*^{0})", "d1" : 1, "d2" : 1, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{K}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{#gamma})", "d1" : 2, "d2" : 0, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(#it{K}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi", "title" : "phi(#it{#gamma})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(#it{K}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0, "xmax" : 3.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(#it{K}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(#it{K}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(#it{#pi}^{-})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(#it{#pi}^{-})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(#it{#pi}^{-})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "SVP_CP__Bd_Kst0gamma,Kpi.root",
+    "reference" : "RefSVP_CP__Bd_Kst0gamma,Kpi.root"
+}
diff --git a/test/jsonFiles/SVP_HELAMP=VSS__Bu_Kstgamma,Kspi.json b/test/jsonFiles/SVP_HELAMP=VSS__Bu_Kstgamma,Kspi.json
new file mode 100644
index 0000000..3e31980
--- /dev/null
+++ b/test/jsonFiles/SVP_HELAMP=VSS__Bu_Kstgamma,Kspi.json
@@ -0,0 +1,34 @@
+{
+    "parent" : "B+",
+    "daughters" : ["K*+", "gamma"],
+    "grand_daughters" : [["K_S0", "pi+"], []],
+    "models" : ["SVP_HELAMP", "VSS", ""],
+    "parameters" : [["1.0", "0.0", "1.0", "0.0"], [], []],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "M(#it{K}*^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.6, "xmax" : 1.5},
+        {"variable" : "mass", "title" : "M(#it{#gamma})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0, "xmax" : 0.01},
+        {"variable" : "p", "title" : "p(#it{K}*^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.0, "xmax" : 3.0},
+        {"variable" : "pSq", "title" : "p^{2}(#it{K}*^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.0, "xmax" : 7.0},
+        {"variable" : "pz", "title" : "pz(#it{K}*^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(#it{#gamma})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 1.0, "xmax" : 3.0},
+        {"variable" : "pSq", "title" : "p^{2}(#it{#gamma})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 2.0, "xmax" : 7.0},
+        {"variable" : "pz", "title" : "pz(#it{#gamma})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(#it{K}*^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelDiTau", "title" : "cosHel(#it{K}*^{+})", "d1" : 1, "d2" : 1, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{K}*^{+})", "d1" : 1, "d2" : 0, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{#gamma})", "d1" : 2, "d2" : 0, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(#it{K}*^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi", "title" : "phi(#it{#gamma})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(#it{K}^{0}_{S})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0, "xmax" : 3.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(#it{K}^{0}_{S})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(#it{K}^{0}_{S})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(#it{#pi}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(#it{#pi}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(#it{#pi}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "SVP_HELAMP=VSS__Bu_Kstgamma,Kspi.root",
+    "reference" : "RefSVP_HELAMP=VSS__Bu_Kstgamma,Kspi.root"
+}
diff --git a/test/jsonFiles/SVP_HELAMP=VVS_PWAVE__Bu_Kprime1gamma,Kstpi.json b/test/jsonFiles/SVP_HELAMP=VVS_PWAVE__Bu_Kprime1gamma,Kstpi.json
new file mode 100644
index 0000000..5e4b5b8
--- /dev/null
+++ b/test/jsonFiles/SVP_HELAMP=VVS_PWAVE__Bu_Kprime1gamma,Kstpi.json
@@ -0,0 +1,34 @@
+{
+    "parent" : "B+",
+    "daughters" : ["K'_1+", "gamma"],
+    "grand_daughters" : [["K*0", "pi+"], []],
+    "models" : ["SVP_HELAMP", "VVS_PWAVE", ""],
+    "parameters" : [["1.0", "0.0", "0.0", "0.0"], ["1.0", "0.0", "0.0", "0.0", "0.0", "0.0"], []],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "M(#it{K}_{1}^{+}')", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.6, "xmax" : 2.5},
+        {"variable" : "mass", "title" : "M(#it{#gamma})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0, "xmax" : 0.01},
+        {"variable" : "p", "title" : "p(#it{K}_{1}^{+}')", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.0, "xmax" : 3.0},
+        {"variable" : "pSq", "title" : "p^{2}(#it{K}_{1}^{+}')", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.0, "xmax" : 7.0},
+        {"variable" : "pz", "title" : "pz(#it{K}_{1}^{+}')", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(#it{#gamma})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 1.0, "xmax" : 3.0},
+        {"variable" : "pSq", "title" : "p^{2}(#it{#gamma})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 2.0, "xmax" : 7.0},
+        {"variable" : "pz", "title" : "pz(#it{#gamma})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(#it{K}_{1}^{+}')", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelDiTau", "title" : "cosHel(#it{K}_{1}^{+}')", "d1" : 1, "d2" : 1, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{K}_{1}^{+}')", "d1" : 1, "d2" : 0, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{#gamma})", "d1" : 2, "d2" : 0, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(#it{K}_{1}^{+}')", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi", "title" : "phi(#it{#gamma})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(#it{K}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0, "xmax" : 3.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(#it{K}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(#it{K}*^{0})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(#it{#pi}^{+})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(#it{#pi}^{+})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(#it{#pi}^{+})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "SVP_HELAMP=VVS_PWAVE__Bu_Kprime1gamma,Kstpi.root",
+    "reference" : "RefSVP_HELAMP=VVS_PWAVE__Bu_Kprime1gamma,Kstpi.root"
+}
diff --git a/test/jsonFiles/SVS=PHSP=VSS__Bu_D0rho,Kpi,pipi.json b/test/jsonFiles/SVS=PHSP=VSS__Bu_D0rho,Kpi,pipi.json
new file mode 100644
index 0000000..4be863a
--- /dev/null
+++ b/test/jsonFiles/SVS=PHSP=VSS__Bu_D0rho,Kpi,pipi.json
@@ -0,0 +1,37 @@
+{
+    "parent" : "B+",
+    "daughters" : ["rho+", "anti-D0"],
+    "grand_daughters" : [["pi+", "pi0"], ["K+", "pi-"]],
+    "models" : ["SVS", "VSS", "PHSP"],
+    "parameters" : [[], [], []],
+    "extras" : ["Define dm_incohMix_B_s0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob(SVS)",  "d1" : 0, "d2" : 0, "nbins" : 110, "xmin" : 0.0, "xmax" : 1.1},
+	{"variable" : "prob_daug1", "title" : "Prob(VSS)",  "d1" : 0, "d2" : 0, "nbins" : 110, "xmin" : 0.0, "xmax" : 1.1},
+	{"variable" : "mass", "title" : "m(#rho^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.2, "xmax" : 2.0},
+	{"variable" : "mass", "title" : "m(#bar{D}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 1.85, "xmax" : 1.88},
+	{"variable" : "cosTheta", "title" : "cosTheta(#rho^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(#bar{D}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi", "title" : "phi(#rho^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "phi", "title" : "phi(#bar{D}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosHel", "title" : "cosHel(#pi^{+},#rho^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel(K^{+},#bar{D}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "p_daug1", "title" : "p(#pi^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.5},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(#pi^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug1", "title" : "phi(#pi^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+	{"variable" : "p_daug1", "title" : "p(#pi^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.5},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(#pi^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug1", "title" : "phi(#pi^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+	{"variable" : "p_daug2", "title" : "p(K^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 1.5},
+	{"variable" : "cosTheta_daug2", "title" : "cosTheta(K^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug2", "title" : "phi(K^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180},
+	{"variable" : "p_daug2", "title" : "p(#pi^{-})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 1.5},
+	{"variable" : "cosTheta_daug2", "title" : "cosTheta(#pi^{-})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "phi_daug2", "title" : "phi(#pi^{-})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180}
+    ],
+    "outfile" : "SVS=PHSP=VSS__Bu_D0rho,Kpi,pipi.root",
+    "reference" : "RefSVS=PHSP=VSS__Bu_D0rho,Kpi,pipi.root"
+}
diff --git a/test/jsonFiles/SVS=SLL=VSS__Bs_chi_c0phi,mumu,KK.json b/test/jsonFiles/SVS=SLL=VSS__Bs_chi_c0phi,mumu,KK.json
new file mode 100644
index 0000000..d126c2b
--- /dev/null
+++ b/test/jsonFiles/SVS=SLL=VSS__Bs_chi_c0phi,mumu,KK.json
@@ -0,0 +1,36 @@
+{
+    "parent" : "B_s0",
+    "daughters" : ["phi", "chi_c0"],
+    "grand_daughters" : [["K+", "K-"], ["mu+", "mu-"]],
+    "models" : ["SVS", "VSS", "SLL"],
+    "parameters" : [[], [], []],
+    "do_conjugate_decay" : [true, false, false],
+    "extras" : ["Define dm_incohMix_B_s0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0},
+        {"variable" : "mass", "title" : "m(phi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 1.5},
+        {"variable" : "mass", "title" : "m(chi_c0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 3.0, "xmax" : 4.0},
+        {"variable" : "p", "title" : "p(phi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.1, "xmax" : 1.5},
+        {"variable" : "pSq", "title" : "pSq(phi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.0, "xmax" : 2.5},
+        {"variable" : "pz", "title" : "pz(phi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.5, "xmax" : 1.5},
+        {"variable" : "cosHel", "title" : "cosHel(K)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(mu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(phi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(chi_c0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(K+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.2},
+        {"variable" : "pLab_daug1", "title" : "pLab(K-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.2},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(K+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(K-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(K+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi_daug1", "title" : "phi(K-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug2", "title" : "pLab(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 3.0},
+        {"variable" : "pLab_daug2", "title" : "pLab(mu-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 3.0},
+        {"variable" : "cosTheta_daug2", "title" : "cosTheta(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug2", "title" : "cosTheta(mu-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug2", "title" : "phi(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi_daug2", "title" : "phi(mu-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "SVS=SLL=VSS__Bs_chi_c0phi,mumu,KK.root",
+    "reference" : "RefSVS=SLL=VSS__Bs_chi_c0phi,mumu,KK.root"
+}
diff --git a/test/jsonFiles/SVVHELCPMIX=VSS=ISGW2__Upsilon5S_Bs_Jpsiphi,Dsenue.json b/test/jsonFiles/SVVHELCPMIX=VSS=ISGW2__Upsilon5S_Bs_Jpsiphi,Dsenue.json
new file mode 100644
index 0000000..d0cc42d
--- /dev/null
+++ b/test/jsonFiles/SVVHELCPMIX=VSS=ISGW2__Upsilon5S_Bs_Jpsiphi,Dsenue.json
@@ -0,0 +1,33 @@
+{
+    "parent" : "Upsilon(5S)",
+    "daughters" : ["B_s0", "anti-B_s0"],
+    "grand_daughters" : [["J/psi", "phi"], ["D_s+","e-","anti-nu_e"]],
+    "models" : ["VSS", "SVVHELCPMIX", "ISGW2"],
+    "parameters" : [[], ["1.0", "0.0", "1.0", "0.0", "1.0", "0.0", "8.15e24", "17.8e12", "65.78e10", "8.42e10", "0.0", "0.025"], []],
+    "do_conjugate_decay" : [false, true, true],
+    "extras" : ["Define dm_incohMix_B_s0 17.8e12", "Define qoverp_incohMix_B_s0 1.0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(VSS)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug1", "title" : "Prob(SVVHELCPMIX)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.1},
+        {"variable" : "prob_daug2", "title" : "Prob(ISGW2)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "lifetime", "title" : "tau(B_{s})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "lifetime", "title" : "tau(anti-B_{s})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "deltaT", "title" : "deltaT", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -12.0, "xmax" : 12.0},
+        {"variable" : "mass", "title" : "m(B_{s})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 5.3, "xmax" : 5.4},
+        {"variable" : "mass", "title" : "m(anti-B_{s})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 5.3, "xmax" : 5.4},
+        {"variable" : "mass_daug1", "title" : "m(J/#psi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.5, "xmax" : 3.5},
+        {"variable" : "mass_daug1", "title" : "m(#phi)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.95, "xmax" : 1.10},
+        {"variable" : "mass_daug2", "title" : "m(D_{s}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.9, "xmax" : 2.1},
+        {"variable" : "pSumSq_daug2", "title" : "qSq(e^{-} anti-#nu_{e})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+	{"variable" : "cosHel_daug2", "title" : "cosHel(D_{s}^{+},e^{-})", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "decayangle_daug1", "title" : "decayAngle(J/#psi,#phi)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "p_daug1", "title" : "p(J/#psi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.5, "xmax" : 1.65},
+	{"variable" : "p_daug1", "title" : "p(#phi)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 1.5, "xmax" : 1.65},
+	{"variable" : "p_daug2", "title" : "p(D_s^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "p_daug2", "title" : "p(e^{-})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "p_daug2", "title" : "p(anti-#nu_{e})", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5}
+    ],
+    "outfile" : "SVVHELCPMIX=VSS=ISGW2__Upsilon5S_Bs_Jpsiphi,Dsenue.root",
+    "reference" : "RefSVVHELCPMIX=VSS=ISGW2__Upsilon5S_Bs_Jpsiphi,Dsenue.root"
+}
diff --git a/test/jsonFiles/SVV_CPLH=VLL=VSS__Bs0_Jpsiphi,ee,KK.json b/test/jsonFiles/SVV_CPLH=VLL=VSS__Bs0_Jpsiphi,ee,KK.json
new file mode 100644
index 0000000..f0a2c99
--- /dev/null
+++ b/test/jsonFiles/SVV_CPLH=VLL=VSS__Bs0_Jpsiphi,ee,KK.json
@@ -0,0 +1,26 @@
+{
+    "parent" : "B_s0",
+    "daughters" : ["J/psi", "phi"],
+    "grand_daughters" : [["e+", "e-"], ["K+", "K-"]],
+    "models" : ["SVV_CPLH", "VLL", "VSS"],
+    "parameters" : [["0.2", "2.0e12", "1.0", "1.0", "0.0", "1.0", "0.0", "1.0", "0.0"], [], []],
+    "do_conjugate_decay" : [true, false, false],
+    "extras" : ["Define dm_incohMix_B_s0 0"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(SVV_CPLH)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug1", "title" : "Prob(VLL)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug2", "title" : "Prob(VSS)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "parMass", "title" : "m(B0s)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 5.2, "xmax" : 5.5},
+        {"variable" : "mass", "title" : "m(J/psi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.5, "xmax" : 3.5},
+        {"variable" : "mass", "title" : "m(phi)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.8, "xmax" : 1.2},
+	{"variable" : "cosHel", "title" : "cosHel(e)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel", "title" : "cosHel(K)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "decayangle_daug1", "title" : "DecayAngle(e)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "decayangle_daug2", "title" : "DecayAngle(K)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "p_daug1", "title" : "p(e)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.0, "xmax" : 1.8},
+	{"variable" : "p_daug2", "title" : "p(K)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.3}
+    ],
+    "outfile" : "SVV_CPLH=VLL=VSS__Bs0_Jpsiphi,ee,KK.root",
+    "reference" : "RefSVV_CPLH=VLL=VSS__Bs0_Jpsiphi,ee,KK.root"
+}
diff --git a/test/jsonFiles/SVV_HELAMP=VLL=VSS__Bu_JpsiKst,mmKspi.json b/test/jsonFiles/SVV_HELAMP=VLL=VSS__Bu_JpsiKst,mmKspi.json
new file mode 100644
index 0000000..160e02b
--- /dev/null
+++ b/test/jsonFiles/SVV_HELAMP=VLL=VSS__Bu_JpsiKst,mmKspi.json
@@ -0,0 +1,35 @@
+{
+    "parent" : "B+",
+    "daughters" : ["J/psi", "K*+"],
+    "grand_daughters" : [["mu+", "mu-"], ["K_S0", "pi+"]],
+    "models" : ["SVV_HELAMP", "VLL", "VSS"],
+    "parameters" : [["0.159", "1.563", "0.775", "0.0", "0.612", "2.712"], [], []],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "M(#it{J/#psi})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 3.0966, "xmax" : 3.098},
+        {"variable" : "mass", "title" : "M(#it{K}*^{+})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.6, "xmax" : 1.5},
+        {"variable" : "p", "title" : "p(#it{J/#psi})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.0, "xmax" : 3.0},
+        {"variable" : "pSq", "title" : "p^{2}(#it{J/#psi})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.0, "xmax" : 7.0},
+        {"variable" : "pz", "title" : "pz(#it{J/#psi})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(#it{J/#psi})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(#it{K}*^{+})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelDiTau", "title" : "cosHel(#it{J/#psi})", "d1" : 1, "d2" : 1, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelDiTau", "title" : "cosHel(#it{K}*^{+})", "d1" : 2, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{J/#psi})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{K}*^{+})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(#it{J/#psi})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi", "title" : "phi(#it{K}*^{+})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(#it{#mu}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0, "xmax" : 3.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(#it{#mu}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(#it{#mu}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(#it{#mu}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(#it{#mu}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(#it{#mu}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "SVV_HELAMP=VLL=VSS__Bu_JpsiKst,mmKspi.root",
+    "reference" : "RefSVV_HELAMP=VLL=VSS__Bu_JpsiKst,mmKspi.root"
+}
diff --git a/test/jsonFiles/SVV_HELAMP=VSS__Bu_rhorho0,pipi0pipi,Longitudinal.json b/test/jsonFiles/SVV_HELAMP=VSS__Bu_rhorho0,pipi0pipi,Longitudinal.json
new file mode 100644
index 0000000..1147ee4
--- /dev/null
+++ b/test/jsonFiles/SVV_HELAMP=VSS__Bu_rhorho0,pipi0pipi,Longitudinal.json
@@ -0,0 +1,35 @@
+{
+    "parent" : "B+",
+    "daughters" : ["rho+", "rho0"],
+    "grand_daughters" : [["pi+", "pi0"], ["pi+", "pi-"]],
+    "models" : ["SVV_HELAMP", "VSS", "VSS"],
+    "parameters" : [["0.0", "0.0", "1.0", "0.0", "0.0", "0.0"], [], []],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "M(#it{#rho}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.4, "xmax" : 1.5},
+        {"variable" : "mass", "title" : "M(#it{#rho}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.4, "xmax" : 1.5},
+        {"variable" : "p", "title" : "p(#it{#rho}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.0, "xmax" : 3.0},
+        {"variable" : "pSq", "title" : "p^{2}(#it{#rho}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.0, "xmax" : 7.0},
+        {"variable" : "pz", "title" : "pz(#it{#rho}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(#it{#rho}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(#it{#rho}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelDiTau", "title" : "cosHel(#it{#rho}^{+})", "d1" : 1, "d2" : 1, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelDiTau", "title" : "cosHel(#it{#rho}^{0})", "d1" : 2, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{#rho}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{#rho}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(#it{#rho}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi", "title" : "phi(#it{#rho}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(#it{#pi}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0, "xmax" : 3.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(#it{#pi}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(#it{#pi}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(#it{#pi}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(#it{#pi}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(#it{#pi}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "SVV_HELAMP=VSS__Bd_rho0rho0,4pi,Longitudinal.root",
+    "reference" : "RefSVV_HELAMP=VSS__Bd_rho0rho0,4pi,Longitudinal.root"
+}
diff --git a/test/jsonFiles/SVV_HELAMP=VSS__Bu_rhorho0,pipi0pipi,Transverse.json b/test/jsonFiles/SVV_HELAMP=VSS__Bu_rhorho0,pipi0pipi,Transverse.json
new file mode 100644
index 0000000..3e2d327
--- /dev/null
+++ b/test/jsonFiles/SVV_HELAMP=VSS__Bu_rhorho0,pipi0pipi,Transverse.json
@@ -0,0 +1,35 @@
+{
+    "parent" : "B+",
+    "daughters" : ["rho+", "rho0"],
+    "grand_daughters" : [["pi+", "pi0"], ["pi+", "pi-"]],
+    "models" : ["SVV_HELAMP", "VSS", "VSS"],
+    "parameters" : [["1.0", "0.0", "0.0", "0.0", "1.0", "0.0"], [], []],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass", "title" : "M(#it{#rho}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.4, "xmax" : 1.5},
+        {"variable" : "mass", "title" : "M(#it{#rho}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.4, "xmax" : 1.5},
+        {"variable" : "p", "title" : "p(#it{#rho}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.0, "xmax" : 3.0},
+        {"variable" : "pSq", "title" : "p^{2}(#it{#rho}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.0, "xmax" : 7.0},
+        {"variable" : "pz", "title" : "pz(#it{#rho}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(#it{#rho}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(#it{#rho}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelDiTau", "title" : "cosHel(#it{#rho}^{+})", "d1" : 1, "d2" : 1, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHelDiTau", "title" : "cosHel(#it{#rho}^{0})", "d1" : 2, "d2" : 2, "nbins" : 50, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosAcoplanarityAngle", "title" : "cosAcopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "acoplanarityAngle", "title" : "acopl", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0, "xmax" : 180.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{#rho}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#it{#rho}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(#it{#rho}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi", "title" : "phi(#it{#rho}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(#it{#pi}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0, "xmax" : 3.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(#it{#pi}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(#it{#pi}^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(#it{#pi}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(#it{#pi}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(#it{#pi}^{0})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "SVV_HELAMP=VSS__Bd_rho0rho0,4pi,Transverse.root",
+    "reference" : "RefSVV_HELAMP=VSS__Bd_rho0rho0,4pi,Transverse.root"
+}
diff --git a/test/jsonFiles/THREEBODYPHSP=VLL=PHSP__Bu_JpsiKpi0,mumu,gammagamma.json b/test/jsonFiles/THREEBODYPHSP=VLL=PHSP__Bu_JpsiKpi0,mumu,gammagamma.json
new file mode 100644
index 0000000..5f29a08
--- /dev/null
+++ b/test/jsonFiles/THREEBODYPHSP=VLL=PHSP__Bu_JpsiKpi0,mumu,gammagamma.json
@@ -0,0 +1,20 @@
+{
+    "parent" : "B+",
+    "daughters" : ["J/psi", "K+", "pi0"],
+    "grand_daughters" : [["mu+", "mu-"], [], ["gamma", "gamma"]],
+    "models" : ["THREEBODYPHSP", "VLL", "", "PHSP"],
+    "parameters" : [["15.0", "22.0", "1.5", "4.5"], [], [], []],
+    "do_conjugate_decay" : [true, false, false, false],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "px", "title" : "px(J/psi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "py", "title" : "py(J/psi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "pz", "title" : "pz(J/psi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -3.0, "xmax" : 3.0},
+        {"variable" : "px", "title" : "pxpy(J/psi)", "d1" : 1, "d2" : 0, "nbins" : 50, "xmin" : -1.8, "xmax" : 1.8, "variableY" : "py", "d1Y" : 1, "d2Y" : 0, "nbinsY" : 50, "ymin" :-1.8, "ymax" : 1.8},
+        {"variable" : "px", "title" : "pxpz(J/psi)", "d1" : 1, "d2" : 0, "nbins" : 50, "xmin" : -1.8, "xmax" : 1.8, "variableY" : "pz", "d1Y" : 1, "d2Y" : 0,  "nbinsY" : 50, "ymin" :-1.8, "ymax" : 1.8},
+        {"variable" : "py", "title" : "pypz(J/psi)", "d1" : 1, "d2" : 0, "nbins" : 50, "xmin" : -1.8, "xmax" : 1.8, "variableY" : "pz", "d1Y" : 1, "d2Y" : 0,  "nbinsY" : 50, "ymin" :-1.8, "ymax" : 1.8},
+        {"variable" : "massSq", "title" : "dalitz", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 12.5, "xmax" : 27.0, "variableY" : "massSq", "d1Y" : 2, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.35, "ymax" : 4.8}
+    ],
+    "outfile" : "THREEBODYPHSP__Bu_JpsiKpi0,mumu,gammagamma.root",
+    "reference" : "RefTHREEBODYPHSP__Bu_JpsiKpi0,mumu,gammagamma.root"
+}
diff --git a/test/jsonFiles/VECTORISR=VSS__Upsilon4S_psi4160gamma,DD.json b/test/jsonFiles/VECTORISR=VSS__Upsilon4S_psi4160gamma,DD.json
new file mode 100644
index 0000000..f0803b2
--- /dev/null
+++ b/test/jsonFiles/VECTORISR=VSS__Upsilon4S_psi4160gamma,DD.json
@@ -0,0 +1,27 @@
+{
+    "parent" : "Upsilon(4S)",
+    "daughters" : ["psi(4160)", "gamma"],
+    "grand_daughters" : [["D+", "D-"], []],
+    "models" : ["VECTORISR", "VSS", ""],
+    "parameters" : [["0.9", "0.9"], [], []],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob_daug1", "title" : "Prob(VSS)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "parMass", "title" : "m(Upsilon4S)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 10.5, "xmax" : 11.0},
+        {"variable" : "mass", "title" : "m(psi4160)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 3.5, "xmax" : 5.5},
+        {"variable" : "mass_daug1", "title" : "m(D+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.85, "xmax" : 1.9},
+        {"variable" : "mass_daug1", "title" : "m(D-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 1.85, "xmax" : 1.9},
+	{"variable" : "cosHel", "title" : "cosHel(D+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "decayangle_daug1", "title" : "decayAngle(D+,D-)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "p", "title" : "p(psi4160)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.0, "xmax" : 5.0},
+	{"variable" : "phi", "title" : "phi(psi4160)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(psi4160)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "p", "title" : "p(gamma)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 1.0, "xmax" : 5.0},
+	{"variable" : "phi", "title" : "phi(gamma)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "cosTheta", "title" : "cosTheta(gamma)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "p_daug1", "title" : "p(D+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.6, "xmax" : 2.0},
+	{"variable" : "p_daug1", "title" : "p(D-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.6, "xmax" : 2.0}
+    ],
+    "outfile" : "VECTORISR=VSS__Upsilon4S_psi4160gamma,DD.root",
+    "reference" : "RefVECTORISR=VSS__Upsilon4S_psi4160gamma,DD.root"
+}
diff --git a/test/jsonFiles/VPHOTOVISRHI=VSS__psi4415_psi4160gamma,DD.json b/test/jsonFiles/VPHOTOVISRHI=VSS__psi4415_psi4160gamma,DD.json
new file mode 100644
index 0000000..9397e38
--- /dev/null
+++ b/test/jsonFiles/VPHOTOVISRHI=VSS__psi4415_psi4160gamma,DD.json
@@ -0,0 +1,27 @@
+{
+    "parent" : "psi(4415)",
+    "daughters" : ["psi(4160)", "gamma"],
+    "grand_daughters" : [["D+", "D-"], []],
+    "models" : ["VPHOTOVISRHI", "VSS", ""],
+    "parameters" : [["1.0"], [], []],
+    "extras" : ["noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "parMass", "title" : "m(#psi(4415))", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 4.2, "xmax" : 5.4},
+        {"variable" : "mass", "title" : "m(#psi(4160))", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 3.8, "xmax" : 5.4},
+        {"variable" : "E", "title" : "E(#gamma)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.55},
+        {"variable" : "p", "title" : "p(#psi(4160))", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.55},
+        {"variable" : "cosTheta", "title" : "cosTheta(#psi(4160))", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#gamma))", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(D+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "mass_daug1", "title" : "m(D^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.8, "xmax" : 1.9},
+        {"variable" : "mass_daug1", "title" : "m(D^{-})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 1.8, "xmax" : 1.9},
+	{"variable" : "pLab_daug1", "title" : "pLab(D^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.2, "xmax" : 2.0},
+	{"variable" : "pLab_daug1", "title" : "pLab(D^{-})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.2, "xmax" : 2.0},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(D^{+})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosTheta_daug1", "title" : "cosTheta(D^{-})", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "VPHOTOVISRHI=VSS__psi4415_psi4160gamma,DD.root",
+    "reference" : "RefVPHOTOVISRHI=VSS__psi4415_psi4160gamma,DD.root"
+}
diff --git a/test/jsonFiles/VSP_PWAVE=PHSP__Dst_D0gamma,Kpi.json b/test/jsonFiles/VSP_PWAVE=PHSP__Dst_D0gamma,Kpi.json
new file mode 100644
index 0000000..f0a5be3
--- /dev/null
+++ b/test/jsonFiles/VSP_PWAVE=PHSP__Dst_D0gamma,Kpi.json
@@ -0,0 +1,28 @@
+{
+    "parent" : "D*0",
+    "daughters" : ["D0", "gamma"],
+    "grand_daughters" : [["K-", "pi+"],[]],
+    "models" : ["VSP_PWAVE", "PHSP", ""],
+    "parameters" : [[], [], []],
+    "events" : 10000,
+    "histograms" : [
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "mass", "title" : "m(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.8, "xmax" : 1.95},
+        {"variable" : "mass", "title" : "m(D0 gamma)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 1.8, "xmax" : 2.1},
+        {"variable" : "p", "title" : "p(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.2},
+        {"variable" : "pz", "title" : "pz(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -0.15, "xmax" : 0.15},
+        {"variable" : "cosHel", "title" : "cosHel(K-)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(gamma)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi", "title" : "phi(gamma)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(K-)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.7, "xmax" : 1.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.7, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(K-)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(K-)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "VSP_PWAVE__Dst_D0gamma,Kpi.root",
+    "reference" : "RefVSP_PWAVE__Dst_D0gamma,Kpi.root"
+}
diff --git a/test/jsonFiles/VSS=BTO2PI_CP_ISO=ISGW2__Upsilon4S_Bd_2pi,Denue.json b/test/jsonFiles/VSS=BTO2PI_CP_ISO=ISGW2__Upsilon4S_Bd_2pi,Denue.json
new file mode 100644
index 0000000..ea7f073
--- /dev/null
+++ b/test/jsonFiles/VSS=BTO2PI_CP_ISO=ISGW2__Upsilon4S_Bd_2pi,Denue.json
@@ -0,0 +1,34 @@
+{
+    "parent" : "Upsilon(4S)",
+    "daughters" : ["B0", "anti-B0"],
+    "grand_daughters" : [["pi+", "pi-"], ["D+","e-","anti-nu_e"]],
+    "models" : ["VSS", "BTO2PI_CP_ISO", "ISGW2"],
+    "parameters" : [[], ["0.4", "0.51e12", "0.8", "1.15", "0.8", "-1.15", "1.0", "1.15", "1.0", "-1.15"], []],
+    "extras" : ["Define dm_incohMix_B0 0"],
+    "do_conjugate_decay" : [false, true, true],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(VSS)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug1", "title" : "Prob(BTO2PI_CP_ISO)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.1},
+        {"variable" : "prob_daug2", "title" : "Prob(ISGW2)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "lifetime", "title" : "tau(B0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "lifetime", "title" : "tau(B0b)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "deltaT", "title" : "deltaT", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -12.0, "xmax" : 12.0},
+        {"variable" : "mass", "title" : "m(B0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 5.27, "xmax" : 5.29},
+        {"variable" : "mass", "title" : "m(B0b)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 5.27, "xmax" : 5.29},
+        {"variable" : "mass_daug1", "title" : "m(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.13, "xmax" : 0.15},
+        {"variable" : "mass_daug1", "title" : "m(pi-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.13, "xmax" : 0.15},
+        {"variable" : "mass_daug2", "title" : "m(D)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.85, "xmax" : 1.90},
+        {"variable" : "pSumSq_daug2", "title" : "qSq(e- anti-nu_e)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+	{"variable" : "cosHel_daug1", "title" : "cosHel(pi+,pi-)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel_daug2", "title" : "cosHel(D,e)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "decayangle_daug1", "title" : "decayAngle(pi+,pi-)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "p_daug1", "title" : "p(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.0, "xmax" : 3.0},
+	{"variable" : "p_daug1", "title" : "p(pi-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 2.0, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(D)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "p_daug2", "title" : "p(e)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "p_daug2", "title" : "p(anti-nu_e)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5}
+    ],
+    "outfile" : "VSS=BTO2PI_CP_ISO=ISGW2__Upsilon4S_Bd_2pi,Denue.root",
+    "reference" : "RefVSS=BTO2PI_CP_ISO=ISGW2__Upsilon4S_Bd_2pi,Denue.root"
+}
diff --git a/test/jsonFiles/VSS=BTOKPI_CP_ISO=ISGW2__Upsilon4S_Bd_Kpi,Denue.json b/test/jsonFiles/VSS=BTOKPI_CP_ISO=ISGW2__Upsilon4S_Bd_Kpi,Denue.json
new file mode 100644
index 0000000..207a457
--- /dev/null
+++ b/test/jsonFiles/VSS=BTOKPI_CP_ISO=ISGW2__Upsilon4S_Bd_Kpi,Denue.json
@@ -0,0 +1,34 @@
+{
+    "parent" : "Upsilon(4S)",
+    "daughters" : ["B0", "anti-B0"],
+    "grand_daughters" : [["K+", "pi-"], ["D+","e-","anti-nu_e"]],
+    "models" : ["VSS", "BTOKPI_CP_ISO", "ISGW2"],
+    "parameters" : [[], ["0.4", "0.51e12", "0.8", "1.48", "0.8", "-1.48", "0.8", "1.48", "0.8", "-1.48", "1.0", "1.48", "1.0", "-1.48"], []],
+    "extras" : ["Define dm_incohMix_B0 0"],
+    "do_conjugate_decay" : [false, true, true],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(VSS)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug1", "title" : "Prob(BTO2PI_CP_ISO)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.1},
+        {"variable" : "prob_daug2", "title" : "Prob(ISGW2)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "lifetime", "title" : "tau(B0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "lifetime", "title" : "tau(B0b)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "deltaT", "title" : "deltaT", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -12.0, "xmax" : 12.0},
+        {"variable" : "mass", "title" : "m(B0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 5.27, "xmax" : 5.29},
+        {"variable" : "mass", "title" : "m(B0b)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 5.27, "xmax" : 5.29},
+        {"variable" : "mass_daug1", "title" : "m(K+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.45, "xmax" : 0.55},
+        {"variable" : "mass_daug1", "title" : "m(pi-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.13, "xmax" : 0.15},
+        {"variable" : "mass_daug2", "title" : "m(D)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.85, "xmax" : 1.90},
+        {"variable" : "pSumSq_daug2", "title" : "qSq(e- anti-nu_e)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+	{"variable" : "cosHel_daug1", "title" : "cosHel(K+,pi-)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel_daug2", "title" : "cosHel(D,e)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "decayangle_daug1", "title" : "decayAngle(K+,pi-)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "p_daug1", "title" : "p(K+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.0, "xmax" : 3.0},
+	{"variable" : "p_daug1", "title" : "p(pi-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 2.0, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(D)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "p_daug2", "title" : "p(e)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5},
+	{"variable" : "p_daug2", "title" : "p(anti-nu_e)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.5}
+    ],
+    "outfile" : "VSS=BTOKPI_CP_ISO=ISGW2__Upsilon4S_Bd_Kpi,Denue.root",
+    "reference" : "RefVSS=BTOKPI_CP_ISO=ISGW2__Upsilon4S_Bd_Kpi,Denue.root"
+}
diff --git a/test/jsonFiles/VSS=SSD_CP=HQET__Upsilon4S_Bd_Dpi,Dstenue.json b/test/jsonFiles/VSS=SSD_CP=HQET__Upsilon4S_Bd_Dpi,Dstenue.json
new file mode 100644
index 0000000..a5c1d3c
--- /dev/null
+++ b/test/jsonFiles/VSS=SSD_CP=HQET__Upsilon4S_Bd_Dpi,Dstenue.json
@@ -0,0 +1,31 @@
+{
+    "parent" : "Upsilon(4S)",
+    "daughters" : ["B0", "anti-B0"],
+    "grand_daughters" : [["D-", "pi+"], ["D*+","e-","anti-nu_e"]],
+    "models" : ["VSS", "SSD_CP", "HQET"],
+    "parameters" : [[], ["0.472e12", "0.0", "1.0", "-0.85", "1.0", "0.0", "0.6", "-0.5", "0.6", "1.5", "1.0", "0.0"], ["0.91", "1.18", "0.72"]],
+    "do_conjugate_decay" : [false, true, true],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(VSS)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug1", "title" : "Prob(SSD_CP)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug2", "title" : "Prob(HQET)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "lifetime", "title" : "tau(B0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "lifetime", "title" : "tau(B0b)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "deltaT", "title" : "deltaT", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -12.0, "xmax" : 12.0},
+        {"variable" : "mass", "title" : "m(B0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 5.2, "xmax" : 5.3},
+        {"variable" : "mass", "title" : "m(B0b)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 5.2, "xmax" : 5.3},
+        {"variable" : "mass_daug1", "title" : "m(D-)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.8, "xmax" : 1.9},
+        {"variable" : "mass_daug1", "title" : "m(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.3},
+        {"variable" : "mass_daug2", "title" : "m(D*+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.8, "xmax" : 2.2},
+        {"variable" : "pSumSq_daug2", "title" : "qSq(e- anti-nu_e)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+	{"variable" : "cosHel_daug2", "title" : "cosHel(D*+,e+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "p_daug1", "title" : "p(D-)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.0, "xmax" : 3.0},
+	{"variable" : "p_daug1", "title" : "p(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 1.5, "xmax" : 2.5},
+	{"variable" : "p_daug2", "title" : "p(D*+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(e-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(anti-nu_e)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0}
+    ],
+    "outfile" : "VSS=SSD_CP=HQET__Upsilon4S_Bd_Dpi,Dstenue.root",
+    "reference" : "RefVSS=SSD_CP=HQET__Upsilon4S_Bd_Dpi,Dstenue.root"
+}
diff --git a/test/jsonFiles/VSS=SSS_CP=ISGW2__Upsilon4S_Bd_pipi,Dstenue.json b/test/jsonFiles/VSS=SSS_CP=ISGW2__Upsilon4S_Bd_pipi,Dstenue.json
new file mode 100644
index 0000000..2008a08
--- /dev/null
+++ b/test/jsonFiles/VSS=SSS_CP=ISGW2__Upsilon4S_Bd_pipi,Dstenue.json
@@ -0,0 +1,29 @@
+{
+    "parent" : "Upsilon(4S)",
+    "daughters" : ["B0", "anti-B0"],
+    "grand_daughters" : [["pi+","pi-"], ["D*+","e-","anti-nu_e"]],
+    "models" : ["VSS", "SSS_CP", "ISGW2"],
+    "parameters" : [[], ["0.4", "0.51e12", "1.0", "1.0", "0.0", "1.0", "0.0"], []],
+    "do_conjugate_decay" : [false, true, true],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(VSS)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug1", "title" : "Prob(SSS_CP)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug2", "title" : "Prob(ISGW2)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "lifetime", "title" : "tau(B0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "lifetime", "title" : "tau(B0b)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "deltaT", "title" : "deltaT", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -12.0, "xmax" : 12.0},
+        {"variable" : "mass", "title" : "m(B0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 5.2, "xmax" : 5.3},
+        {"variable" : "mass", "title" : "m(B0b)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 5.2, "xmax" : 5.3},
+        {"variable" : "mass_daug2", "title" : "m(D*+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.8, "xmax" : 2.2},
+        {"variable" : "pSumSq_daug2", "title" : "qSq(e- anti-nu_e)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+	{"variable" : "cosHel_daug2", "title" : "cosHel(D*+,e+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "p_daug1", "title" : "p(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.5, "xmax" : 3.0},
+	{"variable" : "p_daug1", "title" : "p(pi-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 1.5, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(D*+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(e-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(anti-nu_e)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0}
+    ],
+    "outfile" : "VSS=SSS_CP=ISGW2__Upsilon4S_Bd_pipi,Dstenue.root",
+    "reference" : "RefVSS=SSS_CP=ISGW2__Upsilon4S_Bd_pipi,Dstenue.root"
+}
diff --git a/test/jsonFiles/VSS=SSS_CPT=ISGW2__Upsilon4S_Bd_pipi,Dstenue.json b/test/jsonFiles/VSS=SSS_CPT=ISGW2__Upsilon4S_Bd_pipi,Dstenue.json
new file mode 100644
index 0000000..13fac83
--- /dev/null
+++ b/test/jsonFiles/VSS=SSS_CPT=ISGW2__Upsilon4S_Bd_pipi,Dstenue.json
@@ -0,0 +1,29 @@
+{
+    "parent" : "Upsilon(4S)",
+    "daughters" : ["B0", "anti-B0"],
+    "grand_daughters" : [["pi+","pi-"], ["D*+","e-","anti-nu_e"]],
+    "models" : ["VSS", "SSS_CPT", "ISGW2"],
+    "parameters" : [[], ["0.0", "0.51e12", "1.0", "0.0", "1.0", "0.0", "0.1", "-0.4"], []],
+    "do_conjugate_decay" : [false, true, true],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(VSS)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug1", "title" : "Prob(SSS_CPT)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug2", "title" : "Prob(ISGW2)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "lifetime", "title" : "tau(B0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "lifetime", "title" : "tau(B0b)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "deltaT", "title" : "deltaT", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -12.0, "xmax" : 12.0},
+        {"variable" : "mass", "title" : "m(B0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 5.2, "xmax" : 5.3},
+        {"variable" : "mass", "title" : "m(B0b)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 5.2, "xmax" : 5.3},
+        {"variable" : "mass_daug2", "title" : "m(D*+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.8, "xmax" : 2.2},
+        {"variable" : "pSumSq_daug2", "title" : "qSq(e- anti-nu_e)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+	{"variable" : "cosHel_daug2", "title" : "cosHel(D*+,e+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "p_daug1", "title" : "p(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.5, "xmax" : 3.0},
+	{"variable" : "p_daug1", "title" : "p(pi-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 1.5, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(D*+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(e-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(anti-nu_e)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0}
+    ],
+    "outfile" : "VSS=SSS_CPT=ISGW2__Upsilon4S_Bd_pipi,Dstenue.root",
+    "reference" : "RefVSS=SSS_CPT=ISGW2__Upsilon4S_Bd_pipi,Dstenue.root"
+}
diff --git a/test/jsonFiles/VSS=SSS_CP_PNG=ISGW2__Upsilon4S_Bd_pipi,Dstenue.json b/test/jsonFiles/VSS=SSS_CP_PNG=ISGW2__Upsilon4S_Bd_pipi,Dstenue.json
new file mode 100644
index 0000000..be71939
--- /dev/null
+++ b/test/jsonFiles/VSS=SSS_CP_PNG=ISGW2__Upsilon4S_Bd_pipi,Dstenue.json
@@ -0,0 +1,29 @@
+{
+    "parent" : "Upsilon(4S)",
+    "daughters" : ["B0", "anti-B0"],
+    "grand_daughters" : [["pi+","pi-"], ["D*+","e-","anti-nu_e"]],
+    "models" : ["VSS", "SSS_CP_PNG", "ISGW2"],
+    "parameters" : [[], ["0.4", "1.2", "0.1", "0.51e12", "1.0", "1.0", "0.2"], []],
+    "do_conjugate_decay" : [false, true, true],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(VSS)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug1", "title" : "Prob(SSS_CP_PNG)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug2", "title" : "Prob(ISGW2)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "lifetime", "title" : "tau(B0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "lifetime", "title" : "tau(B0b)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "deltaT", "title" : "deltaT", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -12.0, "xmax" : 12.0},
+        {"variable" : "mass", "title" : "m(B0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 5.2, "xmax" : 5.3},
+        {"variable" : "mass", "title" : "m(B0b)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 5.2, "xmax" : 5.3},
+        {"variable" : "mass_daug2", "title" : "m(D*+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.8, "xmax" : 2.2},
+        {"variable" : "pSumSq_daug2", "title" : "qSq(e- anti-nu_e)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+	{"variable" : "cosHel_daug2", "title" : "cosHel(D*+,e+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "p_daug1", "title" : "p(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.5, "xmax" : 3.0},
+	{"variable" : "p_daug1", "title" : "p(pi-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 1.5, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(D*+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(e-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(anti-nu_e)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0}
+    ],
+    "outfile" : "VSS=SSS_CP_PNG=ISGW2__Upsilon4S_Bd_pipi,Dstenue.root",
+    "reference" : "RefVSS=SSS_CP_PNG=ISGW2__Upsilon4S_Bd_pipi,Dstenue.root"
+}
diff --git a/test/jsonFiles/VSS=SVS_CP=ISGW2__Upsilon4S_Bd_JpsiK0,Dstenue.json b/test/jsonFiles/VSS=SVS_CP=ISGW2__Upsilon4S_Bd_JpsiK0,Dstenue.json
new file mode 100644
index 0000000..dd6e736
--- /dev/null
+++ b/test/jsonFiles/VSS=SVS_CP=ISGW2__Upsilon4S_Bd_JpsiK0,Dstenue.json
@@ -0,0 +1,31 @@
+{
+    "parent" : "Upsilon(4S)",
+    "daughters" : ["B0", "anti-B0"],
+    "grand_daughters" : [["J/psi", "K0"], ["D*+","e-","anti-nu_e"]],
+    "models" : ["VSS", "SVS_CP", "ISGW2"],
+    "parameters" : [[], ["0.4", "0.51e12", "1.0", "1.0", "0.0", "1.0", "0.0"], []],
+    "do_conjugate_decay" : [false, true, true],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(VSS)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug1", "title" : "Prob(SVS_CP)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug2", "title" : "Prob(ISGW2)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "lifetime", "title" : "tau(B0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "lifetime", "title" : "tau(B0b)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "deltaT", "title" : "deltaT", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -12.0, "xmax" : 12.0},
+        {"variable" : "mass", "title" : "m(B0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 5.2, "xmax" : 5.3},
+        {"variable" : "mass", "title" : "m(B0b)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 5.2, "xmax" : 5.3},
+        {"variable" : "mass_daug1", "title" : "m(J/psi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.5, "xmax" : 3.5},
+        {"variable" : "mass_daug1", "title" : "m(K0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass_daug2", "title" : "m(D*+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.8, "xmax" : 2.2},
+        {"variable" : "pSumSq_daug2", "title" : "qSq(e- anti-nu_e)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+	{"variable" : "cosHel_daug2", "title" : "cosHel(D*+,e+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "p_daug1", "title" : "p(J/psi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.5, "xmax" : 2.0},
+	{"variable" : "p_daug1", "title" : "p(K0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 1.5, "xmax" : 2.0},
+	{"variable" : "p_daug2", "title" : "p(D*+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(e-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(anti-nu_e)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0}
+    ],
+    "outfile" : "VSS=SVS_CP=ISGW2__Upsilon4S_Bd_JpsiK0,Dstenue.root",
+    "reference" : "RefVSS=SVS_CP=ISGW2__Upsilon4S_Bd_JpsiK0,Dstenue.root"
+}
diff --git a/test/jsonFiles/VSS=SVS_CPLH=ISGW2__Upsilon4S_Bd_JpsiK0s,Denue.json b/test/jsonFiles/VSS=SVS_CPLH=ISGW2__Upsilon4S_Bd_JpsiK0s,Denue.json
new file mode 100644
index 0000000..73bdcd3
--- /dev/null
+++ b/test/jsonFiles/VSS=SVS_CPLH=ISGW2__Upsilon4S_Bd_JpsiK0s,Denue.json
@@ -0,0 +1,31 @@
+{
+    "parent" : "Upsilon(4S)",
+    "daughters" : ["B0", "anti-B0"],
+    "grand_daughters" : [["J/psi", "K_S0"], ["D+","e-","anti-nu_e"]],
+    "models" : ["VSS", "SVS_CPLH", "ISGW2"],
+    "parameters" : [[], ["0.472e12", "0.2", "1.0", "-0.77", "1.0", "0.0", "1.0", "0.0"], []],
+    "do_conjugate_decay" : [false, true, true],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(VSS)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug1", "title" : "Prob(SVS_CPLH)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug2", "title" : "Prob(ISGW2)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "lifetime", "title" : "tau(B0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "lifetime", "title" : "tau(B0b)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "deltaT", "title" : "deltaT", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -12.0, "xmax" : 12.0},
+        {"variable" : "mass", "title" : "m(B0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 5.2, "xmax" : 5.3},
+        {"variable" : "mass", "title" : "m(B0b)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 5.2, "xmax" : 5.3},
+        {"variable" : "mass_daug1", "title" : "m(J/psi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.5, "xmax" : 3.5},
+        {"variable" : "mass_daug1", "title" : "m(K_S0)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass_daug2", "title" : "m(D+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.8, "xmax" : 2.0},
+        {"variable" : "pSumSq_daug2", "title" : "qSq(e- anti-nu_e)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+	{"variable" : "cosHel_daug1", "title" : "cosHel(J/psi,K_S0)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel_daug2", "title" : "cosHel(D+,e+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "decayangle_daug1", "title" : "DecayAngle(Jpsi,K_S0)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "p_daug2", "title" : "p(D+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(e-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(anti-nu_e)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0}
+    ],
+    "outfile" : "VSS=SVS_CPLH=ISGW2__Upsilon4S_Bd_JpsiK0s,Denue.root",
+    "reference" : "RefVSS=SVS_CPLH=ISGW2__Upsilon4S_Bd_JpsiK0s,Denue.root"
+}
diff --git a/test/jsonFiles/VSS=SVS_CP_ISO=ISGW2__Upsilon4S_Bd_a1pi,Dstenue.json b/test/jsonFiles/VSS=SVS_CP_ISO=ISGW2__Upsilon4S_Bd_a1pi,Dstenue.json
new file mode 100644
index 0000000..b59a5c2
--- /dev/null
+++ b/test/jsonFiles/VSS=SVS_CP_ISO=ISGW2__Upsilon4S_Bd_a1pi,Dstenue.json
@@ -0,0 +1,31 @@
+{
+    "parent" : "Upsilon(4S)",
+    "daughters" : ["B0", "anti-B0"],
+    "grand_daughters" : [["a_1-", "pi+"], ["D*+","e-","anti-nu_e"]],
+    "models" : ["VSS", "SVS_CP_ISO", "ISGW2"],
+    "parameters" : [[], ["0.4", "0.51e12", "0.0", "1.0", "0.0", "1.0", "0.0", "1.0", "0.0", "1.0", "0.0", "1.0", "0.0", "1.0", "0.0", "1.0", "0.0", "1.0", "0.0", "1.0", "1.2", "3.0", "-1.2", "3.0", "1.2", "1.0", "-1.2"], []],
+    "do_conjugate_decay" : [false, true, true],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(VSS)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug1", "title" : "Prob(SVS_CP_ISO)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug2", "title" : "Prob(ISGW2)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "lifetime", "title" : "tau(B0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "lifetime", "title" : "tau(B0b)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "deltaT", "title" : "deltaT", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -12.0, "xmax" : 12.0},
+        {"variable" : "mass", "title" : "m(B0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 5.2, "xmax" : 5.3},
+        {"variable" : "mass", "title" : "m(B0b)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 5.2, "xmax" : 5.3},
+        {"variable" : "mass_daug1", "title" : "m(a1-)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.05, "xmax" : 5.0},
+        {"variable" : "mass_daug1", "title" : "m(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "mass_daug2", "title" : "m(D*+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.8, "xmax" : 2.2},
+        {"variable" : "pSumSq_daug2", "title" : "qSq(e- anti-nu_e)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+	{"variable" : "cosHel_daug2", "title" : "cosHel(D*+,e+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "p_daug1", "title" : "p(a1-)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 3.0},
+	{"variable" : "p_daug1", "title" : "p(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(D*+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(e-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(anti-nu_e)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0}
+    ],
+    "outfile" : "VSS=SVS_CP_ISO=ISGW2__Upsilon4S_Bd_a1pi,Dstenue.root",
+    "reference" : "RefVSS=SVS_CP_ISO=ISGW2__Upsilon4S_Bd_a1pi,Dstenue.root"
+}
diff --git a/test/jsonFiles/VSS=SVS_NONCPEIGEN=ISGW2__Upsilon4S_Bd_a1pi,Dstenue.json b/test/jsonFiles/VSS=SVS_NONCPEIGEN=ISGW2__Upsilon4S_Bd_a1pi,Dstenue.json
new file mode 100644
index 0000000..8ce126a
--- /dev/null
+++ b/test/jsonFiles/VSS=SVS_NONCPEIGEN=ISGW2__Upsilon4S_Bd_a1pi,Dstenue.json
@@ -0,0 +1,32 @@
+{
+    "parent" : "Upsilon(4S)",
+    "daughters" : ["B0", "anti-B0"],
+    "grand_daughters" : [["a_1-", "pi+"], ["D*+","e-","anti-nu_e"]],
+    "models" : ["VSS", "SVS_NONCPEIGEN", "ISGW2"],
+    "parameters" : [[], ["0.35", "0.51e12", "1.0", "1.0", "0.0", "3.0", "0.0", "3.0", "0.0", "1.0", "0.0"], []],
+    "do_conjugate_decay" : [false, true, true],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(VSS)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug1", "title" : "Prob(SVS_NONCPEIGEN)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug2", "title" : "Prob(ISGW2)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "lifetime", "title" : "tau(B0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "lifetime", "title" : "tau(B0b)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "deltaT", "title" : "deltaT", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -12.0, "xmax" : 12.0},
+        {"variable" : "mass", "title" : "m(B0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 5.2, "xmax" : 5.3},
+        {"variable" : "mass", "title" : "m(B0b)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 5.2, "xmax" : 5.3},
+        {"variable" : "mass_daug1", "title" : "m(a_1)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 4.0},
+        {"variable" : "mass_daug1", "title" : "m(pi)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.3},
+        {"variable" : "mass_daug2", "title" : "m(D*+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.8, "xmax" : 2.2},
+        {"variable" : "pSumSq_daug2", "title" : "qSq(e- anti-nu_e)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+	{"variable" : "cosHel_daug2", "title" : "cosHel(D*+,e+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "decayangle_daug1", "title" : "DecayAngle(a1, pi)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 200.0},
+	{"variable" : "p_daug1", "title" : "p(a_1)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "p_daug1", "title" : "p(pi)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(D*+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(e-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(anti-nu_e)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0}
+    ],
+    "outfile" : "VSS=SSD_CP=HQET__Upsilon4S_Bd_Dpi,Dstenue.root",
+    "reference" : "RefVSS=SSD_CP=HQET__Upsilon4S_Bd_Dpi,Dstenue.root"
+}
diff --git a/test/jsonFiles/VSS=SVV_CP=ISGW2__Upsilon4S_Bd_JpsiKst,Denue.json b/test/jsonFiles/VSS=SVV_CP=ISGW2__Upsilon4S_Bd_JpsiKst,Denue.json
new file mode 100644
index 0000000..33dcffb
--- /dev/null
+++ b/test/jsonFiles/VSS=SVV_CP=ISGW2__Upsilon4S_Bd_JpsiKst,Denue.json
@@ -0,0 +1,32 @@
+{
+    "parent" : "Upsilon(4S)",
+    "daughters" : ["B0", "anti-B0"],
+    "grand_daughters" : [["J/psi", "K*0"], ["D+","e-","anti-nu_e"]],
+    "models" : ["VSS", "SVV_CP", "ISGW2"],
+    "parameters" : [[], ["0.4", "0.51e12", "1.0", "1.0", "0.0", "1.0", "0.0", "1.0", "0.0"], []],
+    "do_conjugate_decay" : [false, true, true],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(VSS)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug1", "title" : "Prob(SVV_CP)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug2", "title" : "Prob(ISGW2)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "lifetime", "title" : "tau(B0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "lifetime", "title" : "tau(B0b)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "deltaT", "title" : "deltaT", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -12.0, "xmax" : 12.0},
+        {"variable" : "mass", "title" : "m(B0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 5.2, "xmax" : 5.3},
+        {"variable" : "mass", "title" : "m(B0b)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 5.2, "xmax" : 5.3},
+        {"variable" : "mass_daug1", "title" : "m(J/psi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 2.5, "xmax" : 3.5},
+        {"variable" : "mass_daug1", "title" : "m(K*)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.5, "xmax" : 1.5},
+        {"variable" : "mass_daug2", "title" : "m(D+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.8, "xmax" : 2.0},
+        {"variable" : "pSumSq_daug2", "title" : "qSq(e- anti-nu_e)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+	{"variable" : "cosHel_daug2", "title" : "cosHel(D+,e-)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "decayangle_daug1", "title" : "DecayAngle(Jpsi,K*0)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "p_daug1", "title" : "p(J/psi)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.1, "xmax" : 1.7},
+	{"variable" : "p_daug1", "title" : "p(K*)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 1.1, "xmax" : 1.7},
+	{"variable" : "p_daug2", "title" : "p(D+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(e-)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(anti-nu_e)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0}
+    ],
+    "outfile" : "VSS=SVV_CP=ISGW2__Upsilon4S_Bd_JpsiKst,Dstenue.root",
+    "reference" : "RefVSS=SVV_CP=ISGW2__Upsilon4S_Bd_JpsiKst,Dstenue.root"
+}
diff --git a/test/jsonFiles/VSS=SVV_NONCPEIGEN=ISGW2__Upsilon4S_Bd_Dstrho,Denue.json b/test/jsonFiles/VSS=SVV_NONCPEIGEN=ISGW2__Upsilon4S_Bd_Dstrho,Denue.json
new file mode 100644
index 0000000..2b2db2c
--- /dev/null
+++ b/test/jsonFiles/VSS=SVV_NONCPEIGEN=ISGW2__Upsilon4S_Bd_Dstrho,Denue.json
@@ -0,0 +1,34 @@
+{
+    "parent" : "Upsilon(4S)",
+    "daughters" : ["B0", "anti-B0"],
+    "grand_daughters" : [["D*-", "rho+"], ["D+","e-","anti-nu_e"]],
+    "models" : ["VSS", "SVV_NONCPEIGEN", "ISGW2"],
+    "parameters" : [[], ["0.51e12", "0.4", "1.15", "0.152", "1.48", "0.936", "0.0", "0.317", "0.19", "0.00152", "1.48", "0.00936", "0.0", "0.00317", "0.19"], []],
+    "extras" : ["Define dm_incohMix_B0 0"],
+    "do_conjugate_decay" : [false, true, true],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob(VSS)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug1", "title" : "Prob(SVV_NONCPEIGEN)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "prob_daug2", "title" : "Prob(ISGW2)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "lifetime", "title" : "tau(B0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "lifetime", "title" : "tau(B0b)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 20.0},
+        {"variable" : "deltaT", "title" : "deltaT", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -12.0, "xmax" : 12.0},
+        {"variable" : "mass", "title" : "m(B0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 5.27, "xmax" : 5.29},
+        {"variable" : "mass", "title" : "m(B0b)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 5.27, "xmax" : 5.29},
+        {"variable" : "mass_daug1", "title" : "m(D*)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.9, "xmax" : 2.1},
+        {"variable" : "mass_daug1", "title" : "m(rho)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.2, "xmax" : 2.0},
+        {"variable" : "mass_daug2", "title" : "m(D)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.85, "xmax" : 1.90},
+        {"variable" : "pSumSq_daug2", "title" : "qSq(e- anti-nu_e)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+	{"variable" : "cosHel_daug1", "title" : "cosHel(D*,rho)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "cosHel_daug2", "title" : "cosHel(D,e)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+	{"variable" : "decayangle_daug1", "title" : "decayAngle(D*, rho)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 0.0, "xmax" : 180.0},
+	{"variable" : "p_daug1", "title" : "p(D*)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.0, "xmax" : 2.5},
+	{"variable" : "p_daug1", "title" : "p(rho)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 1.0, "xmax" : 2.5},
+	{"variable" : "p_daug2", "title" : "p(D)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(e)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+	{"variable" : "p_daug2", "title" : "p(anti-nu_e)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0}
+    ],
+    "outfile" : "VSS=SVV_NONCPEIGEN=ISGW2__Upsilon4S_Bd_Dstrho,Denue.root",
+    "reference" : "RefVSS=SVV_NONCPEIGEN=ISGW2__Upsilon4S_Bd_Dstrho,Denue.root"
+}
diff --git a/test/jsonFiles/VSS_BMIX__Ups4S,Bd.json b/test/jsonFiles/VSS_BMIX__Ups4S,Bd.json
new file mode 100644
index 0000000..943b641
--- /dev/null
+++ b/test/jsonFiles/VSS_BMIX__Ups4S,Bd.json
@@ -0,0 +1,17 @@
+{
+    "parent" : "Upsilon(4S)",
+    "daughters" : ["B0", "anti-B0", "B0", "anti-B0"],
+    "models" : ["VSS_BMIX"],
+    "parameters" : [["0.474e12", "0.5", "0.8", "0.0"]],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "id", "title" : "StdHep ID1", "d1" : 1, "d2" : 0, "nbins" : 2, "xmin" : -600.0, "xmax" : 600.0},
+        {"variable" : "id", "title" : "StdHep ID2", "d1" : 2, "d2" : 0, "nbins" : 2, "xmin" : -600.0, "xmax" : 600.0},
+	{"variable" : "lifetime", "title" : "tau1", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+	{"variable" : "lifetime", "title" : "tau2", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+	{"variable" : "deltaT", "title" : "deltaT", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -12.0, "xmax" : 12.0},
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0}
+    ],
+    "outfile" : "VSS_BMIX__Ups4S,Bd.root",
+    "reference" : "RefVSS_BMIX__Ups4S,Bd.root"
+}
diff --git a/test/jsonFiles/VSS_MIX__Ups4S,Bd.json b/test/jsonFiles/VSS_MIX__Ups4S,Bd.json
new file mode 100644
index 0000000..6b3f553
--- /dev/null
+++ b/test/jsonFiles/VSS_MIX__Ups4S,Bd.json
@@ -0,0 +1,17 @@
+{
+    "parent" : "Upsilon(4S)",
+    "daughters" : ["B0", "anti-B0"],
+    "models" : ["VSS_MIX"],
+    "parameters" : [["0.474e12"]],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "id", "title" : "StdHep ID1", "d1" : 1, "d2" : 0, "nbins" : 2, "xmin" : -600.0, "xmax" : 600.0},
+        {"variable" : "id", "title" : "StdHep ID2", "d1" : 2, "d2" : 0, "nbins" : 2, "xmin" : -600.0, "xmax" : 600.0},
+	{"variable" : "lifetime", "title" : "tau1", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+	{"variable" : "lifetime", "title" : "tau2", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 12.0},
+	{"variable" : "deltaT", "title" : "deltaT", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -12.0, "xmax" : 12.0},
+	{"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0}
+    ],
+    "outfile" : "VSS_MIX__Ups4S,Bd.root",
+    "reference" : "RefVSS_MIX__Ups4S,Bd.root"
+}
diff --git a/test/jsonFiles/VTOSLL=PHSP__Dst0_D0ee,Kpi.json b/test/jsonFiles/VTOSLL=PHSP__Dst0_D0ee,Kpi.json
new file mode 100644
index 0000000..0c5828e
--- /dev/null
+++ b/test/jsonFiles/VTOSLL=PHSP__Dst0_D0ee,Kpi.json
@@ -0,0 +1,35 @@
+{
+    "parent" : "D*0",
+    "daughters" : ["D0", "e+", "e-"],
+    "grand_daughters" : [["K-", "pi+"], [], []],
+    "models" : ["VTOSLL", "PHSP", ""],
+    "parameters" : [[], [], []],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "mass", "title" : "m(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.8, "xmax" : 1.95},
+        {"variable" : "mass", "title" : "m(D0 e+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : 1.8, "xmax" : 2.1},
+        {"variable" : "mass", "title" : "m(D0 e-)", "d1" : 1, "d2" : 3, "nbins" : 100, "xmin" : 1.8, "xmax" : 2.1},
+        {"variable" : "mass", "title" : "m(e+e-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.15},
+        {"variable" : "pSumSq", "title" : "qSq(e+ e-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.02},
+        {"variable" : "p", "title" : "p(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.2},
+        {"variable" : "pSq", "title" : "pSq(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.02},
+        {"variable" : "pz", "title" : "pz(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -0.15, "xmax" : 0.15},
+        {"variable" : "cosHel", "title" : "cosHel(D0,e+)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(e+,e-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(K-)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(e+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(e-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(D0)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(K-)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.7, "xmax" : 1.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.7, "xmax" : 1.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(K-)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(K-)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "VTOSLL=PHSP__Dst0_D0ee,Kpi.root",
+    "reference" : "RefVTOSLL=PHSP__Dst0_D0ee,Kpi.root"
+}
diff --git a/test/jsonFiles/VUBHYBRID__Xumunu.json b/test/jsonFiles/VUBHYBRID__Xumunu.json
new file mode 100644
index 0000000..545107c
--- /dev/null
+++ b/test/jsonFiles/VUBHYBRID__Xumunu.json
@@ -0,0 +1,29 @@
+{
+    "parent" : "B0",
+    "daughters" : ["Xu-", "mu+", "nu_mu"],
+    "models" : ["VUBHYBRID"],
+    "parameters" : [["4.8", "1.29", "0.22"]],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.2},
+        {"variable" : "mass", "title" : "m(X_{u})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "pSumSq", "title" : "qSq(#mu #nu_{#mu})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 25.0},
+        {"variable" : "p", "title" : "p(X_{u})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(#mu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(#nu_{#mu})", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(X_{u},#mu)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(#mu,#nu_{#mu})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(X_{u})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#mu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#nu_{#mu})", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(X_{u})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi", "title" : "phi(#mu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi", "title" : "phi(#nu_{#mu})", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "massSq", "title" : "Dalitz m^{2}(X_{u} #mu) vs m^{2}(#mu #nu_{#mu})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.0, "xmax" : 30.0, "variableY" : "massSq", "d1Y" : 2, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 25.0},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0}
+
+    ],
+    "outfile" : "VUBHYBRID__Xumunu.root",
+    "reference" : "RefVUBHYBRID__Xumunu.root"
+}
diff --git a/test/jsonFiles/VUB_BLNPHYBRID__Xumunu.json b/test/jsonFiles/VUB_BLNPHYBRID__Xumunu.json
new file mode 100644
index 0000000..8ab9b1d
--- /dev/null
+++ b/test/jsonFiles/VUB_BLNPHYBRID__Xumunu.json
@@ -0,0 +1,29 @@
+{
+    "parent" : "B0",
+    "daughters" : ["Xu-", "mu+", "nu_mu"],
+    "models" : ["VUB_BLNPHYBRID"],
+    "parameters" : [["3.95", "0.72", "0.5", "1.5", "1.5", "1.0", "1.0", "1.0", "1.0", "1.0"]],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.2},
+        {"variable" : "mass", "title" : "m(X_{u})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "pSumSq", "title" : "qSq(#mu #nu_{#mu})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 25.0},
+        {"variable" : "p", "title" : "p(X_{u})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(#mu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(#nu_{#mu})", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(X_{u},#mu)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(#mu,#nu_{#mu})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(X_{u})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#mu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#nu_{#mu})", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(X_{u})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi", "title" : "phi(#mu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi", "title" : "phi(#nu_{#mu})", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "massSq", "title" : "Dalitz m^{2}(X_{u} #mu) vs m^{2}(#mu #nu_{#mu})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.0, "xmax" : 30.0, "variableY" : "massSq", "d1Y" : 2, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 30.0},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0}
+
+    ],
+    "outfile" : "VUB_BLNPHYBRID__Xumunu.root",
+    "reference" : "RefVUB_BLNPHYBRID__Xumunu.root"
+}
diff --git a/test/jsonFiles/VUB_BLNP__Xumunu.json b/test/jsonFiles/VUB_BLNP__Xumunu.json
new file mode 100644
index 0000000..6c92e99
--- /dev/null
+++ b/test/jsonFiles/VUB_BLNP__Xumunu.json
@@ -0,0 +1,29 @@
+{
+    "parent" : "B0",
+    "daughters" : ["Xu-", "mu+", "nu_mu"],
+    "models" : ["VUB_BLNP"],
+    "parameters" : [["3.95", "0.72", "0.5", "1.5", "1.5", "1.0", "1.0", "1.0", "1.0", "1.0"]],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.2},
+        {"variable" : "mass", "title" : "m(X_{u})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "pSumSq", "title" : "qSq(#mu #nu_{#mu})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 25.0},
+        {"variable" : "p", "title" : "p(X_{u})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(#mu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(#nu_{#mu})", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(X_{u},#mu)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(#mu,#nu_{#mu})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(X_{u})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#mu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#nu_{#mu})", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(X_{u})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi", "title" : "phi(#mu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi", "title" : "phi(#nu_{#mu})", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "massSq", "title" : "Dalitz m^{2}(X_{u} #mu) vs m^{2}(#mu #nu_{#mu})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.0, "xmax" : 30.0, "variableY" : "massSq", "d1Y" : 2, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 30.0},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0}
+
+    ],
+    "outfile" : "VUB_BLNP__Xumunu.root",
+    "reference" : "RefVUB_BLNP__Xumunu.root"
+}
diff --git a/test/jsonFiles/VUB_NLO__Xumunu.json b/test/jsonFiles/VUB_NLO__Xumunu.json
new file mode 100644
index 0000000..d355ee4
--- /dev/null
+++ b/test/jsonFiles/VUB_NLO__Xumunu.json
@@ -0,0 +1,29 @@
+{
+    "parent" : "B0",
+    "daughters" : ["Xu-", "mu+", "nu_mu"],
+    "models" : ["VUB_NLO"],
+    "parameters" : [["4.8", "1.29", "1.0", "0.0", "1.0", "1.0", "0.3", "1.0"]],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.2},
+        {"variable" : "mass", "title" : "m(X_{u})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "pSumSq", "title" : "qSq(#mu #nu_{#mu})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 25.0},
+        {"variable" : "p", "title" : "p(X_{u})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(#mu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(#nu_{#mu})", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(X_{u},#mu)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(#mu,#nu_{#mu})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(X_{u})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#mu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#nu_{#mu})", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(X_{u})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi", "title" : "phi(#mu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi", "title" : "phi(#nu_{#mu})", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "massSq", "title" : "Dalitz m^{2}(X_{u} #mu) vs m^{2}(#mu #nu_{#mu})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.0, "xmax" : 30.0, "variableY" : "massSq", "d1Y" : 2, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 30.0},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0}
+
+    ],
+    "outfile" : "VUB_NLO__Xumunu.root",
+    "reference" : "RefVUB_NLO__Xumunu.root"
+}
diff --git a/test/jsonFiles/VUB__Xumunu.json b/test/jsonFiles/VUB__Xumunu.json
new file mode 100644
index 0000000..ae3d868
--- /dev/null
+++ b/test/jsonFiles/VUB__Xumunu.json
@@ -0,0 +1,29 @@
+{
+    "parent" : "B0",
+    "daughters" : ["Xu-", "mu+", "nu_mu"],
+    "models" : ["VUB"],
+    "parameters" : [["4.8", "1.29", "0.22", "1.0", "0.3", "1.0"]],
+    "extras" : ["Define dm_incohMix_B0 0", "noPhotos"],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "Prob",  "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.2},
+        {"variable" : "mass", "title" : "m(X_{u})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 5.0},
+        {"variable" : "pSumSq", "title" : "qSq(#mu #nu_{#mu})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 25.0},
+        {"variable" : "p", "title" : "p(X_{u})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(#mu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "p", "title" : "p(#nu_{#mu})", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 3.0},
+        {"variable" : "cosHel", "title" : "cosHel(X_{u},#mu)", "d1" : 1, "d2" : 2, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosHel", "title" : "cosHel(#mu,#nu_{#mu})", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(X_{u})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#mu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(#nu_{#mu})", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(X_{u})", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi", "title" : "phi(#mu)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi", "title" : "phi(#nu_{#mu})", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+	{"variable" : "massSq", "title" : "Dalitz m^{2}(X_{u} #mu) vs m^{2}(#mu #nu_{#mu})", "d1" : 1, "d2" : 2, "nbins" : 50, "xmin" : 0.0, "xmax" : 30.0, "variableY" : "massSq", "d1Y" : 2, "d2Y" : 3, "nbinsY" : 50, "ymin" : 0.0, "ymax" : 25.0},
+        {"variable" : "mPrime", "title" : "sqDalitz", "d1" : 1, "d2" : 2, "nbins" : 25, "xmin" : 0.0, "xmax" : 1.00, "variableY" : "thetaPrime", "d1Y" : 1, "d2Y" : 2, "nbinsY" : 25, "ymin" : 0.0, "ymax" : 1.0}
+
+    ],
+    "outfile" : "VUB__Xumunu.root",
+    "reference" : "RefVUB__Xumunu.root"
+}
diff --git a/test/jsonFiles/X38722-+_PSI_GAMMA=VLL=VSS__X3872_JpsiOmega,mumu,pipi.json b/test/jsonFiles/X38722-+_PSI_GAMMA=VLL=VSS__X3872_JpsiOmega,mumu,pipi.json
new file mode 100644
index 0000000..17b4572
--- /dev/null
+++ b/test/jsonFiles/X38722-+_PSI_GAMMA=VLL=VSS__X3872_JpsiOmega,mumu,pipi.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "X_2(3872)",
+    "daughters" : ["omega", "J/psi"],
+    "grand_daughters" : [["pi+", "pi-"], ["mu+", "mu-"]],
+    "models" : ["X38722-+_PSI_GAMMA", "VSS", "VLL"],
+    "parameters" : [[], [], []],
+    "events" : 5000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0, "xmax" : 20 },
+        {"variable" : "mass", "title" : "m(omega)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.3, "xmax" : 0.8},
+        {"variable" : "p", "title" : "p(J/psi)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.65},
+        {"variable" : "pLab_daug2", "title" : "pLab(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.6},
+        {"variable" : "cosTheta_daug2", "title" : "cosTheta(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug2", "title" : "phi(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "X38722-+_PSI_GAMMA=VLL=VSS__X3872_JpsiOmega,mumu,pipi.root",
+    "reference" : "RefX38722-+_PSI_GAMMA=VLL=VSS__X3872_JpsiOmega,mumu,pipi.root"
+}
+
diff --git a/test/jsonFiles/X38722-+_PSI_GAMMA=VLL=VSS__X3872_JpsiRho0,mumu,pipi.json b/test/jsonFiles/X38722-+_PSI_GAMMA=VLL=VSS__X3872_JpsiRho0,mumu,pipi.json
new file mode 100644
index 0000000..9d89469
--- /dev/null
+++ b/test/jsonFiles/X38722-+_PSI_GAMMA=VLL=VSS__X3872_JpsiRho0,mumu,pipi.json
@@ -0,0 +1,22 @@
+{
+    "parent" : "X_2(3872)",
+    "daughters" : ["rho0", "J/psi"],
+    "grand_daughters" : [["pi+", "pi-"], ["mu+", "mu-"]],
+    "models" : ["X38722-+_PSI_GAMMA", "VSS", "VLL"],
+    "parameters" : [[], [], []],
+    "events" : 5000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0, "xmax" : 80 },
+        {"variable" : "mass", "title" : "m(rho)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.3, "xmax" : 0.8},
+        {"variable" : "p", "title" : "p(J/psi)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.65},
+        {"variable" : "pLab_daug2", "title" : "pLab(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 2.0},
+        {"variable" : "pLab_daug1", "title" : "pLab(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 0.6},
+        {"variable" : "cosTheta_daug2", "title" : "cosTheta(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug2", "title" : "phi(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "cosTheta_daug1", "title" : "cosTheta(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug1", "title" : "phi(pi+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "X38722-+_PSI_GAMMA=VLL=VSS__X3872_JpsiRho0,mumu,pipi.root",
+    "reference" : "RefX38722-+_PSI_GAMMA=VLL=VSS__X3872_JpsiRho0,mumu,pipi.root"
+}
+
diff --git a/test/jsonFiles/X38722-+_PSI_GAMMA=VLL__X3872_JpsiGamma,mumu.json b/test/jsonFiles/X38722-+_PSI_GAMMA=VLL__X3872_JpsiGamma,mumu.json
new file mode 100644
index 0000000..23430c6
--- /dev/null
+++ b/test/jsonFiles/X38722-+_PSI_GAMMA=VLL__X3872_JpsiGamma,mumu.json
@@ -0,0 +1,17 @@
+{
+    "parent" : "X_2(3872)",
+    "daughters" : ["gamma", "J/psi"],
+    "grand_daughters" : [[], ["mu+", "mu-"]],
+    "models" : ["X38722-+_PSI_GAMMA", "", "VLL"],
+    "parameters" : [[], [], []],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0, "xmax" : 2.5 },
+        {"variable" : "pLab_daug2", "title" : "pLab(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 1.0, "xmax" : 2.0},
+        {"variable" : "cosTheta_daug2", "title" : "cosTheta(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi_daug2", "title" : "phi(mu+)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(gamma)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0}
+    ],
+    "outfile" : "X38722-+_PSI_GAMMA=VLL__X3872_JpsiGamma,mumu.root",
+    "reference" : "RefX38722-+_PSI_GAMMA=VLL__X3872_JpsiGamma,mumu.root"
+}
diff --git a/test/jsonFiles/Y3STOY1SPIPIMOXHAY__Upsilon3S_Upsilon2pi.json b/test/jsonFiles/Y3STOY1SPIPIMOXHAY__Upsilon3S_Upsilon2pi.json
new file mode 100644
index 0000000..4669533
--- /dev/null
+++ b/test/jsonFiles/Y3STOY1SPIPIMOXHAY__Upsilon3S_Upsilon2pi.json
@@ -0,0 +1,26 @@
+{
+    "parent" : "Upsilon(3S)",
+    "daughters" : ["Upsilon", "pi+", "pi-"],
+    "models" : ["Y3STOY1SPIPIMOXHAY"],
+    "parameters" : [["0.2196", "0.2983"]],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0, "xmax" : 1.0},
+        {"variable" : "parMass", "title" : "m(Upsilon3S)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 10.0, "xmax" : 11.0},
+        {"variable" : "mass", "title" : "m(Upsilon)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 9.0, "xmax" : 10.0},
+        {"variable" : "mass", "title" : "m(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.13, "xmax" : 0.15},
+        {"variable" : "mass", "title" : "m(pi-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.13, "xmax" : 0.15},
+        {"variable" : "p", "title" : "p(Upsilon)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "p", "title" : "p(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "p", "title" : "p(pi-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "pSumSq", "title" : "qSq(pi+pi-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(Upsilon)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(pi-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(Upsilon)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi", "title" : "phi(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi", "title" : "phi(pi-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "Y3STOY1SPIPIMOXHAY__Upsilon3S_Upsilon2pi.root",
+    "reference" : "RefY3STOY1SPIPIMOXHAY__Upsilon3S_Upsilon2pi.root"
+}
diff --git a/test/jsonFiles/YMSTOYNSPIPICLEO__Upsilon3S_Upsilon2pi.json b/test/jsonFiles/YMSTOYNSPIPICLEO__Upsilon3S_Upsilon2pi.json
new file mode 100644
index 0000000..23d74e4
--- /dev/null
+++ b/test/jsonFiles/YMSTOYNSPIPICLEO__Upsilon3S_Upsilon2pi.json
@@ -0,0 +1,26 @@
+{
+    "parent" : "Upsilon(3S)",
+    "daughters" : ["Upsilon", "pi+", "pi-"],
+    "models" : ["YMSTOYNSPIPICLEO"],
+    "parameters" : [["2.523", "1.189"]],
+    "events" : 10000,
+    "histograms" : [
+        {"variable" : "prob", "title" : "probability", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 0, "xmax" : 1.0},
+        {"variable" : "parMass", "title" : "m(Upsilon3S)", "d1" : 0, "d2" : 0, "nbins" : 100, "xmin" : 10.0, "xmax" : 11.0},
+        {"variable" : "mass", "title" : "m(Upsilon)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 9.0, "xmax" : 10.0},
+        {"variable" : "mass", "title" : "m(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.13, "xmax" : 0.15},
+        {"variable" : "mass", "title" : "m(pi-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.13, "xmax" : 0.15},
+        {"variable" : "p", "title" : "p(Upsilon)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "p", "title" : "p(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "p", "title" : "p(pi-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+	{"variable" : "pSumSq", "title" : "qSq(pi+pi-)", "d1" : 2, "d2" : 3, "nbins" : 100, "xmin" : 0.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(Upsilon)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "cosTheta", "title" : "cosTheta(pi-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -1.0, "xmax" : 1.0},
+        {"variable" : "phi", "title" : "phi(Upsilon)", "d1" : 1, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi", "title" : "phi(pi+)", "d1" : 2, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0},
+        {"variable" : "phi", "title" : "phi(pi-)", "d1" : 3, "d2" : 0, "nbins" : 100, "xmin" : -180.0, "xmax" : 180.0}
+    ],
+    "outfile" : "YMSTOYNSPIPICLEO__Upsilon3S_Upsilon2pi.root",
+    "reference" : "RefYMSTOYNSPIPICLEO__Upsilon3S_Upsilon2pi.root"
+}
diff --git a/test/makeModelsJson b/test/makeModelsJson
new file mode 100644
index 0000000..a983a09
--- /dev/null
+++ b/test/makeModelsJson
@@ -0,0 +1,67 @@
+#!/bin/bash
+
+########################################################################
+# Copyright 1998-2022 CERN for the benefit of the EvtGen authors       #
+#                                                                      #
+# This file is part of EvtGen.                                         #
+#                                                                      #
+# EvtGen is free software: you can redistribute it and/or modify       #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or    #
+# (at your option) any later version.                                  #
+#                                                                      #
+# EvtGen is distributed in the hope that it will be useful,            #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of       #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        #
+# GNU General Public License for more details.                         #
+#                                                                      #
+# You should have received a copy of the GNU General Public License    #
+# along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     #
+########################################################################
+
+# Script to find all active decay models and create a JSON file that contains fields for:
+# class name, header file name, source file name
+# for each model, keyed by the model name
+
+if [ $# -ne 1 ]
+then
+    echo "Usage: makeModelsJson <project source dir>"
+    exit 1
+fi
+
+sourceDir=$1
+
+declare -a modelClasses
+
+cd $sourceDir
+
+modelClasses=(`grep registerModel src/EvtGenModels/EvtModelReg.cpp | grep " new " |  awk '{print $3}' | sed -e 's/[\(\)]\{1,2\}//' | sort`)
+
+declare -i nModels=${#modelClasses[@]}
+declare -i lastIndex=$nModels-1
+
+echo "{"
+for i in `seq 0 $lastIndex`
+do
+    modelClass=${modelClasses[$i]}
+    modelHeaderFile=`grep -rl "\<class[ ]\+$modelClass\>" EvtGenModels`
+    modelSourceFile="src/`echo $modelHeaderFile | sed -e 's/\.hh/.cpp/'`"
+    modelName=`grep getName $modelHeaderFile | grep " return " | awk -F'"' '{print $2}'`
+    if [ "x$modelName" == "x" ]
+    then
+        modelName=`grep -A3 "${modelClass}::getName" $modelSourceFile | grep " return " | awk -F'"' '{print $2}'`
+    fi
+
+    echo "    \"${modelName}\" : {"
+    echo "        \"class\" : \"${modelClass}\","
+    echo "        \"header\" : \"${modelHeaderFile}\","
+    echo "        \"source\" : \"${modelSourceFile}\""
+    if [ $i -eq $lastIndex ]
+    then
+        echo "    }"
+    else
+        echo "    },"
+    fi
+
+done
+echo "}"
diff --git a/test/makeSrcDepsJson b/test/makeSrcDepsJson
new file mode 100644
index 0000000..50589b9
--- /dev/null
+++ b/test/makeSrcDepsJson
@@ -0,0 +1,103 @@
+#!/bin/bash
+
+########################################################################
+# Copyright 1998-2022 CERN for the benefit of the EvtGen authors       #
+#                                                                      #
+# This file is part of EvtGen.                                         #
+#                                                                      #
+# EvtGen is free software: you can redistribute it and/or modify       #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or    #
+# (at your option) any later version.                                  #
+#                                                                      #
+# EvtGen is distributed in the hope that it will be useful,            #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of       #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        #
+# GNU General Public License for more details.                         #
+#                                                                      #
+# You should have received a copy of the GNU General Public License    #
+# along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     #
+########################################################################
+
+# Script to find the dependencies for all source files and create a JSON file containing that information
+
+if [ $# -ne 2 ]
+then
+    echo "Usage: makeDepsJson <project source dir - full path> <project build dir - full path>"
+    exit 1
+fi
+sourceDir=$1
+buildDir=$2
+
+# get a list of all the object files that are built in the EvtGen lib
+declare -a objFiles=(`awk -F: '{print $1}' $buildDir/src/CMakeFiles/objlib.dir/depend.make | grep '\.cpp\.o$' | sort -u`)
+
+declare -i nObjFiles=${#objFiles[@]}
+declare -i lastIndex=$nObjFiles-1
+
+echo "{"
+for i in `seq 0 $lastIndex`
+do
+    objFile=${objFiles[$i]}
+    srcFile=`echo $objFile | sed -e 's%CMakeFiles/objlib\.dir/%%' -e 's%\.o$%%'`
+
+    declare -a depFiles=(`grep "${objFile}:" $buildDir/src/CMakeFiles/objlib.dir/depend.make | awk '{print $NF}' | sed -e "s%$sourceDir[/]\?%%" -e "s%\.\./%%"`)
+    declare -i nDepFiles=${#depFiles[@]}
+    declare -i lastDep=$nDepFiles-1
+
+    echo "    \"${srcFile}\" : ["
+    for j in `seq 0 $lastDep`
+    do
+        depFile=${depFiles[$j]}
+
+        if [[ $depFile =~ \.hh$ ]]
+        then
+            dephdr=$depFile
+            depsrc="src/`echo $depFile | sed -e 's/\.hh/.cpp/'`"
+            if [ ! -e $sourceDir/$depsrc ]
+            then
+                depsrc=""
+            fi
+        elif [[ $depFile =~ \.cpp$ ]]
+        then
+            depsrc=$depFile
+            dephdr=`echo $depFile | sed -e 's%src/%%' -e 's/\.cpp/.hh/'`
+            if [ ! -e $sourceDir/$dephdr ]
+            then
+                dephdr=""
+            fi
+        fi
+
+        if [ $j -eq $lastDep ]
+        then
+            if [ "x$dephdr" != "x" -a "x$depsrc" != "x" ]
+            then
+                echo "        \"${dephdr}\","
+                echo "        \"${depsrc}\""
+            elif [ "x$dephdr" != "x" ]
+            then
+                echo "        \"${dephdr}\""
+            elif [ "x$depsrc" != "x" ]
+            then
+                echo "        \"${depsrc}\""
+            fi
+        else
+            if [ "x$dephdr" != "x" ]
+            then
+                echo "        \"${dephdr}\","
+            fi
+            if [ "x$depsrc" != "x" ]
+            then
+                echo "        \"${depsrc}\","
+            fi
+        fi
+    done
+
+    if [ $i -eq $lastIndex ]
+    then
+        echo "    ]"
+    else
+        echo "    ],"
+    fi
+done
+echo "}"
diff --git a/test/runTests.py b/test/runTests.py
new file mode 100644
index 0000000..dc1df79
--- /dev/null
+++ b/test/runTests.py
@@ -0,0 +1,209 @@
+#!/usr/bin/env python
+
+########################################################################
+# Copyright 1998-2022 CERN for the benefit of the EvtGen authors       #
+#                                                                      #
+# This file is part of EvtGen.                                         #
+#                                                                      #
+# EvtGen is free software: you can redistribute it and/or modify       #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or    #
+# (at your option) any later version.                                  #
+#                                                                      #
+# EvtGen is distributed in the hope that it will be useful,            #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of       #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        #
+# GNU General Public License for more details.                         #
+#                                                                      #
+# You should have received a copy of the GNU General Public License    #
+# along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     #
+########################################################################
+
+import os
+import sys
+import json
+import subprocess
+
+# Usage: runTests.py <model json file> <dependency json file> <changed source file 1> [[changed source file 2] ...]
+if len(sys.argv) < 4 :
+    print('ERROR: must provide model and dependency json files and one or more modified files')
+    sys.exit(1)
+
+modelJson = sys.argv[1]
+depJson = sys.argv[2]
+changedFiles = sys.argv[3:]
+
+# load the json files that contain:
+# - the associations between each model and the header/source pair that define the model class
+# - the associations between each source file and the other header/source files on which it depends
+with open(modelJson) as f1 :
+    models = json.load(f1)
+
+with open(depJson) as f2 :
+    srcdeps = json.load(f2)
+
+if not models or not srcdeps or len(models) == 0 or len(srcdeps) == 0 :
+    print('ERROR: problem loading model dependency information')
+    sys.exit(1)
+
+# turn the lists into sets, automatically removes duplicates
+for srcfile in srcdeps :
+    depset = set(srcdeps[srcfile])
+    srcdeps[srcfile] = depset
+
+def getDeps( srcfile, srcdeps, founddeps ) :
+    """
+    Find all the dependencies for a model
+    Arguments:
+    srcfile - the model's source file name (or, in recursion, a source file on which it depends)
+    srcdeps - the dictionary of all source files' dependencies
+    founddeps - a set of dependencies already found for the model
+    """
+    founddeps.add(srcfile) # make sure our source file is already marked as found
+    deps = set(srcdeps[srcfile]) # NB need to make a copy here
+
+    # remove already found dependencies from deps,
+    # then add new ones to founddeps
+    deps.difference_update(founddeps)
+    founddeps.update(deps)
+
+    # make list of source files in the dependencies
+    cpps = []
+    for f in deps :
+        if f.endswith('.cpp') :
+            cpps.append(f)
+
+    for f in cpps :
+        # add the dependencies of this source to our set
+        deps.update( getDeps( f, srcdeps, founddeps ) )
+
+    return deps
+
+# create the inverse look-up dictionary
+fileDeps = {}
+for model in models :
+    hdrfile = models[model]['header']
+    srcfile = models[model]['source']
+
+    founddeps = set([])
+    modeldeps = getDeps(srcfile,srcdeps,founddeps)
+    modeldeps.add(hdrfile)
+    modeldeps.add(srcfile)
+
+    for modeldep in modeldeps :
+        if modeldep in fileDeps :
+            fileDeps[modeldep].append( model )
+        else :
+            fileDeps[modeldep] = [ model ]
+
+testAll = False
+modelsToTest = []
+skippedFiles = []
+jsonFilesChanged = []
+
+for changedFile in changedFiles :
+    # if one of the test json files has changed we need to re-run that test
+    if changedFile.startswith('test/jsonFiles/') and changedFile.endswith('.json') :
+        jsonFilesChanged.append( changedFile )
+
+    # otherwise only consider source code files (TODO - any others that we should consider? evt.pdl, DECAY.DEC and similar?)
+    if not ( changedFile.endswith('.hh') or changedFile.endswith('.cpp') or changedFile.endswith('.cc') ) :
+        skippedFiles.append( changedFile )
+        continue
+
+    # the EvtGen, EvtModelReg, or EvtNoRadCorr objects; or the test code itself should trigger a rerun of all tests
+    # TODO - any others that should be in here?
+    if changedFile == 'EvtGen/EvtGen.hh' or changedFile == 'src/EvtGen.cpp' or changedFile == 'EvtGenModels/EvtModelReg.hh' or changedFile == 'src/EvtGenModels/EvtModelReg.cpp' or changedFile == 'EvtGenModels/EvtNoRadCorr.hh' or changedFile.startswith('test/') :
+        testAll = True
+        modelsToTest = []
+        break
+
+    # TODO temporarily skip EvtGenExternal stuff
+    if 'EvtGenExternal/' in changedFile or changedFile == 'EvtGenModels/EvtAbsExternalGen.hh' :
+        skippedFiles.append( changedFile )
+        continue
+
+    # otherwise check in the model dependency dict
+    if changedFile not in fileDeps :
+        print(f'WARNING: no dependency information for modified file: {changedFile}')
+        continue
+
+    models = fileDeps[changedFile]
+    if len(models) == 0 :
+        print(f'WARNING: no models listed for modified file: {changedFile}')
+        continue
+
+    modelsToTest.extend( models )
+
+if testAll :
+    print('Need to test all models')
+    modelsToTest = list(models.keys())
+
+if len(modelsToTest) == 0 and len(jsonFilesChanged) == 0 :
+    print('No models to test, exiting...')
+    if len(skippedFiles) == len(changedFiles) :
+        sys.exit(0)
+    else :
+        sys.exit(1)
+
+if len(jsonFilesChanged) != 0 :
+    print(f'The following test configs have changed and so need to be run: {jsonFilesChanged}')
+
+modelsToTest = set(modelsToTest)
+if len(modelsToTest) != 0 :
+    print(f'Need to test the following models: {modelsToTest}')
+
+testFilesToRun = []
+allTestFiles = os.listdir('jsonFiles')
+for model in modelsToTest :
+    testFilesForThisModel = []
+    for testFile in allTestFiles :
+        if not testFile.endswith('.json') :
+            continue
+        testModelNames = testFile[:testFile.index('__')].split('=')
+        if model in testModelNames :
+            testFilesForThisModel.append( testFile )
+    if len(testFilesForThisModel) == 0 :
+        print(f'WARNING: no tests available for model: {model}')
+    else :
+        testFilesToRun.extend( testFilesForThisModel )
+
+for jsonFile in jsonFilesChanged :
+    testFilesToRun.append( jsonFile.split('/')[-1] )
+
+if len(testFilesToRun) == 0 :
+    print(f'No tests to run, exiting...')
+    sys.exit(1)
+
+testFilesToRun = set(testFilesToRun)
+print(f'Will run the following tests: {testFilesToRun}')
+
+joinOutput = True
+allOK = True
+for testFile in testFilesToRun :
+    if joinOutput :
+        result = subprocess.run(['./testDecayModel', 'jsonFiles/'+testFile], text=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+    else :
+        result = subprocess.run(['./testDecayModel', 'jsonFiles/'+testFile], text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+    outFileName = testFile.replace('.json','.out')
+    with open(outFileName,'w') as outFile :
+        outFile.write(result.stdout)
+
+    if not joinOutput :
+        errFileName = testFile.replace('.json','.err')
+        with open(errFileName,'w') as errFile :
+            errFile.write(result.stderr)
+
+    if result.returncode == 0 :
+        print(f'Successfully ran test: {testFile}')
+    else :
+        print(f'ERROR: problem running test: {testFile}')
+        if joinOutput :
+            print(f'     : check the log file: {outFileName}')
+        else :
+            print(f'     : check the log files: {outFileName} and {errFileName}')
+        allOK = False
+
+if not allOK :
+    sys.exit(1)
diff --git a/test/testDecayModel.cc b/test/testDecayModel.cc
new file mode 100644
index 0000000..d081e7f
--- /dev/null
+++ b/test/testDecayModel.cc
@@ -0,0 +1,1225 @@
+
+/***********************************************************************
+* Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
+*                                                                      *
+* This file is part of EvtGen.                                         *
+*                                                                      *
+* EvtGen is free software: you can redistribute it and/or modify       *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation, either version 3 of the License, or    *
+* (at your option) any later version.                                  *
+*                                                                      *
+* EvtGen is distributed in the hope that it will be useful,            *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of       *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
+* GNU General Public License for more details.                         *
+*                                                                      *
+* You should have received a copy of the GNU General Public License    *
+* along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
+***********************************************************************/
+
+#include "testDecayModel.hh"
+
+#include "EvtGen/EvtGen.hh"
+
+#include "EvtGenBase/EvtAbsRadCorr.hh"
+#include "EvtGenBase/EvtConst.hh"
+#include "EvtGenBase/EvtDecayBase.hh"
+#include "EvtGenBase/EvtId.hh"
+#include "EvtGenBase/EvtKine.hh"
+#include "EvtGenBase/EvtMTRandomEngine.hh"
+#include "EvtGenBase/EvtPDL.hh"
+#include "EvtGenBase/EvtParticle.hh"
+#include "EvtGenBase/EvtParticleFactory.hh"
+#include "EvtGenBase/EvtRandom.hh"
+#include "EvtGenBase/EvtVector4R.hh"
+
+#ifdef EVTGEN_EXTERNAL
+#include "EvtGenExternal/EvtExternalGenList.hh"
+#endif
+
+#include <fstream>
+#include <iostream>
+#include <list>
+#include <memory>
+
+using nlohmann::json;
+
+TestDecayModel::TestDecayModel( const json& config ) : m_config{ config }
+{
+}
+
+bool TestDecayModel::checkMandatoryFields()
+{
+    const std::array<std::string, 8> mandatoryFields{
+        "parent",  "daughters", "models",    "parameters",
+        "outfile", "events",    "reference", "histograms" };
+    const std::array<std::string, 7> mandatoryHistoFields{
+        "title", "variable", "d1", "d2", "nbins", "xmin", "xmax" };
+    const std::array<std::string, 6> extra2DHistoFields{ "variableY", "d1Y",
+                                                         "d2Y",       "nbinsY",
+                                                         "ymin",      "ymax" };
+
+    bool allMandatoryFields{ true };
+
+    for ( const auto& field : mandatoryFields ) {
+        if ( !m_config.contains( field ) ) {
+            std::cerr << "ERROR : json does not contain required field: " << field
+                      << std::endl;
+            allMandatoryFields = false;
+            continue;
+        }
+        if ( field == "histograms" ) {
+            json jHistos = m_config["histograms"];
+            for ( auto hInfo : jHistos ) {
+                for ( const auto& hField : mandatoryHistoFields ) {
+                    if ( !hInfo.contains( hField ) ) {
+                        std::cerr
+                            << "ERROR : json does not contain required field for histogram definition: "
+                            << hField << std::endl;
+                        allMandatoryFields = false;
+                    }
+                }
+                if ( hInfo.contains( extra2DHistoFields[0] ) ) {
+                    for ( const auto& hField : extra2DHistoFields ) {
+                        if ( !hInfo.contains( hField ) ) {
+                            std::cerr
+                                << "ERROR : json does not contain required field for 2D histogram definition: "
+                                << hField << std::endl;
+                            allMandatoryFields = false;
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    return allMandatoryFields;
+}
+
+bool TestDecayModel::run()
+{
+    // Sometimes an array can be wrongly created when copying the json - fix it
+    if ( m_config.is_array() ) {
+        if ( m_config.size() != 1 ) {
+            std::cerr << "ERROR : json config is an array - dumping config for debugging:\n";
+            std::cerr << m_config << std::endl;
+            return false;
+        }
+        m_config = m_config[0];
+    }
+
+    // Check that we have, and then get all the mandatory fields first
+    if ( !checkMandatoryFields() ) {
+        std::cerr << "ERROR : json does not contain all mandatory fields - dumping config for debugging:\n";
+        std::cerr << m_config << std::endl;
+        return false;
+    }
+
+    const auto parentName = m_config["parent"].get<std::string>();
+    const auto daughterNames =
+        m_config["daughters"].get<std::vector<std::string>>();
+    const auto modelNames = m_config["models"].get<std::vector<std::string>>();
+    const auto modelParameters =
+        m_config["parameters"].get<std::vector<std::vector<std::string>>>();
+    const auto outFileName = m_config["outfile"].get<std::string>();
+    const auto nEvents = m_config["events"].get<int>();
+    const auto refFileName = m_config["reference"].get<std::string>();
+
+    // Then check for optional fields, setting default values if not present
+
+    json grandDaughters = m_config["grand_daughters"];
+    const auto grandDaughterNames =
+        grandDaughters.is_array()
+            ? grandDaughters.get<std::vector<std::vector<std::string>>>()
+            : std::vector<std::vector<std::string>>{};
+
+    json extras = m_config["extras"];
+    const auto extraCommands = extras.is_array()
+                                   ? extras.get<std::vector<std::string>>()
+                                   : std::vector<std::string>{};
+
+    json debug = m_config["debug_flag"];
+    const auto debugFlag = debug.is_boolean() ? debug.get<bool>() : false;
+
+    json conjugates = m_config["do_conjugate_decay"];
+    std::vector<bool> doConjDecay;
+    if ( conjugates.is_array() ) {
+        doConjDecay = conjugates.get<std::vector<bool>>();
+    }
+    if ( doConjDecay.size() != modelNames.size() ) {
+        doConjDecay.resize( modelNames.size(), false );
+    }
+
+    // Initialise the EvtGen object and hence the EvtPDL tables
+    // The EvtGen object is used by generateEvents, while the
+    // latter are also used within createDecFile
+
+    // Define the random number generator
+    auto randomEngine = std::make_unique<EvtMTRandomEngine>();
+
+    EvtAbsRadCorr* radCorrEngine = nullptr;
+    std::list<EvtDecayBase*> extraModels;
+
+#ifdef EVTGEN_EXTERNAL
+    bool convertPythiaCodes( false );
+    bool useEvtGenRandom( true );
+    EvtExternalGenList genList( convertPythiaCodes, "", "gamma", useEvtGenRandom );
+    radCorrEngine = genList.getPhotosModel();
+    extraModels = genList.getListOfModels();
+#endif
+
+    EvtGen theGen( "../DECAY.DEC", "../evt.pdl", randomEngine.get(),
+                   radCorrEngine, &extraModels );
+
+    /*! Creates a decay file based on json file input. */
+    const std::string decFileName = outFileName.substr( 0,
+                                                        outFileName.size() - 5 );
+    const std::string decFile = createDecFile( parentName, daughterNames,
+                                               grandDaughterNames, modelNames,
+                                               modelParameters, doConjDecay,
+                                               extraCommands, decFileName );
+
+    /*! Define the root output file and histograms to be saved. */
+    TFile* outFile = TFile::Open( outFileName.c_str(), "recreate" );
+    defineHistos( m_config, outFile );
+
+    /*!  Generate events and fill histograms. */
+    generateEvents( theGen, decFile, parentName, doConjDecay[0], nEvents,
+                    debugFlag );
+
+    // Normalize histograms.
+    for ( auto hist : m_1DhistVect ) {
+        double area = hist.second->Integral();
+        if ( area > 0.0 ) {
+            hist.second->Scale( 1.0 / area );
+        }
+    }
+    for ( auto hist : m_2DhistVect ) {
+        double area = hist.second->Integral();
+        if ( area > 0.0 ) {
+            hist.second->Scale( 1.0 / area );
+        }
+    }
+
+    /*! Compare with reference histograms. */
+    compareHistos( refFileName );
+
+    // Write output.
+    outFile->cd();
+    for ( auto& hist : m_1DhistVect ) {
+        hist.second->Write();
+    }
+    for ( auto& hist : m_2DhistVect ) {
+        hist.second->Write();
+    }
+    if ( m_mixedHist ) {
+        m_mixedHist->Write();
+    }
+    outFile->Close();
+    std::cout << "Created output file: " << outFileName.c_str() << std::endl;
+
+    return true;
+}
+
+std::string TestDecayModel::createDecFile(
+    const std::string& parent, const std::vector<std::string>& daughterNames,
+    const std::vector<std::vector<std::string>>& grandDaughterNames,
+    const std::vector<std::string>& modelNames,
+    const std::vector<std::vector<std::string>>& parameters,
+    const std::vector<bool>& doConjDecay,
+    const std::vector<std::string>& extras, const std::string decFileName ) const
+{
+    // Create (or overwrite) the decay file
+    std::string decName( decFileName + ".dec" );
+    std::ofstream decFile;
+    decFile.open( decName.c_str() );
+
+    // Create daughter aliases if needed
+    std::vector<std::string> aliasPrefix;
+    for ( long unsigned int daughter_index = 0;
+          daughter_index < daughterNames.size(); daughter_index++ ) {
+        if ( !grandDaughterNames.empty() &&
+             !grandDaughterNames[daughter_index].empty() ) {
+            decFile << "Alias My" << daughterNames[daughter_index] << " "
+                    << daughterNames[daughter_index] << std::endl;
+            if ( doConjDecay[daughter_index + 1] ) {
+                const EvtId daugID{
+                    EvtPDL::getId( daughterNames[daughter_index] ) };
+                const EvtId daugConjID{ EvtPDL::chargeConj( daugID ) };
+                const std::string conjName{ daugConjID.getName() };
+                std::string conjName_Alias{ daugConjID.getName() };
+                if ( std::find( std::begin( daughterNames ),
+                                std::end( daughterNames ), daugConjID.getName() ) !=
+                     std::end( daughterNames ) ) {
+                    conjName_Alias = conjName_Alias + "_" + daughter_index;
+                }
+                decFile << "Alias My" << conjName_Alias << " " << conjName
+                        << std::endl;
+                decFile << "ChargeConj My" << daughterNames[daughter_index]
+                        << "  My" << conjName_Alias << std::endl;
+            } else if ( doConjDecay[0] ) {
+                decFile << "ChargeConj My" << daughterNames[daughter_index]
+                        << "  My" << daughterNames[daughter_index] << std::endl;
+            }
+            aliasPrefix.push_back( "My" );
+        } else {
+            aliasPrefix.push_back( "" );
+        }
+    }
+
+    for ( auto iExtra : extras ) {
+        decFile << iExtra << std::endl;
+    }
+
+    // Parent decay
+    decFile << "Decay " << parent << std::endl;
+    decFile << "1.0";
+
+    for ( long unsigned int daughter_index = 0;
+          daughter_index < daughterNames.size(); daughter_index++ ) {
+        decFile << " " << aliasPrefix[daughter_index]
+                << daughterNames[daughter_index];
+    }
+
+    decFile << " " << modelNames[0];
+
+    for ( auto par : parameters[0] ) {
+        decFile << " " << par;
+    }
+
+    decFile << ";" << std::endl;
+    decFile << "Enddecay" << std::endl;
+    if ( doConjDecay[0] ) {
+        EvtId parID{ EvtPDL::getId( parent ) };
+        EvtId parConjID{ EvtPDL::chargeConj( parID ) };
+        decFile << "CDecay " << parConjID.getName() << std::endl;
+    }
+
+    // Daughter decays into granddaughters
+    for ( long unsigned int daughter_index = 0;
+          daughter_index < grandDaughterNames.size(); daughter_index++ ) {
+        if ( grandDaughterNames[daughter_index].empty() )
+            continue;
+        decFile << "Decay " << aliasPrefix[daughter_index]
+                << daughterNames[daughter_index] << std::endl;
+        decFile << "1.0";
+        for ( long unsigned int grandDaughter_index = 0;
+              grandDaughter_index < grandDaughterNames[daughter_index].size();
+              grandDaughter_index++ ) {
+            decFile << " "
+                    << grandDaughterNames[daughter_index][grandDaughter_index];
+        }
+        decFile << " " << modelNames[daughter_index + 1];
+        for ( auto par : parameters[daughter_index + 1] ) {
+            decFile << " " << par;
+        }
+        decFile << ";" << std::endl;
+        decFile << "Enddecay" << std::endl;
+        if ( doConjDecay[daughter_index + 1] ) {
+            EvtId daugID{ EvtPDL::getId( daughterNames[daughter_index] ) };
+            EvtId daugConjID{ EvtPDL::chargeConj( daugID ) };
+            std::string conjName_Alias{ daugConjID.getName() };
+            if ( std::find( std::begin( daughterNames ),
+                            std::end( daughterNames ), daugConjID.getName() ) !=
+                 std::end( daughterNames ) ) {
+                conjName_Alias = conjName_Alias + "_" + daughter_index;
+            }
+            decFile << "CDecay " << aliasPrefix[daughter_index]
+                    << conjName_Alias << std::endl;
+        }
+    }
+
+    decFile << "End" << std::endl;
+
+    decFile.close();
+
+    return decName;
+}
+
+void TestDecayModel::defineHistos( json& m_config, TFile* outFile )
+{
+    // Histogram information
+    json jHistos = m_config["histograms"];
+    size_t nHistos = jHistos.size();
+
+    m_1DhistVect.reserve( nHistos );
+    m_2DhistVect.reserve( nHistos );
+
+    for ( auto hInfo : jHistos ) {
+        const auto varTitle = hInfo["title"].get<std::string>();
+
+        const auto varName = hInfo["variable"].get<std::string>();
+        // Integer values that define what particles need to be used
+        // for invariant mass combinations or helicity angles etc
+        const auto d1 = hInfo["d1"].get<int>();
+        const auto d2 = hInfo["d2"].get<int>();
+
+        const auto nBins = hInfo["nbins"].get<int>();
+        const auto xmin = hInfo["xmin"].get<double>();
+        const auto xmax = hInfo["xmax"].get<double>();
+
+        std::string histName( varName.c_str() );
+        if ( d1 != 0 ) {
+            histName += "_";
+            histName += std::to_string( d1 );
+        }
+        if ( d2 != 0 ) {
+            histName += "_";
+            histName += std::to_string( d2 );
+        }
+
+        if ( !hInfo.contains( "variableY" ) ) {
+            TH1D* hist = new TH1D( histName.c_str(), varTitle.c_str(), nBins,
+                                   xmin, xmax );
+            hist->SetDirectory( outFile );
+            m_1DhistVect.emplace_back(
+                std::make_pair( TestInfo( varName, d1, d2 ), hist ) );
+            continue;
+        } else {
+            const auto varNameY = hInfo["variableY"].get<std::string>();
+            const auto d1Y = hInfo["d1Y"].get<int>();
+            const auto d2Y = hInfo["d2Y"].get<int>();
+
+            const auto nBinsY = hInfo["nbinsY"].get<int>();
+            const auto ymin = hInfo["ymin"].get<double>();
+            const auto ymax = hInfo["ymax"].get<double>();
+
+            histName += "_";
+            histName += varNameY;
+            if ( d1Y != 0 ) {
+                histName += "_";
+                histName += std::to_string( d1Y );
+            }
+            if ( d2Y != 0 ) {
+                histName += "_";
+                histName += std::to_string( d2Y );
+            }
+            TH2D* hist = new TH2D( histName.c_str(), varTitle.c_str(), nBins,
+                                   xmin, xmax, nBinsY, ymin, ymax );
+            hist->SetDirectory( outFile );
+            m_2DhistVect.emplace_back( std::make_pair(
+                TestInfo( varName, d1, d2, varNameY, d1Y, d2Y ), hist ) );
+        }
+    }
+
+    // For the case where the parent is either a neutral B or D add a mixed/unmixed histogram
+    const auto parentName = m_config["parent"].get<std::string>();
+    const int parentID = abs( EvtPDL::getStdHep( EvtPDL::getId( parentName ) ) );
+    if ( parentID == 511 || parentID == 531 || parentID == 421 ) {
+        const std::string varTitle{ parentName + " mixed" };
+        m_mixedHist = new TH1D( "mixed", varTitle.c_str(), 2, 0.0, 2.0 );
+        // TODO maybe set bin labels?
+        m_mixedHist->SetDirectory( outFile );
+    }
+}
+
+void TestDecayModel::generateEvents( EvtGen& theGen, const std::string& decFile,
+                                     const std::string& parentName,
+                                     bool doConjDecay, int nEvents,
+                                     bool debug_flag )
+{
+    // Read the decay file
+    theGen.readUDecay( decFile.c_str() );
+
+    // Generate the decays
+    EvtId parId = EvtPDL::getId( parentName.c_str() );
+    EvtId conjId = doConjDecay ? EvtPDL::chargeConj( parId ) : parId;
+    for ( int i = 0; i < nEvents; i++ ) {
+        if ( i % 1000 == 0 ) {
+            std::cout << "Event " << nEvents - i << std::endl;
+        }
+
+        // Initial 4-momentum and particle
+        EvtVector4R pInit( EvtPDL::getMass( parId ), 0.0, 0.0, 0.0 );
+        EvtParticle* parent{ nullptr };
+        if ( EvtRandom::Flat() < 0.5 ) {
+            parent = EvtParticleFactory::particleFactory( parId, pInit );
+        } else {
+            parent = EvtParticleFactory::particleFactory( conjId, pInit );
+        }
+
+        theGen.generateDecay( parent );
+
+        // Check for mixing (and fill histogram)
+        EvtParticle* prodParent{ nullptr };
+        if ( m_mixedHist ) {
+            if ( parent->getNDaug() == 1 ) {
+                prodParent = parent;
+                parent = prodParent->getDaug( 0 );
+
+                m_mixedHist->Fill( 1 );
+            } else {
+                m_mixedHist->Fill( 0 );
+            }
+        }
+
+        // To debug
+
+        if ( debug_flag ) {
+            std::cout << "Parent PDG code: " << parent->getPDGId()
+                      << " has daughters " << parent->getNDaug() << std::endl;
+            for ( size_t iDaughter = 0; iDaughter < parent->getNDaug();
+                  iDaughter++ ) {
+                std::cout << "Parent PDG code of daughter " << iDaughter
+                          << " : " << parent->getDaug( iDaughter )->getPDGId()
+                          << " has daughters "
+                          << parent->getDaug( iDaughter )->getNDaug()
+                          << std::endl;
+
+                for ( size_t iGrandDaughter = 0;
+                      iGrandDaughter < parent->getDaug( iDaughter )->getNDaug();
+                      iGrandDaughter++ ) {
+                    std::cout << "Parent PDG code of grand daughter "
+                              << iGrandDaughter << " : "
+                              << parent->getDaug( iDaughter )
+                                     ->getDaug( iGrandDaughter )
+                                     ->getPDGId()
+                              << " has daughters "
+                              << parent->getDaug( iDaughter )
+                                     ->getDaug( iGrandDaughter )
+                                     ->getNDaug()
+                              << std::endl;
+                }
+            }
+        }
+
+        // Store information
+        for ( auto& hist : m_1DhistVect ) {
+            const auto& info = hist.first;
+            const double value = getValue( parent, info.getName(), info.getd1(),
+                                           info.getd2() );
+
+            if ( hist.second ) {
+                hist.second->Fill( value );
+            }
+        }
+        for ( auto& hist : m_2DhistVect ) {
+            const auto& info = hist.first;
+            const double valueX = getValue( parent, info.getName(),
+                                            info.getd1(), info.getd2() );
+            const double valueY = getValue( parent, info.getName( 2 ),
+                                            info.getd1( 2 ), info.getd2( 2 ) );
+            if ( hist.second ) {
+                hist.second->Fill( valueX, valueY );
+            }
+        }
+
+        if ( debug_flag ) {
+            if ( prodParent ) {
+                prodParent->printTree();
+            } else {
+                parent->printTree();
+            }
+        }
+
+        // Cleanup
+        if ( prodParent ) {
+            prodParent->deleteTree();
+        } else {
+            parent->deleteTree();
+        }
+    }
+}
+
+double TestDecayModel::getValue( EvtParticle* parent, const std::string& varName,
+                                 const int d1, const int d2 ) const
+{
+    double value = std::numeric_limits<double>::quiet_NaN();
+    if ( !parent ) {
+        return value;
+    }
+
+    const int NDaugMax( parent->getNDaug() );
+    // If variable name contains "_daugX", we are interested in daughters of daughter X
+    // Else we are interested in daughters
+    EvtParticle* selectedParent = parent;
+    std::string selectedVarName = varName;
+    if ( varName.find( "_daug" ) != std::string::npos ) {
+        // Get daughter index from last character in string
+        const int iDaughter = varName.back() - '0';
+        selectedVarName = varName.substr( 0, varName.size() - 6 );
+        if ( iDaughter > 0 && iDaughter <= NDaugMax ) {
+            selectedParent = parent->getDaug( iDaughter - 1 );
+        } else {
+            return value;
+        }
+    }
+
+    const int sel_NDaugMax( selectedParent->getNDaug() );
+    const EvtParticle* par1 = d1 > 0 && d1 <= sel_NDaugMax
+                                  ? selectedParent->getDaug( d1 - 1 )
+                                  : nullptr;
+    const EvtParticle* par2 = d2 > 0 && d2 <= sel_NDaugMax
+                                  ? selectedParent->getDaug( d2 - 1 )
+                                  : nullptr;
+    const EvtParticle* par3 = sel_NDaugMax > 0
+                                  ? selectedParent->getDaug( sel_NDaugMax - 1 )
+                                  : nullptr;
+
+    // 4-momenta in parent rest frame
+    const EvtVector4R p1 = par1 != nullptr ? par1->getP4() : EvtVector4R();
+    const EvtVector4R p2 = par2 != nullptr ? par2->getP4() : EvtVector4R();
+    const EvtVector4R p3 = par3 != nullptr ? par3->getP4() : EvtVector4R();
+
+    // 4-momenta in lab frame (1st parent in decay tree)
+    const EvtVector4R p1_lab = par1 != nullptr ? par1->getP4Lab() : EvtVector4R();
+    const EvtVector4R p2_lab = par2 != nullptr ? par2->getP4Lab() : EvtVector4R();
+    const EvtVector4R p3_lab = par3 != nullptr ? par3->getP4Lab() : EvtVector4R();
+
+    if ( !selectedVarName.compare( "id" ) ) {
+        // StdHep ID of one of the daughters (controlled by d1) or the parent
+        if ( par1 ) {
+            value = par1->getPDGId();
+        } else {
+            value = selectedParent->getPDGId();
+        }
+
+    } else if ( !selectedVarName.compare( "parMass" ) ) {
+        // Parent invariant mass
+        value = selectedParent->mass();
+
+    } else if ( !selectedVarName.compare( "mass" ) ) {
+        // Invariant mass
+        if ( d2 != 0 ) {
+            // Invariant 4-mass combination of particles d1 and d2
+            value = ( p1 + p2 ).mass();
+        } else {
+            // Invariant mass of particle d1 only
+            value = p1.mass();
+        }
+
+    } else if ( !selectedVarName.compare( "massSq" ) ) {
+        // Invariant mass
+        if ( d2 != 0 ) {
+            // Invariant 4-mass combination of particles d1 and d2
+            value = ( p1 + p2 ).mass2();
+        } else {
+            // Invariant mass of particle d1 only
+            value = p1.mass2();
+        }
+    } else if ( !selectedVarName.compare( "mPrime" ) ) {
+        // pick up first unused particle rather than last one
+        if ( sel_NDaugMax != 3 ) {
+            return -1;
+        }
+        int unused = 0;
+        for ( int ii = 1; ii <= sel_NDaugMax; ++ii ) {
+            if ( ii != d1 && ii != d2 ) {
+                unused = ii;
+                break;
+            }
+        }
+        if ( unused == 0 ) {
+            unused = sel_NDaugMax;
+        }
+        const auto parL = selectedParent->getDaug( unused - 1 );
+        //            const auto& pL = parL->getP4();
+
+        const double mB = selectedParent->mass();
+        const double m1 = par1->mass();
+        const double m2 = par2->mass();
+        const double m3 = parL->mass();
+        const double m12 = ( p1 + p2 ).mass();
+        const double m12norm =
+            2 * ( ( m12 - ( m1 + m2 ) ) / ( mB - ( m1 + m2 + m3 ) ) ) - 1;
+        value = acos( m12norm ) / EvtConst::pi;
+
+    } else if ( !selectedVarName.compare( "thetaPrime" ) ) {
+        // pick up first unused particle rather than last one
+        if ( sel_NDaugMax != 3 ) {
+            return -1;
+        }
+        int unused = 0;
+        for ( int ii = 1; ii <= sel_NDaugMax; ++ii ) {
+            if ( ii != d1 && ii != d2 ) {
+                unused = ii;
+                break;
+            }
+        }
+        if ( unused == 0 ) {
+            unused = sel_NDaugMax;
+        }
+        const auto parL = selectedParent->getDaug( unused - 1 );
+        const auto& pL = parL->getP4();
+
+        const double mB = selectedParent->mass();
+        const double m1 = p1.mass();
+        const double m2 = p2.mass();
+        const double m3 = pL.mass();
+        double mBSq{ mB * mB };
+        double m1Sq{ m1 * m1 };
+        double m2Sq{ m2 * m2 };
+        double m3Sq{ m3 * m3 };
+        const double m12 = ( p1 + p2 ).mass();
+        const double m13 = ( p1 + p3 ).mass();
+        const double m12Sq{ m12 * m12 };
+        const double m13Sq{ m13 * m13 };
+        double en1 = ( m12Sq - m2Sq + m1Sq ) / ( 2.0 * m12 );
+        double en3 = ( mBSq - m12Sq - m3Sq ) / ( 2.0 * m12 );
+        double p1 = std::sqrt( en1 * en1 - m1Sq );
+        double p3 = std::sqrt( en3 * en3 - m3Sq );
+        double cosTheta = ( -m13Sq + m1Sq + m3Sq + 2. * en1 * en3 ) /
+                          ( 2. * p1 * p3 );
+        value = acos( cosTheta ) / EvtConst::pi;
+
+    } else if ( !selectedVarName.compare( "pSumSq" ) ) {
+        // Invariant momentum sum squared
+        value = ( p1 + p2 ).mass2();
+
+    } else if ( !selectedVarName.compare( "pDiffSq" ) ) {
+        // Invariant momentum difference squared
+        value = ( p1 - p2 ).mass2();
+
+    } else if ( !selectedVarName.compare( "mass3" ) ) {
+        // Invariant mass of 3 daughters
+        value = ( p1 + p2 + p3 ).mass();
+
+    } else if ( !selectedVarName.compare( "mass3_specified" ) ) {
+        // Invariant mass of 3 daughters, d1 is first daughter
+        // second daughter is d1 + 1, d2 is last daughter
+        const EvtParticle* daug2 = selectedParent->getDaug( d1 );
+        const EvtParticle* daug3 = selectedParent->getDaug( d2 - 1 );
+
+        const EvtVector4R p2_specified = daug2 != nullptr ? daug2->getP4Lab()
+                                                          : EvtVector4R();
+        const EvtVector4R p3_specified = daug3 != nullptr ? daug3->getP4Lab()
+                                                          : EvtVector4R();
+
+        value = ( p1 + p2_specified + p3_specified ).mass();
+
+    } else if ( !selectedVarName.compare( "cosTheta3" ) ) {
+        // Cosine of the polar angle of the momentum of d1 + d2 + d3
+        const EvtVector4R p123 = p1 + p2 + p3;
+        if ( p123.d3mag() > 0.0 ) {
+            value = p123.get( 3 ) / p123.d3mag();
+        }
+
+    } else if ( !selectedVarName.compare( "pLab" ) ) {
+        // Momentum of particle d1 in lab frame
+        value = p1_lab.d3mag();
+
+    } else if ( !selectedVarName.compare( "p" ) ) {
+        // Momentum of particle d1 in parent rest frame
+        value = p1.d3mag();
+
+    } else if ( !selectedVarName.compare( "pLabSq" ) ) {
+        // Momentum squared of particle d1 (in lab frame)
+        const double p1_lab_x = p1_lab.get( 1 );
+        const double p1_lab_y = p1_lab.get( 2 );
+        const double p1_lab_z = p1_lab.get( 3 );
+        value = p1_lab_x * p1_lab_x + p1_lab_y * p1_lab_y + p1_lab_z * p1_lab_z;
+
+    } else if ( !selectedVarName.compare( "pSq" ) ) {
+        // Momentum squared of particle d1 (in lab frame)
+        const double p1_x = p1.get( 1 );
+        const double p1_y = p1.get( 2 );
+        const double p1_z = p1.get( 3 );
+        value = p1_x * p1_x + p1_y * p1_y + p1_z * p1_z;
+
+    } else if ( !selectedVarName.compare( "pxLab" ) ) {
+        // x momentum of particle d1 in lab frame
+        value = p1_lab.get( 1 );
+
+    } else if ( !selectedVarName.compare( "px" ) ) {
+        // x momentum of particle d1 in parent frame
+        value = p1.get( 1 );
+
+    } else if ( !selectedVarName.compare( "pyLab" ) ) {
+        // y momentum of particle d1 in lab frame
+        value = p1_lab.get( 2 );
+
+    } else if ( !selectedVarName.compare( "py" ) ) {
+        // y momentum of particle d1 in parent frame
+        value = p1.get( 2 );
+
+    } else if ( !selectedVarName.compare( "pzLab" ) ) {
+        // z momentum of particle d1 in lab frame
+        value = p1_lab.get( 3 );
+
+    } else if ( !selectedVarName.compare( "pz" ) ) {
+        // z momentum of particle d1 in parent frame
+        value = p1.get( 3 );
+
+    } else if ( !selectedVarName.compare( "cosHel" ) ||
+                !selectedVarName.compare( "absCosHel" ) ) {
+        // Cosine of helicity angle
+        EvtVector4R p12;
+        EvtVector4R p1Res;
+
+        if ( d2 != 0 ) {
+            // Resonance center-of-mass system (d1 and d2)
+            p12 = p1_lab + p2_lab;
+            // Boost vector
+            const EvtVector4R boost( p12.get( 0 ), -p12.get( 1 ), -p12.get( 2 ),
+                                     -p12.get( 3 ) );
+            // Momentum of particle d1 in resonance frame, p1Res
+            p1Res = boostTo( p1_lab, boost );
+        } else {
+            // The resonance is d1
+            p12 = p1;
+
+            // Find its first daughter
+            const EvtParticle* gpar = par1 != nullptr ? par1->getDaug( 0 )
+                                                      : nullptr;
+
+            p1Res = gpar != nullptr ? gpar->getP4() : EvtVector4R();
+        }
+
+        // Cosine of angle between p1Res and momentum of resonance in parent frame
+        const double p1ResMag = p1Res.d3mag();
+        const double p12Mag = p12.d3mag();
+        if ( p1ResMag > 0.0 && p12Mag > 0.0 ) {
+            value = -p1Res.dot( p12 ) / ( p1ResMag * p12Mag );
+        }
+
+        if ( !selectedVarName.compare( "absCosHel" ) ) {
+            value = std::abs( value );
+        }
+
+    } else if ( !selectedVarName.compare( "cosHelTau" ) ) {
+        // Works only for B -> X nu_1 tau -> pi nu_2.
+        // Cosine of helicity angle between pi momentum and opposite W momentum -(nu_1 + tau)
+        // in the tau rest frame. Index d1 must match with tau.
+        // p3 (momentum of last daughter) is taken as the neutrino momentum
+
+        // W momentum
+        const EvtVector4R p_W = p1_lab + p3_lab;
+
+        // Index d2 must match the index of the pion (daughter of tau)
+        const EvtParticle* pion = selectedParent->getDaug( d1 - 1 )->getDaug(
+            d2 - 1 );
+        const EvtVector4R p_pion = pion != nullptr ? pion->getP4Lab()
+                                                   : EvtVector4R();
+
+        // Boost vector to tau frame
+        const EvtVector4R boost( p1_lab.get( 0 ), -p1_lab.get( 1 ),
+                                 -p1_lab.get( 2 ), -p1_lab.get( 3 ) );
+
+        // Boost both momenta to tau frame
+        const EvtVector4R p_W_boosted = boostTo( p_W, boost );
+        const EvtVector4R p_pion_boosted = boostTo( p_pion, boost );
+        // Cosine of angle between opposite W momentum and pion momentum in tau frame
+        const double p_W_boostedMag = p_W_boosted.d3mag();
+        const double p_pion_boostedMag = p_pion_boosted.d3mag();
+
+        if ( p_W_boostedMag > 0.0 && p_pion_boostedMag > 0.0 ) {
+            value = -p_W_boosted.dot( p_pion_boosted ) /
+                    ( p_W_boostedMag * p_pion_boostedMag );
+        }
+
+    } else if ( !selectedVarName.compare( "cosHelDiTau" ) ||
+                !selectedVarName.compare( "cosHelDiTau_over05" ) ||
+                !selectedVarName.compare( "cosHelDiTau_under05" ) ) {
+        // Works for B -> tau (pi nu) tau -> (pi nu), B -> phi (-> KK) l l decays,
+        // B -> 4 pions, or similar decays..
+        // Cosine of helicity angle between pi momentum and opposite B momentum in tau rest frame.
+        // Index d1 must match with tau
+
+        if ( sel_NDaugMax < 2 || sel_NDaugMax > 4 ) {
+            return value;
+        }
+
+        // B momentum
+        const EvtVector4R p_B = selectedParent->getP4Lab();
+
+        // Index d2 must match the index of the pion (daughter of tau)
+        const EvtParticle* pion_1 =
+            sel_NDaugMax <= 3
+                ? selectedParent->getDaug( d1 - 1 )->getDaug( d2 - 1 )
+                : selectedParent->getDaug( d1 - 1 );
+        const EvtVector4R p_pion_1 = pion_1 != nullptr ? pion_1->getP4Lab()
+                                                       : EvtVector4R();
+
+        const EvtVector4R p_first_daughter =
+            sel_NDaugMax <= 3 ? selectedParent->getDaug( d1 - 1 )->getP4Lab()
+                              : selectedParent->getDaug( d1 - 1 )->getP4Lab() +
+                                    selectedParent->getDaug( d1 )->getP4Lab();
+
+        // Boost vector to tau frame
+        const EvtVector4R boost_1( p_first_daughter.get( 0 ),
+                                   -p_first_daughter.get( 1 ),
+                                   -p_first_daughter.get( 2 ),
+                                   -p_first_daughter.get( 3 ) );
+
+        // Boost both momenta to tau frame
+        const EvtVector4R p_B_boosted_1 = boostTo( p_B, boost_1 );
+        const EvtVector4R p_pion_boosted_1 = boostTo( p_pion_1, boost_1 );
+        // Cosine of angle between opposite W momentum and pion momentum in tau frame
+        const double p_B_boosted_1_Mag = p_B_boosted_1.d3mag();
+        const double p_pion_boosted_1_Mag = p_pion_boosted_1.d3mag();
+
+        double hel1 = std::numeric_limits<double>::quiet_NaN();
+        double hel = std::numeric_limits<double>::quiet_NaN();
+
+        if ( p_B_boosted_1_Mag > 0.0 && p_pion_boosted_1_Mag > 0.0 ) {
+            hel1 = -p_B_boosted_1.dot( p_pion_boosted_1 ) /
+                   ( p_B_boosted_1_Mag * p_pion_boosted_1_Mag );
+        }
+
+        if ( ( !selectedVarName.compare( "cosHelDiTau_over05" ) ) ||
+             ( !selectedVarName.compare( "cosHelDiTau_under05" ) ) ) {
+            // Works for B -> tau (pi nu) tau -> (pi nu) or similar decays.
+            // Cosine of helicity angle between pi momentum and opposite B momentum in tau rest frame
+            // Index d1 must match with tau; cosHelicity above +0.5 or below -0.5
+
+            // Index d2 must match the index of the pion (daughter of tau)
+            const EvtParticle* pion =
+                sel_NDaugMax <= 3
+                    ? selectedParent->getDaug( 0 )->getDaug( d2 - 1 )
+                    : selectedParent->getDaug( 0 );
+            const EvtVector4R p_pion = pion != nullptr ? pion->getP4Lab()
+                                                       : EvtVector4R();
+            // Boost vector to tau frame
+            const EvtVector4R p_second_daughter =
+                sel_NDaugMax == 2 ? selectedParent->getDaug( 0 )->getP4Lab()
+                                  : selectedParent->getDaug( 0 )->getP4Lab() +
+                                        selectedParent->getDaug( 1 )->getP4Lab();
+
+            const EvtVector4R boost( p_second_daughter.get( 0 ),
+                                     -p_second_daughter.get( 1 ),
+                                     -p_second_daughter.get( 2 ),
+                                     -p_second_daughter.get( 3 ) );
+
+            // Boost both momenta to tau frame
+            const EvtVector4R p_B_boosted = boostTo( p_B, boost );
+            const EvtVector4R p_pion_boosted = boostTo( p_pion, boost );
+            // Cosine of angle between opposite W momentum and pion momentum in tau frame
+            const double p_B_boostedMag = p_B_boosted.d3mag();
+            const double p_pion_boostedMag = p_pion_boosted.d3mag();
+
+            if ( p_B_boostedMag > 0.0 && p_pion_boostedMag > 0.0 ) {
+                hel = -p_B_boosted.dot( p_pion_boosted ) /
+                      ( p_B_boostedMag * p_pion_boostedMag );
+            }
+        }
+
+        if ( !selectedVarName.compare( "cosHelDiTau" ) ||
+             ( hel > 0.5 && !selectedVarName.compare( "cosHelDiTau_over05" ) ) ||
+             ( hel < -0.5 && !selectedVarName.compare( "cosHelDiTau_under05" ) ) ) {
+            value = hel1;
+        }
+
+    } else if ( !selectedVarName.compare( "cosAcoplanarityAngle" ) ||
+                !selectedVarName.compare( "acoplanarityAngle" ) ) {
+        // Acoplanarity angle or cosine for B -> tau (pi nu) tau -> (pi nu),
+        // B -> phi (-> KK) l l decays, B -> 4 pions, or similar decays
+
+        value = getCosAcoplanarityAngle( selectedParent, sel_NDaugMax, d1, d2 );
+        if ( !selectedVarName.compare( "acoplanarityAngle" ) ) {
+            value = std::acos( value ) * 180.0 / EvtConst::pi;    // degrees
+        }
+
+    } else if ( !selectedVarName.compare( "cosTheta" ) ) {
+        // Cosine of polar angle of first daughter in lab frame
+        const double p1_lab_mag = p1_lab.d3mag();
+        if ( p1_lab_mag > 0.0 ) {
+            value = p1_lab.get( 3 ) / p1_lab_mag;
+        }
+
+    } else if ( !selectedVarName.compare( "phi" ) ) {
+        // Azimuthal angle of first daughter in lab frame (degrees)
+        const double p1_lab_mag = p1_lab.d3mag();
+        if ( p1_lab_mag > 0.0 ) {
+            value = atan2( p1_lab.get( 1 ), p1_lab.get( 2 ) ) * 180.0 /
+                    EvtConst::pi;
+        }
+
+    } else if ( !selectedVarName.compare( "decayangle" ) ) {
+        // Polar angle between first and second daughters in lab frame
+
+        const EvtVector4R p = selectedParent->getP4();
+        const EvtVector4R q = p1 + p2;
+        const EvtVector4R d = p1;
+
+        const double cost = EvtDecayAngle( p, q, d );
+
+        value = acos( cost ) * 180.0 / EvtConst::pi;
+
+    } else if ( !selectedVarName.compare( "decayangle3" ) ) {
+        // Polar angle between combined first and second daughters
+        // with the third daughter in lab frame
+
+        const EvtVector4R p = selectedParent->getP4();
+        const EvtVector4R q = p1 + p2 + p3;
+        const EvtVector4R d = p1 + p2;
+
+        const double cost = EvtDecayAngle( p, q, d );
+
+        value = acos( cost ) * 180.0 / EvtConst::pi;
+
+    } else if ( !selectedVarName.compare( "decayangle_BTO4PI" ) ) {
+        // Polar angle between first and second daughters in lab frame.
+        // Used in PIPIPI (BTO4PI_CP) model
+
+        const EvtVector4R p = p1 + p2 + p3;
+        const EvtVector4R q = p1 + p2;
+        const EvtVector4R d = p1;
+
+        const double cost = EvtDecayAngle( p, q, d );
+
+        value = acos( cost ) * 180.0 / EvtConst::pi;
+
+    } else if ( !selectedVarName.compare( "chi" ) ) {
+        // Chi angle (degrees) using all 4 daughters and parent 4 mom
+
+        const EvtParticle* daug1 = selectedParent->getDaug( d1 - 1 );
+        const EvtParticle* daug2 = selectedParent->getDaug( d1 );
+        const EvtParticle* daug3 = selectedParent->getDaug( d1 + 1 );
+        const EvtParticle* daug4 = selectedParent->getDaug( d1 + 2 );
+
+        const EvtVector4R p_parent = selectedParent->getP4();
+        const EvtVector4R p_daug1 = daug1 != nullptr ? daug1->getP4()
+                                                     : EvtVector4R();
+        const EvtVector4R p_daug2 = daug2 != nullptr ? daug2->getP4()
+                                                     : EvtVector4R();
+        const EvtVector4R p_daug3 = daug3 != nullptr ? daug3->getP4()
+                                                     : EvtVector4R();
+        const EvtVector4R p_daug4 = daug4 != nullptr ? daug4->getP4()
+                                                     : EvtVector4R();
+
+        const double chi = EvtDecayAngleChi( p_parent, p_daug1, p_daug2,
+                                             p_daug3, p_daug4 );
+        value = chi * 180.0 / EvtConst::pi;
+
+    } else if ( !selectedVarName.compare( "E" ) ) {
+        // Energy of first daughter in lab frame
+        value = p1_lab.get( 0 );
+
+    } else if ( !selectedVarName.compare( "E_over_Eparent" ) ) {
+        // Energy of first daughter w.r.t parent energy (lab frame)
+        value = p1_lab.get( 0 ) / selectedParent->getP4Lab().get( 0 );
+
+    } else if ( !selectedVarName.compare( "E_over_Eparent_over05" ) ) {
+        // First daughter E_over_Eparent (lab frame) if d2 granddaughter E ratio > 0.5
+        const double E_over_Eparent_2 =
+            parent->getDaug( 0 )->getDaug( d2 - 1 )->getP4Lab().get( 0 ) /
+            parent->getDaug( 0 )->getP4Lab().get( 0 );
+
+        if ( E_over_Eparent_2 > 0.5 ) {
+            value = p1_lab.get( 0 ) / selectedParent->getP4Lab().get( 0 );
+        }
+
+    } else if ( !selectedVarName.compare( "totE_over_Mparent" ) ) {
+        // Energy of given daughters w.r.t parent mass (lab frame)
+        value = ( p1_lab.get( 0 ) + p2_lab.get( 0 ) ) / selectedParent->mass();
+
+    } else if ( !selectedVarName.compare( "prob" ) ) {
+        // Decay probability
+        double* dProb = selectedParent->decayProb();
+        if ( dProb ) {
+            value = *dProb;
+        }
+
+    } else if ( !selectedVarName.compare( "lifetime" ) ) {
+        // Lifetime of particle d1 (ps)
+        if ( d1 ) {
+            value = par1 != nullptr ? par1->getLifetime() * 1e12 / EvtConst::c
+                                    : 0.0;
+        } else {
+            value = parent != nullptr
+                        ? parent->getLifetime() * 1e12 / EvtConst::c
+                        : 0.0;
+        }
+
+    } else if ( !selectedVarName.compare( "deltaT" ) ) {
+        // Lifetime difference between particles d1 and d2
+        const double t1 = par1 != nullptr
+                              ? par1->getLifetime() * 1e12 / EvtConst::c
+                              : 0.0;
+        const double t2 = par2 != nullptr
+                              ? par2->getLifetime() * 1e12 / EvtConst::c
+                              : 0.0;
+        value = t1 - t2;
+
+    } else if ( !selectedVarName.compare( "decTime" ) ) {
+        // Decay flight time of particle d1 in picoseconds.
+        // Decay vertex = position of (1st) decay particle of d1
+        const EvtParticle* gpar = par1 != nullptr ? par1->getDaug( 0 ) : nullptr;
+        const EvtVector4R vtxPos = gpar != nullptr ? gpar->get4Pos()
+                                                   : EvtVector4R();
+        const double p = p1_lab.d3mag();
+        value = p > 0.0
+                    ? 1e12 * vtxPos.d3mag() * p1_lab.mass() / ( p * EvtConst::c )
+                    : 0.0;
+    } else {
+        std::cerr << "Warning: Did not recognise variable name "
+                  << selectedVarName << std::endl;
+    }
+
+    return value;
+}
+
+void TestDecayModel::compareHistos( const std::string& refFileName ) const
+{
+    // Compare histograms with the same name, calculating the chi-squared
+    TFile* refFile = TFile::Open( refFileName.c_str(), "read" );
+
+    if ( !refFile ) {
+        std::cerr << "Could not open reference file " << refFileName << std::endl;
+        return;
+    }
+
+    for ( auto& hist : m_1DhistVect ) {
+        const std::string histName = hist.second->GetName();
+        // Get equivalent reference histogram
+        const TH1* refHist = dynamic_cast<TH1*>(
+            refFile->Get( histName.c_str() ) );
+
+        if ( refHist ) {
+            double chiSq( 0.0 );
+            int nDof( 0 );
+            int iGood( 0 );
+            double pValue = refHist->Chi2TestX( hist.second, chiSq, nDof, iGood,
+                                                "WW" );
+            std::cout << "Histogram " << histName << " chiSq/nDof = " << chiSq
+                      << "/" << nDof << ", pValue = " << pValue << std::endl;
+
+        } else {
+            std::cerr << "Could not find reference histogram " << histName
+                      << std::endl;
+        }
+    }
+    for ( auto& hist : m_2DhistVect ) {
+        const std::string histName = hist.second->GetName();
+        // Get equivalent reference histogram
+        const TH2* refHist = dynamic_cast<TH2*>(
+            refFile->Get( histName.c_str() ) );
+
+        if ( refHist ) {
+            double chiSq( 0.0 );
+            int nDof( 0 );
+            int iGood( 0 );
+            double pValue = refHist->Chi2TestX( hist.second, chiSq, nDof, iGood,
+                                                "WW" );
+            std::cout << "Histogram " << histName << " chiSq/nDof = " << chiSq
+                      << "/" << nDof << ", pValue = " << pValue << std::endl;
+
+        } else {
+            std::cerr << "Could not find reference histogram " << histName
+                      << std::endl;
+        }
+    }
+
+    refFile->Close();
+}
+
+double TestDecayModel::getCosAcoplanarityAngle( EvtParticle* selectedParent,
+                                                int sel_NDaugMax, int d1,
+                                                int d2 ) const
+{
+    // Given a two-body decay, the acoplanarity angle is defined as the angle between the
+    // two decay planes (normal vectors) in the reference frame of the mother.
+    // Each normal vector is the cross product of the momentum of one daughter (in the frame of the mother)
+    // and the momentum of one of the granddaughters (in the reference frame of the daughter).
+    // In case of 3 daughters, we build an intermediate daughter (2+3) from the last 2 daughters
+    // (which are then treated as grand daughters), and in case of 4 daughters, we build
+    // 2 intermediate daughters (1+2) and (3+4)
+
+    double cosAco( 0.0 );
+
+    if ( sel_NDaugMax < 2 || sel_NDaugMax > 4 ) {
+        return cosAco;
+    }
+
+    const EvtParticle* daughter1 = selectedParent->getDaug( 0 );
+    const EvtParticle* daughter2 = selectedParent->getDaug( 1 );
+    const EvtParticle* daughter3 = selectedParent->getDaug( 2 );
+    const EvtParticle* daughter4 = selectedParent->getDaug( 3 );
+
+    const EvtParticle* grandDaughter1 = daughter1->getDaug( d1 - 1 );
+    const EvtParticle* grandDaughter2 = daughter2->getDaug( d2 - 1 );
+
+    const EvtVector4R parent4Vector = selectedParent->getP4Lab();
+
+    const EvtVector4R daughter4Vector1 = sel_NDaugMax <= 3
+                                             ? daughter1->getP4Lab()
+                                             : daughter1->getP4Lab() +
+                                                   daughter2->getP4Lab();
+
+    const EvtVector4R daughter4Vector2 =
+        sel_NDaugMax == 2
+            ? daughter2->getP4Lab()
+            : sel_NDaugMax == 3 ? daughter2->getP4Lab() + daughter3->getP4Lab()
+                                : daughter3->getP4Lab() + daughter4->getP4Lab();
+
+    const EvtVector4R grandDaughter4Vector1 = sel_NDaugMax <= 3
+                                                  ? grandDaughter1->getP4Lab()
+                                                  : daughter1->getP4Lab();
+
+    const EvtVector4R grandDaughter4Vector2 = sel_NDaugMax == 2
+                                                  ? grandDaughter2->getP4Lab()
+                                                  : sel_NDaugMax == 3
+                                                        ? daughter2->getP4Lab()
+                                                        : daughter3->getP4Lab();
+
+    const EvtVector4R parentBoost( parent4Vector.get( 0 ),
+                                   -parent4Vector.get( 1 ),
+                                   -parent4Vector.get( 2 ),
+                                   -parent4Vector.get( 3 ) );
+
+    const EvtVector4R daughter1Boost( daughter4Vector1.get( 0 ),
+                                      -daughter4Vector1.get( 1 ),
+                                      -daughter4Vector1.get( 2 ),
+                                      -daughter4Vector1.get( 3 ) );
+
+    const EvtVector4R daughter2Boost( daughter4Vector2.get( 0 ),
+                                      -daughter4Vector2.get( 1 ),
+                                      -daughter4Vector2.get( 2 ),
+                                      -daughter4Vector2.get( 3 ) );
+
+    // Boosting daughters to reference frame of the mother
+    EvtVector4R daughter4Vector1_boosted = boostTo( daughter4Vector1,
+                                                    parentBoost );
+    EvtVector4R daughter4Vector2_boosted = boostTo( daughter4Vector2,
+                                                    parentBoost );
+
+    // Boosting each granddaughter to reference frame of its mother
+    EvtVector4R grandDaughter4Vector1_boosted = boostTo( grandDaughter4Vector1,
+                                                         daughter1Boost );
+    EvtVector4R grandDaughter4Vector2_boosted = boostTo( grandDaughter4Vector2,
+                                                         daughter2Boost );
+
+    // We calculate the normal vectors of the decay two planes
+    const EvtVector4R normalVector1 = daughter4Vector1_boosted.cross(
+        grandDaughter4Vector1_boosted );
+    const EvtVector4R normalVector2 = daughter4Vector2_boosted.cross(
+        grandDaughter4Vector2_boosted );
+
+    const double normalVector1Mag = normalVector1.d3mag();
+    const double normalVector2Mag = normalVector2.d3mag();
+
+    if ( normalVector1Mag > 0.0 && normalVector2Mag > 0.0 ) {
+        cosAco = normalVector1.dot( normalVector2 ) /
+                 ( normalVector1Mag * normalVector2Mag );
+    }
+
+    return cosAco;
+}
+
+int main( int argc, char* argv[] )
+{
+    if ( argc != 2 ) {
+        std::cerr << "Expecting one argument: json input file" << std::endl;
+        return 1;
+    }
+
+    /*! Load input file in json format. */
+    json config;
+    std::ifstream inputStr( argv[1] );
+    inputStr >> config;
+    inputStr.close();
+
+    bool allOK{ true };
+    if ( config.is_array() ) {
+        for ( const auto& cc : config ) {
+            TestDecayModel test( cc );
+            allOK &= test.run();
+        }
+    } else {
+        TestDecayModel test( config );
+        allOK &= test.run();
+    }
+
+    return allOK ? 0 : 1;
+}
diff --git a/test/testDecayModel.hh b/test/testDecayModel.hh
new file mode 100644
index 0000000..6a09b5b
--- /dev/null
+++ b/test/testDecayModel.hh
@@ -0,0 +1,101 @@
+
+/***********************************************************************
+* Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
+*                                                                      *
+* This file is part of EvtGen.                                         *
+*                                                                      *
+* EvtGen is free software: you can redistribute it and/or modify       *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation, either version 3 of the License, or    *
+* (at your option) any later version.                                  *
+*                                                                      *
+* EvtGen is distributed in the hope that it will be useful,            *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of       *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
+* GNU General Public License for more details.                         *
+*                                                                      *
+* You should have received a copy of the GNU General Public License    *
+* along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
+***********************************************************************/
+
+#ifndef TEST_DECAY_MODEL_HH
+#define TEST_DECAY_MODEL_HH
+
+#include "TFile.h"
+#include "TH1D.h"
+#include "TH2D.h"
+
+#include "nlohmann/json.hpp"
+
+#include <cmath>
+#include <string>
+#include <utility>
+#include <vector>
+
+class EvtGen;
+class EvtParticle;
+
+class TestInfo {
+  public:
+    TestInfo( const std::string& name, const int d1, const int d2,
+              const std::string& nameY = "", const int d1Y = 0,
+              const int d2Y = 0 ) :
+        m_name{ name }, m_nameY{ nameY }, m_d1{ d1 }, m_d2{ d2 }, m_d1Y{ d1Y }, m_d2Y{ d2Y }
+    {
+    }
+
+    const std::string getName( const int var = 1 ) const
+    {
+        return var == 2 ? m_nameY : m_name;
+    }
+    int getd1( const int var = 1 ) const { return var == 2 ? m_d1Y : m_d1; }
+    int getd2( const int var = 1 ) const { return var == 2 ? m_d2Y : m_d2; }
+
+  private:
+    std::string m_name;
+    std::string m_nameY;
+    int m_d1;
+    int m_d2;
+    int m_d1Y;
+    int m_d2Y;
+};
+
+class TestDecayModel {
+  public:
+    TestDecayModel( const nlohmann::json& config );
+
+    bool run();
+
+  private:
+    bool checkMandatoryFields();
+
+    std::string createDecFile(
+        const std::string& parent, const std::vector<std::string>& daughterNames,
+        const std::vector<std::vector<std::string>>& grandDaughterNames,
+        const std::vector<std::string>& models,
+        const std::vector<std::vector<std::string>>& parameters,
+        const std::vector<bool>& doConjDecay,
+        const std::vector<std::string>& extras,
+        const std::string decFileName ) const;
+
+    void defineHistos( nlohmann::json& config, TFile* theFile );
+
+    void generateEvents( EvtGen& theGen, const std::string& decFile,
+                         const std::string& parentName, bool doConjDecay,
+                         int nEvents, bool debugFlag );
+
+    double getValue( EvtParticle* rootPart, const std::string& varName,
+                     const int d1, const int d2 ) const;
+
+    void compareHistos( const std::string& refFileName ) const;
+
+    double getCosAcoplanarityAngle( EvtParticle* selectedParent,
+                                    int sel_NDaugMax, int d1, int d2 ) const;
+
+    nlohmann::json m_config;
+    std::vector<std::pair<TestInfo, TH1D*>> m_1DhistVect;
+    std::vector<std::pair<TestInfo, TH2D*>> m_2DhistVect;
+    TH1D* m_mixedHist{ nullptr };
+};
+
+#endif