void MCnucl::addDensity(Nucleus* nucl, double** dens) { vector<Particle*> participant = nucl->getParticipants(); for(unsigned int ipart=0; ipart<participant.size(); ipart++) { Particle* part = participant[ipart]; Box2D partBox = part->getBoundingBox(); double x = part->getX(); double y = part->getY(); int x_idx_left = (int)((partBox.getXL() - Xmin)/dx); int x_idx_right = (int)((partBox.getXR() - Xmin)/dx); int y_idx_left = (int)((partBox.getYL() - Ymin)/dy); int y_idx_right = (int)((partBox.getYR() - Ymin)/dy); if(x_idx_left < 0 || y_idx_left < 0 || x_idx_left > Maxx || y_idx_left > Maxy) { cerr << "Wounded nucleon extends out of grid bounds " << "("<< part->getX() << "," << part->getY() << ")" << endl; } x_idx_left = max(0, x_idx_left); x_idx_right = min(Maxx, x_idx_right); y_idx_left = max(0, y_idx_left); y_idx_right = min(Maxy, y_idx_right); for(int ir = x_idx_left; ir < x_idx_right; ir++) { double xg = Xmin + ir*dx; for(int jr = y_idx_left; jr < y_idx_right; jr++) { double yg = Ymin + jr*dy; double dc = (x-xg)*(x-xg) + (y-yg)*(y-yg); if (shape_of_entropy==1) // "Checker" nucleons: { if(dc>dsq) continue; double areai = 10.0/siginNN; dens[ir][jr] += areai*participant[ipart]->getFluctfactor(); } else if (shape_of_entropy>=2 && shape_of_entropy<=9) // Gaussian nucleons: { double density; if (shape_of_entropy == 3) { density = participant[ipart]->getFluctuatedDensity(xg,yg); } else { density = participant[ipart]->getSmoothDensity(xg,yg); } dens[ir][jr] += density; } } } } }
// --- find participants from proj/target and the number of binary coll. --- int MCnucl::getBinaryCollision() { bool missingNucleus = false; // Handling for the intrinsic nucleus case if(proj->getAtomic() == 0) { vector<Particle*> nucl2 = targ->getNucleons(); missingNucleus = true; for(int i = 0; i < (int)nucl2.size(); i++){ selectFluctFactors(nucl2[i]); nucl2[i]->addCollidingParticle(nucl2[i]); targ->markWounded(nucl2[i]); } } else if(targ->getAtomic() == 0) { vector<Particle*> nucl1 = proj->getNucleons(); missingNucleus = true; for(int i = 0; i < (int)nucl1.size(); i++){ selectFluctFactors(nucl1[i]); nucl1[i]->addCollidingParticle(nucl1[i]); proj->markWounded(nucl1[i]); } } else { vector<Particle*> projNucleons = proj->getNucleons(); vector<Particle*> targNucleons = targ->getNucleons(); int startingIndex = 0; for(int iproj = 0; iproj < projNucleons.size(); iproj++) { Particle* projPart = projNucleons[iproj]; Box2D projBox = projPart->getBoundingBox(); Box2D targBox; // Skip the left most nucleons for each proj nucleon. while(startingIndex < targNucleons.size()) { targBox = targNucleons[startingIndex]->getBoundingBox(); if(targBox.getXR() >= projBox.getXL()) break; startingIndex++; } // Actually test a collision for the next ones, // until they get too far away. int i = startingIndex; while(i < targNucleons.size() && projBox.getXR() >= targBox.getXL() ) { Particle* targPart = targNucleons[i]; targBox = targPart->getBoundingBox(); if(projBox.getYL() <= targBox.getYR()) { if(projBox.getYR() >= targBox.getYL()) { // Now we know the boxes do overlap in x and y. if(hit(projPart,targPart)) { selectFluctFactors(projPart); selectFluctFactors(targPart); projPart->addCollidingParticle(targPart); targPart->addCollidingParticle(projPart); proj->markWounded(projPart); targ->markWounded(targPart); } } } i++; } // Continue loop over projBoxes } // Exit hit detection } createBinaryCollisions(); Npart1=proj->getNpart(); Npart2=targ->getNpart(); Npart1 /= overSample; Npart2 /= overSample; if(missingNucleus) return 1; else return binaryCollision.size(); }