Skip to content

Commit

Permalink
Merge pull request #149 from DUNE/kleykamp_fix_nersc_pileup
Browse files Browse the repository at this point in the history
Fix spillPeriod_s to match overlaySinglesIntoSpillsSorted
  • Loading branch information
LiamOS authored Sep 9, 2024
2 parents 78ad98a + 62232f6 commit e942855
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
12 changes: 9 additions & 3 deletions app/ConvertToTMSTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,18 @@ bool ConvertToTMSTree(std::string filename, std::string output_filename) {
std::vector<TMS_Event> overlay_events;

bool NerscOverlay = false;
TParameter<float>* spillPeriod_s = (TParameter<float>*)input->Get("spillPeriod_s");
TParameter<double>* spillPeriod_s = (TParameter<double>*)input->Get("spillPeriod_s");
if (spillPeriod_s != NULL) NerscOverlay = true;
double SpillPeriod = 0;
if (NerscOverlay) {
std::cout<<"Combining spills"<<std::endl;
SpillPeriod = spillPeriod_s->GetVal() * 1e9; // convert to ns
std::cout<<"Found spillSeriod_s of "<<SpillPeriod<<"ns"<<std::endl;
if (SpillPeriod < 1e7 || SpillPeriod > 1e11) {
std::cout<<"Fatal: Found spillSeriod_s that is unusually high or low. Expecting something like ~1.2e9 ns"<<std::endl;
exit(1);
}
TMS_Manager::GetInstance().Set_Nersc_Spill_Period(SpillPeriod);
std::cout<<"Found spillSeriod_s of "<<SpillPeriod<<std::endl;
}
int current_spill_number = 0;

Expand Down Expand Up @@ -130,7 +134,7 @@ bool ConvertToTMSTree(std::string filename, std::string output_filename) {

// Keep filling up the vector if within spill
if (NerscOverlay) {
double next_spill_time = (current_spill_number + 0.5) * SpillPeriod;
double next_spill_time = (current_spill_number + 0.5) * TMS_Manager::GetInstance().Get_Nersc_Spill_Period();
double current_spill_time = event->Primaries.begin()->Position.T();
// Check that this neutrino is within spill, but not last event
if (current_spill_time < next_spill_time && i != N_entries - 1) {
Expand All @@ -149,8 +153,10 @@ bool ConvertToTMSTree(std::string filename, std::string output_filename) {
overlay_events.pop_back();
for (auto &event : overlay_events) last_event.AddEvent(event);
overlay_events.clear();
// Now add this event as the first event in the next set
overlay_events.push_back(tms_event);
if (NerscOverlay) current_spill_number += 1;
// ... and make this event the combined spill called "last_event"
tms_event = last_event;
}

Expand Down
5 changes: 5 additions & 0 deletions scripts/Validation/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ SRCS = $(wildcard *.cpp)
OBJS = $(SRCS:.cpp=.o)
EXEC = $(SRCS:.cpp=)

BRANCH_NAME := $(shell git rev-parse --abbrev-ref HEAD)
GIT_STATUS := $(shell git diff-index --quiet HEAD -- src/ app/ || echo "-modified")

CXXFLAGS += -DGIT_BRANCH_NAME=\"$(BRANCH_NAME)$(GIT_STATUS)\"

.PHONY: all clean

all: $(EXEC)
Expand Down
4 changes: 2 additions & 2 deletions scripts/Validation/Tracking_Validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Long64_t PrimaryLoop(Truth_Info& truth, Reco_Tree& reco, Line_Candidates& lc, in
// First draw some hists for validation
TH1D hist_ntracks("n_tracks", "N Tracks;N Tracks;N Events",
10, -0.5, 9.5);
TH1D hist_nhits("n_hits", "N Hits;N Hits;N Tracks",
TH1D hist_nhits("n_hits", "N Hits per Track;N Hits;N Tracks",
25, 0, 100);
TH1D hist_energy_range("energy_range", "Energy Range;Energy Range (MeV);N Tracks",
20, 0, 5000);
Expand Down Expand Up @@ -467,7 +467,7 @@ int main(int argc, char* argv[]) {
}

// Create output filename
std::string outputFilename = directoryPath + getOutputFilename(inputFilename);
std::string outputFilename = directoryPath + GIT_BRANCH_NAME + "_" + getOutputFilename(inputFilename);

// Create TFile with the output filename
TFile outputFile(outputFilename.c_str(), "RECREATE");
Expand Down

0 comments on commit e942855

Please sign in to comment.