LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
vertex::VertexFinder2D Class Reference
Inheritance diagram for vertex::VertexFinder2D:
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

 VertexFinder2D (fhicl::ParameterSet const &pset)
 
virtual ~VertexFinder2D ()
 
void beginJob ()
 
void reconfigure (fhicl::ParameterSet const &p)
 
void produce (art::Event &evt)
 
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

TH1D * dtIC
 
std::string fClusterModuleLabel
 

Detailed Description

Definition at line 76 of file VertexFinder2D_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

vertex::VertexFinder2D::VertexFinder2D ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 101 of file VertexFinder2D_module.cc.

102  {
103  this->reconfigure(pset);
104  produces< std::vector<recob::Vertex> >();
105  produces< std::vector<recob::EndPoint2D> >();
106  produces< art::Assns<recob::EndPoint2D, recob::Hit> >();
107  produces< art::Assns<recob::Vertex, recob::Hit> >();
108  produces< art::Assns<recob::Vertex, recob::Shower> >();
109  produces< art::Assns<recob::Vertex, recob::Track> >();
110  }
void reconfigure(fhicl::ParameterSet const &p)
vertex::VertexFinder2D::~VertexFinder2D ( )
virtual

Definition at line 112 of file VertexFinder2D_module.cc.

113  {
114  }

Member Function Documentation

void vertex::VertexFinder2D::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 123 of file VertexFinder2D_module.cc.

References art::TFileDirectory::make().

123  {
124  // get access to the TFile service
126  dtIC = tfs->make<TH1D>("dtIC","It0-Ct0",100,-5,5);
127  dtIC->Sumw2();
128  }
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
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 vertex::VertexFinder2D::produce ( art::Event evt)
virtual
Todo:
should really get the actual vector of hits corresponding to end point
Todo:
for now will get all hits from the current cluster
Todo:
need to actually make tracks and showers to go into 3D vertex
Todo:
currently just passing empty collections to the ctor
Todo:
uncomment following lines when the shower vector actually contains showers from the art::Event
Todo:
uncomment following lines when the track vector actually contains tracks from the art::Event

Implements art::EDProducer.

Definition at line 131 of file VertexFinder2D_module.cc.

References evd::details::begin(), c1, c2, geo::GeometryCore::ChannelsIntersect(), detinfo::DetectorProperties::ConvertTicksToX(), util::CreateAssn(), DEFINE_ART_MODULE, geo::GeometryCore::DetHalfHeight(), detinfo::DetectorProperties::DriftVelocity(), detinfo::DetectorProperties::Efield(), evd::details::end(), art::DataViewImpl::getByLabel(), geo::GeometryCore::GetLArTPCVolumeName(), hits(), CluLen::index, geo::kU, geo::kV, geo::kZ, CluLen::length, LOG_VERBATIM, min, myfunction(), n, geo::GeometryCore::Plane(), geo::GeometryCore::PlaneWireToChannel(), art::PtrVector< T >::push_back(), art::Event::put(), detinfo::DetectorProperties::SamplingRate(), art::PtrVector< T >::size(), SortByWire(), t1, t2, detinfo::DetectorProperties::Temperature(), geo::WireGeo::ThetaZ(), detinfo::DetectorProperties::TriggerOffset(), geo::GeometryCore::Views(), geo::PlaneGeo::Wire(), geo::GeometryCore::WirePitch(), and zz.

