LArSoft  v10_04_05
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);
46  auto const& wireReadoutGeom = art::ServiceHandle<geo::WireReadout const>()->Get();
47  unsigned int nplanes = wireReadoutGeom.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  }
65 
66  //......................................................................
68 
69  //......................................................................
71  {
72  auto const& wireReadoutGeom = art::ServiceHandle<geo::WireReadout const>()->Get();
73  unsigned int nplanes = wireReadoutGeom.Nplanes();
74  //clear everything
75  fRefinedHitlist.resize(nplanes);
76  fSelectedHitlist.resize(nplanes);
77  for (unsigned int i = 0; i < nplanes; i++) {
78  fRefinedHitlist[i].clear();
79  fSelectedHitlist[i].clear();
80  }
81  fHitModuleLabel = pset.get<std::string>("HitModuleLabel", "ffthit");
82  }
83 
84  //......................................................................
86  {
87  auto const& wireReadoutGeom = art::ServiceHandle<geo::WireReadout const>()->Get();
88  unsigned int nplanes = wireReadoutGeom.Nplanes();
89  unsigned int which_call = evdb::NavState::Which();
90  if (which_call != 2) {
91  //unless we're reloading we want to clear all the selected and refined hits
92  fRefinedHitlist.resize(nplanes);
93  fSelectedHitlist.resize(nplanes);
94  for (unsigned int j = 0; j < nplanes; j++) {
95  fRefinedHitlist[j].clear();
96  fSelectedHitlist[j].clear();
97  starthitout[j].clear();
98  endhitout[j].clear();
99  starthitout[j].resize(2);
100  endhitout[j].resize(2);
101  refstarthitout[j].clear();
102  refendhitout[j].clear();
103  refstarthitout[j].resize(2);
104  refendhitout[j].resize(2);
105  }
106  //also clear start and end points
107  fRefStartHit.clear();
108  fRefEndHit.clear();
109  fFullHitlist.clear();
110  }
112 
113  fEvt = evt.id().event();
114  fRun = evt.id().run();
115  fSubRun = evt.id().subRun();
116  evt.getByLabel(fHitModuleLabel, hHandle);
117 
118  if (hHandle.failedToGet()) { return; }
119 
120  // Clear out anything remaining from previous calls to Rebuild
121 
122  fRefinedHitlist.resize(nplanes);
123 
124  for (unsigned int i = 0; i < nplanes; i++) {
125  fRefinedHitlist[i].clear();
126  }
127 
128  fFullHitlist.clear();
129  for (unsigned int i = 0; i < fRefStartHit.size(); i++) {
130  fRefStartHit[i] = NULL;
131  fRefEndHit[i] = NULL;
132  }
133 
135  for (unsigned int i = 0; i < nplanes; i++) {
136  refstarthitout[i].clear();
137  refendhitout[i].clear();
138  refstarthitout[i].resize(2);
139  refendhitout[i].resize(2);
140 
141  refstarthitout[i] = starthitout[i];
142  refendhitout[i] = endhitout[i];
143 
144  starthitout[i].clear();
145  endhitout[i].clear();
146  starthitout[i].resize(2);
147  endhitout[i].resize(2);
148  }
149 
150  for (size_t p = 0; p < hHandle->size(); ++p) {
151  art::Ptr<recob::Hit> hit(hHandle, p);
152  fFullHitlist.push_back(hit);
153  }
154 
155  // fill the selected Hits into the fRefinedHitList from the fSelectedHitList
156  char buf[200];
157  for (unsigned int j = 0; j < nplanes; j++) {
158  sprintf(buf,
159  " ++++rebuilding with %lu selected hits in plane %u \n",
160  fSelectedHitlist[j].size(),
161  j);
162  WriteMsg(buf);
163  }
164 
165  for (size_t t = 0; t < fFullHitlist.size(); ++t) {
166  for (unsigned int ip = 0; ip < nplanes; ip++) {
167  for (size_t xx = 0; xx < fSelectedHitlist[ip].size(); ++xx) {
168  if (fFullHitlist[t] == fSelectedHitlist[ip][xx]) {
169  fRefinedHitlist[ip].push_back(fFullHitlist[t]);
170  break;
171  }
172  }
173 
174  if (fStartHit[ip] && fFullHitlist[t].get() == fStartHit[ip]) {
175  fRefStartHit[ip] = const_cast<recob::Hit*>(fFullHitlist[t].get());
176  }
177 
178  if (fEndHit[ip] && fFullHitlist[t].get() == fEndHit[ip]) {
179  fRefEndHit[ip] = const_cast<recob::Hit*>(fFullHitlist[t].get());
180  }
181  }
182  }
183 
184  fSelectedHitlist.clear();
186 
187  return;
188  }
189 
190  //......................................................................
191  void InfoTransfer::SetSeedList(std::vector<util::PxLine> seedlines)
192  {
193  fSeedList = seedlines;
194  }
195 
196  //......................................................................
197  std::vector<util::PxLine> const& InfoTransfer::GetSeedList() const
198  {
199  return fSeedList;
200  }
201 
202  //......................................................................
203  void InfoTransfer::FillStartEndHitCoords(unsigned int plane)
204  {
205  if (fRefStartHit[plane]) {
206  starthitout[plane][1] = fRefStartHit[plane]->PeakTime();
207  try {
208  if (fRefStartHit[plane]->WireID().isValid) {
209  starthitout[plane][0] = fRefStartHit[plane]->WireID().Wire;
210  }
211  else {
212  starthitout[plane][0] = 0;
213  }
214  }
215  catch (cet::exception const& e) {
216  mf::LogWarning("GraphCluster") << "caught exception \n" << e;
217  starthitout[plane][0] = 0;
218  }
219  }
220  else {
221  starthitout[plane][1] = 0.;
222  starthitout[plane][0] = 0.;
223  }
224 
225  if (fRefEndHit[plane]) {
226  endhitout[plane][1] = fRefEndHit[plane]->PeakTime();
227  try {
228  if (fRefEndHit[plane]->WireID().isValid) {
229  endhitout[plane][0] = fRefEndHit[plane]->WireID().Wire;
230  }
231  else {
232  endhitout[plane][0] = 0;
233  }
234  }
235  catch (cet::exception const& e) {
236  mf::LogWarning("GraphCluster") << "caught exception \n" << e;
237  endhitout[plane][0] = 0;
238  }
239  }
240  else {
241  endhitout[plane][1] = 0.;
242  endhitout[plane][0] = 0.;
243  }
244  }
245 
246 } //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
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
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:85
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
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:70
std::vector< util::PxLine > fSeedList
Definition: InfoTransfer.h:150
Float_t e
Definition: plot.C:35
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
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