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

Public Member Functions

 CosmicClusterTagger (fhicl::ParameterSet const &p)
 
void produce (art::Event &e) override
 
- 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 Attributes

std::string fClusterModuleLabel
 
int fDetectorWidthTicks
 
int fTickLimit
 
int fMinTickDrift
 
int fMaxTickDrift
 

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 32 of file CosmicClusterTagger_module.cc.

Constructor & Destructor Documentation

cosmic::CosmicClusterTagger::CosmicClusterTagger ( fhicl::ParameterSet const &  p)
explicit

Definition at line 46 of file CosmicClusterTagger_module.cc.

46  : EDProducer{p}
47 {
48  auto const* geo = lar::providerFrom<geo::Geometry>();
49 
50  auto const clock_data = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
51  auto const detp =
53  double const samplingRate = sampling_rate(clock_data);
54  fClusterModuleLabel = p.get<std::string>("ClusterModuleLabel", "cluster");
55  fTickLimit = p.get<int>("TickLimit", 0);
56  const double driftVelocity = detp.DriftVelocity(detp.Efield(), detp.Temperature()); // cm/us
57 
59  2 * geo->DetHalfWidth() / (driftVelocity * samplingRate / 1000); // ~3200 for uB
60  fMinTickDrift = p.get("MinTickDrift", 3200);
62 
63  produces<std::vector<anab::CosmicTag>>();
64  produces<art::Assns<recob::Cluster, anab::CosmicTag>>();
65 }
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
p
Definition: test.py:223
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
LArSoft geometry interface.
Definition: ChannelGeo.h:16

Member Function Documentation

void cosmic::CosmicClusterTagger::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 68 of file CosmicClusterTagger_module.cc.

69 {
70  std::unique_ptr<std::vector<anab::CosmicTag>> cosmicTagClusterVector(
71  new std::vector<anab::CosmicTag>);
72  std::unique_ptr<art::Assns<recob::Cluster, anab::CosmicTag>> assnOutCosmicTagCluster(
74 
76  e.getByLabel(fClusterModuleLabel, Cluster_h);
77  std::vector<art::Ptr<recob::Cluster>> ClusterVec;
78  art::fill_ptr_vector(ClusterVec, Cluster_h);
79 
80  /////////////////////////////////
81  // LOOP OVER CLUSTERS
82  /////////////////////////////////
83 
84  for (unsigned int iCluster = 0; iCluster < Cluster_h->size(); iCluster++) {
85 
86  float cosmicScore = 0;
88 
89  art::Ptr<recob::Cluster> tCluster = ClusterVec.at(iCluster);
90  // art::Ptr<recob::Track> tTrack; // unused
91 
92  std::vector<float> endPt1;
93  std::vector<float> endPt2;
94 
95  // Doing some checks on the cluster to determine if it's a cosmic
96  bool failClusterTickCheck = false;
97 
98  auto const [t0, t1] = std::minmax(tCluster->StartTick(), tCluster->EndTick());
99  if (t0 + fTickLimit < fMinTickDrift) { // This is into the pre-spill window
100  failClusterTickCheck = true;
101  }
102  if (t1 - fTickLimit > fMaxTickDrift) { // This is into the post-spill window
103  failClusterTickCheck = true;
104  }
105 
106  if (failClusterTickCheck) {
107  cosmicScore = 1.;
109  }
110 
111  if (endPt1.size() < 1) {
112  for (int s = 0; s < 3; s++) {
113  endPt1.push_back(-999);
114  endPt2.push_back(-999);
115  }
116  }
117 
118  // Making stuff to save!
119  cosmicTagClusterVector->emplace_back(endPt1, endPt2, cosmicScore, tag_id);
120 
121  util::CreateAssn(e, *cosmicTagClusterVector, tCluster, *assnOutCosmicTagCluster);
122  }
123 
124  /////////////////////////////////
125  // END OF CLUSTER LOOP
126  /////////////////////////////////
127 
128  e.put(std::move(cosmicTagClusterVector));
129  e.put(std::move(assnOutCosmicTagCluster));
130 
131 } // end of produce
code to link reconstructed objects back to the MC truth information
std::pair< float, float > minmax(const float a, const float b)
minmax
enum anab::cosmic_tag_id CosmicTagID_t
float EndTick() const
Returns the tick coordinate of the end of the cluster.
Definition: Cluster.h:342
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
def move(depos, offset)
Definition: depos.py:107
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.
std::vector< gar::rec::Cluster * > ClusterVec
Definition: KNNClusterAlg.h:38
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
float StartTick() const
Returns the tick coordinate of the start of the cluster.
Definition: Cluster.h:297
static QCString * s
Definition: config.cpp:1042

Member Data Documentation

std::string cosmic::CosmicClusterTagger::fClusterModuleLabel
private

Definition at line 39 of file CosmicClusterTagger_module.cc.

int cosmic::CosmicClusterTagger::fDetectorWidthTicks
private

Definition at line 40 of file CosmicClusterTagger_module.cc.

int cosmic::CosmicClusterTagger::fMaxTickDrift
private

Definition at line 43 of file CosmicClusterTagger_module.cc.

int cosmic::CosmicClusterTagger::fMinTickDrift
private

Definition at line 42 of file CosmicClusterTagger_module.cc.

int cosmic::CosmicClusterTagger::fTickLimit
private

Definition at line 41 of file CosmicClusterTagger_module.cc.


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