12 #include "fhiclcpp/ParameterSet.h"
13 #include "messagefacility/MessageLogger/MessageLogger.h"
14 #include "art/Framework/Core/ModuleMacros.h"
15 #include "art/Framework/Core/EDProducer.h"
16 #include "art/Framework/Principal/Event.h"
17 #include "art/Framework/Principal/Handle.h"
18 #include "canvas/Persistency/Common/Ptr.h"
19 #include "art/Framework/Services/Registry/ServiceHandle.h"
20 #include "canvas/Utilities/InputTag.h"
76 fDigitModuleLabel = pset.get< art::InputTag >(
"DigitModuleLabel",
"daq");
77 fCalDataModuleLabel = pset.get< std::string >(
"CalDataModuleLabel");
78 fMinSigInd = pset.get<
double >(
"MinSigInd");
79 fMinSigCol = pset.get<
double >(
"MinSigCol");
80 fIncludeMoreTail = pset.get<
double >(
"IncludeMoreTail", 0.);
81 fIndWidth = pset.get<
int >(
"IndWidth",20);
82 fColWidth = pset.get<
double >(
"ColWidth");
83 fIndMinWidth = pset.get<
double >(
"IndMinWidth");
84 fColMinWidth = pset.get<
double >(
"ColMinWidth",0.);
87 fAreaNorms = pset.get< std::vector< double > >(
"AreaNorms");
88 fUncompressWithPed = pset.get<
bool >(
"UncompressWithPed",
true);
89 fSkipInd = pset.get<
bool >(
"SkipInd",
false);
90 fColMinWindow = pset.get<
int >(
"ColMinWindow",0);
91 fIndCutoff = pset.get<
int >(
"IndCutoff",20);
92 mf::LogInfo(
"RawHitFinder_module") <<
"fDigitModuleLabel: " << fDigitModuleLabel << std::endl;
107 art::ServiceHandle<geo::Geometry const> geom;
110 art::Handle< std::vector<raw::RawDigit> > digitVecHandle;
114 mf::LogInfo(
"RawHitFinder_module") <<
"I got fDigitModuleLabel: " <<
fDigitModuleLabel << std::endl;
116 mf::LogWarning(
"RawHitFinder_module") <<
"Could not get fDigitModuleLabel: " <<
fDigitModuleLabel << std::endl;
118 std::vector<float> holder;
119 std::vector<short> rawadc;
127 std::vector<float> startTimes;
128 std::vector<float> maxTimes;
129 std::vector<float> endTimes;
130 std::vector<float> peakHeight;
131 std::vector<float> hitrms;
132 std::vector<double> charge;
134 uint32_t channel = 0;
135 double threshold = 0;
140 std::stringstream numConv;
142 hcol.
reserve(digitVecHandle->size());
143 for(
size_t rdIter = 0; rdIter < digitVecHandle->size(); ++rdIter){
147 art::Ptr<raw::RawDigit> digitVec(digitVecHandle, rdIter);
148 channel = digitVec->Channel();
155 if (fUncompressWithPed){
156 int pedestal = (int)digitVec->GetPedestal();
157 raw::Uncompress(digitVec->ADCs(), rawadc, pedestal, digitVec->Compression());
165 = art::ServiceHandle<lariov::ChannelStatusService const>()->GetProvider();
171 holder[
bin]=(rawadc[
bin]-digitVec->GetPedestal());
174 sigType = geom->SignalType(channel);
183 bool channelSwitch =
false;
185 for(
auto it = BadChannels.begin(); it != BadChannels.end(); it++)
189 channelSwitch =
true;
194 if(channelSwitch==
false)
209 float negthr=-1.0*threshold;
214 while (bin<(fDataSize-1)) {
215 float thisadc = holder[
bin];
float nextadc = holder[bin+1];
216 if (thisadc<negthr && nextadc < negthr) {
219 unsigned int place =
bin;
220 while (thisadc<=0 && bin>0) {
225 float hittime = bin+thisadc/(thisadc-holder[bin+1]);
226 maxTimes.push_back(hittime);
231 while (thisadc<threshold && bin>stop) {
237 while (thisadc>threshold && bin>stop) {
242 startTimes.push_back(bin+1);
248 totSig = fabs(thisadc);
249 while (thisadc<negthr && bin<fDataSize) {
250 totSig += fabs(thisadc);
252 if (thisadc<minadc) minadc=thisadc;
255 endTimes.push_back(bin-1);
256 peakHeight.push_back(-1.0*minadc);
257 charge.push_back(totSig);
258 hitrms.push_back(5.0);
263 while (thisadc<0 && bin<fDataSize) {
266 if (bin == fDataSize)
break;
282 float madc = threshold;
286 unsigned int bin = 0;
288 while (bin<fDataSize)
290 float thisadc = holder[
bin];
298 if(thisadc>threshold && bin<fDataSize)
300 while (thisadc>threshold && bin<fDataSize)
308 if (bin == fDataSize)
break;
321 maxTimes.push_back(ibin);
322 peakHeight.push_back(madc);
323 startTimes.push_back(start);
324 endTimes.push_back(end);
333 for(
int i = start-moreTail; i <= end+moreTail; i++)
335 if(i<(
int)(holder.size()) && i>=0)
338 myrms += temp*temp*holder[i];
344 charge.push_back(totSig);
347 hitrms.push_back(sqrt(myrms));
384 double amplitude(0), position(0);
385 double start(0),
end(0);
386 double amplitudeErr(0), positionErr(0);
387 double goodnessOfFit(0), chargeErr(0);
390 numHits = maxTimes.size();
391 for (
int i = 0; i < numHits; ++i)
393 amplitude = peakHeight[i];
394 position = maxTimes[i];
395 start = startTimes[i];
405 std::vector<geo::WireID> wids = geom->ChannelToWire(channel);
410 mf::LogWarning(
"RawHitFinder_module") <<
"Hit start " << start <<
" is >= hit end " <<
end;
426 std::accumulate(holder.begin() + (int) start, holder.begin() + (int) end, 0.),
void produce(art::Event &evt) override
std::set< raw::ChannelID_t > ChannelSet_t
Type of set of channel IDs.
std::string fHitLabelName
fMaxMultiHit(pset.get< int >("MaxMultiHit"))
std::vector< double > fAreaNorms
Definition of basic raw digits.
virtual ChannelSet_t BadChannels() const =0
Returns a copy of set of bad channel IDs for the current run.
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.
constexpr details::BinObj< T > bin(T value)
Returns a wrapper to print the specified data in binary format.
Class managing the creation of a new recob::Hit object.
Helper functions to create a hit.
A class handling a collection of hits and its associations.
Signal from induction planes.
void reserve(size_t new_size)
Prepares the collection to host at least new_size hits.
enum geo::_plane_sigtype SigType_t
Collect all the RawData header files together.
RawHitFinder(fhicl::ParameterSet const &pset)
auto end(FixedBins< T, C > const &) noexcept
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.
Class providing information about the quality of channels.
Definition of data types for geometry description.
void put_into(art::Event &)
Moves the data into an event.
std::string fCalDataModuleLabel
art::InputTag fDigitModuleLabel
Interface for experiment-specific channel quality info provider.
fAreaMethod(pset.get< int >("AreaMethod"))
Interface for experiment-specific service for channel quality info.
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
art framework interface to geometry description
Signal from collection planes.