LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
sim::SimListUtils Class Reference

#include "SimListUtils.h"

Static Public Member Functions

static sim::LArVoxelList GetLArVoxelList (const art::Event &evt, std::string moduleLabel)
 
static sim::SimPhotonsCollection GetSimPhotonsCollection (const art::Event &evt, std::string moduleLabel)
 

Detailed Description

Definition at line 22 of file SimListUtils.h.

Member Function Documentation

sim::LArVoxelList sim::SimListUtils::GetLArVoxelList ( const art::Event evt,
std::string  moduleLabel 
)
static

Definition at line 24 of file SimListUtils.cxx.

References sim::LArVoxelList::Add(), sim::LArVoxelList::find(), art::ProductRetriever::getView(), sim::LArG4Parameters::GeVToElectrons(), detinfo::sampling_rate(), detinfo::trigger_offset(), x, y, and z.

Referenced by evdb_tool::DrawLArVoxel3D::Draw(), evd::SimulationDrawer::MCTruth3D(), and evd::SimulationDrawer::MCTruthOrtho().

25  {
27  auto const clocks = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
28 
29  // get the sim::SimChannels
30  std::vector<const sim::SimChannel*> sccol;
31  evt.getView(moduleLabel, sccol);
32 
33  sim::LArVoxelList voxList;
34 
35  // loop over the voxels and put them into the list
36  for (auto itr = sccol.begin(); itr != sccol.end(); ++itr) {
37 
38  // get all sim::IDE associated with this channel
39  const auto& idemap = (*itr)->TDCIDEMap();
40 
41  // loop over all the sim::IDE values
42  for (auto mitr = idemap.begin(); mitr != idemap.end(); mitr++) {
43 
44  double time = (*mitr).first - trigger_offset(clocks);
45  time *= sampling_rate(clocks);
46 
47  // loop over the sim::IDE objects
48  const std::vector<sim::IDE>& ide = (*mitr).second;
49  for (size_t i = 0; i < ide.size(); ++i) {
50 
51  sim::LArVoxelID larVoxelID(ide[i].x, ide[i].y, ide[i].z, time);
52 
53  // if energy is unassigned the TrackId is sim::kNoParticleId
54  voxList.Add(larVoxelID, ide[i].numElectrons / lgp->GeVToElectrons(), ide[i].trackID);
55 
56  // set the voxel id for the just added LArVoxelData
57  (*voxList.find(larVoxelID)).second.SetVoxelID(larVoxelID);
58 
59  } // end loop over ide for this tdc
60  } // end loop over map
61  } // end loop over sim::SimChannels
62 
63  return voxList;
64  }
Float_t x
Definition: compare.C:6
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:276
iterator find(const key_type &key)
Definition: LArVoxelList.h:144
std::size_t getView(std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName, std::vector< ELEMENT const * > &result) const
int trigger_offset(DetectorClocksData const &data)
void Add(const key_type &key, const double &energy)
Definition: LArVoxelList.h:93
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:82
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
double GeVToElectrons() const
sim::SimPhotonsCollection sim::SimListUtils::GetSimPhotonsCollection ( const art::Event evt,
std::string  moduleLabel 
)
static

get the voxels from the event handle

loop over the pmthits and put them into the list

make an entry in the list for this pmt id

add the photons to the entry

Definition at line 69 of file SimListUtils.cxx.

References art::ProductRetriever::getByLabel(), and sim::SimPhotons::SetChannel().

Referenced by opdet::OptDetDigitizer::produce(), and opdet::OpMCDigi::produce().

71  {
74  evt.getByLabel(moduleLabel, pmtHandle);
75  const std::vector<sim::SimPhotons>& pmt(*pmtHandle);
76 
78  pmtList.clear();
79  // std::cout << "Building SimPhotonsCollection" << std::endl;
80 
82  for (auto itr = pmt.begin(); itr != pmt.end(); ++itr) {
83 
84  int ch = (*itr).OpChannel();
86  if (pmtList.find(ch) == pmtList.end()) {
87  // Create new photon object
88  sim::SimPhotons new_photons;
89  new_photons.clear();
90  new_photons.SetChannel(ch);
91  new_photons.reserve((*itr).size());
92  pmtList.insert(std::pair<int, sim::SimPhotons>(ch, new_photons));
93  }
94 
96  for (auto pitr = (*itr).begin(); pitr != (*itr).end(); ++pitr)
97  pmtList[ch].push_back(sim::OnePhoton((*pitr)));
98  }
99 
100  return pmtList;
101  // return std::move(pmtList);
102  }
All information of a photon entering the sensitive optical detector volume.
Definition: SimPhotons.h:60
void SetChannel(int ch)
Sets the optical detector channel number this object is associated to.
Definition: SimPhotons.h:244
Collection of photons which recorded on one channel.
Definition: SimPhotons.h:127
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Collection of sim::SimPhotons, indexed by channel number.
Definition: SimPhotons.h:178

The documentation for this class was generated from the following files: