Public Member Functions | Private Member Functions | Private Attributes | List of all members
cluster::ClusterCheater Class Reference
Inheritance diagram for cluster::ClusterCheater:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 ClusterCheater (fhicl::ParameterSet const &pset)
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

void produce (art::Event &evt) override
 

Private Attributes

std::string fMCGeneratorLabel
 label for module to get MC truth information More...
 
std::string fHitModuleLabel
 label for module creating recob::Hit objects More...
 
std::string fG4ModuleLabel
 label for module running G4 and making particles, etc More...
 
unsigned int fMinHits
 minimum number of hits to make a cluster More...
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 40 of file ClusterCheater_module.cc.

Constructor & Destructor Documentation

cluster::ClusterCheater::ClusterCheater ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 78 of file ClusterCheater_module.cc.

78  : EDProducer{pset}
79  {
80  fMCGeneratorLabel = pset.get<std::string>("MCGeneratorLabel", "generator");
81  fHitModuleLabel = pset.get<std::string>("HitModuleLabel", "hit");
82  fG4ModuleLabel = pset.get<std::string>("G4ModuleLabel", "largeant");
83  fMinHits = pset.get<unsigned int>("MinHits", 1);
84 
85  produces<std::vector<recob::Cluster>>();
86  produces<art::Assns<recob::Cluster, recob::Hit>>();
87  }
std::string fMCGeneratorLabel
label for module to get MC truth information
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
unsigned int fMinHits
minimum number of hits to make a cluster
std::string fHitModuleLabel
label for module creating recob::Hit objects
std::string fG4ModuleLabel
label for module running G4 and making particles, etc

Member Function Documentation

void cluster::ClusterCheater::produce ( art::Event evt)
overrideprivatevirtual
Todo:
: The above encoding of the ID probably won't work for DUNE and should be revisited

Implements art::EDProducer.

Definition at line 91 of file ClusterCheater_module.cc.

