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

Public Member Functions

 HitHandScan (fhicl::ParameterSet const &p)
 
 HitHandScan (HitHandScan const &)=delete
 
 HitHandScan (HitHandScan &&)=delete
 
HitHandScanoperator= (HitHandScan const &)=delete
 
HitHandScanoperator= (HitHandScan &&)=delete
 
void produce (art::Event &e) override
 
void reconfigure (fhicl::ParameterSet const &p)
 
- 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

bool insidePolygon (std::vector< Point > polygon, Point ptest)
 

Private Attributes

std::string fPreviousHitModuleLabel
 
std::string fHandScanFileName
 

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 49 of file HitHandScan_module.cc.

Constructor & Destructor Documentation

HitHandScan::HitHandScan ( fhicl::ParameterSet const &  p)
explicit

Definition at line 76 of file HitHandScan_module.cc.

76  : EDProducer{p}
77 {
78  this->reconfigure(p);
80 }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
static void declare_products(art::ProducesCollector &collector, std::string instance_name="", bool doWireAssns=true, bool doRawDigitAssns=true)
Declares the hit products we are going to fill.
Definition: HitCreator.cxx:248
p
Definition: test.py:223
void reconfigure(fhicl::ParameterSet const &p)
ProducesCollector & producesCollector() noexcept
HitHandScan::HitHandScan ( HitHandScan const &  )
delete
HitHandScan::HitHandScan ( HitHandScan &&  )
delete

Member Function Documentation

bool HitHandScan::insidePolygon ( std::vector< Point polygon,
Point  ptest 
)
private

Definition at line 191 of file HitHandScan_module.cc.

192 {
193  size_t n = polygon.size();
194  size_t i, j;
195  bool c = false;
196  for (i = 0, j = n - 1; i < n; j = i++)
197  {
198  if ( ((polygon[i].tick > ptest.tick) != (polygon[j].tick > ptest.tick)) &&
199  (ptest.wire < (polygon[j].wire - polygon[i].wire) *
200  (ptest.tick - polygon[i].tick) / (polygon[j].tick - polygon[i].tick) + polygon[i].wire) )
201  c = !c;
202  }
203  return c;
204 }
std::void_t< T > n
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
HitHandScan& HitHandScan::operator= ( HitHandScan const &  )
delete
HitHandScan& HitHandScan::operator= ( HitHandScan &&  )
delete
void HitHandScan::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 82 of file HitHandScan_module.cc.

83 {
84  auto prevHitHandle = e.getHandle< std::vector< recob::Hit> >(fPreviousHitModuleLabel);
85 
86  art::FindOneP<recob::Wire> wires(prevHitHandle,e,fPreviousHitModuleLabel);
87  art::FindOneP<raw::RawDigit> rawdigits(prevHitHandle,e,fPreviousHitModuleLabel);
88 
89  recob::HitCollectionCreator hcol(e, wires.isValid(), rawdigits.isValid());
90 
91  std::vector<Point> trackBox;
92 
93  std::string readrun,readevent,readtpc,readplane,readwire,readtick,readnumpoly;
94  unsigned int run,event,tpc,plane,numpoly;
95  double tick,wire;
96  int linenumber = 0;
98  std::ifstream handscanfile(fHandScanFileName.c_str(),std::ifstream::in);
99  if (handscanfile.is_open())
100  {
101  while (std::getline(handscanfile,line))
102  {
103  linenumber++;
104  std::stringstream ss(line);
105  ss >> std::ws >> readrun >> readevent >> readtpc >> readplane >> readwire >> readtick >> readnumpoly;
106  try
107  {
108  run = stoul(readrun);
109  event = stoul(readevent);
110  tick = stod(readtick);
111  tpc = stoul(readtpc);
112  plane = stoul(readplane);
113  wire = stod(readwire);
114  numpoly = stoul(readnumpoly);
115 
116  Point p;
117  p.run = run;
118  p.event = event;
119  p.tpc = tpc;
120  p.plane = plane;
121  p.wire = wire;
122  p.tick = tick;
123  p.numpoly = numpoly;
124  trackBox.push_back(p);
125  }
126  catch (const std::exception& ex)
127  {
128  std::cout << "Line # " << linenumber << " is invalid, skipping..." << std::endl;
129  }
130  }
131  handscanfile.close();
132  }
133  else
134  {
135  std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
136  << "NO FILE FOUND WITH HAND SCANNED HIT DATA\n"
137  << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
138  return;
139  }
140 
141  for (size_t i_hit = 0; i_hit < prevHitHandle->size(); i_hit++)
142  {
143  art::Ptr<recob::Hit> phit(prevHitHandle,i_hit);
144 
145  art::Ptr<recob::Wire> wire(wires.at(i_hit));
146  art::Ptr<raw::RawDigit> rawdigit(rawdigits.at(i_hit));
147 
148  Point ptest;
149  ptest.run = e.run();
150  ptest.event = e.event();
151  ptest.tpc = phit->WireID().TPC;
152  ptest.plane = phit->WireID().Plane;
153  ptest.wire = phit->WireID().Wire;
154  ptest.tick = phit->PeakTime();
155 
156  std::map< unsigned int, std::vector<Point> > polygons;
157  for (auto const &poly : trackBox)
158  {
159  if (poly.run == ptest.run
160  && poly.event == ptest.event
161  && poly.tpc == ptest.tpc
162  && poly.plane == ptest.plane)
163  {
164  polygons[poly.numpoly].push_back(poly);
165  }
166  }
167  bool acceptPoint = false;
168  for (auto const &p : polygons)
169  {
170  if (insidePolygon(p.second,ptest))
171  {
172  acceptPoint = true;
173  }
174  }
175  if (acceptPoint)
176  {
177  hcol.emplace_back(*phit,wire,rawdigit);
178  }
179  }
180 
181  hcol.put_into(e);
182 
183 }
EventNumber_t event() const
Definition: DataViewImpl.cc:85
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
std::string string
Definition: nybbler.cc:12
unsigned int tpc
std::string fPreviousHitModuleLabel
unsigned int numpoly
A class handling a collection of hits and its associations.
Definition: HitCreator.h:508
unsigned int run
std::string fHandScanFileName
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
p
Definition: test.py:223
RunNumber_t run() const
Definition: DataViewImpl.cc:71
unsigned int event
bool insidePolygon(std::vector< Point > polygon, Point ptest)
unsigned int plane
void line(double t, double *p, double &x, double &y, double &z)
Wire()
Default constructor: a wire with no signal information.
Definition: Wire.cxx:17
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
void HitHandScan::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 185 of file HitHandScan_module.cc.

186 {
187  fHandScanFileName = p.get<std::string>("HandScanFileName");
188  fPreviousHitModuleLabel = p.get<std::string>("PreviousHitModuleLabel");
189 }
std::string string
Definition: nybbler.cc:12
std::string fPreviousHitModuleLabel
std::string fHandScanFileName
p
Definition: test.py:223

Member Data Documentation

std::string HitHandScan::fHandScanFileName
private

Definition at line 71 of file HitHandScan_module.cc.

std::string HitHandScan::fPreviousHitModuleLabel
private

Definition at line 70 of file HitHandScan_module.cc.


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