Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
sn::SNBackgroundRejection Class Reference
Inheritance diagram for sn::SNBackgroundRejection:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 SNBackgroundRejection (fhicl::ParameterSet const &p)
 
 SNBackgroundRejection (SNBackgroundRejection const &)=delete
 
 SNBackgroundRejection (SNBackgroundRejection &&)=delete
 
SNBackgroundRejectionoperator= (SNBackgroundRejection const &)=delete
 
SNBackgroundRejectionoperator= (SNBackgroundRejection &&)=delete
 
float FOM (std::vector< rb::CellHit > hits)
 
std::pair< uint64_t, uint64_t > MicrosliceTimeMarkers (rawdata::FlatDAQData &flat)
 
void produce (art::Event &e)
 
void endJob ()
 
std::string workerType () const
 
void doBeginJob ()
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< TconsumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< TmayConsumeView (InputTag const &tag)
 

Protected Member Functions

ConsumesCollector & consumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< Tconsumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< TmayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Private Attributes

fhicl::ParameterSet const fParams
 
std::string fRawDataLabel
 ART module label for raw data. More...
 
std::string fFlatDAQDataLabel
 ART module label for flatDaqData. More...
 
std::string fCellHitLabel
 ART module label for cell hits. More...
 
std::string fClusterLabel
 ART module label for clusters. More...
 
std::string fCleanupClusterLabel
 ART module label for cleanup clusters. More...
 
std::string fTrackLabel
 ART module label for tracks. More...
 
bool fVerbose
 Enable/disable verbose output. More...
 
int fNSigFinal
 Number of signal (MC) hits seen by job. More...
 
int fNBkgFinal
 Number of background hits seen by job. More...
 
int fTriggerTimeTotal
 
int fVetoTimeTotal
 
bool fRemoveFirstMicroslice
 Enable/disable removing hits from first microslice. More...
 
bool fRemoveLowHighADC
 Enable/disable removing these hits. More...
 
int fLowADCThresh
 Min. acceptable ADC. More...
 
int fHighADCThresh
 Max. acceptable ADC. More...
 
bool fRemoveColdHotChannels
 Enable/disable removing these hits. More...
 
float fColdRateThreshold
 Min. acceptable channel hit rate. More...
 
float fHotRateThreshold
 Max. acceptable channel hit rate. More...
 
float fRateDuration
 Total time (s) to accumulate statistics. More...
 
bool fRemoveFEBFlashers
 Enable/disable removing these hits. More...
 
unsigned int fInstigatorQ
 Min. accumulated charge to be a "flash instigator". More...
 
unsigned int fInstigatorT
 Time over which fInstigatorQ charge must be accumulated. More...
 
unsigned int fVetoQ
 Min. charge for a hit to be a "flash hit". More...
 
unsigned int fVetoT
 Max. time after the. More...
 
bool fRemoveTrackActivity
 Enable/disable removing these hits. More...
 
int fMuonEndTimeCut
 Min. time difference between hit and track end to reject [ns]. More...
 
int fMuonBodyTimeCut
 Min. time difference between hit and track to reject [ns]. More...
 
int fMuonEndSphereRadius
 Min. distance of hit from track end to reject [cm]. More...
 
int fMuonBodyCylinderRadius
 Min. distance of hit from track to reject [cm]. More...
 
bool fRemovePhysicsSlices
 Enable/disable removing these hits. More...
 
bool fRemoveHighEnergyActivity
 Enable/disable removing hits from time windows with HE activity. More...
 
float fPeakThreshold
 Number standard deviations above baseline for a peak that should be vetoed. More...
 
float fVetoWindowPadding
 Fraction of peak width that should added to either side of TDC veto window. More...
 
art::ServiceHandle< geo::GeometryfGeom
 
sn::DaqChannelMaskfChannelMask
 

Detailed Description

Definition at line 53 of file SNBackgroundRejection_module.cc.

Member Typedef Documentation

Definition at line 17 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::detail::Producer::Table = Modifier::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 25 of file Producer.h.

using art::EDProducer::WorkerType = WorkerT<EDProducer>
inherited

Definition at line 18 of file EDProducer.h.

Constructor & Destructor Documentation

sn::SNBackgroundRejection::SNBackgroundRejection ( fhicl::ParameterSet const &  p)
explicit

Definition at line 122 of file SNBackgroundRejection_module.cc.