92  {
96 
97  // grab the hits that have been reconstructed
99  evt.getByLabel(fHitModuleLabel, hitcol);
100 
101  // make a vector of them - we aren't writing anything out to a file
102  // so no need for a art::PtrVector here
103  std::vector<art::Ptr<recob::Hit>> hits;
104  art::fill_ptr_vector(hits, hitcol);
105 
106  // adopt an EmEveIdCalculator to find the eve ID.
107  // will return a primary particle if it doesn't find
108  // a responsible particle for an EM process
109  pi_serv->SetEveIdCalculator(new sim::EmEveIdCalculator);
110 
111  MF_LOG_DEBUG("ClusterCheater") << pi_serv->ParticleList();
112 
113  // make a map of vectors of art::Ptrs keyed by eveID values and
114  // location in cryostat, TPC, plane coordinates of where the hit originated
115  std::map<eveLoc, std::vector<art::Ptr<recob::Hit>>> eveHitMap;
116 
117  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
118 
119  // loop over all hits and fill in the map
120  for (auto const& itr : hits) {
121 
122  std::vector<sim::TrackIDE> eveides = bt_serv->HitToEveTrackIDEs(clockData, itr);
123 
124  // loop over all eveides for this hit
125  for (size_t e = 0; e < eveides.size(); ++e) {
126 
127  // don't worry about eve particles that contribute less than 10% of the
128  // energy in the current hit
129  if (eveides[e].energyFrac < 0.1) continue;
130 
131  eveLoc el(eveides[e].trackID, itr->WireID().planeID());
132 
133  eveHitMap[el].push_back(itr);
134 
135  } // end loop over eve IDs for this hit
136 
137  } // end loop over hits
138 
139  // loop over the map and make clusters
140  std::unique_ptr<std::vector<recob::Cluster>> clustercol(new std::vector<recob::Cluster>);
141  std::unique_ptr<art::Assns<recob::Cluster, recob::Hit>> assn(
143 
144  auto const detProp =
146  util::GeometryUtilities const gser{*geo, clockData, detProp};
147 
148  // prepare the algorithm to compute the cluster characteristics;
149  // we use the "standard" one here; configuration would happen here,
150  // but we are using the default configuration for that algorithm
151  ClusterParamsImportWrapper<StandardClusterParamsAlg> ClusterParamAlgo;
152 
153  for (auto hitMapItr : eveHitMap) {
154 
155  // ================================================================================
156  // === Only keeping clusters with fMinHits
157  // ================================================================================
158  if (hitMapItr.second.size() < fMinHits) continue;
159 
160  // get the center of this plane in world coordinates
161  double xyz[3] = {0.};
162  double xyz2[3] = {0.};
163  double local[3] = {0.};
164  unsigned int cryostat = hitMapItr.first.planeID.Cryostat;
165  unsigned int tpc = hitMapItr.first.planeID.TPC;
166  unsigned int plane = hitMapItr.first.planeID.Plane;
167  geo->Cryostat(cryostat).TPC(tpc).Plane(plane).LocalToWorld(local, xyz);
168 
169  MF_LOG_DEBUG("ClusterCheater")
170  << "make cluster for eveID: " << hitMapItr.first.eveID << " in cryostat: " << cryostat
171  << " tpc: " << tpc << " plane: " << plane << " view: " << hitMapItr.second.at(0)->View();
172 
173  // get the direction of this particle in the current cryostat, tpc and plane
174  const simb::MCParticle* part = pi_serv->TrackIdToParticle_P(hitMapItr.first.eveID);
175  if (!part) continue;
176 
177  // now set the y and z coordinates of xyz to be the first point on the particle
178  // trajectory and use the initial directions to determine the dT/dW
179  // multiply the direction cosine by 10 to give a decent lever arm for determining
180  // dW
181  xyz[1] = part->Vy();
182  xyz[2] = part->Vz();
183  xyz2[0] = xyz[0];
184  xyz2[1] = xyz[1] + 10. * part->Py() / part->P();
185  xyz2[2] = xyz[2] + 10. * part->Pz() / part->P();
186 
187  // convert positions to wire and time
188  unsigned int w1 = 0;
189  unsigned int w2 = 0;
190 
191  try {
192  w1 = geo->NearestWire(xyz, plane, tpc, cryostat);
193  }
194  catch (cet::exception& e) {
195  w1 = atoi(e.explain_self().substr(e.explain_self().find("#") + 1, 5).c_str());
196  }
197  try {
198  w2 = geo->NearestWire(xyz2, plane, tpc, cryostat);
199  }
200  catch (cet::exception& e) {
201  w2 = atoi(e.explain_self().substr(e.explain_self().find("#") + 1, 5).c_str());
202  }
203 
204  // sort the vector of hits with respect to the directionality of the wires determined by
205  if (w2 < w1)
206  std::sort(hitMapItr.second.rbegin(), hitMapItr.second.rend(), sortHitsByWire);
207  else
208  std::sort(hitMapItr.second.begin(), hitMapItr.second.end(), sortHitsByWire);
209 
210  // set the start and end wires and times
211  double startWire = hitMapItr.second.front()->WireID().Wire;
212  double startTime = hitMapItr.second.front()->PeakTimeMinusRMS();
213  double endWire = hitMapItr.second.back()->WireID().Wire;
214  double endTime = hitMapItr.second.back()->PeakTimePlusRMS();
215 
216  // add a cluster to the collection. Make the ID be the eve particle
217  // trackID*1000 + plane number*100 + tpc*10 + cryostat that the current hits are from
218  ///\todo: The above encoding of the ID probably won't work for DUNE and should be revisited
219  const geo::PlaneID& planeID = hitMapItr.first.planeID;
220  recob::Cluster::ID_t clusterID =
221  (((hitMapItr.first.eveID) * 10 + planeID.Plane) * 10 +
222  planeID.TPC // 10 is weird choice for DUNE FD... should be 1000! FIXME
223  ) *
224  10 +
225  planeID.Cryostat;
226 
227  // feed the algorithm with all the cluster hits
228  ClusterParamAlgo.ImportHits(gser, hitMapItr.second);
229 
230  // create the recob::Cluster directly in the vector
231  ClusterCreator cluster(gser,
232  ClusterParamAlgo, // algo
233  startWire, // start_wire
234  0., // sigma_start_wire
235  startTime, // start_tick
236  0., // sigma_start_tick
237  endWire, // end_wire
238  0., // sigma_end_wire
239  endTime, // end_tick
240  0., // sigma_end_tick
241  clusterID, // ID
242  hitMapItr.second.at(0)->View(), // view
243  planeID, // plane
244  recob::Cluster::Sentry // sentry
245  );
246 
247  clustercol->emplace_back(cluster.move());
248 
249  // association the hits to this cluster
250  util::CreateAssn(evt, *clustercol, hitMapItr.second, *assn);
251 
252  mf::LogInfo("ClusterCheater") << "adding cluster: \n"
253  << clustercol->back() << "\nto collection.";
254 
255  } // end loop over the map
256 
257  evt.put(std::move(clustercol));
258  evt.put(std::move(assn));
259  } // end produce
double Py(const int i=0) const
Definition: MCParticle.h:231
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
const simb::MCParticle * TrackIdToParticle_P(int id) const
void SetEveIdCalculator(sim::EveIdCalculator *ec)
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:212
Cluster finding and building.
unsigned int fMinHits
minimum number of hits to make a cluster
std::string fHitModuleLabel
label for module creating recob::Hit objects
static const SentryArgument_t Sentry
An instance of the sentry object.
Definition: Cluster.h:182
bool sortHitsByWire(art::Ptr< recob::Hit > a, art::Ptr< recob::Hit > b)
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
const double e
def move(depos, offset)
Definition: depos.py:107
double P(const int i=0) const
Definition: MCParticle.h:234
geo::WireID::WireID_t NearestWire(geo::Point_t const &point, geo::PlaneID const &planeid) const
Returns the index of wire closest to position in the specified TPC.
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:493
const sim::ParticleList & ParticleList() const
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc&#39;th TPC in the cryostat.
Definition: CryostatGeo.cxx:93
std::vector< sim::TrackIDE > HitToEveTrackIDEs(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
#define MF_LOG_DEBUG(id)
double Pz(const int i=0) const
Definition: MCParticle.h:232
double Vz(const int i=0) const
Definition: MCParticle.h:223
PlaneGeo const & Plane(geo::View_t view) const
Return the plane in the tpc with View_t view.
Definition: TPCGeo.cxx:263
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
LArSoft geometry interface.
Definition: ChannelGeo.h:16
void LocalToWorld(const double *plane, double *world) const
Transform point from local plane frame to world frame.
Definition: PlaneGeo.h:1343
double Vy(const int i=0) const
Definition: MCParticle.h:222
int ID_t
Type of cluster ID.
Definition: Cluster.h:74
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33

Member Data Documentation

std::string cluster::ClusterCheater::fG4ModuleLabel
private

label for module running G4 and making particles, etc

Definition at line 49 of file ClusterCheater_module.cc.

std::string cluster::ClusterCheater::fHitModuleLabel
private

label for module creating recob::Hit objects

Definition at line 48 of file ClusterCheater_module.cc.

std::string cluster::ClusterCheater::fMCGeneratorLabel
private

label for module to get MC truth information

Definition at line 47 of file ClusterCheater_module.cc.

unsigned int cluster::ClusterCheater::fMinHits
private

minimum number of hits to make a cluster

Definition at line 50 of file ClusterCheater_module.cc.


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