Example #1
0
double Qjets::ComputeNormalization(double dmin){
  double norm(0.);
  for(list<jet_distance>::iterator it = _distances.begin(); it != _distances.end(); )
    if(JetsUnmerged(*it)){
      double inc = 0.;
      /*
	We need to be careful about dmin == 0 which happens for collinear jets.
	(Thanks go to Nhan V Tran for finding this bug)
      */
      if(dmin == 0.){
	if((*it).dij == 0.)
	  inc = 1.;
	else
	  inc = 0.;
      } else 
	inc = exp(-_rigidity*((*it).dij-dmin)/dmin);      
      
      assert(inc <= 1. && !isnan((float) inc));      
      norm += inc;          
      it++;
    } else 
      it = _distances.erase(it); 

  return norm;
}
Example #2
0
jet_distance Qjets::GetNextDistance(){
  vector< pair<jet_distance, double> > popped_distances;
  double norm(0.);
  jet_distance ret;
  ret.j1 = -1;
  ret.j2 = -1;
  ret.dij = -1.;
  bool dmin_set(false);
  double dmin(0.);

  while(!_distances.empty()){
    jet_distance dist = _distances.top();
    _distances.pop();
    if(JetsUnmerged(dist)){
      if(!dmin_set){
dmin = dist.dij;
dmin_set = true;
      }
      double weight = exp(-_rigidity * (dist.dij-dmin) /dmin);
      popped_distances.push_back(make_pair(dist,weight));
      norm += weight;
      if(weight/norm < _truncation_fctr)
break;
    }
  }
  
  double rand(Rand()), tot_weight(0.);
  for(vector<pair<jet_distance, double> >::iterator it = popped_distances.begin(); it != popped_distances.end(); it++){
    tot_weight += (*it).second/norm;
    if(tot_weight >= rand){
      ret = (*it).first;
      break;
    }
  }
  
  // repopulate in reverse (maybe quicker?)
  for(vector<pair<jet_distance, double> >::reverse_iterator it = popped_distances.rbegin(); it != popped_distances.rend(); it++)
    if(JetsUnmerged((*it).first))
      _distances.push((*it).first);

  return ret;
}
Example #3
0
double Qjets::ComputeMinimumDistance(){
  double dmin(-1.);
  for(list<jet_distance>::iterator it = _distances.begin(); it != _distances.end(); )
    if(JetsUnmerged(*it)){
      if(dmin == -1. || (*it).dij < dmin)
	dmin = (*it).dij;	      
      it++;
    } else
      it = _distances.erase(it);    
  return dmin;
}
Example #4
0
double Qjets::ComputeNormalization(double dmin) {
    double norm(0.);
    for(list<jet_distance>::iterator it = _distances.begin(); it != _distances.end(); )
        if(JetsUnmerged(*it)) {
            double inc = exp(-_rigidity*((*it).dij-dmin)/dmin);
//            assert(inc <= 1. && !std::isnan(inc));
//            assert(inc <= 1);
            if (!( inc <= 1.)) {
                std::cout << "_rigidity: " << _rigidity << std::endl;
                std::cout << "(*it).dij: " << (*it).dij << std::endl;
                std::cout << "dmin: " << dmin << std::endl;
                std::cout << "-_rigidity*((*it).dij-dmin)/dmin: " << -_rigidity*((*it).dij-dmin)/dmin << std::endl;
                std::cout << "exp(-_rigidity*((*it).dij-dmin)/dmin): " << exp(-_rigidity*((*it).dij-dmin)/dmin) << std::endl;
                assert(inc <= 1.);
            }
            assert(!std::isnan(inc));
            norm += inc;
            it++;
        } else
            it = _distances.erase(it);

    return norm;
}