LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
SimListUtils.cxx
Go to the documentation of this file.
1 //
9 
14 
15 // Framework includes
18 
19 namespace sim {
20 
21  //----------------------------------------------------------------------
22  // moduleLabel is the label of the module that created the voxels you
23  // are putting into the list
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  }
65 
66  //----------------------------------------------------------------------
67  // moduleLabel is the label of the module that created the pmthits you
68  // are putting into the list
70  std::string moduleLabel)
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  }
103 
104 } // end namespace util
Float_t x
Definition: compare.C:6
Store parameters for running LArG4.
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:276
static sim::LArVoxelList GetLArVoxelList(const art::Event &evt, std::string moduleLabel)
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
iterator find(const key_type &key)
Definition: LArVoxelList.h:144
Monte Carlo Simulation.
std::size_t getView(std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName, std::vector< ELEMENT const * > &result) const
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
object containing MC truth information necessary for making RawDigits and doing back tracking ...
int trigger_offset(DetectorClocksData const &data)
void Add(const key_type &key, const double &energy)
Definition: LArVoxelList.h:93
TCEvent evt
Definition: DataStructs.cxx:8
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.
Collection of sim::SimPhotons, indexed by channel number.
Definition: SimPhotons.h:178
double GeVToElectrons() const
static sim::SimPhotonsCollection GetSimPhotonsCollection(const art::Event &evt, std::string moduleLabel)