122  :
123 EDProducer(p),
124 fParams(p),
125 fRawDataLabel(p.get<std::string>("RawDataLabel")),
126 fFlatDAQDataLabel(p.get<std::string>("FlatDAQDataLabel")),
127 fCellHitLabel(p.get<std::string>("CellHitLabel")),
128 fClusterLabel(p.get<std::string>("ClusterLabel")),
129 fCleanupClusterLabel(p.get<std::string>("CleanupClusterLabel")),
130 fTrackLabel(p.get<std::string>("TrackLabel")),
131 fVerbose(p.get<bool>("Verbose")),
132 fNSigFinal(0),
133 fNBkgFinal(0),
135 fVetoTimeTotal(0),
136 fRemoveFirstMicroslice(p.get<bool>("RemoveFirstMicroslice")),
137 fRemoveLowHighADC(p.get<bool>("RemoveLowHighADC")),
138 fLowADCThresh(p.get<unsigned int>("LowADCThresh")),
139 fHighADCThresh(p.get<unsigned int>("HighADCThresh")),
140 fRemoveColdHotChannels(p.get<bool>("RemoveColdHotChannels")),
141 fColdRateThreshold(p.get<float>("ColdRateThreshold")),
142 fHotRateThreshold(p.get<float>("HotRateThreshold")),
143 fRateDuration(p.get<float>("RateDuration")),
144 fRemoveFEBFlashers(p.get<bool>("RemoveFEBFlashers")),
145 fInstigatorQ(p.get<unsigned int>("InstigatorQ")),
146 fInstigatorT(p.get<unsigned int>("InstigatorT")),
147 fVetoQ(p.get<unsigned int>("VetoQ")),
148 fVetoT(p.get<unsigned int>("VetoT")),
149 fRemoveTrackActivity(p.get<bool>("RemoveTrackActivity")),
150 fMuonEndTimeCut(p.get<int>("MuonEndTimeCut")),
151 fMuonBodyTimeCut(p.get<int>("MuonBodyTimeCut")),
152 fMuonEndSphereRadius(p.get<int>("MuonEndSphereRadius")),
153 fMuonBodyCylinderRadius(p.get<int>("MuonBodyCylinderRadius")),
154 fRemovePhysicsSlices(p.get<bool>("RemovePhysicsSlices")),
155 fRemoveHighEnergyActivity(p.get<bool>("RemoveHighEnergyActivity")),
156 fPeakThreshold(p.get<float>("PeakThreshold")),
157 fVetoWindowPadding(p.get<float>("VetoWindowPadding")),
159 {
160  produces<std::vector<rb::CellHit>>();
161  produces<int>();
162 }
int fNSigFinal
Number of signal (MC) hits seen by job.
std::string fClusterLabel
ART module label for clusters.
unsigned int fVetoT
Max. time after the.
unsigned int fVetoQ
Min. charge for a hit to be a "flash hit".
int fNBkgFinal
Number of background hits seen by job.
std::string fCleanupClusterLabel
ART module label for cleanup clusters.
bool fRemoveFirstMicroslice
Enable/disable removing hits from first microslice.
const char * p
Definition: xmltok.h:285
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
std::string fFlatDAQDataLabel
ART module label for flatDaqData.
float fColdRateThreshold
Min. acceptable channel hit rate.
int fMuonEndTimeCut
Min. time difference between hit and track end to reject [ns].
bool fRemoveTrackActivity
Enable/disable removing these hits.
bool fRemoveFEBFlashers
Enable/disable removing these hits.
int fMuonEndSphereRadius
Min. distance of hit from track end to reject [cm].
unsigned int fInstigatorT
Time over which fInstigatorQ charge must be accumulated.
float fPeakThreshold
Number standard deviations above baseline for a peak that should be vetoed.
int fMuonBodyTimeCut
Min. time difference between hit and track to reject [ns].
bool fVerbose
Enable/disable verbose output.
bool fRemoveColdHotChannels
Enable/disable removing these hits.
std::string fCellHitLabel
ART module label for cell hits.
int fMuonBodyCylinderRadius
Min. distance of hit from track to reject [cm].
float fHotRateThreshold
Max. acceptable channel hit rate.
bool fRemoveHighEnergyActivity
Enable/disable removing hits from time windows with HE activity.
bool fRemovePhysicsSlices
Enable/disable removing these hits.
float fRateDuration
Total time (s) to accumulate statistics.
unsigned int fInstigatorQ
Min. accumulated charge to be a "flash instigator".
bool fRemoveLowHighADC
Enable/disable removing these hits.
int fHighADCThresh
Max. acceptable ADC.
std::string fTrackLabel
ART module label for tracks.
float fVetoWindowPadding
Fraction of peak width that should added to either side of TDC veto window.
int fLowADCThresh
Min. acceptable ADC.
std::string fRawDataLabel
ART module label for raw data.
enum BeamMode string
sn::SNBackgroundRejection::SNBackgroundRejection ( SNBackgroundRejection const &  )
delete
sn::SNBackgroundRejection::SNBackgroundRejection ( SNBackgroundRejection &&  )
delete

Member Function Documentation

template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::consumes ( InputTag const &  tag)
protectedinherited

Definition at line 55 of file ModuleBase.h.

References art::ModuleBase::collector_, art::ConsumesCollector::consumes(), T, and getGoodRuns4SAM::tag.

56  {
57  return collector_.consumes<T, BT>(tag);
58  }
ConsumesCollector collector_
Definition: ModuleBase.h:50
ProductToken< T > consumes(InputTag const &)
double T
Definition: Xdiff_gwt.C:5
ConsumesCollector& art::ModuleBase::consumesCollector ( )
protectedinherited
template<typename T , BranchType BT>
void art::ModuleBase::consumesMany ( )
protectedinherited

Definition at line 69 of file ModuleBase.h.

References art::ModuleBase::collector_, art::ConsumesCollector::consumesMany(), and T.

70  {
71  collector_.consumesMany<T, BT>();
72  }
ConsumesCollector collector_
Definition: ModuleBase.h:50
double T
Definition: Xdiff_gwt.C:5
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::consumesView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::consumesView ( InputTag const &  tag)
inherited

Definition at line 62 of file ModuleBase.h.

References art::ModuleBase::collector_, art::ConsumesCollector::consumesView(), T, and getGoodRuns4SAM::tag.

63  {
64  return collector_.consumesView<T, BT>(tag);
65  }
ConsumesCollector collector_
Definition: ModuleBase.h:50
ViewToken< Element > consumesView(InputTag const &)
double T
Definition: Xdiff_gwt.C:5
void art::detail::Producer::doBeginJob ( )
inherited
bool art::detail::Producer::doBeginRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited
bool art::detail::Producer::doBeginSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited
void art::detail::Producer::doEndJob ( )
inherited
bool art::detail::Producer::doEndRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited
bool art::detail::Producer::doEndSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited
bool art::detail::Producer::doEvent ( EventPrincipal ep,
ModuleContext const &  mc,
std::atomic< std::size_t > &  counts_run,
std::atomic< std::size_t > &  counts_passed,
std::atomic< std::size_t > &  counts_failed 
)
inherited
void art::detail::Producer::doRespondToCloseInputFile ( FileBlock const &  fb)
inherited
void art::detail::Producer::doRespondToCloseOutputFiles ( FileBlock const &  fb)
inherited
void art::detail::Producer::doRespondToOpenInputFile ( FileBlock const &  fb)
inherited
void art::detail::Producer::doRespondToOpenOutputFiles ( FileBlock const &  fb)
inherited
void sn::SNBackgroundRejection::endJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 451 of file SNBackgroundRejection_module.cc.

References om::cout, DEFINE_ART_MODULE(), e, allTimeWatchdog::endl, check_time_usage::float, fNBkgFinal, fNSigFinal, fTriggerTimeTotal, fVerbose, fVetoTimeTotal, and std::sqrt().

452 {
453  if (fVerbose) {
454  std::cout << std::endl;
455  std::cout << "----------------------------------------------" << std::endl;
456  std::cout << "JOB-END SUMMARY" << std::endl;
457  std::cout << "----------------------------------------------" << std::endl;
458  std::cout << "Final number of sig hits: " << fNSigFinal << std::endl;
459  std::cout << "Final number of bkg hits: " << fNBkgFinal << std::endl;
461  std::cout << "Final trigger time (TDC): " << fTriggerTimeTotal << std::endl;
462  std::cout << "Final veto time (TDC): " << fVetoTimeTotal << std::endl;
463  std::cout << "Final livetime (ms): " << (fTriggerTimeTotal-fVetoTimeTotal)*15.625*1e-6 << std::endl;
464  std::cout << "Final livetime loss (%): " << ((float)fVetoTimeTotal / (float)fTriggerTimeTotal)*100 << std::endl;
465  std::cout << "----------------------------------------------" << std::endl;
466  }
467 }
int fNSigFinal
Number of signal (MC) hits seen by job.
int fNBkgFinal
Number of background hits seen by job.
T sqrt(T number)
Definition: d0nt_math.hpp:156
bool fVerbose
Enable/disable verbose output.
OStream cout
Definition: OStream.cxx:6
Float_t e
Definition: plot.C:35
float sn::SNBackgroundRejection::FOM ( std::vector< rb::CellHit hits)

Definition at line 166 of file SNBackgroundRejection_module.cc.

References b, and std::sqrt().

Referenced by produce().

167 {
168  int s = 0;
169  int b = 0;
170 
171  for (rb::CellHit hit : hits) {
172  (hit.IsMC()) ? ++s : ++b;
173  }
174 
175  return (float)s / std::sqrt(s+b);
176 }
T sqrt(T number)
Definition: d0nt_math.hpp:156
const XML_Char * s
Definition: expat.h:262
void hits()
Definition: readHits.C:15
A rawdata::RawDigit with channel information decoded.
Definition: CellHit.h:27
Definition: structs.h:12
const hit & b
Definition: hits.cxx:21
std::array<std::vector<ProductInfo>, NumBranchTypes> const& art::ModuleBase::getConsumables ( ) const
inherited
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::mayConsume ( InputTag const &  tag)
protectedinherited

Definition at line 76 of file ModuleBase.h.

References art::ModuleBase::collector_, art::ConsumesCollector::mayConsume(), T, and getGoodRuns4SAM::tag.

77  {
78  return collector_.mayConsume<T, BT>(tag);
79  }
ProductToken< T > mayConsume(InputTag const &)
ConsumesCollector collector_
Definition: ModuleBase.h:50
double T
Definition: Xdiff_gwt.C:5
template<typename T , BranchType BT>
void art::ModuleBase::mayConsumeMany ( )
protectedinherited

Definition at line 90 of file ModuleBase.h.

References art::ModuleBase::collector_, art::ConsumesCollector::mayConsumeMany(), and T.

91  {
93  }
ConsumesCollector collector_
Definition: ModuleBase.h:50
double T
Definition: Xdiff_gwt.C:5
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::mayConsumeView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::mayConsumeView ( InputTag const &  tag)
inherited

Definition at line 83 of file ModuleBase.h.

References art::ModuleBase::collector_, art::ConsumesCollector::mayConsumeView(), T, and getGoodRuns4SAM::tag.

84  {
85  return collector_.mayConsumeView<T, BT>(tag);
86  }
ConsumesCollector collector_
Definition: ModuleBase.h:50
ViewToken< Element > mayConsumeView(InputTag const &)
double T
Definition: Xdiff_gwt.C:5
std::pair< uint64_t, uint64_t > sn::SNBackgroundRejection::MicrosliceTimeMarkers ( rawdata::FlatDAQData flat)

Definition at line 179 of file SNBackgroundRejection_module.cc.

References rawdata::FlatDAQData::getRawBufferPointer(), and make_pair().

Referenced by produce().

