float MelaReweighterWW::weightStoH(){

  //setupDaughters(_isVBF, id_l1, id_l2, id_n1, id_n2, l1, l2, n1, n2, associated, idsAssociated);
 
  float meSpow;
  _mela->setProcess(TVar::HSMHiggs, TVar::MCFM, _isVBF ? TVar::JJVBF_S : TVar::ZZGG);
  // Added here -- U. Sarica
  _mela->setMelaHiggsMassWidth(_mpole, _width, 0);
  //
  if (!_isVBF)
    _mela->computeP(meSpow, false);
  else
    _mela->computeProdDecP(meSpow, false);

  float meH;
  _mela->setProcess(TVar::HSMHiggs, TVar::MCFM, _isVBF ? TVar::JJVBF : TVar::ZZGG);
  //Added here -- U. Sarica
  _mela->setMelaHiggsMassWidth(125., 4.07e-3, 0);
  //
  if (!_isVBF)
    _mela->computeP(meH, false);
  else
    _mela->computeProdDecP(meH, false);


  //_mela->resetInputEvent();

  //std::cout << "### meS = " << meS << " meSpow = " << meSpow << " meB = " << meB << " meSBI = " << meSBI << std::endl;
  //std::cout << "### weight = " << (meSBI-meS-meB)/meSpow << std::endl;

  return (meH)/meSpow;
}
float MelaReweighterWW::weightStoSBI(){    
  
  //setupDaughters(isVBF, id_l1, id_l2, id_n1, id_n2, l1, l2, n1, n2, associated, idsAssociated);

  float meS;
  _mela->setProcess(TVar::HSMHiggs, TVar::MCFM, _isVBF ? TVar::JJVBF_S : TVar::ZZGG);
  // Added here -- U. Sarica
  _mela->setMelaHiggsMassWidth(_mpole, _width, 0);
  _mela->setMelaHiggsMassWidth(125., 4.07e-3, 1);
  //
  if (!_isVBF)
    _mela->computeP(meS, false);
  else
    _mela->computeProdDecP(meS, false);
  float meSBI;
  _mela->setProcess(TVar::bkgWW_SMHiggs, TVar::MCFM, _isVBF ? TVar::JJEW : TVar::ZZGG);
  // Added here -- U. Sarica
  _mela->setMelaHiggsMassWidth(_mpole, _width, 0);
  _mela->setMelaHiggsMassWidth(125., 4.07e-3, 1);
  //
  if (!_isVBF)
    _mela->computeP(meSBI, false);
  else
    _mela->computeProdDecP(meSBI, false);
  
  _mela->resetInputEvent();  
  return meSBI/meS;
}
float getJHUGenMELAWeight(Mela& myMela, int lepId[4], float angularOrdered[8], double selfDHvvcoupl[SIZE_HVV][2]){
	float myprob=1.0;
	int myflavor=-1;
	if(abs(lepId[0])==abs(lepId[1]) &&
		abs(lepId[0])==abs(lepId[2]) &&
		abs(lepId[0])==abs(lepId[3])){
			if(abs(lepId[0])==11) myflavor=1;
			else myflavor=2;
	}
	else myflavor=3;

	if(myflavor>=0) myMela.computeP(angularOrdered[0],angularOrdered[1],angularOrdered[2],angularOrdered[3],
		angularOrdered[4],angularOrdered[5],angularOrdered[6],angularOrdered[7],
	    myflavor,
	    selfDHvvcoupl,
	    myprob
		);
	return myprob;
};
float getMCFMMELAWeight(Mela& myMela, int lepId[4], float angularOrdered[8], double ggcoupl[2],int useConstant=0){
	float myprob=1.0;
	int myflavor=-1;
	if(abs(lepId[0])==abs(lepId[1]) &&
		abs(lepId[0])==abs(lepId[2]) &&
		abs(lepId[0])==abs(lepId[3])){
			if(abs(lepId[0])==11) myflavor=1;
			else myflavor=2;
	}
	else myflavor=3;

	if(myflavor>=0) myMela.computeP(angularOrdered[0],angularOrdered[1],angularOrdered[2],angularOrdered[3],
		angularOrdered[4],angularOrdered[5],angularOrdered[6],angularOrdered[7],
	    myflavor,
	    myprob,
		useConstant
		);
	return myprob;
};