LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
cluster::TrajCluster Class Reference

Produces clusters by the TrajCluster algorithm. More...

Inheritance diagram for cluster::TrajCluster:
art::EDProducer art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = ProducerBase::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 TrajCluster (fhicl::ParameterSet const &pset)
 
void reconfigure (fhicl::ParameterSet const &pset)
 
void produce (art::Event &evt) override
 
void beginJob () override
 
void endJob () override
 
template<typename PROD , BranchType B = InEvent>
ProductID getProductID (std::string const &instanceName={}) const
 
template<typename PROD , BranchType B>
ProductID getProductID (ModuleDescription const &moduleDescription, std::string const &instanceName) const
 
bool modifiesEvent () const
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > consumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > consumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > mayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > mayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

CurrentProcessingContext const * currentContext () const
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Private Attributes

std::unique_ptr< tca::TrajClusterAlgfTCAlg
 
TTree * showertree
 
TTree * crtree
 
bool fDoWireAssns
 
bool fDoRawDigitAssns
 

Detailed Description

Produces clusters by the TrajCluster algorithm.

Configuration parameters

  • HitFinderModuleLabel (InputTag, mandatory): label of the hits to be used as input (usually the label of the producing module is enough)
  • TrajClusterAlg (parameter set, mandatory): full configuration for TrajClusterAlg algorithm

Definition at line 46 of file TrajCluster_module.cc.

Member Typedef Documentation

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::EDProducer::Table = ProducerBase::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 43 of file EDProducer.h.

using art::EDProducer::WorkerType = WorkerT<EDProducer>
inherited

Definition at line 35 of file EDProducer.h.

Constructor & Destructor Documentation

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

Definition at line 109 of file TrajCluster_module.cc.

References recob::HitAndAssociationsWriterBase::declare_products(), fDoRawDigitAssns, fDoWireAssns, and reconfigure().

109  {
110 
111  reconfigure(pset);
112 
113  // let HitCollectionAssociator declare that we are going to produce
114  // hits and associations with wires and raw digits
115  // (with no particular product label)
117 
118  produces< std::vector<recob::Cluster> >();
119  produces< std::vector<recob::Vertex> >();
120  produces< std::vector<recob::EndPoint2D> >();
121  produces< std::vector<recob::Shower> >();
122  produces< art::Assns<recob::Cluster, recob::Hit> >();
123  produces< art::Assns<recob::Cluster, recob::Vertex, unsigned short> >();
124  produces< art::Assns<recob::Shower, recob::Hit> >();
125 
126  produces< std::vector<recob::PFParticle> >();
127 // produces< std::vector<recob::SpacePoint> >();
128  produces< art::Assns<recob::PFParticle, recob::Cluster> >();
129  produces< art::Assns<recob::PFParticle, recob::Shower> >();
130  produces< art::Assns<recob::PFParticle, recob::Vertex> >();
131 
132 // produces< art::Assns<recob::PFParticle, recob::SpacePoint> >();
133 // produces< art::Assns<recob::SpacePoint, recob::Hit> >();
134 
135  produces< std::vector<anab::CosmicTag>>();
136  produces< art::Assns<recob::PFParticle, anab::CosmicTag>>();
137  } // TrajCluster::TrajCluster()
static void declare_products(ModuleType &producer, std::string instance_name="", bool doWireAssns=true, bool doRawDigitAssns=true)
Declares the hit products we are going to fill.
Definition: HitCreator.h:1117
void reconfigure(fhicl::ParameterSet const &pset)

Member Function Documentation

void cluster::TrajCluster::beginJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 141 of file TrajCluster_module.cc.

References crtree, fTCAlg, art::TFileDirectory::make(), and showertree.

142  {
144 
145  showertree = tfs->make<TTree>("showervarstree", "showerVarsTree");
146  fTCAlg->DefineShTree(showertree);
147  crtree = tfs->make<TTree>("crtree", "Cosmic removal variables");
148  fTCAlg->DefineCRTree(crtree);
149  }
std::unique_ptr< tca::TrajClusterAlg > fTCAlg
T * make(ARGS...args) const
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 147 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