180 {
181  uint64_t maxTimingMarker = 0x0;
182  uint64_t minTimingMarker = 0xFFFFFFFFFFFFFFFF;
183 
184  // Unpack raw event
186  rawEvt.readData(flat.getRawBufferPointer());
187 
188  // Loop over data blocks
189  size_t nDataBlocks = rawEvt.getDataBlockNumber();
190  for (size_t idxDB=0; idxDB<nDataBlocks; ++idxDB) {
191  rawEvt.setFloatingDataBlock(idxDB);
192  daqdataformats::RawDataBlock dataBlock = (*rawEvt.getFloatingDataBlock());
193 
194  // Loop over microslices
195  size_t nMicroBlocks = dataBlock.getNumMicroBlocks();
196  for (size_t idxMB=0; idxMB<nMicroBlocks; ++idxMB) {
197  dataBlock.setFloatingMicroBlock(idxMB);
198 
199  // Extract max/min timing marker across all microslices
200  uint64_t tm = dataBlock.getFloatingMicroBlock()->getMicroSlice()->getTimingMarker()->getTime();
201  if (tm > maxTimingMarker) {
202  maxTimingMarker = tm;
203  }
204  if (tm < minTimingMarker) {
205  minTimingMarker = tm;
206  }
207  }
208  }
209 
210  return std::make_pair(minTimingMarker, maxTimingMarker);
211 }
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
Definition: DataMCLoad.C:336
void * getRawBufferPointer() const
Definition: FlatDAQData.h:21
ModuleDescription const& art::ModuleBase::moduleDescription ( ) const
inherited
SNBackgroundRejection& sn::SNBackgroundRejection::operator= ( SNBackgroundRejection const &  )
delete
SNBackgroundRejection& sn::SNBackgroundRejection::operator= ( SNBackgroundRejection &&  )
delete
void sn::SNBackgroundRejection::produce ( art::Event e)
virtual

Implements art::EDProducer.

Definition at line 215 of file SNBackgroundRejection_module.cc.

References sn::DaqChannelMask::AddHit(), sn::HitVetoMap::AddHit(), sn::DaqChannelMask::CalculateRates(), sn::HitVetoMap::ContainsHit(), om::cout, sn::DaqChannelMask::CurrentDuration(), allTimeWatchdog::endl, fCellHitLabel, fChannelMask, fCleanupClusterLabel, fClusterLabel, fColdRateThreshold, fFlatDAQDataLabel, fGeom, fHighADCThresh, fHotRateThreshold, art::fill_ptr_vector(), fInstigatorQ, fInstigatorT, check_time_usage::float, fLowADCThresh, fMuonBodyCylinderRadius, fMuonBodyTimeCut, fMuonEndSphereRadius, fMuonEndTimeCut, fNBkgFinal, fNSigFinal, FOM(), fParams, fPeakThreshold, fRateDuration, fRawDataLabel, fRemoveColdHotChannels, fRemoveFEBFlashers, fRemoveFirstMicroslice, fRemoveHighEnergyActivity, fRemoveLowHighADC, fRemovePhysicsSlices, fRemoveTrackActivity, fTrackLabel, rawdata::RawTrigger::fTriggerRange_TriggerLength, fTriggerTimeTotal, rawdata::RawTrigger::fTriggerTimingMarker_TimeStart, fVerbose, fVetoQ, fVetoT, fVetoTimeTotal, fVetoWindowPadding, art::DataViewImpl::getByLabel(), hits(), compare_h5_caf::idx, sn::DaqChannelMask::IncrementDuration(), rawdata::RawDigit::IsMC(), sn::DaqChannelMask::MaskSize(), MicrosliceTimeMarkers(), sn::FEBFlasherRemover::NFlasherHits(), sn::FEBFlasherRemover::NInstigators(), sn::HighEnergyRemover::NPeaks(), sn::SliceRemover::NumRemoved(), sn::TrackActivityRemover::NumRemovedBody(), sn::ColdHotChannelsRemover::NumRemovedCold(), sn::LowHighADCRemover::NumRemovedHigh(), sn::ColdHotChannelsRemover::NumRemovedHot(), sn::LowHighADCRemover::NumRemovedLow(), sn::TrackActivityRemover::NumRemovedMichel(), sn::TrackActivityRemover::NumRemovedTrack(), art::DataViewImpl::put(), sn::DaqChannelMask::RatesCalculated(), sn::FEBFlasherRemover::remove(), sn::ColdHotChannelsRemover::remove(), sn::SliceRemover::remove(), sn::LowHighADCRemover::remove(), sn::HighEnergyRemover::remove(), sn::TrackActivityRemover::remove(), sn::HighEnergyRemover::SetPeakThreshold(), sn::TrackActivityRemover::SetVetoRegion(), sn::HighEnergyRemover::SetVetoWindowPadding(), sn::HitVetoMap::Size(), rb::SortByTime(), rb::SortTracksByTime(), and sn::HighEnergyRemover::TotalTDCVetoed().

