LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
TTHitFinder_module.cc
Go to the documentation of this file.
1 #ifndef TTHITFINDER_H
2 #define TTHITFINDER_H
3 
15 #include <string>
16 #include <math.h>
17 
18 // Framework includes
23 
24 // LArSoft Includes
31 
32 namespace hit{
33 
34  class TTHitFinder : public art::EDProducer {
35 
36  public:
37 
38  explicit TTHitFinder(fhicl::ParameterSet const& pset);
39  virtual ~TTHitFinder();
40 
41  void produce(art::Event& evt);
42  void beginJob();
43  void endJob();
44  void reconfigure(fhicl::ParameterSet const& p);
45 
46  private:
47 
48  std::string fCalDataModuleLabel;
53  int fIndWidth;
54  int fColWidth;
55 
56  float getTotalCharge(const float*,int,float);
57 
58  protected:
59 
60  }; // class TTHitFinder
61 
62  //-------------------------------------------------
64  this->reconfigure(pset);
65 
66  // let HitCollectionCreator declare that we are going to produce
67  // hits and associations with wires and raw digits
71 
72  }
73 
74  //-------------------------------------------------
76 
77  //-------------------------------------------------
79  fCalDataModuleLabel = p.get< std::string >("CalDataModuleLabel");
80  fMinSigPeakInd = p.get< float >("MinSigPeakInd");
81  fMinSigPeakCol = p.get< float >("MinSigPeakCol");
82  fMinSigTailInd = p.get< float >("MinSigTailInd",-99); //defaulting to well-below zero
83  fMinSigTailCol = p.get< float >("MinSigTailCol",-99); //defaulting to well-below zero
84  fIndWidth = p.get< int >("IndWidth", 3); //defaulting to 3
85  fColWidth = p.get< int >("ColWidth", 3); //defaulting to 3
86 
87  //enforce a minimum width
88  if(fIndWidth<1){
89  mf::LogWarning("TTHitFinder") << "IndWidth must be 1 at minimum. Resetting width to one time tick";
90  fIndWidth = 1;
91  }
92  if(fColWidth<1){
93  mf::LogWarning("TTHitFinder") << "ColWidth must be 1 at minimum. Resetting width to one time tick";
94  fColWidth = 1;
95  }
96 
97  }
98 
99  //-------------------------------------------------
101 
102  //-------------------------------------------------
104 
105  //-------------------------------------------------
107  {
108 
109  // these objects contain the hit collections
110  // and their associations to wires and raw digits:
111  recob::HitCollectionCreator hitCollection_U(*this, evt, "uhits");
112  recob::HitCollectionCreator hitCollection_V(*this, evt, "vhits");
113  recob::HitCollectionCreator hitCollection_Y(*this, evt, "yhits");
114 
115  // Read in the wire List object(s).
117  evt.getByLabel(fCalDataModuleLabel,wireVecHandle);
118  std::vector<recob::Wire> const& wireVec(*wireVecHandle);
119 
120  // also get the raw digits associated with wires
121  art::FindOneP<raw::RawDigit> WireToRawDigits
122  (wireVecHandle, evt, fCalDataModuleLabel);
123 
125 
126  //initialize some variables that will be in the loop.
127  float threshold_peak = 0;
128  float threshold_tail = -99;
129  int width = 3;
130 
131  //Loop over wires
132  for(unsigned int wireIter = 0; wireIter < wireVec.size(); wireIter++) {
133 
134  //get our wire
135  art::Ptr<recob::Wire> wire(wireVecHandle, wireIter);
136  art::Ptr<raw::RawDigit> const& rawdigits = WireToRawDigits.at(wireIter);
137 
138  std::vector<float> signal(wire->Signal());
139  std::vector<float>::iterator timeIter; // iterator for time bins
140  geo::WireID wire_id = (geom->ChannelToWire(wire->Channel())).at(0); //just grabbing the first one
141 
142 
143  //set the thresholds and widths based on wire type
144  geo::SigType_t sigType = geom->SignalType(wire->Channel());
145  if(sigType == geo::kInduction){
146  threshold_peak = fMinSigPeakInd;
147  threshold_tail = fMinSigTailInd;
148  width = fIndWidth;
149  }
150  else if(sigType == geo::kCollection){
151  threshold_peak = fMinSigPeakCol;
152  threshold_tail = fMinSigTailCol;
153  width = fColWidth;
154  }
155 
156  //make a half_width variable to be the search window around each time tick.
157  float half_width = ((float)width-1)/2.;
158 
159  //now do the loop over the time ticks on the wire
160  int time_bin = -1;
161  float peak_val = 0;
162  for(timeIter = signal.begin(); timeIter < signal.end(); timeIter++){
163  time_bin++;
164 
165  //set the peak value, taking average between ticks if desired total width is even
166  if(width%2==1) peak_val = *timeIter;
167  else if(width%2==0) peak_val = 0.5 * (*timeIter + *(timeIter+1));
168 
169  //continue immediately if we are not above the threshold
170  if(peak_val < threshold_peak) continue;
171 
172  //continue if we are too close to the edge
173  if( time_bin-half_width < 0 ) continue;
174  if( time_bin+half_width > signal.size() ) continue;
175 
176  //if necessary, do loop over hit width, and check tail thresholds
177  int begin_tail_tick = std::floor(time_bin-half_width);
178  float totalCharge = getTotalCharge(&signal[begin_tail_tick],width,threshold_tail);
179  if(totalCharge==-999) {
180  LOG_DEBUG("TTHitFinder") << "Rejecting would be hit at (plane,wire,time_bin,first_bin,last_bin)=("
181  << wire_id.Plane << "," << wire_id.Wire << "," << time_bin << "," << begin_tail_tick << "," << begin_tail_tick+width-1 << "): "
182  << signal.at(time_bin-1) << " "
183  << signal.at(time_bin) << " "
184  << signal.at(time_bin+1);
185  continue;
186  }
187 
188  //OK, if we've passed all tests up to this point, we have a hit!
189 
190  float hit_time = time_bin;
191  if(width%2==0) hit_time = time_bin+0.5;
192 
193  // hit time region is 2 widths (4 RMS) wide
194  const raw::TDCtick_t start_tick = hit_time - width,
195  end_tick = hit_time + width;
196 
197  // make the hit
199  *wire, // wire
200  wire_id, // wireID
201  start_tick, // start_tick
202  end_tick, // end_tick
203  width / 2., // rms
204  hit_time, // peak_time
205  0., // sigma_peak_time
206  peak_val, // peak_amplitude
207  0., // sigma_peak_amplitude
208  totalCharge, // hit_integral
209  0., // hit_sigma_integral
210  totalCharge, // summedADC
211  1, // multiplicity (dummy value)
212  0, // local_index (dummy value)
213  1., // goodness_of_fit (dummy value)
214  0 // dof
215  );
216  if(wire_id.Plane==0)
217  hitCollection_U.emplace_back(hit.move(), wire, rawdigits);
218  else if(wire_id.Plane==1)
219  hitCollection_V.emplace_back(hit.move(), wire, rawdigits);
220  else if(wire_id.Plane==2)
221  hitCollection_Y.emplace_back(hit.move(), wire, rawdigits);
222 
223  }//End loop over time ticks on wire
224 
225  LOG_DEBUG("TTHitFinder") << "Finished wire " << wire_id.Wire << " (plane " << wire_id.Plane << ")"
226  << "\tTotal hits (U,V,Y)= ("
227  << hitCollection_U.size() << ","
228  << hitCollection_V.size() << ","
229  << hitCollection_Y.size() << ")";
230 
231  }//End loop over all wires
232 
233  // put the hit collection and associations into the event
234  mf::LogInfo("TTHitFinder") << "Total TTHitFinder hits (U,V,Y)=("
235  << hitCollection_U.size() << ","
236  << hitCollection_V.size() << ","
237  << hitCollection_Y.size() << ")";
238  hitCollection_U.put_into(evt); // reminder: instance name was "uhits"
239  hitCollection_V.put_into(evt); // reminder: instance name was "vhits"
240  hitCollection_Y.put_into(evt); // reminder: instance name was "yhits"
241 
242  } // End of produce()
243 
244 
245  //-------------------------------------------------
246  float TTHitFinder::getTotalCharge(const float* signal_vector,int width=3,float threshold=-99){
247 
248  float totalCharge = 0;
249  for(int tick=0; tick<width; tick++){
250  if(signal_vector[tick] < threshold){
251  totalCharge = -999; //special value for being below threshold
252  break;
253  }
254  totalCharge += signal_vector[tick];
255  }
256  return totalCharge;
257 
258  }//end getTotalCharge method
259 
261 
262 } // end of hit namespace
263 
264 
265 #endif // TTHITFINDER_H
int fColWidth
Induction wire hit width (in time ticks)
float fMinSigTailInd
Collection wire signal height threshold at peak.
void produce(art::Event &evt)
intermediate_table::iterator iterator
float fMinSigPeakCol
Induction wire signal height threshold at peak.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Declaration of signal hit object.
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
Definition of basic raw digits.
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:313
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
static void declare_products(ModuleType &producer, std::string instance_name="", bool doWireAssns=true, bool doRawDigitAssns=true)
Declares the hit products we are going to fill.
Definition: HitCreator.h:1117
int TDCtick_t
Type representing a TDC tick.
Definition: RawTypes.h:24
Class managing the creation of a new recob::Hit object.
Definition: HitCreator.h:84
Helper functions to create a hit.
A class handling a collection of hits and its associations.
Definition: HitCreator.h:513
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
Signal from induction planes.
Definition: geo_types.h:92
raw::ChannelID_t Channel() const
Returns the ID of the channel (or InvalidChannelID)
Definition: Wire.h:164
enum geo::_plane_sigtype SigType_t
Enumerate the possible plane projections.
T get(std::string const &key) const
Definition: ParameterSet.h:231
void emplace_back(recob::Hit &&hit, art::Ptr< recob::Wire > const &wire=art::Ptr< recob::Wire >(), art::Ptr< raw::RawDigit > const &digits=art::Ptr< raw::RawDigit >())
Adds the specified hit to the data collection.
Definition: HitCreator.cxx:245
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:258
float fMinSigTailCol
Induction wire signal height threshold outside peak.
Definition of data types for geometry description.
void put_into(art::Event &)
Moves the data into an event.
Definition: HitCreator.h:663
Detector simulation of raw signals on wires.
std::vector< float > Signal() const
Return a zero-padded full length vector filled with RoI signal.
Definition: Wire.cxx:47
std::string fCalDataModuleLabel
size_t size() const
Returns the number of hits currently in the collection.
Definition: HitCreator.h:647
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
float fMinSigPeakInd
Input caldata module name.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
#define LOG_DEBUG(id)
Declaration of basic channel signal object.
int fIndWidth
Collection wire signal height threshold outside peak.
TCEvent evt
Definition: DataStructs.cxx:5
TTHitFinder(fhicl::ParameterSet const &pset)
recob::Hit && move()
Prepares the constructed hit to be moved away.
Definition: HitCreator.h:344
Definition: fwd.h:25
art framework interface to geometry description
float getTotalCharge(const float *, int, float)
Collection wire hit width (in time ticks)
Signal from collection planes.
Definition: geo_types.h:93
void reconfigure(fhicl::ParameterSet const &p)