Skip to content

Commit

Permalink
Spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
austinschneider committed May 29, 2024
1 parent 2e84d2e commit 8a1f33c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 20 deletions.
2 changes: 1 addition & 1 deletion projects/dataclasses/public/SIREN/dataclasses/ParticleID.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <cstdint> // for uint32_t
#include <ostream> // for ostream
#include <stdexcept> // for runtime_error
#include <sstream>
#include <sstream>

#include <cereal/cereal.hpp>
#include <cereal/archives/json.hpp>
Expand Down
7 changes: 3 additions & 4 deletions projects/injection/private/TreeWeighter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <initializer_list> // for ini...
#include <iostream> // for ope...
#include <set> // for set
#include <stdexcept>
#include <stdexcept>
#include <tuple>
#include <cassert>
#include <fstream>
Expand Down Expand Up @@ -153,12 +153,11 @@ TreeWeighter::TreeWeighter(std::vector<std::shared_ptr<Injector>> injectors, std
Initialize();
}

TreeWeighter::TreeWeighter(std::vector<std::shared_ptr<Injector>> _injectors, std::string filename)
{
TreeWeighter::TreeWeighter(std::vector<std::shared_ptr<Injector>> _injectors, std::string filename) {
LoadWeighter(filename);
if(_injectors.size() > 0) {
// overwrite the serialized injectors if the user have provided any
injectors = _injectors;
injectors = _injectors;
}
Initialize();
}
Expand Down
2 changes: 1 addition & 1 deletion projects/injection/public/SIREN/injection/Injector.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ friend cereal::access;
unsigned int injected_events = 0;
std::shared_ptr<siren::utilities::SIREN_random> random;
std::shared_ptr<siren::detector::DetectorModel> detector_model;
// This funciton returns true if the given secondary index i of the datum should not be simulated
// This function returns true if the given secondary index i of the datum should not be simulated
// Defaults to no secondary interactions being saved
std::function<bool(std::shared_ptr<siren::dataclasses::InteractionTreeDatum>, size_t)> stopping_condition= [&](std::shared_ptr<siren::dataclasses::InteractionTreeDatum> datum, size_t i) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion projects/interactions/private/pybindings/pyDecay.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class pyDecay : public Decay,Pybind11Trampoline<Decay, pyDecay> {
interaction
)
}

double TotalDecayWidth(dataclasses::InteractionRecord const & interaction) const override {
SELF_OVERRIDE_PURE(
self,
Expand Down
23 changes: 10 additions & 13 deletions python/SIREN_Controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def SetProcesses(
"""
self.SetInjectionProcesses(primary_type,primary_injection_distributions,secondary_types,secondary_injection_distributions)
self.SetPhysicalProcesses(primary_type,primary_physical_distributions,secondary_types,secondary_physical_distributions)

def InputDarkNewsModel(self, primary_type, table_dir, fill_tables_at_start=False, Emax=None, **kwargs):
"""
Sets up the relevant processes and cross section/decay objects related to a provided DarkNews model dictionary.
Expand Down Expand Up @@ -318,7 +318,7 @@ def GetCylinderVolumePositionDistributionFromSector(self, sector_name):
det_rotation = geo.placement.Quaternion
det_placement = _geometry.Placement(det_position.get(), det_rotation)
cylinder = _geometry.Cylinder(det_placement,geo.Radius,geo.InnerRadius,geo.Z)
return _distributions.CylinderVolumePositionDistribution(cylinder)
return _distributions.CylinderVolumePositionDistribution(cylinder)

def GetDetectorModelTargets(self):
"""
Expand Down Expand Up @@ -411,7 +411,7 @@ def SetInteractions(
# must accept two arguments, assumes first is datum and the second is the index of the secondary particle
def SetInjectorStoppingCondition(self, stopping_condition):
self.injector.SetStoppingCondition(stopping_condition)

# Initialize the injector, either from an existing .siren_injector file or from controller injection objects
def InitializeInjector(self,filenames=None):
if type(filenames)==str:
Expand Down Expand Up @@ -443,7 +443,6 @@ def InitializeInjector(self,filenames=None):
)
self.injectors[-1].ResetInjectedEvents()
self.injector = self.injectors[0] # presume that injection happens with only the first provided injector


# Initialize the weighter, either from an existing .siren_weighter file or from controller injection objects
def InitializeWeighter(self,filename=None):
Expand All @@ -462,7 +461,6 @@ def InitializeWeighter(self,filename=None):
self.injectors,
filename
)


# Initialize the injector and weighter objects
# Use existing .siren_injector and/or .siren_weighter files if they exist
Expand All @@ -474,7 +472,7 @@ def Initialize(self, injection_filenames=None, weighter_filename=None):
# Define the weighter object
self.InitializeWeighter(filename=weighter_filename)

# Generate events using the self.injector object
# Generate events using the self.injector object
def GenerateEvents(self, N=None, fill_tables_at_exit=True):
if N is None:
N = self.events_to_inject
Expand All @@ -499,13 +497,13 @@ def LoadEvents(self, filename):
self.events = _dataclasses.LoadInteractionTrees(filename)
self.gen_times = np.zeros_like(self.events)
self.global_times = np.zeros_like(self.events)

# Save events to hdf5, parquet, and/or custom SIREN filetypes
# if the weighter exists, calculate the event weight too
def SaveEvents(self, filename, fill_tables_at_exit=True,
hdf5=True, parquet=True, siren_events=True # filetypes to save events
):

if siren_events:
_dataclasses.SaveInteractionTrees(self.events, filename)
# A dictionary containing each dataset we'd like to save
Expand Down Expand Up @@ -545,23 +543,22 @@ def SaveEvents(self, filename, fill_tables_at_exit=True,
datasets[k].append([])
# loop over interactions
for id, datum in enumerate(event.tree):

datasets["vertex"][-1].append(np.array(datum.record.interaction_vertex,dtype=float))

# primary particle stuff
datasets["primary_type"][-1].append(int(datum.record.signature.primary_type))
datasets["primary_momentum"][-1].append(np.array(datum.record.primary_momentum, dtype=float))

# check parent idx; match on secondary momenta
if datum.depth()==0:
if datum.depth()==0:
datasets["parent_idx"][-1].append(-1)
else:
for _id in range(len(datasets["secondary_momenta"][-1])):
for secondary_momentum in datasets["secondary_momenta"][-1][_id]:
if (datasets["primary_momentum"][-1][-1] == secondary_momentum).all():
datasets["parent_idx"][-1].append(_id)
break

if self.fid_vol is not None:
pos = _math.Vector3D(datasets["vertex"][-1][-1])
dir = _math.Vector3D(datasets["primary_momentum"][-1][-1][1:])
Expand All @@ -572,7 +569,7 @@ def SaveEvents(self, filename, fill_tables_at_exit=True,

# target particle stuff
datasets["target_type"][-1].append(int(datum.record.signature.target_type))

# secondary particle stuff
datasets["secondary_types"][-1].append([])
datasets["secondary_momenta"][-1].append([])
Expand All @@ -599,7 +596,7 @@ def SaveEvents(self, filename, fill_tables_at_exit=True,
fout.close()
if parquet:
ak.to_parquet(ak_array,filename+".parquet")

# save darknews cross section tables
if hasattr(self, "DN_processes"):
self.DN_processes.SaveCrossSectionTables(fill_tables_at_exit=fill_tables_at_exit)

0 comments on commit 8a1f33c

Please sign in to comment.