216 {
217  std::unique_ptr<std::vector<rb::CellHit>> product_cellhits(new std::vector<rb::CellHit>);
218  std::unique_ptr<int> product_livetime(new int);
219 
220  /* Get the FlatDAQData from the event */
222  e.getByLabel(fFlatDAQDataLabel, hdlFlatDaqData);
223  rawdata::FlatDAQData flatDaqData = hdlFlatDaqData->at(0);
224 
225  /* Get the trigger information from event */
227  e.getByLabel(fRawDataLabel, hdlTrigger);
228  const rawdata::RawTrigger rawTrigger = hdlTrigger->at(0);
229  uint64_t triggerStartTime = rawTrigger.fTriggerTimingMarker_TimeStart;
230  // NOTE: 1 unit of trigger length = 500 ns = 32 TDC
231  uint32_t triggerLengthTDC = rawTrigger.fTriggerRange_TriggerLength * 32;
232 
233  /* Get RawDigits from event, put them into a vector, and sort them by time */
235  e.getByLabel(fRawDataLabel, hdlDigits);
236  std::vector<art::Ptr<rawdata::RawDigit>> digits;
237  digits.reserve(hdlDigits->size());
238  int nHitSigBefore = 0;
239  int nHitBkgBefore = 0;
240  for (unsigned int idx=0; idx<hdlDigits->size(); ++idx){
241  art::Ptr<rawdata::RawDigit> digit(hdlDigits, idx);
242  digits.push_back(digit);
243  (digit->IsMC()) ? ++nHitSigBefore : ++nHitBkgBefore;
244  }
245 
246  /* Get CellHits from event, put them into a vector, and sort them by time */
248  e.getByLabel(fCellHitLabel, hdlHits);
249  std::vector<art::Ptr<rb::CellHit>> hits;
250  hits.reserve(hdlHits->size());
251  for (unsigned int idx=0; idx<hdlHits->size(); ++idx){
252  art::Ptr<rb::CellHit> hit(hdlHits, idx);
253 
254  // Add hit to channel map
257  }
258 
259  hits.push_back(hit);
260  }
261  rb::SortByTime(hits);
262 
263  /* Accumulate channel hit stats or calculate rates */
265  fChannelMask->IncrementDuration((float)rawTrigger.fTriggerRange_TriggerLength * 500e-9);
266  } else {
268  if (fVerbose) std::cout << "Masked " << fChannelMask->MaskSize() << " channels." << std::endl;
269  }
270 
271  /* Get Clusters from event */
273  e.getByLabel(fClusterLabel, hdlClusters);
274 
275  /* Get Cleanup Clusters from event */
276  art::Handle<std::vector<rb::Cluster>> hdlCleanupClusters;
277  e.getByLabel(fCleanupClusterLabel, hdlCleanupClusters);
278  std::vector<art::Ptr<rb::Cluster>> cleanupClusters;
279  art::fill_ptr_vector(cleanupClusters, hdlCleanupClusters);
280 
281  /* Get Tracks from event, put them in a ptrVector, and sort them by time */
283  e.getByLabel(fTrackLabel, hdlTracks);
284  art::FindOneP<rb::Cluster> clusterFromTrack(hdlTracks, e, fTrackLabel);
285  std::vector<art::Ptr<rb::Track>> tracks;
286  art::fill_ptr_vector(tracks, hdlTracks);
287  rb::SortTracksByTime(tracks);
288 
289 
290  /* ..... BEGIN BACKGROUND REJECTION ..... */
291 
292  // Run each algorithm, add to the hit veto map
293  if (fVerbose) std::cout << "=========== SN BACKGROUND REMOVAL ===========" << std::endl << std::endl;
294 
295  // Initialize hit veto map & hit removal classes
296  sn::HitVetoMap* vetoMapHits = new sn::HitVetoMap();
297 
298  /* Remove first microslice */
300  if (fVerbose) std::cout << "-- FIRST (DUPLICATED) MICROSLICE ------------" << std::endl;
301  std::pair<uint64_t,uint64_t> microsliceMarkers = this->MicrosliceTimeMarkers(flatDaqData);
302  if (fVerbose) std::cout << "• uslice start time = " << microsliceMarkers.first << std::endl;
303  if (fVerbose) std::cout << "• Remove hits between times: [" << microsliceMarkers.first << ", " << microsliceMarkers.first+3200 << "]" << std::endl;
304  for (art::Ptr<rb::CellHit> hit : hits) {
305  // Add first 50us to time window veto map (duplicate microslices)
306  // NOTE: 3200 64-MHz clock ticks = 50 us
307  if (hit->TDC() + triggerStartTime > microsliceMarkers.first + 3200) break;
308  vetoMapHits->AddHit(*hit);
309  }
310 
311  if (fVerbose) std::cout << "Veto map size: " << vetoMapHits->Size() << std::endl << std::endl;
312  }
313 
314  /* Hot/Cold Channel Remove */
316  if (fVerbose) std::cout << "-- COLD/HOT CHANNEL HITS --------------------" << std::endl;
318  coldHotChanRemover->remove(digits);
319  if (fVerbose) {
320  if (!fChannelMask->RatesCalculated()) {
321  std::cout << "• Accumulating statistics for cold/hot channel map..." << std::endl;
322  } else {
323  std::cout << "• Found " << coldHotChanRemover->NumRemovedCold() << " cold channel hits." << std::endl;
324  std::cout << "• Found " << coldHotChanRemover->NumRemovedHot() << " hot channel hits." << std::endl;
325  }
326  std::cout << "Veto map size: " << vetoMapHits->Size() << std::endl << std::endl;
327  }
328  delete coldHotChanRemover;
329  }
330 
331  /* FEB Flasher Remove */
332  if (fRemoveFEBFlashers) {
333  if (fVerbose) std::cout << "-- FEB FLASHERS -----------------------------" << std::endl;
335  flashRemover->remove(digits);
336  if (fVerbose) {
337  std::cout << "• Found " << flashRemover->NInstigators() << " instigators of " << flashRemover->NFlasherHits() << " flasher hits." << std::endl;
338  std::cout << "Veto map size: " << vetoMapHits->Size() << std::endl << std::endl;
339  }
340  delete flashRemover;
341  }
342 
343  /* Low/High ADC Remove */
344  if (fRemoveLowHighADC) {
345  if (fVerbose) std::cout << "-- LOW/HIGH-ADC HITS ------------------------" << std::endl;
347  adcRemover->remove(digits);
348  if (fVerbose) {
349  std::cout << "• Found " << adcRemover->NumRemovedLow() << " low-ADC hits." << std::endl;
350  std::cout << "• Found " << adcRemover->NumRemovedHigh() << " high-ADC hits." << std::endl;
351  std::cout << "Veto map size: " << vetoMapHits->Size() << std::endl << std::endl;
352  }
353  delete adcRemover;
354  }
355 
356  /* Track & Michel Remove */
357  if (fRemoveTrackActivity) {
358  if (fVerbose) std::cout << "-- TRACK ACTIVITY HITS ----------------------" << std::endl;
359  sn::TrackActivityRemover* trackActivityRemover = new sn::TrackActivityRemover(*vetoMapHits, fParams, fGeom, clusterFromTrack);
361  trackActivityRemover->remove(hits, hdlTracks);
362  if (fVerbose) {
363  std::cout << "• Found " << trackActivityRemover->NumRemovedMichel() << " hits associated with Michel electrons." << std::endl;
364  std::cout << "• Found " << trackActivityRemover->NumRemovedBody() << " hits near track body." << std::endl;
365  std::cout << "• Found " << trackActivityRemover->NumRemovedTrack() << " track hits." << std::endl;
366  std::cout << "Veto map size: " << vetoMapHits->Size() << std::endl << std::endl;
367  }
368  delete trackActivityRemover;
369  }
370 
371  /* Slice Hits Remove */
372  if (fRemovePhysicsSlices) {
373  if (fVerbose) std::cout << "-- SLICE HITS ----------------------" << std::endl;
374  sn::SliceRemover* sliceRemover = new sn::SliceRemover(*vetoMapHits);
375  sliceRemover->remove(hits, cleanupClusters);
376  if (fVerbose) {
377  std::cout << "• Found " << sliceRemover->NumRemoved()
378  << " hits associated with " << cleanupClusters.size()
379  << " physics clusters." << std::endl;
380  std::cout << "Veto map size: " << vetoMapHits->Size() << std::endl << std::endl;
381  }
382  delete sliceRemover;
383  }
384 
385  /* High-Energy Activity Remove */
386  uint32_t TDCVetoed = 0;
388  if (fVerbose) std::cout << "-- HIGH-ENERGY ACTIVITY ---------------------" << std::endl;
389  sn::HighEnergyRemover* highEnergyRemover = new sn::HighEnergyRemover(*vetoMapHits);
390  highEnergyRemover->SetPeakThreshold(fPeakThreshold);
391  highEnergyRemover->SetVetoWindowPadding(fVetoWindowPadding);
392  highEnergyRemover->remove(hits);
393  TDCVetoed = highEnergyRemover->TotalTDCVetoed();
394  if (fVerbose) {
395  std::cout << "• Found " << highEnergyRemover->NPeaks() << " peaks" << std::endl;
396  std::cout << "• Vetoed " << highEnergyRemover->TotalTDCVetoed()
397  << " / " << triggerLengthTDC << " TDC ("
398  << (float)highEnergyRemover->TotalTDCVetoed() / (float)triggerLengthTDC * 100.0
399  << "%)" << std::endl;
400  std::cout << "Veto map size: " << vetoMapHits->Size() << std::endl << std::endl;
401  }
402  delete highEnergyRemover;
403  }
404 
405  *product_livetime = triggerLengthTDC - TDCVetoed;
406  fTriggerTimeTotal += triggerLengthTDC;
407  fVetoTimeTotal += TDCVetoed;
408 
409  int nHitSigAfter = 0;
410  int nHitBkgAfter = 0;
411 
412  // Invert hit veto map
413  for (art::Ptr<rb::CellHit> hit : hits) {
414  if (!vetoMapHits->ContainsHit(*hit)) {
415  product_cellhits->push_back(*hit);
416  (hit->IsMC()) ? ++nHitSigAfter : ++nHitBkgAfter;
417  (hit->IsMC()) ? ++fNSigFinal : ++fNBkgFinal;
418  }
419  }
420 
421  delete vetoMapHits;
422 
423  /* ..... END BACKGROUND REJECTION ..... */
424 
425 
426  if (fVerbose) {
427  std::cout << "----------------------------------------------" << std::endl;
428  std::cout << "Total hits in event: " << hits.size() << std::endl;
429  std::cout << "Hits filtered: " << hits.size() - product_cellhits->size() << std::endl;
430  std::cout << "Hits passed: " << product_cellhits->size() << std::endl;
431  std::cout << "Signal loss: " << nHitSigBefore - nHitSigAfter
432  << " (" << (float)(nHitSigBefore-nHitSigAfter)/(float)nHitSigBefore * 100.0 << "%)" << std::endl;
433  std::cout << "Bkgrnd loss: " << nHitBkgBefore - nHitBkgAfter
434  << " (" << (float)(nHitBkgBefore-nHitBkgAfter)/(float)nHitBkgBefore * 100.0 << "%)" << std::endl;
435  std::cout << "Rejection power: " << ((float)(hits.size() - product_cellhits->size()) / (float)hits.size()) * 100.0
436  << "%" << std::endl << std::endl;
437  }
438 
439  // Calculate FOM, write value and config params to TTree.
440  if (fVerbose) {
441  float fom = this->FOM(*product_cellhits);
442  std::cout << "FOM = " << fom << std::endl;
443  std::cout << "==============================================" << std::endl << std::endl;
444  }
445 
446  e.put(std::move(product_livetime));
447  e.put(std::move(product_cellhits));
448  return;
449 }
int fNSigFinal
Number of signal (MC) hits seen by job.
std::string fClusterLabel
ART module label for clusters.
void remove(std::vector< art::Ptr< rb::CellHit >> &hits, std::vector< art::Ptr< rb::Cluster >> &clusters)
unsigned int fVetoT
Max. time after the.
void SetVetoRegion(int muonEndTimeCut, int muonBodyTimeCut, int muonEndSphereRadius, int muonBodyCylinderRadius)
unsigned int fVetoQ
Min. charge for a hit to be a "flash hit".
int fNBkgFinal
Number of background hits seen by job.
std::string fCleanupClusterLabel
ART module label for cleanup clusters.
bool fRemoveFirstMicroslice
Enable/disable removing hits from first microslice.
art::ServiceHandle< geo::Geometry > fGeom
void IncrementDuration(float i)
size_t Size()
Definition: HitVetoMap.cxx:55
void SetVetoWindowPadding(float val)
void SortByTime(std::vector< art::Ptr< rb::CellHit > > &c)
Sort c in time order (earliest to latest).
Definition: CellHit.cxx:134
std::string fFlatDAQDataLabel
ART module label for flatDaqData.
bool ContainsHit(rawdata::RawDigit h)
Definition: HitVetoMap.cxx:41
float fColdRateThreshold
Min. acceptable channel hit rate.
int fMuonEndTimeCut
Min. time difference between hit and track end to reject [ns].
bool fRemoveTrackActivity
Enable/disable removing these hits.
bool fRemoveFEBFlashers
Enable/disable removing these hits.
void SetPeakThreshold(float val)
int fMuonEndSphereRadius
Min. distance of hit from track end to reject [cm].
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:446
void SortTracksByTime(std::vector< art::Ptr< rb::Track >> &t)
Sort t in time order (earliest to latest).
Definition: Track.cxx:539
void hits()
Definition: readHits.C:15
if(dump)
unsigned int fInstigatorT
Time over which fInstigatorQ charge must be accumulated.
float fPeakThreshold
Number standard deviations above baseline for a peak that should be vetoed.
std::pair< uint64_t, uint64_t > MicrosliceTimeMarkers(rawdata::FlatDAQData &flat)
void AddHit(rawdata::RawDigit h)
Definition: HitVetoMap.cxx:27
int fMuonBodyTimeCut
Min. time difference between hit and track to reject [ns].
void remove(art::Ptr< rawdata::RawDigit > hit)
bool fVerbose
Enable/disable verbose output.
void remove(art::Ptr< rawdata::RawDigit > hit)
void remove(std::vector< art::Ptr< rb::CellHit >> &hits)
OStream cout
Definition: OStream.cxx:6
float FOM(std::vector< rb::CellHit > hits)
bool fRemoveColdHotChannels
Enable/disable removing these hits.
std::string fCellHitLabel
ART module label for cell hits.
int fMuonBodyCylinderRadius
Min. distance of hit from track to reject [cm].
float fHotRateThreshold
Max. acceptable channel hit rate.
void remove(std::vector< art::Ptr< rawdata::RawDigit >> hits)
unsigned long long fTriggerTimingMarker_TimeStart
Definition: RawTrigger.h:38
bool fRemoveHighEnergyActivity
Enable/disable removing hits from time windows with HE activity.
Definition: structs.h:12
void AddHit(rawdata::RawDigit d)
bool fRemovePhysicsSlices
Enable/disable removing these hits.
float fRateDuration
Total time (s) to accumulate statistics.
unsigned int fInstigatorQ
Min. accumulated charge to be a "flash instigator".
bool fRemoveLowHighADC
Enable/disable removing these hits.
uint32_t fTriggerRange_TriggerLength
Definition: RawTrigger.h:40
void remove(std::vector< art::Ptr< rb::CellHit >> &hits, art::Handle< std::vector< rb::Track >> &hdlTracks)
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:291
int fHighADCThresh
Max. acceptable ADC.
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
Definition: DataViewImpl.h:730
std::string fTrackLabel
ART module label for tracks.
float fVetoWindowPadding
Fraction of peak width that should added to either side of TDC veto window.
Definition: fwd.h:29
int fLowADCThresh
Min. acceptable ADC.
std::string fRawDataLabel
ART module label for raw data.
void art::ModuleBase::setModuleDescription ( ModuleDescription const &  )
inherited
void art::ModuleBase::sortConsumables ( std::string const &  current_process_name)
inherited
std::string art::EDProducer::workerType ( ) const
inherited