148 {
149  if (!moduleContext_)
150  return ProductToken<T>::invalid();
151 
152  consumables_[BT].emplace_back(ConsumableType::Product,
153  TypeID{typeid(T)},
154  it.label(),
155  it.instance(),
156  it.process());
157  return ProductToken<T>{it};
158 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 162 of file Consumer.h.

163 {
164  if (!moduleContext_)
165  return;
166 
167  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
168 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 172 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

173 {
174  if (!moduleContext_)
175  return ViewToken<T>::invalid();
176 
177  consumables_[BT].emplace_back(ConsumableType::ViewElement,
178  TypeID{typeid(T)},
179  it.label(),
180  it.instance(),
181  it.process());
182  return ViewToken<T>{it};
183 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited

Definition at line 32 of file EngineCreator.cc.

References art::EngineCreator::rng().

34 {
35  return rng()->createEngine(
36  placeholder_schedule_id(), seed, kind_of_engine_to_make);
37 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited

Definition at line 40 of file EngineCreator.cc.

References art::EngineCreator::rng().

43 {
44  return rng()->createEngine(
45  placeholder_schedule_id(), seed, kind_of_engine_to_make, engine_label);
46 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
CurrentProcessingContext const * art::EDProducer::currentContext ( ) const
protectedinherited

Definition at line 120 of file EDProducer.cc.

References art::EDProducer::current_context_.

121  {
122  return current_context_.get();
123  }
CPC_exempt_ptr current_context_
Definition: EDProducer.h:116
void cluster::TrajCluster::endJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 152 of file TrajCluster_module.cc.

References fTCAlg, tca::kKilled, art::left(), and art::right().

153  {
154  std::vector<unsigned int> const& fAlgModCount = fTCAlg->GetAlgModCount();
155  std::vector<std::string> const& fAlgBitNames = fTCAlg->GetAlgBitNames();
156  if(fAlgBitNames.size() != fAlgModCount.size()) return;
157  mf::LogVerbatim myprt("TC");
158  myprt<<"TrajCluster algorithm counts\n";
159  unsigned short icol = 0;
160  for(unsigned short ib = 0; ib < fAlgModCount.size(); ++ib) {
161  if(ib == tca::kKilled) continue;
162  myprt<<std::left<<std::setw(16)<<fAlgBitNames[ib]<<std::right<<std::setw(10)<<fAlgModCount[ib]<<" ";
163  ++icol;
164  if(icol == 4) { myprt<<"\n"; icol = 0; }
165  } // ib
166  } // endJob
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:112
std::unique_ptr< tca::TrajClusterAlg > fTCAlg
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:104
EngineCreator::seed_t EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited

Definition at line 49 of file EngineCreator.cc.

References fhicl::ParameterSet::get().

Referenced by art::MixFilter< T >::initEngine_().

52 {
53  auto const& explicit_seeds = pset.get<std::vector<int>>(key, {});
54  return explicit_seeds.empty() ? implicit_seed : explicit_seeds.front();
55 }
template<typename PROD , BranchType B>
ProductID art::EDProducer::getProductID ( std::string const &  instanceName = {}) const
inlineinherited

Definition at line 123 of file EDProducer.h.

References art::EDProducer::moduleDescription_.

124  {
125  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
126  instanceName);
127  }
ModuleDescription moduleDescription_
Definition: EDProducer.h:115
template<typename PROD , BranchType B>
ProductID art::ProducerBase::getProductID ( ModuleDescription const &  moduleDescription,
std::string const &  instanceName 
) const
inherited

Definition at line 56 of file ProducerBase.h.

References B, and art::ModuleDescription::moduleLabel().

Referenced by art::ProducerBase::modifiesEvent().

58  {
59  auto const& pd =
60  get_ProductDescription<PROD>(B, md.moduleLabel(), instanceName);
61  return pd.productID();
62  }
Int_t B
Definition: plot.C:25
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 190 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

191 {
192  if (!moduleContext_)
193  return ProductToken<T>::invalid();
194 
195  consumables_[BT].emplace_back(ConsumableType::Product,
196  TypeID{typeid(T)},
197  it.label(),
198  it.instance(),
199  it.process());
200  return ProductToken<T>{it};
201 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 205 of file Consumer.h.

206 {
207  if (!moduleContext_)
208  return;
209 
210  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
211 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 215 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

216 {
217  if (!moduleContext_)
218  return ViewToken<T>::invalid();
219 
220  consumables_[BT].emplace_back(ConsumableType::ViewElement,
221  TypeID{typeid(T)},
222  it.label(),
223  it.instance(),
224  it.process());
225  return ViewToken<T>{it};
226 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
bool art::ProducerBase::modifiesEvent ( ) const
inlineinherited

Definition at line 40 of file ProducerBase.h.

References art::ProducerBase::getProductID().

41  {
42  return true;
43  }
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited

Definition at line 89 of file Consumer.cc.

References fhicl::ParameterSet::get_if_present().

Referenced by art::EDProducer::doBeginJob(), art::EDFilter::doBeginJob(), and art::EDAnalyzer::doBeginJob().

90 {
91  if (!moduleContext_)
92  return;
93 
94  pset.get_if_present("errorOnMissingConsumes", requireConsumes_);
95  for (auto& consumablesPerBranch : consumables_) {
96  cet::sort_all(consumablesPerBranch);
97  }
98 }
bool requireConsumes_
Definition: Consumer.h:137
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
void cluster::TrajCluster::produce ( art::Event evt)
overridevirtual

Implements art::EDProducer.

Definition at line 169 of file TrajCluster_module.cc.

References tca::ClusterStore::BeginAng, tca::ClusterStore::BeginChg, tca::ClusterStore::BeginTim, tca::ClusterStore::BeginVtx, tca::ClusterStore::BeginWir, tca::ShowerStruct3D::BestPlane, util::CreateAssn(), util::CreateAssnD(), geo::CryostatID::Cryostat, tca::ClusterStore::CTP, tca::DecodeCTP(), tca::ShowerStruct3D::dEdx, tca::ShowerStruct3D::dEdxErr, DEFINE_ART_MODULE, dir, tca::ShowerStruct3D::Dir, tca::ShowerStruct3D::DirErr, evd::details::end(), tca::ClusterStore::EndAng, tca::ClusterStore::EndChg, tca::ClusterStore::EndTim, tca::ClusterStore::EndVtx, tca::ClusterStore::EndWir, tca::ShowerStruct3D::Energy, tca::ShowerStruct3D::EnergyErr, fDoRawDigitAssns, fDoWireAssns, fTCAlg, tca::ShowerStruct3D::Hits, tca::ClusterStore::ID, tca::ShowerStruct3D::ID, recob::Hit::Integral(), anab::kNotTagged, tca::ShowerStruct3D::Len, tca::ShowerStruct3D::MIPEnergy, tca::ShowerStruct3D::MIPEnergyErr, tca::ShowerStruct3D::OpenAngle, tca::ShowerStruct3D::PFPIndex, geo::PlaneID::Plane, art::errors::ProductRegistrationFailure, art::Event::put(), recob::HitRefinerAssociator::put_into(), recob::Cluster::Sentry, recob::Shower::set_dedx(), recob::Shower::set_dedx_err(), recob::Shower::set_direction(), recob::Shower::set_direction_err(), recob::Shower::set_id(), recob::Shower::set_length(), recob::Shower::set_open_angle(), recob::Shower::set_start_point(), recob::Shower::set_start_point_err(), recob::Shower::set_total_best_plane(), recob::Shower::set_total_energy(), recob::Shower::set_total_energy_err(), recob::Shower::set_total_MIPenergy(), recob::Shower::set_total_MIPenergy_err(), tca::ShowerStruct3D::Start, tca::ShowerStruct3D::StartErr, recob::Hit::SummedADC(), tca::ClusterStore::tclhits, geo::TPCID::TPC, recob::HitRefinerAssociator::use_hits(), and geo::GeometryCore::View().

170  {
171 
172  // look for clusters in all planes
173  fTCAlg->RunTrajClusterAlg(evt);
174 
175  std::unique_ptr<std::vector<recob::Hit>> newHits = std::make_unique<std::vector<recob::Hit>>(fTCAlg->YieldHits());
176 
177  std::vector<recob::Cluster> sccol;
178  std::vector<recob::PFParticle> spcol;
179 // std::vector<recob::SpacePoint> ssptcol;
180  std::vector<recob::Vertex> sv3col;
181  std::vector<recob::EndPoint2D> sv2col;
182  std::vector<recob::Shower> sscol;
183  std::vector<anab::CosmicTag> ctcol;
184 
185  std::unique_ptr<art::Assns<recob::Cluster, recob::Hit>>
186  cls_hit_assn(new art::Assns<recob::Cluster, recob::Hit>);
187  std::unique_ptr<art::Assns<recob::Cluster, recob::Vertex, unsigned short>>
189  std::unique_ptr<art::Assns<recob::Shower, recob::Hit>>
190  shwr_hit_assn(new art::Assns<recob::Shower, recob::Hit>);
191 
192  std::unique_ptr<art::Assns<recob::PFParticle, recob::Cluster>>
194  std::unique_ptr<art::Assns<recob::PFParticle, recob::Shower>>
196  std::unique_ptr<art::Assns<recob::PFParticle, recob::Vertex>>
198 /*
199  std::unique_ptr<art::Assns<recob::PFParticle, recob::SpacePoint>>
200  pfp_spt_assn(new art::Assns<recob::PFParticle, recob::SpacePoint>);
201  std::unique_ptr<art::Assns<recob::SpacePoint, recob::Hit>>
202  spt_hit_assn(new art::Assns<recob::SpacePoint, recob::Hit>);
203 */
204  std::unique_ptr<art::Assns<recob::PFParticle, anab::CosmicTag>>
206 
207  std::vector<tca::ClusterStore> const& Clusters = fTCAlg->GetClusters();
208 
209  // make EndPoints (aka 2D vertices)
210  std::vector<tca::VtxStore> const& EndPts = fTCAlg->GetEndPoints();
212  for(tca::VtxStore const& vtx2: EndPts) {
213  if(vtx2.ID == 0) continue;
214  unsigned int vtxID = vtx2.ID;
215  unsigned int wire = std::nearbyint(vtx2.Pos[0]);
216  geo::PlaneID plID = tca::DecodeCTP(vtx2.CTP);
217  geo::WireID wID = geo::WireID(plID.Cryostat, plID.TPC, plID.Plane, wire);
218  geo::View_t view = geom->View(wID);
219  sv2col.emplace_back((double)vtx2.Pos[1], // Time
220  wID, // WireID
221  0, // strength - not relevant
222  vtxID, // ID
223  view, // View
224  0); // total charge - not relevant
225  } // Endpoints
226  // convert 2D Vertex vector to unique_ptrs
227  std::unique_ptr<std::vector<recob::EndPoint2D> > v2col(new std::vector<recob::EndPoint2D>(std::move(sv2col)));
228 
229  // make 3D vertices
230  std::vector<tca::Vtx3Store> const& Vertices = fTCAlg->GetVertices();
231  double xyz[3] = {0, 0, 0};
232  for(tca::Vtx3Store const& vtx3: Vertices) {
233  // ignore incomplete vertices or obsolete
234  if(vtx3.Wire >= 0) continue;
235  if(vtx3.ID == 0) continue;
236  unsigned int vtxID = vtx3.ID;
237  xyz[0] = vtx3.X;
238  xyz[1] = vtx3.Y;
239  xyz[2] = vtx3.Z;
240  sv3col.emplace_back(xyz, vtxID);
241  } // 3D vertices
242  // convert Vertex vector to unique_ptrs
243  std::unique_ptr<std::vector<recob::Vertex> > v3col(new std::vector<recob::Vertex>(std::move(sv3col)));
244 
245  // make the clusters and associations
246  std::vector<art::Ptr<recob::Hit>> clusterHits;
247  float sumChg, sumADC;
248  std::vector<size_t> dtrIndices;
249  unsigned short clsID = 0;
250  for(size_t icl = 0; icl < Clusters.size(); ++icl) {
251  tca::ClusterStore const& clstr = Clusters[icl];
252  ++clsID;
253  geo::PlaneID planeID = tca::DecodeCTP(clstr.CTP);
254  unsigned short plane = planeID.Plane;
255  unsigned short nclhits = clstr.tclhits.size();
256 
257  sumChg = 0;
258  sumADC = 0;
259  for(unsigned short itt = 0; itt < nclhits; ++itt) {
260  unsigned int iht = clstr.tclhits[itt];
261  recob::Hit const& hit = (*newHits)[iht];
262  sumChg += hit.Integral();
263  sumADC += hit.SummedADC();
264  } // itt
265  geo::View_t view = (*newHits)[clstr.tclhits[0]].View();
266 
267  sccol.emplace_back(
268  clstr.BeginWir, // Start wire
269  0, // sigma start wire
270  clstr.BeginTim, // start tick
271  0, // sigma start tick
272  clstr.BeginChg, // start charge
273  clstr.BeginAng, // start angle
274  0, // start opening angle (0 for line-like clusters)
275  clstr.EndWir, // end wire
276  0, // sigma end wire
277  clstr.EndTim, // end tick
278  0, // sigma end tick
279  clstr.EndChg, // end charge
280  clstr.EndAng, // end angle
281  0, // end opening angle (0 for line-like clusters)
282  sumChg, // integral
283  0, // sigma integral
284  sumADC, // summed ADC
285  0, // sigma summed ADC
286  nclhits, // n hits
287  0, // wires over hits
288  0, // width (0 for line-like clusters)
289  clstr.ID, // ID from TrajClusterAlg
290  view, // view
291  planeID, // plane
292  recob::Cluster::Sentry // sentry
293  );
294  // make the cluster - hit association
295  if(!util::CreateAssn(*this, evt, *cls_hit_assn, sccol.size()-1, clstr.tclhits.begin(), clstr.tclhits.end()))
296  {
297  throw art::Exception(art::errors::ProductRegistrationFailure)<<"Failed to associate hits with cluster ID "<<clstr.ID;
298  } // exception
299 
300  // make the cluster - endpoint associations
301  unsigned short end;
302  if(clstr.BeginVtx >= 0) {
303  end = 0;
304  // See if this endpoint is associated with a 3D vertex
305  unsigned short vtxIndex = 0;
306  for(tca::Vtx3Store const& vtx3 : Vertices) {
307  // ignore killed vertices
308  if(vtx3.ID == 0) continue;
309  // ignore incomplete vertices
310  if(vtx3.Wire > 0) continue;
311  if(vtx3.Vx2ID[plane] == 0) continue;
312  if(vtx3.Vx2ID[plane] == clstr.BeginVtx) {
313  if(!util::CreateAssnD(*this, evt, *cls_vtx_assn, clsID - 1, vtxIndex, end))
314  {
315  throw art::Exception(art::errors::ProductRegistrationFailure)<<"Failed to associate cluster "<<icl<<" with vertex";
316  } // exception
317  break;
318  } // vertex match
319  ++vtxIndex;
320  } // 3D vertices
321  } // clstr.BeginVtx >= 0
322  if(clstr.EndVtx >= 0) {
323  end = 1;
324  // See if this endpoint is associated with a 3D vertex
325  unsigned short vtxIndex = 0;
326  for(tca::Vtx3Store const& vtx3 : Vertices) {
327  // ignore killed vertices
328  if(vtx3.ID == 0) continue;
329  // ignore incomplete vertices
330  if(vtx3.Wire >= 0) continue;
331  if(vtx3.Vx2ID[plane] == 0) continue;
332  if(vtx3.Vx2ID[plane] == clstr.EndVtx) {
333  if(!util::CreateAssnD(*this, evt, *cls_vtx_assn, clsID - 1, vtxIndex, end))
334  {
335  throw art::Exception(art::errors::ProductRegistrationFailure)<<"Failed to associate cluster ID "<<clsID<<" with endpoint";
336  } // exception
337  break;
338  } // vertex match
339  ++vtxIndex;
340  } // 3D vertices
341  } // clstr.BeginVtx >= 0
342  } // icl
343 
344  // Get the list of PFParticles. These are a subset of the set of 3D matches of trajectory hits
345  std::vector<tca::PFPStruct> pfpList = fTCAlg->GetPFParticles();
346 
347  // Make showers
348  std::vector<unsigned int> shwrIndices(pfpList.size(),UINT_MAX);
349  unsigned short nshower = fTCAlg->GetShowerStructSize();
350  for(unsigned short ish = 0; ish < nshower; ++ish) {
351  tca::ShowerStruct3D const& ss3 = fTCAlg->GetShowerStruct(ish);
352  if(ss3.ID == 0) continue;
354  shower.set_id(ish + 1);
355  shower.set_total_energy(ss3.Energy);
356  shower.set_total_energy_err(ss3.EnergyErr);
357  shower.set_total_MIPenergy(ss3.MIPEnergy);
359  shower.set_total_best_plane(ss3.BestPlane);
360  TVector3 dir = {ss3.Dir[0], ss3.Dir[1], ss3.Dir[2]};
361  shower.set_direction(dir);
362  TVector3 dirErr = {ss3.DirErr[0], ss3.DirErr[1], ss3.DirErr[2]};
363  shower.set_direction_err(dirErr);
364  TVector3 pos = {ss3.Start[0], ss3.Start[1], ss3.Start[2]};
365  shower.set_start_point(pos);
366  TVector3 posErr = {ss3.StartErr[0], ss3.StartErr[1], ss3.StartErr[2]};
367  shower.set_start_point_err(posErr);
368  shower.set_dedx(ss3.dEdx);
369  shower.set_dedx_err(ss3.dEdxErr);
370  shower.set_length(ss3.Len);
371  shower.set_open_angle(ss3.OpenAngle);
372  sscol.push_back(shower);
373  if(ss3.PFPIndex < shwrIndices.size()) {
374  shwrIndices[ss3.PFPIndex] = ish;
375  } else {
376 // std::cout<<"Invalid PFPIndex "<<ss3.PFPIndex<<" "<<shwrIndices.size()<<"\n";
377  }
378  // make the shower - hit association
379  if(!util::CreateAssn(*this, evt, *shwr_hit_assn, sscol.size()-1, ss3.Hits.begin(), ss3.Hits.end()))
380  {
381  throw art::Exception(art::errors::ProductRegistrationFailure)<<"Failed to associate hits with Shower";
382  } // exception
383  } // ish
384 
385  // get each of the match vector elements and construct the PFParticle
386  for(size_t ipfp = 0; ipfp < pfpList.size(); ++ipfp) {
387  auto& pfp = pfpList[ipfp];
388  if(pfp.ID == 0) continue;
389  // ignore special PFParticles (e.g. truth photons)
390  if(pfp.PDGCode == 22) continue;
391  size_t parentIndex = pfp.ID - 1;
392  std::vector<size_t> dtrIndices(pfp.DtrIDs.size());
393  for(unsigned short idtr = 0; idtr < pfp.DtrIDs.size(); ++idtr) dtrIndices[idtr] = pfp.DtrIDs[idtr] - 1;
394  spcol.emplace_back(pfp.PDGCode, ipfp, parentIndex, dtrIndices);
395  // make a list of clusters that are associated with this PFParticle. Trace the association
396  // through the trajectories that
397  std::vector<unsigned int> clsIndices;
398  for(auto tjid : pfp.TjIDs) {
399  if(tjid == 0) {
400  std::cout<<"TC: Found an invalid tj ID "<<tjid<<" in P"<<pfp.ID;
401  continue;
402  }
403  unsigned int clsIndex = fTCAlg->GetTjClusterIndex(tjid);
404  if(clsIndex > Clusters.size() - 1) {
405  std::cout<<"Retrieved an invalid cluster index for PFParticle "<<pfp.ID<<" TjID "<<tjid<<". Ignoring it...\n";
406  clsIndices.clear();
407  break;
408  }
409  clsIndices.push_back(clsIndex);
410  } // tjid
411  if(pfp.Vx3ID[0] > (int)Vertices.size()) std::cout<<"TC module: Bad Vtx3DIndex = "<<pfp.Vx3ID[0]<<" size "<<Vertices.size()<<"\n";
412 
413  // PFParticle - Cluster associations
414  if(!util::CreateAssn(*this, evt, *pfp_cls_assn, spcol.size()-1, clsIndices.begin(), clsIndices.end()))
415  {
416  throw art::Exception(art::errors::ProductRegistrationFailure)<<"Failed to associate clusters with PFParticle";
417  } // exception
418  // PFParticle - Vertex association
419  std::vector<unsigned int> vtmp(1);
420  // Translate the 3D vertex index into the index of complete 3D vertices that have been put into sv3col
421  unsigned short vtxIndex = 0;
422  for(unsigned short iv = 0; iv < Vertices.size(); ++iv) {
423  if(Vertices[iv].ID == 0) continue;
424  if(Vertices[iv].Wire >= 0) continue;
425  if(pfp.Vx3ID[0] == Vertices[iv].ID) {
426  vtmp[0] = vtxIndex;
427  if(!util::CreateAssn(*this, evt, *pfp_vtx_assn, spcol.size()-1, vtmp.begin(), vtmp.end()))
428  {
429  throw art::Exception(art::errors::ProductRegistrationFailure)<<"Failed to associate vertex with PFParticle";
430  }
431  break;
432  }
433  ++vtxIndex;
434  } // iv
435  // PFParticle - Shower associations
436  if (shwrIndices[ipfp]<UINT_MAX) {
437  if(!util::CreateAssn(*this, evt, *pfp_shwr_assn, spcol.size()-1, shwrIndices.begin()+ipfp, shwrIndices.begin()+ipfp+1))
438  {
439  throw art::Exception(art::errors::ProductRegistrationFailure)<<"Failed to associate showers with PFParticle";
440  } // exception
441  }
442  // PFParticle - CosmicTag association
443  if (fTCAlg->GetTJS().TagCosmics){
444  std::vector<float> tempPt1, tempPt2;
445  tempPt1.push_back(-999);
446  tempPt1.push_back(-999);
447  tempPt1.push_back(-999);
448  tempPt2.push_back(-999);
449  tempPt2.push_back(-999);
450  tempPt2.push_back(-999);
451  ctcol.emplace_back(tempPt1, tempPt2, pfp.CosmicScore, anab::CosmicTagID_t::kNotTagged);
452  if (!util::CreateAssn(*this, evt, spcol, ctcol, *pfp_cos_assn, ctcol.size()-1, ctcol.size())){
453  throw art::Exception(art::errors::ProductRegistrationFailure)<<"Failed to associate CosmicTag with PFParticle";
454  }
455  } // TagCosmics
456 /*
457  // Make a SpacePoint from each Tp3
458  double zeros[6] = {0};
459  double chisq = 0;
460  for(unsigned short ip3 = 0; ip3 < pfp.Tp3s.size(); ++ip3) {
461  int id = ip3 + 1;
462  auto& tp3 = pfp.Tp3s[ip3];
463  if(!tp3.IsValid) continue;
464  double xyz[3];
465  for(unsigned short ixyz = 0; ixyz < 3; ++ixyz) xyz[ixyz] = tp3.Pos[ixyz];
466  // add a space point
467  ssptcol.emplace_back(xyz, zeros, chisq, id);
468  // make a list of the hits from the trajectory points
469  std::vector<unsigned int> spthits;
470  for(auto& tj2pt : tp3.Tj2Pts) {
471  auto& tj = fTCAlg->GetTJS().allTraj[tj2pt.id - 1];
472  auto& tp = tj.Pts[tj2pt.ipt];
473  for(unsigned short ii = 0; ii < tp.Hits.size(); ++ii) {
474  if(tp.UseHit[ii]) spthits.push_back(tp.Hits[ii]);
475  }
476  } // tp2
477  // make the space point - hit association
478  if(!util::CreateAssn(*this, evt, *spt_hit_assn, ssptcol.size()-1, spthits.begin(), spthits.end()))
479  {
480  throw art::Exception(art::errors::ProductRegistrationFailure)<<"Failed to associate hits with space point in pfp "<<pfp.ID;
481  } // exception
482  } // ip3
483  // make the PFParticle - space point association
484  std::vector<unsigned int> stmp(1);
485  stmp[0] = ssptcol.size()-1;
486  if(!util::CreateAssn(*this, evt, *pfp_spt_assn, spcol.size()-1, stmp.begin(), stmp.end()))
487  {
488  throw art::Exception(art::errors::ProductRegistrationFailure)<<"Failed to associate space point with PFParticle "<<pfp.ID;
489  } // exception
490 */
491  } // ipfp
492 
493  // convert cluster vector to unique_ptrs
494  std::unique_ptr<std::vector<recob::Cluster> > ccol(new std::vector<recob::Cluster>(std::move(sccol)));
495  std::unique_ptr<std::vector<recob::PFParticle> > pcol(new std::vector<recob::PFParticle>(std::move(spcol)));
496 // std::unique_ptr<std::vector<recob::SpacePoint> > sptcol(new std::vector<recob::SpacePoint>(std::move(ssptcol)));
497  std::unique_ptr<std::vector<recob::Shower> > scol(new std::vector<recob::Shower>(std::move(sscol)));
498  std::unique_ptr<std::vector<anab::CosmicTag>> ctgcol(new std::vector<anab::CosmicTag>(std::move(ctcol)));
499 
500  // clean up
501  fTCAlg->ClearResults();
502 
503  // move the cluster collection and the associations into the event:
504  art::InputTag hitModuleLabel = fTCAlg->GetHitFinderModuleLabel();
505  recob::HitRefinerAssociator shcol(*this, evt, hitModuleLabel, fDoWireAssns, fDoRawDigitAssns);
506  shcol.use_hits(std::move(newHits));
507  shcol.put_into(evt);
508  evt.put(std::move(ccol));
509  evt.put(std::move(cls_hit_assn));
510  evt.put(std::move(v2col));
511  evt.put(std::move(v3col));
512  evt.put(std::move(scol));
513  evt.put(std::move(shwr_hit_assn));
514  evt.put(std::move(cls_vtx_assn));
515  evt.put(std::move(pcol));
516  evt.put(std::move(pfp_cls_assn));
517  evt.put(std::move(pfp_shwr_assn));
518  evt.put(std::move(pfp_vtx_assn));
519 // evt.put(std::move(sptcol));
520 // evt.put(std::move(pfp_spt_assn));
521 // evt.put(std::move(spt_hit_assn));
522  evt.put(std::move(ctgcol));
523  evt.put(std::move(pfp_cos_assn));
524  } // TrajCluster::produce()
void set_start_point_err(const TVector3 &xyz_e)
Definition: Shower.h:138
void set_dedx_err(const std::vector< double > &q)
Definition: Shower.h:140
void set_direction_err(const TVector3 &dir_e)
Definition: Shower.h:136
std::vector< unsigned int > tclhits
Definition: DataStructs.h:79
struct of temporary 2D vertices (end points)
Definition: DataStructs.h:83
std::vector< double > dEdxErr
Definition: DataStructs.h:310
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
The data type to uniquely identify a Plane.
Definition: geo_types.h:250
std::vector< double > MIPEnergy
Definition: DataStructs.h:307
void set_total_energy(const std::vector< double > &q)
Definition: Shower.h:129
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:130
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
Definition: Hit.h:225
void set_total_MIPenergy_err(const std::vector< double > &q)
Definition: Shower.h:132
void set_total_energy_err(const std::vector< double > &q)
Definition: Shower.h:130
static const SentryArgument_t Sentry
An instance of the sentry object.
Definition: Cluster.h:182
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
void set_id(const int id)
Definition: Shower.h:128
struct of temporary 3D vertices
Definition: DataStructs.h:111
void set_direction(const TVector3 &dir)
Definition: Shower.h:135
bool CreateAssnD(PRODUCER const &prod, art::Event &evt, art::Assns< T, U, D > &assn, size_t first_index, size_t second_index, typename art::Assns< T, U, D >::data_t &&data)
Creates a single one-to-one association with associated data.
void set_length(const double &l)
Definition: Shower.h:141
void set_open_angle(const double &a)
Definition: Shower.h:142
A class handling a collection of hits and its associations.
Definition: HitCreator.h:865
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:258
void set_total_best_plane(const int q)
Definition: Shower.h:133
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
std::vector< unsigned int > Hits
Definition: DataStructs.h:313
std::unique_ptr< tca::TrajClusterAlg > fTCAlg
void set_total_MIPenergy(const std::vector< double > &q)
Definition: Shower.h:131
Detector simulation of raw signals on wires.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::vector< double > EnergyErr
Definition: DataStructs.h:306
std::vector< double > MIPEnergyErr
Definition: DataStructs.h:308
TDirectory * dir
Definition: macro.C:5
std::vector< double > Energy
Definition: DataStructs.h:305
geo::PlaneID DecodeCTP(CTP_t CTP)
Definition: DataStructs.cxx:89
float SummedADC() const
The sum of calibrated ADC counts of the hit (0. by default)
Definition: Hit.h:224
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:49
unsigned short PFPIndex
Definition: DataStructs.h:318
void set_start_point(const TVector3 &xyz)
Definition: Shower.h:137
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:203
std::vector< double > dEdx
Definition: DataStructs.h:309
size_t size() const
Definition: DataViewImpl.cc:34
struct of temporary clusters
Definition: DataStructs.h:65
void set_dedx(const std::vector< double > &q)
Definition: Shower.h:139
void cluster::TrajCluster::reconfigure ( fhicl::ParameterSet const &  pset)

Definition at line 94 of file TrajCluster_module.cc.

References fDoRawDigitAssns, fDoWireAssns, fTCAlg, and fhicl::ParameterSet::get().

Referenced by TrajCluster().

95  {
96  // this trick avoids double configuration on construction
97  if (fTCAlg)
98  fTCAlg->reconfigure(pset.get< fhicl::ParameterSet >("TrajClusterAlg"));
99  else {
100  fTCAlg.reset(new tca::TrajClusterAlg(pset.get< fhicl::ParameterSet >("TrajClusterAlg")));
101  }
102 
103  fDoWireAssns = pset.get<bool>("DoWireAssns",true);
104  fDoRawDigitAssns = pset.get<bool>("DoRawDigitAssns",true);
105 
106  } // TrajCluster::reconfigure()
std::unique_ptr< tca::TrajClusterAlg > fTCAlg
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Definition at line 125 of file Consumer.cc.

Referenced by art::EDProducer::doEndJob(), art::EDFilter::doEndJob(), art::EDAnalyzer::doEndJob(), and art::RootOutput::endJob().

126 {
127  if (!moduleContext_)
128  return;
129 
130  // If none of the branches have missing consumes statements, exit early.
131  if (std::all_of(cbegin(missingConsumes_),
132  cend(missingConsumes_),
133  [](auto const& perBranch) { return perBranch.empty(); }))
134  return;
135 
136  constexpr cet::HorizontalRule rule{60};
137  mf::LogPrint log{"MTdiagnostics"};
138  log << '\n'
139  << rule('=') << '\n'
140  << "The following consumes (or mayConsume) statements are missing from\n"
141  << module_context(moduleDescription_) << '\n'
142  << rule('-') << '\n';
143 
144  cet::for_all_with_index(
145  missingConsumes_, [&log](std::size_t const i, auto const& perBranch) {
146  for (auto const& pi : perBranch) {
147  log << " "
148  << assemble_consumes_statement(static_cast<BranchType>(i), pi)
149  << '\n';
150  }
151  });
152  log << rule('=');
153 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139
void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Definition at line 101 of file Consumer.cc.

References art::errors::ProductRegistrationFailure.

103 {
104  // Early exits if consumes tracking has been disabled or if the
105  // consumed product is an allowed consumable.
106  if (!moduleContext_)
107  return;
108 
109  if (cet::binary_search_all(consumables_[bt], pi))
110  return;
111 
112  if (requireConsumes_) {
114  "Consumer: an error occurred during validation of a "
115  "retrieved product\n\n")
116  << "The following consumes (or mayConsume) statement is missing from\n"
117  << module_context(moduleDescription_) << ":\n\n"
118  << " " << assemble_consumes_statement(bt, pi) << "\n\n";
119  }
120 
121  missingConsumes_[bt].insert(pi);
122 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
bool requireConsumes_
Definition: Consumer.h:137
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139

Member Data Documentation

TTree* cluster::TrajCluster::crtree
private

Definition at line 59 of file TrajCluster_module.cc.

Referenced by beginJob().

bool cluster::TrajCluster::fDoRawDigitAssns
private

Definition at line 62 of file TrajCluster_module.cc.

Referenced by produce(), reconfigure(), and TrajCluster().

bool cluster::TrajCluster::fDoWireAssns
private

Definition at line 61 of file TrajCluster_module.cc.

Referenced by produce(), reconfigure(), and TrajCluster().

std::unique_ptr<tca::TrajClusterAlg> cluster::TrajCluster::fTCAlg
private

Definition at line 57 of file TrajCluster_module.cc.

Referenced by beginJob(), endJob(), produce(), and reconfigure().

TTree* cluster::TrajCluster::showertree
private

Definition at line 58 of file TrajCluster_module.cc.

Referenced by beginJob().


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