LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
InfoTransfer.cc
Go to the documentation of this file.
1 //
3 // Transfer hitlist and run info into a producer module.
4 // Do not copy this code without contacting Andrzej Szelc and Brian Rebel first.
5 //
6 // \author andrzej.szelc@yale.edu
7 // ellen.klein@yale.edu
9 
11 
16 
18 
19 // Framework includes
26 
27 namespace {
28  void WriteMsg(const char* fcn)
29  {
30  mf::LogWarning("InfoTransfer") << "InfoTransfer::" << fcn << " \n";
31  }
32 }
33 
34 namespace evd {
35 
36  //......................................................................
38  : evdb::Reconfigurable{pset}
39  {
40  this->reconfigure(pset);
41  testflag = -1;
42  fEvt = -1;
43  fRun = -1;
44  fSubRun = -1;
45  reg.sPreProcessEvent.watch(this, &InfoTransfer::Rebuild);
47  unsigned int nplanes = geo->Nplanes();
48 
49  fSelectedHitlist.resize(nplanes);
50  fStartHit.resize(nplanes);
51  fRefStartHit.resize(nplanes);
52  fEndHit.resize(nplanes);
53  fRefEndHit.resize(nplanes);
54  starthitout.resize(nplanes);
55  endhitout.resize(nplanes);
56  refstarthitout.resize(nplanes);
57  refendhitout.resize(nplanes);
58  for (unsigned int i = 0; i < nplanes; i++) {
59  starthitout[i].resize(2);
60  endhitout[i].resize(2);
61  refstarthitout[i].resize(2);
62  refendhitout[i].resize(2);
63  }
64  // hitlist=NULL;
65  }
66 
67  //......................................................................
69 
70  //......................................................................
72  {
74  unsigned int nplanes = geo->Nplanes();
75  //clear everything
76  fRefinedHitlist.resize(nplanes);
77  fSelectedHitlist.resize(nplanes);
78  for (unsigned int i = 0; i < nplanes; i++) {
79  fRefinedHitlist[i].clear();
80  fSelectedHitlist[i].clear();
81  }
82  fHitModuleLabel = pset.get<std::string>("HitModuleLabel", "ffthit");
83  }
84 
85  //......................................................................
87  {
89  unsigned int nplanes = geo->Nplanes();
90  unsigned int which_call = evdb::NavState::Which();
91  if (which_call != 2) {
92  //unless we're reloading we want to clear all the selected and refined hits
93  fRefinedHitlist.resize(nplanes);
94  fSelectedHitlist.resize(nplanes);
95  for (unsigned int j = 0; j < nplanes; j++) {
96  fRefinedHitlist[j].clear();
97  fSelectedHitlist[j].clear();
98  starthitout[j].clear();
99  endhitout[j].clear();
100  starthitout[j].resize(2);
101  endhitout[j].resize(2);
102  refstarthitout[j].clear();
103  refendhitout[j].clear();
104  refstarthitout[j].resize(2);
105  refendhitout[j].resize(2);
106  }
107  //also clear start and end points
108  fRefStartHit.clear();
109  fRefEndHit.clear();
110  fFullHitlist.clear();
111  }
113 
114  fEvt = evt.id().event();
115  fRun = evt.id().run();
116  fSubRun = evt.id().subRun();
117  evt.getByLabel(fHitModuleLabel, hHandle);
118 
119  if (hHandle.failedToGet()) {
120  // mf::LogWarning("InfoTransfer") << "failed to get handle to std::vector<recob::Hit> from "<< fHitModuleLabel;
121  return;
122  }
123 
124  // Clear out anything remaining from previous calls to Rebuild
125 
126  fRefinedHitlist.resize(nplanes);
127 
128  for (unsigned int i = 0; i < nplanes; i++) {
129  fRefinedHitlist[i].clear();
130  }
131 
132  fFullHitlist.clear();
133  for (unsigned int i = 0; i < fRefStartHit.size(); i++) {
134  fRefStartHit[i] = NULL;
135  fRefEndHit[i] = NULL;
136  }
137 
139  for (unsigned int i = 0; i < nplanes; i++) {
140  refstarthitout[i].clear();
141  refendhitout[i].clear();
142  refstarthitout[i].resize(2);
143  refendhitout[i].resize(2);
144 
145  refstarthitout[i] = starthitout[i];
146  refendhitout[i] = endhitout[i];
147 
148  starthitout[i].clear();
149  endhitout[i].clear();
150  starthitout[i].resize(2);
151  endhitout[i].resize(2);
152  }
153 
154  for (size_t p = 0; p < hHandle->size(); ++p) {
155  art::Ptr<recob::Hit> hit(hHandle, p);
156  fFullHitlist.push_back(hit);
157  }
158 
159  // fill the selected Hits into the fRefinedHitList from the fSelectedHitList
160  char buf[200];
161  for (unsigned int j = 0; j < nplanes; j++) {
162  sprintf(buf,
163  " ++++rebuilding with %lu selected hits in plane %u \n",
164  fSelectedHitlist[j].size(),
165  j);
166  WriteMsg(buf);
167  }
168 
169  for (size_t t = 0; t < fFullHitlist.size(); ++t) {
170  for (unsigned int ip = 0; ip < nplanes; ip++) {
171  for (size_t xx = 0; xx < fSelectedHitlist[ip].size(); ++xx) {
172  if (fFullHitlist[t] == fSelectedHitlist[ip][xx]) {
173  fRefinedHitlist[ip].push_back(fFullHitlist[t]);
174  break;
175  }
176  }
177 
178  if (fStartHit[ip] && fFullHitlist[t].get() == fStartHit[ip]) {
179  fRefStartHit[ip] = const_cast<recob::Hit*>(fFullHitlist[t].get());
180  }
181 
182  if (fEndHit[ip] && fFullHitlist[t].get() == fEndHit[ip]) {
183  fRefEndHit[ip] = const_cast<recob::Hit*>(fFullHitlist[t].get());
184  }
185  }
186  }
187  //for(int ip=0;ip<nplanes;ip++)
188  // FillStartEndHitCoords(ip);
189 
190  fSelectedHitlist.clear();
192 
193  return;
194  }
195 
196  //......................................................................
197  void InfoTransfer::SetSeedList(std::vector<util::PxLine> seedlines)
198  {
199  fSeedList = seedlines;
200  }
201 
202  //......................................................................
203  std::vector<util::PxLine> const& InfoTransfer::GetSeedList() const
204  {
205  return fSeedList;
206  }
207 
208  //......................................................................
209  void InfoTransfer::FillStartEndHitCoords(unsigned int plane)
210  {
211 
213  // std::vector <double> sthitout(2);
214  if (fRefStartHit[plane]) {
215  starthitout[plane][1] = fRefStartHit[plane]->PeakTime();
216  try {
217  if (fRefStartHit[plane]->WireID().isValid) {
218  starthitout[plane][0] = fRefStartHit[plane]->WireID().Wire;
219  }
220  else {
221  starthitout[plane][0] = 0;
222  }
223  }
224  catch (cet::exception const& e) {
225  mf::LogWarning("GraphCluster") << "caught exception \n" << e;
226  starthitout[plane][0] = 0;
227  }
228  }
229  else {
230  starthitout[plane][1] = 0.;
231  starthitout[plane][0] = 0.;
232  }
233 
234  if (fRefEndHit[plane]) {
235  endhitout[plane][1] = fRefEndHit[plane]->PeakTime();
236  try {
237  if (fRefEndHit[plane]->WireID().isValid) {
238  endhitout[plane][0] = fRefEndHit[plane]->WireID().Wire;
239  }
240  else {
241  endhitout[plane][0] = 0;
242  }
243  }
244  catch (cet::exception const& e) {
245  mf::LogWarning("GraphCluster") << "caught exception \n" << e;
246  endhitout[plane][0] = 0;
247  }
248  }
249  else {
250  endhitout[plane][1] = 0.;
251  endhitout[plane][0] = 0.;
252  }
253  }
254 
255 } //namespace
void FillStartEndHitCoords(unsigned int plane)
Double_t xx
Definition: macro.C:12
InfoTransfer(fhicl::ParameterSet const &pset, art::ActivityRegistry &reg)
Definition: InfoTransfer.cc:37
Declaration of signal hit object.
std::vector< recob::Hit * > fEndHit
The Starthit.
Definition: InfoTransfer.h:147
std::vector< recob::Hit * > fStartHit
The Starthit.
Definition: InfoTransfer.h:144
std::vector< art::Ptr< recob::Hit > > fFullHitlist
the full Hit list from the Hitfinder.
Definition: InfoTransfer.h:141
Manage all things related to colors for the event display.
RunNumber_t run() const
Definition: EventID.h:98
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
std::vector< std::vector< double > > endhitout
Definition: InfoTransfer.h:153
LArSoft includes.
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
T get(std::string const &key) const
Definition: ParameterSet.h:314
std::vector< std::vector< double > > refendhitout
Definition: InfoTransfer.h:156
std::string fHitModuleLabel
label for geant4 module
Definition: InfoTransfer.h:142
Definition of data types for geometry description.
std::vector< std::vector< art::Ptr< recob::Hit > > > fRefinedHitlist
the refined hitlist after rebuild (one for each plane)
Definition: InfoTransfer.h:140
Detector simulation of raw signals on wires.
std::vector< recob::Hit * > fRefStartHit
The Refined Starthit.
Definition: InfoTransfer.h:145
void Rebuild(const art::Event &evt, art::ScheduleContext)
Definition: InfoTransfer.cc:86
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
void SetSeedList(std::vector< util::PxLine > seedlines)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
static int Which()
Definition: NavState.cxx:20
std::vector< recob::Hit * > fRefEndHit
The Refined Starthit.
Definition: InfoTransfer.h:148
EventNumber_t event() const
Definition: EventID.h:116
unsigned int Nplanes(TPCID const &tpcid=tpc_zero) const
Returns the total number of planes in the specified TPC.
Definition: GeometryCore.h:977
std::vector< util::PxLine > const & GetSeedList() const
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:46
TCEvent evt
Definition: DataStructs.cxx:8
void reconfigure(fhicl::ParameterSet const &pset)
Definition: InfoTransfer.cc:71
std::vector< util::PxLine > fSeedList
Definition: InfoTransfer.h:150
Float_t e
Definition: plot.C:35
Namespace collecting geometry-related classes utilities.
std::vector< std::vector< double > > starthitout
Definition: InfoTransfer.h:152
SubRunNumber_t subRun() const
Definition: EventID.h:110
EventID id() const
Definition: Event.cc:23
art framework interface to geometry description
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::vector< std::vector< art::Ptr< recob::Hit > > > fSelectedHitlist
the list selected by the GUI (one for each plane)
Definition: InfoTransfer.h:138
bool failedToGet() const
Definition: Handle.h:210
std::vector< std::vector< double > > refstarthitout
Definition: InfoTransfer.h:155