Member Data Documentation

std::string sn::SNBackgroundRejection::fCellHitLabel
private

ART module label for cell hits.

Definition at line 74 of file SNBackgroundRejection_module.cc.

Referenced by produce().

sn::DaqChannelMask* sn::SNBackgroundRejection::fChannelMask
private

Definition at line 117 of file SNBackgroundRejection_module.cc.

Referenced by produce().

std::string sn::SNBackgroundRejection::fCleanupClusterLabel
private

ART module label for cleanup clusters.

Definition at line 76 of file SNBackgroundRejection_module.cc.

Referenced by produce().

std::string sn::SNBackgroundRejection::fClusterLabel
private

ART module label for clusters.

Definition at line 75 of file SNBackgroundRejection_module.cc.

Referenced by produce().

float sn::SNBackgroundRejection::fColdRateThreshold
private

Min. acceptable channel hit rate.

Definition at line 94 of file SNBackgroundRejection_module.cc.

Referenced by produce().

std::string sn::SNBackgroundRejection::fFlatDAQDataLabel
private

ART module label for flatDaqData.

Definition at line 73 of file SNBackgroundRejection_module.cc.

Referenced by produce().

art::ServiceHandle<geo::Geometry> sn::SNBackgroundRejection::fGeom
private

Definition at line 116 of file SNBackgroundRejection_module.cc.

