LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
SimListUtils.cxx
Go to the documentation of this file.
1 //
9 
14 
15 // Framework includes
19 
20 namespace sim{
21 
22  //----------------------------------------------------------------------
24  {
25  }
26 
27  //----------------------------------------------------------------------
29  {
30  }
31 
32  //----------------------------------------------------------------------
33  // moduleLabel is the label of the module that created the voxels you
34  // are putting into the list
35  sim::LArVoxelList SimListUtils::GetLArVoxelList(const art::Event& evt, std::string moduleLabel)
36  {
38  const detinfo::DetectorProperties* detprop = lar::providerFrom<detinfo::DetectorPropertiesService>();
39 
40  // get the sim::SimChannels
41  std::vector<const sim::SimChannel*> sccol;
42  evt.getView(moduleLabel, sccol);
43 
44  sim::LArVoxelList voxList;
45 
46  // loop over the voxels and put them into the list
47  for(auto itr = sccol.begin(); itr != sccol.end(); ++itr){
48 
49  // get all sim::IDE associated with this channel
50  const auto &idemap = (*itr)->TDCIDEMap();
51  //std::map<unsigned short, std::vector<sim::IDE> >::const_iterator mitr;
52 
53  // loop over all the sim::IDE values
54  for(auto mitr = idemap.begin(); mitr != idemap.end(); mitr++){
55 
56  double time = (*mitr).first - detprop->TriggerOffset();
57  time *= detprop->SamplingRate();
58 
59  // loop over the sim::IDE objects
60  const std::vector<sim::IDE> &ide = (*mitr).second;
61  for(size_t i = 0; i < ide.size(); ++i){
62 
63  sim::LArVoxelID larVoxelID(ide[i].x,
64  ide[i].y,
65  ide[i].z,
66  time);
67 
68  // if energy is unassigned the TrackId is sim::kNoParticleId
69  voxList.Add(larVoxelID, ide[i].numElectrons/lgp->GeVToElectrons(), ide[i].trackID);
70 
71  // set the voxel id for the just added LArVoxelData
72  (*voxList.find(larVoxelID)).second.SetVoxelID(larVoxelID);
73 
74  }// end loop over ide for this tdc
75  }// end loop over map
76  }// end loop over sim::SimChannels
77 
78  return voxList;
79  }
80 
81  //----------------------------------------------------------------------
82  // moduleLabel is the label of the module that created the pmthits you
83  // are putting into the list
85  {
88  evt.getByLabel(moduleLabel, pmtHandle);
89  const std::vector<sim::SimPhotons>& pmt(*pmtHandle);
90 
92  pmtList.clear();
93  //std::cout << "Building SimPhotonsCollection" << std::endl;
94 
96  for(auto itr = pmt.begin(); itr != pmt.end(); ++itr){
97 
98  int ch = (*itr).OpChannel();
100  if(pmtList.find(ch) == pmtList.end()) {
101  // Create new photon object
102  sim::SimPhotons new_photons;
103  new_photons.clear();
104  new_photons.SetChannel(ch);
105  new_photons.reserve((*itr).size());
106  pmtList.insert(std::pair<int,sim::SimPhotons>(ch,new_photons));
107  }
108 
110  for(auto pitr = (*itr).begin(); pitr != (*itr).end(); ++pitr)
111  pmtList[ch].push_back(sim::OnePhoton((*pitr)));
112  }
113 
114  return pmtList;
115  //return std::move(pmtList);
116  }
117 
118 
119 }//end namespace util
Float_t x
Definition: compare.C:6
Store parameters for running LArG4.
virtual int TriggerOffset() const =0
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:279
static sim::LArVoxelList GetLArVoxelList(const art::Event &evt, std::string moduleLabel)
virtual double SamplingRate() const =0
Returns the period of the TPC readout electronics clock.
void SetChannel(int ch)
Definition: SimPhotons.h:162
std::size_t getView(std::string const &moduleLabel, std::string const &productInstanceName, std::vector< ELEMENT const * > &result) const
Definition: DataViewImpl.h:474
iterator find(const key_type &key)
Definition: LArVoxelList.h:145
Monte Carlo Simulation.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
object containing MC truth information necessary for making RawDigits and doing back tracking ...
void Add(const key_type &key, const double &energy)
Definition: LArVoxelList.h:94
double GeVToElectrons() const
static sim::SimPhotonsCollection GetSimPhotonsCollection(const art::Event &evt, std::string moduleLabel)
virtual ~SimListUtils()