Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ColliderBit/include/gambit/ColliderBit/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,16 +403,16 @@ namespace Gambit


/// Utility function for returning a collection of same-flavour, oppsosite-sign particle pairs
std::vector<std::vector<const HEPUtils::Particle*>> getSFOSpairs(std::vector<const HEPUtils::Particle*> particles);
std::vector<std::vector<const HEPUtils::Particle*>> getSFOSpairs(const std::vector<const HEPUtils::Particle*>& particles);

/// Utility function for returning a collection of oppsosite-sign particle pairs
std::vector<std::vector<const HEPUtils::Particle*>> getOSpairs(std::vector<const HEPUtils::Particle*> particles);
std::vector<std::vector<const HEPUtils::Particle*>> getOSpairs(const std::vector<const HEPUtils::Particle*>& particles);

/// Utility function for returning a collection of same-sign particle pairs
std::vector<std::vector<const HEPUtils::Particle*>> getSSpairs(std::vector<const HEPUtils::Particle*> particles);
std::vector<std::vector<const HEPUtils::Particle*>> getSSpairs(const std::vector<const HEPUtils::Particle*>& particles);

/// Utility function for returning a collection of b-tagged jets
std::vector<std::vector<const HEPUtils::Jet*>> getBJetPairs(std::vector<const HEPUtils::Jet*> bjets);
std::vector<std::vector<const HEPUtils::Jet*>> getBJetPairs(const std::vector<const HEPUtils::Jet*>& bjets);


/// @name Sorting
Expand Down
27 changes: 18 additions & 9 deletions ColliderBit/src/ColliderBit_eventloop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ namespace Gambit
max_nEvents[collider] = colOptions.getValueOrDef<int>(10000, "max_nEvents");
double mean_nEvents = colOptions.getValueOrDef<double>(10000, "mean_nEvents");
result.ratio_MC_expected[collider] = colOptions.getValueOrDef<double>(1.0, "mean_relative_nEvents");
result.estimator = colOptions.getValueOrDef<std::string>("MLE", "poisson_like_estimator");
result.estimator = colOptions.getValueOrDef<std::string>("MLE", "poisson_like_estimator");