Referenced by produce().

int sn::SNBackgroundRejection::fHighADCThresh
private

Max. acceptable ADC.

Definition at line 91 of file SNBackgroundRejection_module.cc.

Referenced by produce().

float sn::SNBackgroundRejection::fHotRateThreshold
private

Max. acceptable channel hit rate.

Definition at line 95 of file SNBackgroundRejection_module.cc.

Referenced by produce().

unsigned int sn::SNBackgroundRejection::fInstigatorQ
private

Min. accumulated charge to be a "flash instigator".

Definition at line 99 of file SNBackgroundRejection_module.cc.

Referenced by produce().

unsigned int sn::SNBackgroundRejection::fInstigatorT
private

Time over which fInstigatorQ charge must be accumulated.

Definition at line 100 of file SNBackgroundRejection_module.cc.

Referenced by produce().

int sn::SNBackgroundRejection::fLowADCThresh
private

Min. acceptable ADC.

Definition at line 90 of file SNBackgroundRejection_module.cc.

Referenced by produce().

int sn::SNBackgroundRejection::fMuonBodyCylinderRadius
private

Min. distance of hit from track to reject [cm].

Definition at line 108 of file SNBackgroundRejection_module.cc.

Referenced by produce().

int sn::SNBackgroundRejection::fMuonBodyTimeCut
private

