LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
InfoTransfer_service.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 #include <iostream>
10 
11 // Framework includes
13 
18 
19 namespace{
20  void WriteMsg(const char* fcn)
21  {
22  mf::LogWarning("InfoTransfer") << "InfoTransfer::" << fcn << " \n";
23  }
24 }
25 
26 namespace evd {
27 
28  //......................................................................
31  : evdb::Reconfigurable{pset}
32  {
33  this->reconfigure(pset);
34  testflag=-1;
35  fEvt=-1;
36  fRun=-1;
37  fSubRun=-1;
38  reg.sPreProcessEvent.watch(this, &InfoTransfer::Rebuild);
40  unsigned int nplanes = geo->Nplanes();
41 
42  fSelectedHitlist.resize(nplanes);
43  fStartHit.resize(nplanes);
44  fRefStartHit.resize(nplanes);
45  fEndHit.resize(nplanes);
46  fRefEndHit.resize(nplanes);
47  starthitout.resize(nplanes);
48  endhitout.resize(nplanes);
49  refstarthitout.resize(nplanes);
50  refendhitout.resize(nplanes);
51  for(unsigned int i=0;i<nplanes;i++){
52  starthitout[i].resize(2);
53  endhitout[i].resize(2);
54  refstarthitout[i].resize(2);
55  refendhitout[i].resize(2);
56  }
57  // hitlist=NULL;
58  }
59 
60  //......................................................................
62  {
63  }
64 
65  //......................................................................
67  {
69  unsigned int nplanes = geo->Nplanes();
70  //clear everything
71  fRefinedHitlist.resize(nplanes);
72  fSelectedHitlist.resize(nplanes);
73  for (unsigned int i=0;i<nplanes;i++){
74  fRefinedHitlist[i].clear();
75  fSelectedHitlist[i].clear();
76  }
77  fHitModuleLabel = pset.get<std::string>("HitModuleLabel", "ffthit");
78  }
79 
80 
81 
82  //......................................................................
84  {
86  unsigned int nplanes = geo->Nplanes();
87  unsigned int which_call=evdb::NavState::Which();
88  if(which_call!=2){
89  //unless we're reloading we want to clear all the selected and refined hits
90  fRefinedHitlist.resize(nplanes);
91  fSelectedHitlist.resize(nplanes);
92  for(unsigned int j=0; j<nplanes;j++){
93  fRefinedHitlist[j].clear();
94  fSelectedHitlist[j].clear();
95  starthitout[j].clear();
96  endhitout[j].clear();
97  starthitout[j].resize(2);
98  endhitout[j].resize(2);
99  refstarthitout[j].clear();
100  refendhitout[j].clear();
101  refstarthitout[j].resize(2);
102  refendhitout[j].resize(2);
103  }
104  //also clear start and end points
105  fRefStartHit.clear();
106  fRefEndHit.clear();
107  fFullHitlist.clear();
108  }
110 
111  fEvt=evt.id().event();
112  fRun=evt.id().run();
113  fSubRun=evt.id().subRun();
114  evt.getByLabel(fHitModuleLabel, hHandle);
115 
116  if(hHandle.failedToGet()){
117 // mf::LogWarning("InfoTransfer") << "failed to get handle to std::vector<recob::Hit> from "<< fHitModuleLabel;
118  return;
119  }
120 
121  // Clear out anything remaining from previous calls to Rebuild
122 
123  fRefinedHitlist.resize(nplanes);
124 
125  for(unsigned int i=0;i<nplanes;i++){
126  fRefinedHitlist[i].clear();
127  }
128 
129 
130  fFullHitlist.clear();
131  for(unsigned int i=0; i<fRefStartHit.size(); i++){
132  fRefStartHit[i]=NULL;
133  fRefEndHit[i]=NULL;
134  }
135 
137  for(unsigned int i=0;i<nplanes;i++ )
138  { refstarthitout[i].clear();
139  refendhitout[i].clear();
140  refstarthitout[i].resize(2);
141  refendhitout[i].resize(2);
142 
144  refendhitout[i]=endhitout[i];
145 
146  starthitout[i].clear();
147  endhitout[i].clear();
148  starthitout[i].resize(2);
149  endhitout[i].resize(2);
150  }
151 
152  for(size_t p = 0; p < hHandle->size(); ++p){
153  art::Ptr<recob::Hit> hit(hHandle, p);
154  fFullHitlist.push_back(hit);
155  }
156 
157  // fill the selected Hits into the fRefinedHitList from the fSelectedHitList
158  char buf[200];
159  for(unsigned int j=0; j<nplanes; j++){
160  sprintf(buf," ++++rebuilding with %lu selected hits in plane %u \n", fSelectedHitlist[j].size(),j);
161  WriteMsg(buf);
162  }
163 
164  for(size_t t = 0; t < fFullHitlist.size(); ++t){
165  for(unsigned int ip=0;ip<nplanes;ip++) {
166  for(size_t xx = 0; xx < fSelectedHitlist[ip].size(); ++xx){
167  if(fFullHitlist[t]==fSelectedHitlist[ip][xx]) {
168  fRefinedHitlist[ip].push_back(fFullHitlist[t]);
169  break;
170  }
171  }
172 
173  if(fStartHit[ip] && fFullHitlist[t].get()==fStartHit[ip]){
174  fRefStartHit[ip]=const_cast<recob::Hit *>(fFullHitlist[t].get());
175  }
176 
177  if(fEndHit[ip] && fFullHitlist[t].get()==fEndHit[ip]){
178  fRefEndHit[ip]=const_cast<recob::Hit *>(fFullHitlist[t].get());
179  }
180 
181  }
182  }
183  //for(int ip=0;ip<nplanes;ip++)
184  // FillStartEndHitCoords(ip);
185 
186  fSelectedHitlist.clear();
188 
189  return;
190  }
191 
192  //......................................................................
193  void InfoTransfer::SetSeedList(std::vector < util::PxLine > seedlines)
194  {
195  fSeedList=seedlines;
196  }
197 
198 
199  //......................................................................
200  std::vector < util::PxLine > InfoTransfer::GetSeedList()
201  {
202  return fSeedList;
203  }
204 
205 
206  //......................................................................
207  void InfoTransfer::FillStartEndHitCoords(unsigned int plane)
208  {
209 
211  // std::vector <double> sthitout(2);
212  if(fRefStartHit[plane]){
213  starthitout[plane][1] = fRefStartHit[plane]->PeakTime() ;
214  try{
215  if(fRefStartHit[plane]->WireID().isValid){
216  starthitout[plane][0] = fRefStartHit[plane]->WireID().Wire;
217  }
218  else{
219  starthitout[plane][0]=0;
220  }
221  }
222  catch(cet::exception e) {
223  mf::LogWarning("GraphCluster") << "caught exception \n"
224  << e;
225  starthitout[plane][0]=0;
226  }
227  }
228  else{
229  starthitout[plane][1]=0.;
230  starthitout[plane][0]=0.;
231  }
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 e) {
245  mf::LogWarning("GraphCluster") << "caught exception \n"
246  << e;
247  endhitout[plane][0]=0;
248  }
249  }
250  else{
251  endhitout[plane][1]=0.;
252  endhitout[plane][0]=0.;
253  }
254 
255 
256  }
257 
258 }//namespace
259 
260 namespace evd {
261 
263 
264 } // namespace evd
266 
267 
void FillStartEndHitCoords(unsigned int plane)
Double_t xx
Definition: macro.C:12
std::vector< util::PxLine > GetSeedList()
#define DEFINE_ART_SERVICE(svc)
Definition: ServiceMacros.h:93
InfoTransfer(fhicl::ParameterSet const &pset, art::ActivityRegistry &reg)
std::vector< std::vector< double > > endhitout
Definition: InfoTransfer.h:136
Manage all things related to colors for the event display.
std::vector< recob::Hit * > fStartHit
The Starthit.
Definition: InfoTransfer.h:127
RunNumber_t run() const
Definition: EventID.h:99
void Rebuild(const art::Event &evt)
std::vector< recob::Hit * > fRefStartHit
The Refined Starthit.
Definition: InfoTransfer.h:128
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
std::vector< std::vector< double > > refstarthitout
Definition: InfoTransfer.h:138
LArSoft includes.
T get(std::string const &key) const
Definition: ParameterSet.h:231
std::vector< recob::Hit * > fRefEndHit
The Refined Starthit.
Definition: InfoTransfer.h:131
std::vector< recob::Hit * > fEndHit
The Starthit.
Definition: InfoTransfer.h:130
std::vector< std::vector< art::Ptr< recob::Hit > > > fRefinedHitlist
the refined hitlist after rebuild (one for each plane)
Definition: InfoTransfer.h:123
std::string fHitModuleLabel
label for geant4 module
Definition: InfoTransfer.h:125
std::vector< std::vector< double > > starthitout
Definition: InfoTransfer.h:135
std::vector< art::Ptr< recob::Hit > > fFullHitlist
the full Hit list from the Hitfinder.
Definition: InfoTransfer.h:124
Detector simulation of raw signals on wires.
std::vector< std::vector< art::Ptr< recob::Hit > > > fSelectedHitlist
the list selected by the GUI (one for each plane)
Definition: InfoTransfer.h:122
Utility object to perform functions of association.
void SetSeedList(std::vector< util::PxLine > seedlines)
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
std::vector< std::vector< double > > refendhitout
Definition: InfoTransfer.h:139
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
static int Which()
Definition: NavState.cxx:20
EventNumber_t event() const
Definition: EventID.h:117
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:49
TCEvent evt
Definition: DataStructs.cxx:5
void reconfigure(fhicl::ParameterSet const &pset)
Float_t e
Definition: plot.C:34
Namespace collecting geometry-related classes utilities.
SubRunNumber_t subRun() const
Definition: EventID.h:111
EventID id() const
Definition: Event.h:56
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool failedToGet() const
Definition: Handle.h:197
std::vector< util::PxLine > fSeedList
Definition: InfoTransfer.h:133