132  {
133 
134 
136  const detinfo::DetectorProperties* detprop = lar::providerFrom<detinfo::DetectorPropertiesService>();
137  // define TPC parameters
138  TString tpcName = geom->GetLArTPCVolumeName();
139 
140  double YC = (geom->DetHalfHeight())*2.;
141 
142  // wire angle with respect to the vertical direction
143  double Angle = geom->Plane(1).Wire(0).ThetaZ(false)-TMath::Pi()/2.;
144 
145  // Parameters temporary defined here, but possibly to be retrieved somewhere in the code
146  double timetick = detprop->SamplingRate()*1.e-3; //time sample in us
147  double presamplings = detprop->TriggerOffset(); //trigger offset
148 
149  double wire_pitch = geom->WirePitch(); //wire pitch in cm
150  double Efield_drift = detprop->Efield(); // Electric Field in the drift region in kV/cm
151  double Temperature = detprop->Temperature(); // LAr Temperature in K
152 
153  //drift velocity in the drift region (cm/us)
154  double driftvelocity = detprop->DriftVelocity(Efield_drift,Temperature);
155 
156  //time sample (cm)
157  double timepitch = driftvelocity*timetick;
158 
159  art::Handle< std::vector<recob::Cluster> > clusterListHandle;
160  evt.getByLabel(fClusterModuleLabel,clusterListHandle);
161 
163  for (unsigned int ii = 0; ii < clusterListHandle->size(); ++ii){
164  art::Ptr<recob::Cluster> clusterHolder(clusterListHandle,ii);
165  clusters.push_back(clusterHolder);
166  }
167 
168  art::FindManyP<recob::Hit> fmh(clusterListHandle, evt, fClusterModuleLabel);
169 
170  //Point to a collection of vertices to output.
171  std::unique_ptr<std::vector<recob::Vertex> > vcol(new std::vector<recob::Vertex>); //3D vertex
172  std::unique_ptr<std::vector<recob::EndPoint2D> > epcol(new std::vector<recob::EndPoint2D>); //2D vertex
173  std::unique_ptr< art::Assns<recob::EndPoint2D, recob::Hit> > assnep(new art::Assns<recob::EndPoint2D, recob::Hit>);
174  std::unique_ptr< art::Assns<recob::Vertex, recob::Shower> > assnsh(new art::Assns<recob::Vertex, recob::Shower>);
175  std::unique_ptr< art::Assns<recob::Vertex, recob::Track> > assntr(new art::Assns<recob::Vertex, recob::Track>);
176  std::unique_ptr< art::Assns<recob::Vertex, recob::Hit> > assnh(new art::Assns<recob::Vertex, recob::Hit>);
177 
178  // nplanes here is really being used as a proxy for the
179  // number of views in the detector
180  int nplanes = geom->Views().size();
181 
182  std::vector< std::vector<int> > Cls(nplanes); //index to clusters in each view
183  std::vector< std::vector<CluLen> > clulens(nplanes);
184 
185  std::vector<double> dtdwstart;
186 
187  //loop over clusters
188  for(size_t iclu = 0; iclu < clusters.size(); ++iclu){
189 
190  float w0 = clusters[iclu]->StartWire();
191  float w1 = clusters[iclu]->EndWire();
192  float t0 = clusters[iclu]->StartTick();
193  float t1 = clusters[iclu]->EndTick();
194 // t0 -= detprop->GetXTicksOffset(clusters[iclu]->View(),0,0);
195 // t1 -= detprop->GetXTicksOffset(clusters[iclu]->View(),0,0);
196 
197  CluLen clulen;
198  clulen.index = iclu;
199  clulen.length = sqrt(pow((w0-w1)*wire_pitch,2)+pow(detprop->ConvertTicksToX(t0,clusters[iclu]->View(),0,0)-detprop->ConvertTicksToX(t1,clusters[iclu]->View(),0,0),2));
200 
201  switch(clusters[iclu]->View()){
202 
203  case geo::kU :
204  clulens[0].push_back(clulen);
205  break;
206  case geo::kV :
207  clulens[1].push_back(clulen);
208  break;
209  case geo::kZ :
210  clulens[2].push_back(clulen);
211  break;
212  default :
213  break;
214  }
215 
216  std::vector<double> wires;
217  std::vector<double> times;
218 
219  std::vector< art::Ptr<recob::Hit> > hit = fmh.at(iclu);
220  std::sort(hit.begin(), hit.end(), SortByWire());
221  int n = 0;
222  for(size_t i = 0; i < hit.size(); ++i){
223  wires.push_back(hit[i]->WireID().Wire);
224  times.push_back(hit[i]->PeakTime());
225  ++n;
226  }
227  if(n>=2){
228  TGraph *the2Dtrack = new TGraph(std::min(10,n),&wires[0],&times[0]);
229  try{
230  the2Dtrack->Fit("pol1","Q");
231  TF1 *pol1=(TF1*) the2Dtrack->GetFunction("pol1");
232  double par[2];
233  pol1->GetParameters(par);
234  //std::cout<<iclu<<" "<<par[1]<<" "<<clusters[iclu]->dTdW()<<std::endl;
235  dtdwstart.push_back(par[1]);
236  }
237  catch(...){
238  mf::LogWarning("VertexFinder2D") << "Fitter failed";
239  delete the2Dtrack;
240  dtdwstart.push_back(std::tan(clusters[iclu]->StartAngle()));
241  continue;
242  }
243  delete the2Dtrack;
244  }
245  else dtdwstart.push_back(std::tan(clusters[iclu]->StartAngle()));
246 
247  }
248 
249  //sort clusters based on 2D length
250  for (size_t i = 0; i<clulens.size(); ++i){
251  std::sort (clulens[i].begin(),clulens[i].end(), myfunction);
252  for (size_t j = 0; j<clulens[i].size(); ++j){
253  Cls[i].push_back(clulens[i][j].index);
254  }
255  }
256 
257  std::vector< std::vector<int> > cluvtx(nplanes);
258  std::vector<double> vtx_w;
259  std::vector<double> vtx_t;
260 
261  for (int i = 0; i < nplanes; ++i){
262  if (Cls[i].size() >= 1){
263  //at least one cluster
264  //find the longest two clusters
265  int c1 = -1;
266  int c2 = -1;
267  double ww0 = -999;
268  double wb1 = -999;
269  double we1 = -999;
270  double wb2 = -999;
271  double we2 = -999;
272  double tt1 = -999;
273  double tt2 = -999;
274  double dtdw1 = -999;
275  double dtdw2 = -999;
276  double lclu1 = -999;
277  double lclu2 = -999;
278  for (unsigned j = 0; j<Cls[i].size(); ++j){
279  double lclu = std::sqrt(pow((clusters[Cls[i][j]]->StartWire()-clusters[Cls[i][j]]->EndWire())*13.5,2)
280  +pow(clusters[Cls[i][j]]->StartTick()-clusters[Cls[i][j]]->EndTick(),2));
281  bool rev = false;
282  bool deltaraylike = false;
283  bool enoughhits = false;
284  if (c1 != -1){
285  double wb = clusters[Cls[i][j]]->StartWire();
286  double we = clusters[Cls[i][j]]->EndWire();
287  double tt = clusters[Cls[i][j]]->StartTick();
288  double dtdw = dtdwstart[Cls[i][j]];
289  int nhits = fmh.at(Cls[i][j]).size();
290  ww0 = (tt-tt1+dtdw1*wb1-dtdw*wb)/(dtdw1-dtdw);
291  if (std::abs(wb1-ww0) > std::abs(we1-ww0)) rev = true;//reverse cluster dir
292  if ((!rev && ww0 > wb1+15)||(rev && ww0 < we1-15)) deltaraylike = true;
293  if (((!rev && ww0 > wb1+10)||(rev && ww0 < we1-10)) && nhits < 5) deltaraylike = true;
294  if (wb > wb1+20 && nhits < 20) deltaraylike = true;
295  if (wb > wb1+50 && nhits < 20) deltaraylike = true;
296  if (wb > wb1+8 && TMath::Abs(dtdw1-dtdw) < 0.15) deltaraylike = true;
297  if (std::abs(wb-wb1) > 30 && std::abs(we-we1) > 30) deltaraylike = true;
298  if (std::abs(tt-tt1) > 100) deltaraylike = true; //not really deltaray, but isolated cluster
299  //make sure there are enough hits in the cluster
300  //at leaset 2 hits if goes horizentally, at leaset 4 hits if goes vertically
301  double alpha = std::atan(dtdw);
302  if (nhits >= int(2+3*(1-std::abs(std::cos(alpha))))) enoughhits = true;
303  if (nhits < 5 && (ww0 < wb1-20 || ww0 > we1+20)) enoughhits = false;
304 
305  }
306  //do not replace the second cluster if the 3rd cluster is not consistent with the existing 2
307  bool replace = true;
308  if (c1 != -1 && c2 != -1){
309  double wb = clusters[Cls[i][j]]->StartWire();
310  double we = clusters[Cls[i][j]]->EndWire();
311  ww0 = (tt2-tt1+dtdw1*wb1-dtdw2*wb2)/(dtdw1-dtdw2);
312  if ((std::abs(ww0-wb1) < 10 || std::abs(ww0-we1) < 10) &&
313  (std::abs(ww0-wb2) < 10 || std::abs(ww0-we2) < 10)){
314  if (std::abs(ww0-wb) > 15 && std::abs(ww0-we) > 15) replace = false;
315  }
316  //std::cout<<c1<<" "<<c2<<" "<<ww0<<" "<<wb1<<" "<<wb2<<" "<<wb<<" "<<we<<std::endl;
317  }
318  if (lclu1 < lclu){
319  if (c1 != -1 && !deltaraylike && enoughhits){
320  lclu2 = lclu1;
321  c2 = c1;
322  wb2 = wb1;
323  we2 = we1;
324  tt2 = tt1;
325  dtdw2 = dtdw1;
326  }
327  lclu1 = lclu;
328  c1 = Cls[i][j];
329  wb1 = clusters[Cls[i][j]]->StartWire();
330  we1 = clusters[Cls[i][j]]->EndWire();
331  tt1 = clusters[Cls[i][j]]->StartTick();
332  if (wb1>we1){
333  wb1 = clusters[Cls[i][j]]->EndWire();
334  we1 = clusters[Cls[i][j]]->StartWire();
335  tt1 = clusters[Cls[i][j]]->EndTick();
336  }
337  dtdw1 = dtdwstart[Cls[i][j]];
338  }
339  else if (lclu2 < lclu){
340  if (!deltaraylike && enoughhits && replace){
341  lclu2 = lclu;
342  c2 = Cls[i][j];
343  wb2 = clusters[Cls[i][j]]->StartWire();
344  we2 = clusters[Cls[i][j]]->EndWire();
345  tt2 = clusters[Cls[i][j]]->StartTick();
346  dtdw2 = dtdwstart[Cls[i][j]];
347  }
348  }
349  }
350  if (c1 != -1 && c2 != -1){
351  cluvtx[i].push_back(c1);
352  cluvtx[i].push_back(c2);
353 
354  double w1 = clusters[c1]->StartWire();
355  double t1 = clusters[c1]->StartTick();
356  if (clusters[c1]->StartWire()>clusters[c1]->EndWire()){
357  w1 = clusters[c1]->EndWire();
358  t1 = clusters[c1]->EndTick();
359  }
360  double k1 = dtdwstart[c1];
361  double w2 = clusters[c2]->StartWire();
362  double t2 = clusters[c2]->StartTick();
363  if (clusters[c2]->StartWire()>clusters[c2]->EndWire()){
364  w1 = clusters[c2]->EndWire();
365  t1 = clusters[c2]->EndTick();
366  }
367  double k2 = dtdwstart[c2];
368 // std::cout<<c1<<" "<<w1<<" "<<t1<<" "<<k1<<" "<<std::endl;
369 // std::cout<<c2<<" "<<w2<<" "<<t2<<" "<<k2<<" "<<std::endl;
370  //calculate the vertex
371  if (std::abs(k1-k2) < 0.5){
372  vtx_w.push_back(w1);
373  vtx_t.push_back(t1);
374  }
375  else{
376  double t0 = (k1*k2*(w1-w2)+k1*t2-k2*t1)/(k1-k2);
377  double w0 = (t2-t1+k1*w1-k2*w2)/(k1-k2);
378  vtx_w.push_back(w0);
379  vtx_t.push_back(t0);
380  }
381  }
382  else if (Cls[i].size() >= 1){
383  if (c1 != -1){
384  cluvtx[i].push_back(c1);
385  vtx_w.push_back(wb1);
386  vtx_t.push_back(tt1);
387  }
388  else{
389  cluvtx[i].push_back(Cls[i][0]);
390  vtx_w.push_back(clusters[Cls[i][0]]->StartWire());
391  vtx_t.push_back(clusters[Cls[i][0]]->StartTick());
392  }
393  }
394  //save 2D vertex
395  // make an empty art::PtrVector of hits
398  std::vector< art::Ptr<recob::Hit> > hits = fmh.at(Cls[i][0]);
399  double totalQ = 0.;
400  for(size_t h = 0; h < hits.size(); ++h) totalQ += hits[h]->Integral();
401 
402  geo::WireID wireID(hits[0]->WireID().Cryostat,
403  hits[0]->WireID().TPC,
404  hits[0]->WireID().Plane,
405  (unsigned int)vtx_w.back()); //for update to EndPoint2D ... WK 4/22/13
406 
407  recob::EndPoint2D vertex(vtx_t.back(),
408  wireID, //for update to EndPoint2D ... WK 4/22/13
409  1,
410  epcol->size(),
411  clusters[Cls[i][0]]->View(),
412  totalQ);
413  epcol->push_back(vertex);
414 
415  util::CreateAssn(*this, evt, *epcol, hits, *assnep);
416 
417  }
418  else{
419  //no cluster found
420  vtx_w.push_back(-1);
421  vtx_t.push_back(-1);
422  }
423  }
424  //std::cout<<vtx_w[0]<<" "<<vtx_t[0]<<" "<<vtx_w[1]<<" "<<vtx_t[1]<<std::endl;
425 
426  Double_t vtxcoord[3];
427  if (Cls[0].size()>0&&Cls[1].size()>0){//ignore w view
428  double Iw0 = (vtx_w[0]+3.95)*wire_pitch;
429  double Cw0 = (vtx_w[1]+1.84)*wire_pitch;
430 
431  double It0 = vtx_t[0] - presamplings;
432  It0 *= timepitch;
433  double Ct0 = vtx_t[1] - presamplings ;
434  Ct0 *= timepitch;
435  vtxcoord[0] = detprop->ConvertTicksToX(vtx_t[1],1,0,0);
436  vtxcoord[1] = (Cw0-Iw0)/(2.*std::sin(Angle));
437  vtxcoord[2] = (Cw0+Iw0)/(2.*std::cos(Angle))-YC/2.*std::tan(Angle);
438 
439  double yy,zz;
440  if(vtx_w[0]>=0&&vtx_w[0]<=239&&vtx_w[1]>=0&&vtx_w[1]<=239){
441  if(geom->ChannelsIntersect(geom->PlaneWireToChannel(0,(int)((Iw0/wire_pitch)-3.95)),
442  geom->PlaneWireToChannel(1,(int)((Cw0/wire_pitch)-1.84)),
443  yy,zz)){
444  //channelsintersect provides a slightly more accurate set of y and z coordinates.
445  // use channelsintersect in case the wires in question do cross.
446  vtxcoord[1] = yy;
447  vtxcoord[2] = zz;
448  }
449  else{
450  vtxcoord[0] = -99999;
451  vtxcoord[1] = -99999;
452  vtxcoord[2] = -99999;
453  }
454  }
455  dtIC->Fill(It0-Ct0);
456  }
457  else{
458  vtxcoord[0] = -99999;
459  vtxcoord[1] = -99999;
460  vtxcoord[2] = -99999;
461  }
462 
465  art::PtrVector<recob::Track> vTracks_vec;
466  art::PtrVector<recob::Shower> vShowers_vec;
467 
468  recob::Vertex the3Dvertex(vtxcoord, vcol->size());
469  vcol->push_back(the3Dvertex);
470 
471  if(vShowers_vec.size() > 0){
472  util::CreateAssn(*this, evt, *vcol, vShowers_vec, *assnsh);
473  // get the hits associated with each track and associate those with the vertex
475  // for(size_t p = 0; p < vShowers_vec.size(); ++p){
476  // std::vector< art::Ptr<recob::Hit> > hits = fms.at(p);
477  // util::CreateAssn(*this, evt, *vcol, hits, *assnh);
478  // }
479  }
480 
481  if(vTracks_vec.size() > 0){
482  util::CreateAssn(*this, evt, *vcol, vTracks_vec, *assntr);
483  // get the hits associated with each track and associate those with the vertex
485  // for(size_t p = 0; p < vTracks_vec.size(); ++p){
486  // std::vector< art::Ptr<recob::Hit> > hits = fmt.at(p);
487  // util::CreateAssn(*this, evt, *vcol, hits, *assnh);
488  // }
489  }
490 
491  LOG_VERBATIM("Summary") << std::setfill('-') << std::setw(175) << "-" << std::setfill(' ');
492  LOG_VERBATIM("Summary") << "VertexFinder2D Summary:";
493  for(size_t i = 0; i<epcol->size(); ++i) LOG_VERBATIM("Summary") << epcol->at(i) ;
494  for(size_t i = 0; i<vcol->size(); ++i) LOG_VERBATIM("Summary") << vcol->at(i) ;
495 
496  evt.put(std::move(epcol));
497  evt.put(std::move(vcol));
498  evt.put(std::move(assnep));
499  evt.put(std::move(assntr));
500  evt.put(std::move(assnsh));
501  evt.put(std::move(assnh));
502 
503  } // end of produce
code to link reconstructed objects back to the MC truth information
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
TTree * t1
Definition: plottest35.C:26
virtual int TriggerOffset() const =0
WireGeo const & Wire(unsigned int iwire) const
Definition: PlaneGeo.cxx:506
Planes which measure V.
Definition: geo_types.h:77
std::set< geo::View_t > const & Views() const
Returns a list of possible views in the detector.
bool ChannelsIntersect(raw::ChannelID_t c1, raw::ChannelID_t c2, double &y, double &z) const
Returns an intersection point of two channels.
virtual double SamplingRate() const =0
Returns the period of the TPC readout electronics clock.
Planes which measure Z direction.
Definition: geo_types.h:79
Double_t zz
Definition: plot.C:279
Definition of vertex object for LArSoft.
Definition: Vertex.h:35
double ThetaZ() const
Returns angle of wire with respect to z axis in the Y-Z plane in radians.
Definition: WireGeo.h:192
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
bool myfunction(CluLen c1, CluLen c2)
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
Definition: type_traits.h:56
Planes which measure U.
Definition: geo_types.h:76
void hits()
Definition: readHits.C:15
geo::Length_t DetHalfHeight(geo::TPCID const &tpcid) const
Returns the half height of the active volume of the specified TPC.
TCanvas * c1
Definition: plotHisto.C:7
TCanvas * c2
Definition: plot_hist.C:75
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
virtual double Temperature() const =0
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
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.
bool SortByWire(art::Ptr< recob::Hit > const &h1, art::Ptr< recob::Hit > const &h2)
size_type size() const
Definition: PtrVector.h:308
Detector simulation of raw signals on wires.
TTree * t2
Definition: plottest35.C:36
virtual double ConvertTicksToX(double ticks, int p, int t, int c) const =0
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Int_t min
Definition: plot.C:26
virtual double DriftVelocity(double efield=0., double temperature=0.) const =0
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Char_t n[5]
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
#define LOG_VERBATIM(category)
virtual double Efield(unsigned int planegap=0) const =0
Returns the nominal electric field in the specified volume.
recob::tracking::Plane Plane
Definition: TrackState.h:17
std::string GetLArTPCVolumeName(geo::TPCID const &tpcid) const
Return the name of specified LAr TPC volume.
vertex reconstruction
void vertex::VertexFinder2D::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 117 of file VertexFinder2D_module.cc.

References fhicl::ParameterSet::get().

118  {
119  fClusterModuleLabel = p.get< std::string >("ClusterModuleLabel");
120  return;
121  }
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

TH1D* vertex::VertexFinder2D::dtIC
private

Definition at line 90 of file VertexFinder2D_module.cc.

std::string vertex::VertexFinder2D::fClusterModuleLabel
private

Definition at line 92 of file VertexFinder2D_module.cc.


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