All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SimListUtils.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file SimListUtils.cxx
3 //
4 /// \author brebel@fnal.gov
5 ///
6 /// this class is designed to hold methods that access the event handle
7 /// to make the various simulation lists, ie ParticleList, LArVoxelList, etc
8 ////////////////////////////////////////////////////////////////////////
9 
14 
15 // Framework includes
16 #include "art/Framework/Principal/Event.h"
17 #include "art/Framework/Services/Registry/ServiceHandle.h"
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  SimListUtils::GetLArVoxelList(const art::Event& evt, std::string moduleLabel)
26  {
27  art::ServiceHandle<sim::LArG4Parameters const> lgp;
28  auto const clocks = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
29 
30  // get the sim::SimChannels
31  std::vector<const sim::SimChannel*> sccol;
32  evt.getView(moduleLabel, sccol);
33 
34  sim::LArVoxelList voxList;
35 
36  // loop over the voxels and put them into the list
37  for (auto itr = sccol.begin(); itr != sccol.end(); ++itr) {
38 
39  // get all sim::IDE associated with this channel
40  const auto& idemap = (*itr)->TDCIDEMap();
41 
42  // loop over all the sim::IDE values
43  for (auto mitr = idemap.begin(); mitr != idemap.end(); mitr++) {
44 
45  double time = (*mitr).first - trigger_offset(clocks);
46  time *= sampling_rate(clocks);
47 
48  // loop over the sim::IDE objects
49  const std::vector<sim::IDE>& ide = (*mitr).second;
50  for (size_t i = 0; i < ide.size(); ++i) {
51 
52  sim::LArVoxelID larVoxelID(ide[i].x, ide[i].y, ide[i].z, time);
53 
54  // if energy is unassigned the TrackId is sim::kNoParticleId
55  voxList.Add(larVoxelID, ide[i].numElectrons / lgp->GeVToElectrons(), ide[i].trackID);
56 
57  // set the voxel id for the just added LArVoxelData
58  (*voxList.find(larVoxelID)).second.SetVoxelID(larVoxelID);
59 
60  } // end loop over ide for this tdc
61  } // end loop over map
62  } // end loop over sim::SimChannels
63 
64  return voxList;
65  }
66 
67  //----------------------------------------------------------------------
68  // moduleLabel is the label of the module that created the pmthits you
69  // are putting into the list
71  SimListUtils::GetSimPhotonsCollection(const art::Event& evt, std::string moduleLabel)
72  {
73  /// get the voxels from the event handle
74  art::Handle<std::vector<sim::SimPhotons>> pmtHandle;
75  evt.getByLabel(moduleLabel, pmtHandle);
76  const std::vector<sim::SimPhotons>& pmt(*pmtHandle);
77 
79  pmtList.clear();
80  // std::cout << "Building SimPhotonsCollection" << std::endl;
81 
82  /// loop over the pmthits and put them into the list
83  for (auto itr = pmt.begin(); itr != pmt.end(); ++itr) {
84 
85  int ch = (*itr).OpChannel();
86  /// make an entry in the list for this pmt id
87  if (pmtList.find(ch) == pmtList.end()) {
88  // Create new photon object
89  sim::SimPhotons new_photons;
90  new_photons.clear();
91  new_photons.SetChannel(ch);
92  new_photons.reserve((*itr).size());
93  pmtList.insert(std::pair<int, sim::SimPhotons>(ch, new_photons));
94  }
95 
96  /// add the photons to the entry
97  for (auto pitr = (*itr).begin(); pitr != (*itr).end(); ++pitr)
98  pmtList[ch].push_back(sim::OnePhoton((*pitr)));
99  }
100 
101  return pmtList;
102  // return std::move(pmtList);
103  }
104 
105 } // end namespace util
Store parameters for running LArG4.
process_name opflash particleana ie ie ie z
process_name opflash particleana ie x
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:64
void SetChannel(int ch)
Sets the optical detector channel number this object is associated to.
Definition: SimPhotons.h:256
process_name opflash particleana ie ie y
iterator find(const key_type &key)
Definition: LArVoxelList.h:145
Collection of photons which recorded on one channel.
Definition: SimPhotons.h:136
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:94
TCEvent evt
Definition: DataStructs.cxx:8
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:192
static sim::SimPhotonsCollection GetSimPhotonsCollection(const art::Event &evt, std::string moduleLabel)