// Check that the nEvents options given make sense.
if (fixed_nEvents and (min_nEvents.at(collider) > max_nEvents.at(collider)) )
Expand All @@ -168,6 +168,7 @@ namespace Gambit
if (colOptions.hasKey("mean_relative_nEvents"))
{
double max_lumi = GetMaxLumi(result.analyses.at(collider));

std::map<std::string, xsec_container> xsec_map = *Dep::InitialTotalCrossSection;
double xsec = xsec_map[collider].xsec();
mean_nEvents = max_lumi * xsec * result.ratio_MC_expected[collider];
Expand Down Expand Up @@ -284,20 +285,28 @@ namespace Gambit
piped_errors.check(ColliderBit_error());
piped_invalid_point.check();

const int max_nEvents_collider = max_nEvents.at(collider);
const int desired_nEvents_collider = result.desired_nEvents[collider];

// Convergence loop
while(((fixed_nEvents && result.current_event_count() < max_nEvents.at(collider)) or (!fixed_nEvents && result.current_event_count() < result.desired_nEvents[collider])) and not *Loop::done)
while(((fixed_nEvents && result.current_event_count() < max_nEvents_collider) or (!fixed_nEvents && result.current_event_count() < desired_nEvents_collider)) and not *Loop::done)
{
const int max_nEvents_val = max_nEvents.at(collider);
Comment thread
ChrisJChang marked this conversation as resolved.
Outdated
const int min_nEvents_val = min_nEvents.at(collider);
const int stoppingres_val = stoppingres.at(collider);
const int desired_nEvents_val = result.desired_nEvents[collider];

int eventCountBetweenConvergenceChecks = 0;
#ifdef COLLIDERBIT_DEBUG
cout << DEBUG_PREFIX << "Starting main event loop. Will do " << stoppingres.at(collider) << " events before testing convergence." << endl;
cout << DEBUG_PREFIX << "Starting main event loop. Will do " << stoppingres_val << " events before testing convergence." << endl;
#endif

// Main event loop
result.event_generation_began = true;
#pragma omp parallel
{
while(eventCountBetweenConvergenceChecks < stoppingres.at(collider) and
((fixed_nEvents && result.current_event_count() < max_nEvents.at(collider)) or (!fixed_nEvents && result.current_event_count() < result.desired_nEvents[collider])) and
while(eventCountBetweenConvergenceChecks < stoppingres_val and
((fixed_nEvents && result.current_event_count() < max_nEvents_val) or (!fixed_nEvents && result.current_event_count() < desired_nEvents_val)) and
not *Loop::done and
not result.end_of_event_file and
not result.exceeded_maxFailedEvents and
Expand All @@ -307,12 +316,12 @@ namespace Gambit
bool thread_do_iteration = true;
int thread_my_iteration;

// Increment counters before executing the corresponding event loop iteration,
// Increment counters before executing the corresponding event loop iteration,
// to stop other threads from starting any event iterations beyond max_nEvents.
#pragma omp critical
{
if ( (fixed_nEvents && result.current_event_count() < max_nEvents.at(collider))
or (!fixed_nEvents && result.current_event_count() < result.desired_nEvents[collider]))
if ( (fixed_nEvents && result.current_event_count() < max_nEvents_val)
or (!fixed_nEvents && result.current_event_count() < desired_nEvents_val))
{
result.current_event_count()++;
thread_my_iteration = result.current_event_count();
Expand Down Expand Up @@ -361,7 +370,7 @@ namespace Gambit

// Don't bother with convergence stuff if we haven't passed the minimum number of events yet.
// Only do this if we are using a fixed number of events.
if (fixed_nEvents and result.current_event_count() >= min_nEvents.at(collider))
if (fixed_nEvents and result.current_event_count() >= min_nEvents_val)
{
#pragma omp parallel
{
Expand Down
8 changes: 4 additions & 4 deletions ColliderBit/src/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ namespace Gambit


// Utility function for returning a collection of same-flavour, oppsosite-sign particle pairs
std::vector<std::vector<const HEPUtils::Particle*>> getSFOSpairs(std::vector<const HEPUtils::Particle*> particles)
std::vector<std::vector<const HEPUtils::Particle*>> getSFOSpairs(const std::vector<const HEPUtils::Particle*>& particles)
{
std::vector<std::vector<const HEPUtils::Particle*>> SFOSpair_container;
for (size_t ip1=0; ip1<particles.size(); ip1++)
Expand All @@ -171,7 +171,7 @@ namespace Gambit


// Utility function for returning a collection of oppsosite-sign particle pairs
std::vector<std::vector<const HEPUtils::Particle*>> getOSpairs(std::vector<const HEPUtils::Particle*> particles)
std::vector<std::vector<const HEPUtils::Particle*>> getOSpairs(const std::vector<const HEPUtils::Particle*>& particles)
{
std::vector<std::vector<const HEPUtils::Particle*>> OSpair_container;
for (size_t ip1=0;ip1<particles.size();ip1++)
Expand All @@ -192,7 +192,7 @@ namespace Gambit


// Utility function for returning a collection of same-sign particle pairs
std::vector<std::vector<const HEPUtils::Particle*>> getSSpairs(std::vector<const HEPUtils::Particle*> particles)
std::vector<std::vector<const HEPUtils::Particle*>> getSSpairs(const std::vector<const HEPUtils::Particle*>& particles)
{
std::vector<std::vector<const HEPUtils::Particle*>> SSpair_container;
for (size_t ip1=0;ip1<particles.size();ip1++)
Expand All @@ -212,7 +212,7 @@ namespace Gambit
}

// Utility function for returning a collection of b-tagged jet pairs
std::vector<std::vector<const HEPUtils::Jet*>> getBJetPairs(std::vector<const HEPUtils::Jet*> bjets)
std::vector<std::vector<const HEPUtils::Jet*>> getBJetPairs(const std::vector<const HEPUtils::Jet*>& bjets)
{
std::vector<std::vector<const HEPUtils::Jet*>> BJetpair_container;
for (size_t ibj1=0; ibj1<bjets.size(); ++ibj1)
Expand Down
17 changes: 10 additions & 7 deletions Core/src/depresolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,9 +611,10 @@ namespace Gambit
/// Evaluates ObsLike vertex, and everything it depends on, and prints results
void DependencyResolver::calcObsLike(VertexID vertex)
{
if (SortedParentVertices.find(vertex) == SortedParentVertices.end())
auto found = SortedParentVertices.find(vertex);
if (found == SortedParentVertices.end())
core_error().raise(LOCAL_INFO, "Tried to calculate a function not in or not at top of dependency graph.");
std::vector<VertexID> order = SortedParentVertices.at(vertex);
std::vector<VertexID> order = found->second;

for (const VertexID& v : order)
{
Expand Down Expand Up @@ -641,9 +642,10 @@ namespace Gambit
// pointID is supplied by the scanner, and is used to tell the printer which model
// point the results should be associated with.

if (SortedParentVertices.find(vertex) == SortedParentVertices.end())
auto found = SortedParentVertices.find(vertex);
if (found == SortedParentVertices.end())
core_error().raise(LOCAL_INFO, "Tried to calculate a function not in or not at top of dependency graph.");
std::vector<VertexID> order = SortedParentVertices.at(vertex);
std::vector<VertexID> order = found->second;

for (const VertexID& v : order)
{
Expand Down Expand Up @@ -1499,10 +1501,11 @@ namespace Gambit

// Take any dependencies of loop-managed vertices that have already been resolved,
// and add them as "hidden" dependencies to this loop manager.
if (edges_to_force_on_manager.find(entry.toVertex) != edges_to_force_on_manager.end())
auto found_edges_it = edges_to_force_on_manager.find(entry.toVertex);
if (found_edges_it != edges_to_force_on_manager.end())
{
for (auto it = edges_to_force_on_manager.at(entry.toVertex).begin();
it != edges_to_force_on_manager.at(entry.toVertex).end(); ++it)
for (auto it = found_edges_it->second.begin();
it != found_edges_it->second.end(); ++it)
{
logger() << "Dynamically adding dependency of " << masterGraph[fromVertex]->origin()
<< "::" << masterGraph[fromVertex]->name() << " on "
Expand Down
Loading
Loading