Min. time difference between hit and track to reject [ns].

Definition at line 106 of file SNBackgroundRejection_module.cc.

Referenced by produce().

int sn::SNBackgroundRejection::fMuonEndSphereRadius
private

Min. distance of hit from track end to reject [cm].

Definition at line 107 of file SNBackgroundRejection_module.cc.

Referenced by produce().

int sn::SNBackgroundRejection::fMuonEndTimeCut
private

Min. time difference between hit and track end to reject [ns].

Definition at line 105 of file SNBackgroundRejection_module.cc.

Referenced by produce().

int sn::SNBackgroundRejection::fNBkgFinal
private

Number of background hits seen by job.

Definition at line 82 of file SNBackgroundRejection_module.cc.

Referenced by endJob(), and produce().

int sn::SNBackgroundRejection::fNSigFinal
private

Number of signal (MC) hits seen by job.

Definition at line 81 of file SNBackgroundRejection_module.cc.

Referenced by endJob(), and produce().

fhicl::ParameterSet const sn::SNBackgroundRejection::fParams
private

Definition at line 70 of file SNBackgroundRejection_module.cc.

Referenced by produce().

float sn::SNBackgroundRejection::fPeakThreshold
private

Number standard deviations above baseline for a peak that should be vetoed.

Definition at line 113 of file SNBackgroundRejection_module.cc.

Referenced by produce().

float sn::SNBackgroundRejection::fRateDuration
private

Total time (s) to accumulate statistics.

Definition at line 96 of file SNBackgroundRejection_module.cc.

Referenced by produce().

std::string sn::SNBackgroundRejection::fRawDataLabel
private

ART module label for raw data.

Definition at line 72 of file SNBackgroundRejection_module.cc.

Referenced by produce().

bool sn::SNBackgroundRejection::fRemoveColdHotChannels
private

Enable/disable removing these hits.

Definition at line 93 of file SNBackgroundRejection_module.cc.

Referenced by produce().

bool sn::SNBackgroundRejection::fRemoveFEBFlashers
private

Enable/disable removing these hits.

Definition at line 98 of file SNBackgroundRejection_module.cc.

Referenced by produce().

bool sn::SNBackgroundRejection::fRemoveFirstMicroslice
private

Enable/disable removing hits from first microslice.

Definition at line 87 of file SNBackgroundRejection_module.cc.

Referenced by produce().

bool sn::SNBackgroundRejection::fRemoveHighEnergyActivity
private

Enable/disable removing hits from time windows with HE activity.

Definition at line 112 of file SNBackgroundRejection_module.cc.

Referenced by produce().

bool sn::SNBackgroundRejection::fRemoveLowHighADC
private

Enable/disable removing these hits.

Definition at line 89 of file SNBackgroundRejection_module.cc.

Referenced by produce().

bool sn::SNBackgroundRejection::fRemovePhysicsSlices
private

Enable/disable removing these hits.

Definition at line 110 of file SNBackgroundRejection_module.cc.

Referenced by produce().

bool sn::SNBackgroundRejection::fRemoveTrackActivity
private

Enable/disable removing these hits.

Definition at line 104 of file SNBackgroundRejection_module.cc.

Referenced by produce().

std::string sn::SNBackgroundRejection::fTrackLabel
private

ART module label for tracks.

Definition at line 77 of file SNBackgroundRejection_module.cc.

Referenced by produce().

int sn::SNBackgroundRejection::fTriggerTimeTotal
private

Definition at line 84 of file SNBackgroundRejection_module.cc.

Referenced by endJob(), and produce().

bool sn::SNBackgroundRejection::fVerbose
private

Enable/disable verbose output.

Definition at line 79 of file SNBackgroundRejection_module.cc.

Referenced by endJob(), and produce().

unsigned int sn::SNBackgroundRejection::fVetoQ
private

Min. charge for a hit to be a "flash hit".

Definition at line 101 of file SNBackgroundRejection_module.cc.

Referenced by produce().

unsigned int sn::SNBackgroundRejection::fVetoT
private

Max. time after the.

Definition at line 102 of file SNBackgroundRejection_module.cc.

Referenced by produce().

int sn::SNBackgroundRejection::fVetoTimeTotal
private

Definition at line 85 of file SNBackgroundRejection_module.cc.

Referenced by endJob(), and produce().

float sn::SNBackgroundRejection::fVetoWindowPadding
private

Fraction of peak width that should added to either side of TDC veto window.

Definition at line 114 of file SNBackgroundRejection_module.cc.

Referenced by produce().


The documentation for this class was generated from the following file: