Esempio n. 1
0
void vec_pop(pvec v) {
	if (v->destruct != NULL) {
		v->destruct(v->_data + v->size * v->_element_size);
	}
	v->size--;
	if (v->size <= v->_capacity / 2 && v->_capacity > 1) {
		byte *new_data = (byte*)malloc(v->_capacity / 2 * v->_element_size);
	    memcpy(new_data, v->_data, v->_element_size * v->size);
	    free(v->_data);
	    v->_data = new_data;
	} 
}
Esempio n. 2
0
    bool FixedListComm::add(pvec pids) {


        // ADD THE LOCAL PARTICLES
        Particle* p;
        std::vector<Particle*> tmp;
        
        pvec::iterator it = pids.begin();
        p = storage->lookupRealParticle(*it); //wrong, last particle is key
        if (!p) return false;
        tmp.push_back(p);
        
        for (++it; it!=pids.end(); ++it) {
            p = storage->lookupLocalParticle(*it);
            if (!p)
                // Particle does not exist here, return false
                return false;
            tmp.push_back(p);
        }
        //add(tmp);
        if (pids.size() == 2) this->PairList::add(tmp.at(1), tmp.at(0));
        else if (pids.size() == 3) this->TripleList::add(tmp.at(0), tmp.at(2), tmp.at(1));
        else if (pids.size() == 4) this->QuadrupleList::add(tmp.at(3), tmp.at(0), tmp.at(1), tmp.at(2));
        tmp.clear();

        // ADD THE GLOBAL PARTICLES
        longint pidK = pids.back(); // last pid is key
        pids.pop_back(); // remove last pid
        std::pair<GlobalList::const_iterator, GlobalList::const_iterator>
        equalRange = globalLists.equal_range(pidK);
        // see whether the particle already has pairs
        if (equalRange.first == globalLists.end()) {
            // it hasn't, insert the new pair
            //globalLists.insert(make_pair(pid1, pid2));
            globalLists.insert(make_pair(pidK, pids));
        }
        else {// otherwise test whether the pair already exists
            for (GlobalList::const_iterator it = equalRange.first;
            it != equalRange.second; ++it) {
                if (it->second == pids) {
                   // TODO: Pair already exists, generate error!
                }
                // if not, insert the new pair
                globalLists.insert(equalRange.first, make_pair(pidK, pids));
            }
        }
        LOG4ESPP_INFO(theLogger, "added fixed pair to global pair list");

        return true;
    }
Esempio n. 3
0
inline ttbarX identifier_GM::id_ttH_SL_bx(const pvec &p, const movec &mo)
{
    // local links to manipulate with
    const auto sz = p.size();
    double **ptr = new double *[sz];
    pair<int, int> *amo = new pair<int, int>[sz];
    int *id = new int[sz];

    for (unsigned int i = 0; i < sz; ++i) {
        id[i] = p[i].first;
        ptr[i] = p[i].second;
        amo[i] = mo[i];
    }

    // start with Higgs
    ttbarX result = id_H_bbx(id, ptr, amo, sz);

    // start leptonic top
    top_GM t1 = id_ttH_SL_bx_lep(id, ptr, amo, sz);

    // identify leptonic comps
    id_ttH_SL_bx_tlep(id, ptr, amo, sz, t1);

    // second top
    top_GM t2;
    id_ttH_SL_bx_thad(id, ptr, amo, sz, t2);

    //     // leftovers
    //     for (unsigned int i = 0; i < sz; ++i)
    //         cout << id[i] << " " << ptr[i] << " " << amo[i].first << endl;

    // place tops into container
    top_GM_to_ttbarX(t1, t2, result);

    return result;
}