LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
sim::SimListUtils Class Reference

#include "SimListUtils.h"

Public Member Functions

 SimListUtils ()
 
virtual ~SimListUtils ()
 

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 21 of file SimListUtils.h.

Constructor & Destructor Documentation

sim::SimListUtils::SimListUtils ( )

Definition at line 23 of file SimListUtils.cxx.

24  {
25  }
sim::SimListUtils::~SimListUtils ( )
virtual

Definition at line 28 of file SimListUtils.cxx.

29  {
30  }

Member Function Documentation

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

Definition at line 35 of file SimListUtils.cxx.

References sim::LArVoxelList::Add(), sim::LArVoxelList::find(), art::DataViewImpl::getView(), sim::LArG4Parameters::GeVToElectrons(), detinfo::DetectorProperties::SamplingRate(), detinfo::DetectorProperties::TriggerOffset(), x, y, and z.

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

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  }
Float_t x
Definition: compare.C:6
virtual int TriggerOffset() const =0
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:279
virtual double SamplingRate() const =0
Returns the period of the TPC readout electronics clock.
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
void Add(const key_type &key, const double &energy)
Definition: LArVoxelList.h:94
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 84 of file SimListUtils.cxx.

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

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

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  }
void SetChannel(int ch)
Definition: SimPhotons.h:162
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344

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