Skip to content

Commit

Permalink
Implement Drag Race, inspired by Dan's feature in oscialltor
Browse files Browse the repository at this point in the history
  • Loading branch information
KSkwarczynski committed Jul 3, 2024
1 parent 945dce8 commit d99d5d2
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
46 changes: 46 additions & 0 deletions mcmc/FitterBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,52 @@ void FitterBase::ProcessMCMC() {
}
}

// *************************
// Run Drag Race
void FitterBase::DragRace() {
// *************************

MACH3LOG_INFO("Let the Race Begin!");
// Reweight the MC
for(unsigned int ivs = 0; ivs < samples.size(); ivs++ )
{
double *fake = 0;
TStopwatch clockRace;
clockRace.Start();
samples[ivs]->reweight(fake);
clockRace.Stop();
MACH3LOG_INFO("It took {:.6f} s for a single reweight of sample: {}", clockRace.RealTime(), samples[ivs]->GetName());
}

for(unsigned int ivs = 0; ivs < samples.size(); ivs++ )
{
TStopwatch clockRace;
clockRace.Start();
samples[ivs]->GetLikelihood();
clockRace.Stop();
MACH3LOG_INFO("It took {:.6f} s for a single GetLikelihood of sample: {}", clockRace.RealTime(), samples[ivs]->GetName());
}


for (size_t s = 0; s < systematics.size(); ++s) {
TStopwatch clockRace;
clockRace.Start();
systematics[s]->proposeStep();
clockRace.Stop();
MACH3LOG_INFO("It took {:.6f} s for a single propose step of cov: {}", clockRace.RealTime(), systematics[s]->getName());
}

for (size_t s = 0; s < systematics.size(); ++s) {
TStopwatch clockRace;
clockRace.Start();
systematics[s]->GetLikelihood();
clockRace.Stop();
MACH3LOG_INFO("It took {:.6f} s for a single get likelihood of cov: {}", clockRace.RealTime(), systematics[s]->getName());
}
MACH3LOG_INFO("End of race");

}

// *************************
// Run LLH scan
void FitterBase::RunLLHScan() {
Expand Down
3 changes: 3 additions & 0 deletions mcmc/FitterBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class FitterBase {
/// @brief The specific fitting algorithm implemented in this function depends on the derived class. It could be Markov Chain Monte Carlo (MCMC), MinuitFit, or another algorithm.
virtual void runMCMC() = 0;

/// @brief Checks how much time we need for every sample/covariance object
void DragRace();

/// @brief Perform a 1D likelihood scan.
void RunLLHScan();

Expand Down

0 comments on commit d99d5d2

Please sign in to comment.