Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | List of all members
sn::SNBackgroundRejection Class Reference
Inheritance diagram for sn::SNBackgroundRejection:
art::EDProducer art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = ProducerBase::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 ()
 
template<typename PROD , BranchType B = InEvent>
ProductID getProductID (std::string const &instanceName={}) const
 
template<typename PROD , BranchType B>
ProductID getProductID (ModuleDescription const &moduleDescription, std::string const &instanceName) const
 
bool modifiesEvent () const
 
template<typename T , BranchType = InEvent>
ProductToken< Tconsumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< Tconsumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< TconsumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< TmayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< TmayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< TmayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

CurrentProcessingContext const * currentContext () const
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Private Attributes

fhicl::ParameterSet const fParams
 
std::string fRawDataLabel
 ART module label for raw data. 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

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::EDProducer::Table = ProducerBase::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 43 of file EDProducer.h.

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

Definition at line 35 of file EDProducer.h.

Constructor & Destructor Documentation

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

Definition at line 121 of file SNBackgroundRejection_module.cc.

121  :
122 fParams(p),
123 fRawDataLabel(p.get<std::string>("RawDataLabel")),
124 fCellHitLabel(p.get<std::string>("CellHitLabel")),
125 fClusterLabel(p.get<std::string>("ClusterLabel")),
126 fCleanupClusterLabel(p.get<std::string>("CleanupClusterLabel")),
127 fTrackLabel(p.get<std::string>("TrackLabel")),
128 fNSigFinal(0),
129 fNBkgFinal(0),
131 fVetoTimeTotal(0),
132 fRemoveFirstMicroslice(p.get<bool>("RemoveFirstMicroslice")),
133 fRemoveLowHighADC(p.get<bool>("RemoveLowHighADC")),
134 fLowADCThresh(p.get<unsigned int>("LowADCThresh")),
135 fHighADCThresh(p.get<unsigned int>("HighADCThresh")),
136 fRemoveColdHotChannels(p.get<bool>("RemoveColdHotChannels")),
137 fColdRateThreshold(p.get<float>("ColdRateThreshold")),
138 fHotRateThreshold(p.get<float>("HotRateThreshold")),
139 fRateDuration(p.get<float>("RateDuration")),
140 fRemoveFEBFlashers(p.get<bool>("RemoveFEBFlashers")),
141 fInstigatorQ(p.get<unsigned int>("InstigatorQ")),
142 fInstigatorT(p.get<unsigned int>("InstigatorT")),
143 fVetoQ(p.get<unsigned int>("VetoQ")),
144 fVetoT(p.get<unsigned int>("VetoT")),
145 fRemoveTrackActivity(p.get<bool>("RemoveTrackActivity")),
146 fMuonEndTimeCut(p.get<int>("MuonEndTimeCut")),
147 fMuonBodyTimeCut(p.get<int>("MuonBodyTimeCut")),
148 fMuonEndSphereRadius(p.get<int>("MuonEndSphereRadius")),
149 fMuonBodyCylinderRadius(p.get<int>("MuonBodyCylinderRadius")),
150 fRemovePhysicsSlices(p.get<bool>("RemovePhysicsSlices")),
151 fRemoveHighEnergyActivity(p.get<bool>("RemoveHighEnergyActivity")),
152 fPeakThreshold(p.get<float>("PeakThreshold")),
153 fVetoWindowPadding(p.get<float>("VetoWindowPadding")),
155 {
156  produces<std::vector<rb::CellHit>>();
157  produces<int>();
158 }
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
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 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 = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 146 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

147 {
148  if (!moduleContext_)
149  return ProductToken<T>::invalid();
150 
151  consumables_[BT].emplace_back(ConsumableType::Product,
152  TypeID{typeid(T)},
153  it.label(),
154  it.instance(),
155  it.process());
156  return ProductToken<T>{it};
157 }
set< int >::iterator it
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 161 of file Consumer.h.

References T.

162 {
163  if (!moduleContext_)
164  return;
165 
166  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
167 }
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 171 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

172 {
173  if (!moduleContext_)
174  return ViewToken<T>::invalid();
175 
176  consumables_[BT].emplace_back(ConsumableType::ViewElement,
177  TypeID{typeid(T)},
178  it.label(),
179  it.instance(),
180  it.process());
181  return ViewToken<T>{it};
182 }
set< int >::iterator it
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed)
inherited
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited
CurrentProcessingContext const* art::EDProducer::currentContext ( ) const
protectedinherited
void sn::SNBackgroundRejection::endJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 448 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().

449 {
450  if (fVerbose) {
451  std::cout << std::endl;
452  std::cout << "----------------------------------------------" << std::endl;
453  std::cout << "JOB-END SUMMARY" << std::endl;
454  std::cout << "----------------------------------------------" << std::endl;
455  std::cout << "Final number of sig hits: " << fNSigFinal << std::endl;
456  std::cout << "Final number of bkg hits: " << fNBkgFinal << std::endl;
458  std::cout << "Final trigger time (TDC): " << fTriggerTimeTotal << std::endl;
459  std::cout << "Final veto time (TDC): " << fVetoTimeTotal << std::endl;
460  std::cout << "Final livetime (ms): " << (fTriggerTimeTotal-fVetoTimeTotal)*15.625*1e-6 << std::endl;
461  std::cout << "Final livetime loss (%): " << ((float)fVetoTimeTotal / (float)fTriggerTimeTotal)*100 << std::endl;
462  std::cout << "----------------------------------------------" << std::endl;
463  }
464 }
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 162 of file SNBackgroundRejection_module.cc.

References b, and std::sqrt().

Referenced by produce().

163 {
164  int s = 0;
165  int b = 0;
166 
167  for (rb::CellHit hit : hits) {
168  (hit.IsMC()) ? ++s : ++b;
169  }
170 
171  return (float)s / std::sqrt(s+b);
172 }
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
seed_t art::EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited
template<typename PROD , BranchType B>
ProductID art::EDProducer::getProductID ( std::string const &  instanceName = {}) const
inlineinherited

Definition at line 123 of file EDProducer.h.

References art::EDProducer::moduleDescription_.

Referenced by skim::NueSkimmer::CopyMichelSlice(), and skim::NueSkimmer::CopyMichelTrack().

124  {
125  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
126  instanceName);
127  }
ModuleDescription moduleDescription_
Definition: EDProducer.h:115
template<typename PROD , BranchType B>
ProductID art::ProducerBase::getProductID ( ModuleDescription const &  moduleDescription,
std::string const &  instanceName 
) const
inherited

Definition at line 56 of file ProducerBase.h.

References art::ModuleDescription::moduleLabel().

Referenced by art::ProducerBase::modifiesEvent().

58  {
59  auto const& pd =
60  get_ProductDescription<PROD>(B, md.moduleLabel(), instanceName);
61  return pd.productID();
62  }
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 189 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

190 {
191  if (!moduleContext_)
192  return ProductToken<T>::invalid();
193 
194  consumables_[BT].emplace_back(ConsumableType::Product,
195  TypeID{typeid(T)},
196  it.label(),
197  it.instance(),
198  it.process());
199  return ProductToken<T>{it};
200 }
set< int >::iterator it
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 204 of file Consumer.h.

References T.

205 {
206  if (!moduleContext_)
207  return;
208 
209  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
210 }
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 214 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

215 {
216  if (!moduleContext_)
217  return ViewToken<T>::invalid();
218 
219  consumables_[BT].emplace_back(ConsumableType::ViewElement,
220  TypeID{typeid(T)},
221  it.label(),
222  it.instance(),
223  it.process());
224  return ViewToken<T>{it};
225 }
set< int >::iterator it
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
std::pair< uint64_t, uint64_t > sn::SNBackgroundRejection::MicrosliceTimeMarkers ( rawdata::FlatDAQData flat)

Definition at line 175 of file SNBackgroundRejection_module.cc.

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

Referenced by produce().

176 {
177  uint64_t maxTimingMarker = 0x0;
178  uint64_t minTimingMarker = 0xFFFFFFFFFFFFFFFF;
179 
180  // Unpack raw event
182  rawEvt.readData(flat.getRawBufferPointer());
183 
184  // Loop over data blocks
185  size_t nDataBlocks = rawEvt.getDataBlockNumber();
186  for (size_t idxDB=0; idxDB<nDataBlocks; ++idxDB) {
187  rawEvt.setFloatingDataBlock(idxDB);
188  daqdataformats::RawDataBlock dataBlock = (*rawEvt.getFloatingDataBlock());
189 
190  // Loop over microslices
191  size_t nMicroBlocks = dataBlock.getNumMicroBlocks();
192  for (size_t idxMB=0; idxMB<nMicroBlocks; ++idxMB) {
193  dataBlock.setFloatingMicroBlock(idxMB);
194 
195  // Extract max/min timing marker across all microslices
196  uint64_t tm = dataBlock.getFloatingMicroBlock()->getMicroSlice()->getTimingMarker()->getTime();
197  if (tm > maxTimingMarker) {
198  maxTimingMarker = tm;
199  }
200  if (tm < minTimingMarker) {
201  minTimingMarker = tm;
202  }
203  }
204  }
205 
206  return std::make_pair(minTimingMarker, maxTimingMarker);
207 }
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
bool art::ProducerBase::modifiesEvent ( ) const
inlineinherited

Definition at line 40 of file ProducerBase.h.

References art::ProducerBase::getProductID(), and string.

41  {
42  return true;
43  }
static cet::exempt_ptr<Consumer> art::Consumer::non_module_context ( )
staticinherited
SNBackgroundRejection& sn::SNBackgroundRejection::operator= ( SNBackgroundRejection const &  )
delete
SNBackgroundRejection& sn::SNBackgroundRejection::operator= ( SNBackgroundRejection &&  )
delete
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
void sn::SNBackgroundRejection::produce ( art::Event e)
virtual

Implements art::EDProducer.

Definition at line 211 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, 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(), sn::DaqChannelMask::Print(), art::Event::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().

212 {
213  std::unique_ptr<std::vector<rb::CellHit>> product_cellhits(new std::vector<rb::CellHit>);
214  std::unique_ptr<int> product_livetime(new int);
215 
216  /* Get the FlatDAQData from the event */
218  e.getByLabel(fRawDataLabel, hdlFlatDaqData);
219  rawdata::FlatDAQData flatDaqData = hdlFlatDaqData->at(0);
220 
221  /* Get the trigger information from event */
223  e.getByLabel(fRawDataLabel, hdlTrigger);
224  const rawdata::RawTrigger rawTrigger = hdlTrigger->at(0);
225  uint64_t triggerStartTime = rawTrigger.fTriggerTimingMarker_TimeStart;
226  // NOTE: 1 unit of trigger length = 500 ns = 32 TDC
227  uint32_t triggerLengthTDC = rawTrigger.fTriggerRange_TriggerLength * 32;
228 
229  /* Get RawDigits from event, put them into a vector, and sort them by time */
231  e.getByLabel(fRawDataLabel, hdlDigits);
232  std::vector<art::Ptr<rawdata::RawDigit>> digits;
233  digits.reserve(hdlDigits->size());
234  int nHitSigBefore = 0;
235  int nHitBkgBefore = 0;
236  for (unsigned int idx=0; idx<hdlDigits->size(); ++idx){
237  art::Ptr<rawdata::RawDigit> digit(hdlDigits, idx);
238  digits.push_back(digit);
239  (digit->IsMC()) ? ++nHitSigBefore : ++nHitBkgBefore;
240  }
241 
242  /* Get CellHits from event, put them into a vector, and sort them by time */
244  e.getByLabel(fCellHitLabel, hdlHits);
245  std::vector<art::Ptr<rb::CellHit>> hits;
246  hits.reserve(hdlHits->size());
247  for (unsigned int idx=0; idx<hdlHits->size(); ++idx){
248  art::Ptr<rb::CellHit> hit(hdlHits, idx);
249 
250  // Add hit to channel map
253  }
254 
255  hits.push_back(hit);
256  }
257  rb::SortByTime(hits);
258 
259  /* Accumulate channel hit stats or calculate rates */
261  fChannelMask->IncrementDuration((float)rawTrigger.fTriggerRange_TriggerLength * 500e-9);
262  } else {
264  if (fVerbose) std::cout << "Masked " << fChannelMask->MaskSize() << " channels." << std::endl;
265  fChannelMask->Print();
266  }
267 
268  /* Get Clusters from event */
270  e.getByLabel(fClusterLabel, hdlClusters);
271 
272  /* Get Cleanup Clusters from event */
273  art::Handle<std::vector<rb::Cluster>> hdlCleanupClusters;
274  e.getByLabel(fCleanupClusterLabel, hdlCleanupClusters);
275  std::vector<art::Ptr<rb::Cluster>> cleanupClusters;
276  art::fill_ptr_vector(cleanupClusters, hdlCleanupClusters);
277 
278  /* Get Tracks from event, put them in a ptrVector, and sort them by time */
280  e.getByLabel(fTrackLabel, hdlTracks);
281  art::FindOneP<rb::Cluster> clusterFromTrack(hdlTracks, e, fTrackLabel);
282  std::vector<art::Ptr<rb::Track>> tracks;
283  art::fill_ptr_vector(tracks, hdlTracks);
284  rb::SortTracksByTime(tracks);
285 
286 
287  /* ..... BEGIN BACKGROUND REJECTION ..... */
288 
289  // Run each algorithm, add to the hit veto map
290  if (fVerbose) std::cout << "=========== SN BACKGROUND REMOVAL ===========" << std::endl << std::endl;
291 
292  // Initialize hit veto map & hit removal classes
293  sn::HitVetoMap* vetoMapHits = new sn::HitVetoMap();
294 
295  /* Remove first microslice */
297  if (fVerbose) std::cout << "-- FIRST (DUPLICATED) MICROSLICE ------------" << std::endl;
298  std::pair<uint64_t,uint64_t> microsliceMarkers = this->MicrosliceTimeMarkers(flatDaqData);
299  std::cout << "• uslice start time = " << microsliceMarkers.first << std::endl;
300  std::cout << "• Remove hits between times: [" << microsliceMarkers.first << ", " << microsliceMarkers.first+3200 << "]" << std::endl;
301  for (art::Ptr<rb::CellHit> hit : hits) {
302  // Add first 50us to time window veto map (duplicate microslices)
303  // NOTE: 3200 64-MHz clock ticks = 50 us
304  if (hit->TDC() + triggerStartTime > microsliceMarkers.first + 3200) break;
305  vetoMapHits->AddHit(*hit);
306  }
307 
308  if (fVerbose) std::cout << "Veto map size: " << vetoMapHits->Size() << std::endl << std::endl;
309  }
310 
311  /* Hot/Cold Channel Remove */
313  if (fVerbose) std::cout << "-- COLD/HOT CHANNEL HITS --------------------" << std::endl;
315  coldHotChanRemover->remove(digits);
316  if (fVerbose) {
317  if (!fChannelMask->RatesCalculated()) {
318  std::cout << "• Accumulating statistics for cold/hot channel map..." << std::endl;
319  } else {
320  std::cout << "• Found " << coldHotChanRemover->NumRemovedCold() << " cold channel hits." << std::endl;
321  std::cout << "• Found " << coldHotChanRemover->NumRemovedHot() << " hot channel hits." << std::endl;
322  }
323  std::cout << "Veto map size: " << vetoMapHits->Size() << std::endl << std::endl;
324  }
325  delete coldHotChanRemover;
326  }
327 
328  /* FEB Flasher Remove */
329  if (fRemoveFEBFlashers) {
330  if (fVerbose) std::cout << "-- FEB FLASHERS -----------------------------" << std::endl;
332  flashRemover->remove(digits);
333  if (fVerbose) {
334  std::cout << "• Found " << flashRemover->NInstigators() << " instigators of " << flashRemover->NFlasherHits() << " flasher hits." << std::endl;
335  std::cout << "Veto map size: " << vetoMapHits->Size() << std::endl << std::endl;
336  }
337  delete flashRemover;
338  }
339 
340  /* Low/High ADC Remove */
341  if (fRemoveLowHighADC) {
342  if (fVerbose) std::cout << "-- LOW/HIGH-ADC HITS ------------------------" << std::endl;
344  adcRemover->remove(digits);
345  if (fVerbose) {
346  std::cout << "• Found " << adcRemover->NumRemovedLow() << " low-ADC hits." << std::endl;
347  std::cout << "• Found " << adcRemover->NumRemovedHigh() << " high-ADC hits." << std::endl;
348  std::cout << "Veto map size: " << vetoMapHits->Size() << std::endl << std::endl;
349  }
350  delete adcRemover;
351  }
352 
353  /* Track & Michel Remove */
354  if (fRemoveTrackActivity) {
355  if (fVerbose) std::cout << "-- TRACK ACTIVITY HITS ----------------------" << std::endl;
356  sn::TrackActivityRemover* trackActivityRemover = new sn::TrackActivityRemover(*vetoMapHits, fParams, fGeom, clusterFromTrack);
358  trackActivityRemover->remove(hits, hdlTracks);
359  if (fVerbose) {
360  std::cout << "• Found " << trackActivityRemover->NumRemovedMichel() << " hits associated with Michel electrons." << std::endl;
361  std::cout << "• Found " << trackActivityRemover->NumRemovedBody() << " hits near track body." << std::endl;
362  std::cout << "• Found " << trackActivityRemover->NumRemovedTrack() << " track hits." << std::endl;
363  std::cout << "Veto map size: " << vetoMapHits->Size() << std::endl << std::endl;
364  }
365  delete trackActivityRemover;
366  }
367 
368  /* Slice Hits Remove */
369  if (fRemovePhysicsSlices) {
370  if (fVerbose) std::cout << "-- SLICE HITS ----------------------" << std::endl;
371  sn::SliceRemover* sliceRemover = new sn::SliceRemover(*vetoMapHits);
372  sliceRemover->remove(hits, cleanupClusters);
373  if (fVerbose) {
374  std::cout << "• Found " << sliceRemover->NumRemoved()
375  << " hits associated with " << cleanupClusters.size()
376  << " physics clusters." << std::endl;
377  std::cout << "Veto map size: " << vetoMapHits->Size() << std::endl << std::endl;
378  }
379  delete sliceRemover;
380  }
381 
382  /* High-Energy Activity Remove */
383  uint32_t TDCVetoed = 0;
385  if (fVerbose) std::cout << "-- HIGH-ENERGY ACTIVITY ---------------------" << std::endl;
386  sn::HighEnergyRemover* highEnergyRemover = new sn::HighEnergyRemover(*vetoMapHits);
387  highEnergyRemover->SetPeakThreshold(fPeakThreshold);
388  highEnergyRemover->SetVetoWindowPadding(fVetoWindowPadding);
389  highEnergyRemover->remove(hits);
390  TDCVetoed = highEnergyRemover->TotalTDCVetoed();
391  if (fVerbose) {
392  std::cout << "• Found " << highEnergyRemover->NPeaks() << " peaks" << std::endl;
393  std::cout << "• Vetoed " << highEnergyRemover->TotalTDCVetoed()
394  << " / " << triggerLengthTDC << " TDC ("
395  << (float)highEnergyRemover->TotalTDCVetoed() / (float)triggerLengthTDC * 100.0
396  << "%)" << std::endl;
397  std::cout << "Veto map size: " << vetoMapHits->Size() << std::endl << std::endl;
398  }
399  delete highEnergyRemover;
400  }
401 
402  *product_livetime = triggerLengthTDC - TDCVetoed;
403  fTriggerTimeTotal += triggerLengthTDC;
404  fVetoTimeTotal += TDCVetoed;
405 
406  int nHitSigAfter = 0;
407  int nHitBkgAfter = 0;
408 
409  // Invert hit veto map
410  for (art::Ptr<rb::CellHit> hit : hits) {
411  if (!vetoMapHits->ContainsHit(*hit)) {
412  product_cellhits->push_back(*hit);
413  (hit->IsMC()) ? ++nHitSigAfter : ++nHitBkgAfter;
414  (hit->IsMC()) ? ++fNSigFinal : ++fNBkgFinal;
415  }
416  }
417 
418  delete vetoMapHits;
419 
420  /* ..... END BACKGROUND REJECTION ..... */
421 
422 
423  if (fVerbose) {
424  std::cout << "----------------------------------------------" << std::endl;
425  std::cout << "Total hits in event: " << hits.size() << std::endl;
426  std::cout << "Hits filtered: " << hits.size() - product_cellhits->size() << std::endl;
427  std::cout << "Hits passed: " << product_cellhits->size() << std::endl;
428  std::cout << "Signal loss: " << nHitSigBefore - nHitSigAfter
429  << " (" << (float)(nHitSigBefore-nHitSigAfter)/(float)nHitSigBefore * 100.0 << "%)" << std::endl;
430  std::cout << "Bkgrnd loss: " << nHitBkgBefore - nHitBkgAfter
431  << " (" << (float)(nHitBkgBefore-nHitBkgAfter)/(float)nHitBkgBefore * 100.0 << "%)" << std::endl;
432  std::cout << "Rejection power: " << ((float)(hits.size() - product_cellhits->size()) / (float)hits.size()) * 100.0
433  << "%" << std::endl << std::endl;
434  }
435 
436  // Calculate FOM, write value and config params to TTree.
437  if (fVerbose) {
438  float fom = this->FOM(*product_cellhits);
439  std::cout << "FOM = " << fom << std::endl;
440  std::cout << "==============================================" << std::endl << std::endl;
441  }
442 
443  e.put(std::move(product_livetime));
444  e.put(std::move(product_cellhits));
445  return;
446 }
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
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.
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
bool fRemoveFEBFlashers
Enable/disable removing these hits.
void SetPeakThreshold(float val)
int fMuonEndSphereRadius
Min. distance of hit from track end to reject [cm].
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)
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
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:464
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.
Definition: fwd.h:28
int fLowADCThresh
Min. acceptable ADC.
std::string fRawDataLabel
ART module label for raw data.
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Referenced by art::RootOutput::endJob().

void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Member Data Documentation

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

ART module label for cell hits.

Definition at line 73 of file SNBackgroundRejection_module.cc.

Referenced by produce().

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

Definition at line 116 of file SNBackgroundRejection_module.cc.

Referenced by produce().

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

ART module label for cleanup clusters.

Definition at line 75 of file SNBackgroundRejection_module.cc.

Referenced by produce().

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

ART module label for clusters.

Definition at line 74 of file SNBackgroundRejection_module.cc.

Referenced by produce().

float sn::SNBackgroundRejection::fColdRateThreshold
private

Min. acceptable channel hit rate.

Definition at line 93 of file SNBackgroundRejection_module.cc.

Referenced by produce().

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

Definition at line 115 of file SNBackgroundRejection_module.cc.

Referenced by produce().

int sn::SNBackgroundRejection::fHighADCThresh
private

Max. acceptable ADC.

Definition at line 90 of file SNBackgroundRejection_module.cc.

Referenced by produce().

float sn::SNBackgroundRejection::fHotRateThreshold
private

Max. acceptable channel hit rate.

Definition at line 94 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 98 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 99 of file SNBackgroundRejection_module.cc.

Referenced by produce().

int sn::SNBackgroundRejection::fLowADCThresh
private

Min. acceptable ADC.

Definition at line 89 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 107 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 105 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 106 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 104 of file SNBackgroundRejection_module.cc.

Referenced by produce().

int sn::SNBackgroundRejection::fNBkgFinal
private

Number of background hits seen by job.

Definition at line 81 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 80 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 112 of file SNBackgroundRejection_module.cc.

Referenced by produce().

float sn::SNBackgroundRejection::fRateDuration
private

Total time (s) to accumulate statistics.

Definition at line 95 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 92 of file SNBackgroundRejection_module.cc.

Referenced by produce().

bool sn::SNBackgroundRejection::fRemoveFEBFlashers
private

Enable/disable removing these hits.

Definition at line 97 of file SNBackgroundRejection_module.cc.

Referenced by produce().

bool sn::SNBackgroundRejection::fRemoveFirstMicroslice
private

Enable/disable removing hits from first microslice.

Definition at line 86 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 111 of file SNBackgroundRejection_module.cc.

Referenced by produce().

bool sn::SNBackgroundRejection::fRemoveLowHighADC
private

Enable/disable removing these hits.

Definition at line 88 of file SNBackgroundRejection_module.cc.

Referenced by produce().

bool sn::SNBackgroundRejection::fRemovePhysicsSlices
private

Enable/disable removing these hits.

Definition at line 109 of file SNBackgroundRejection_module.cc.

Referenced by produce().

bool sn::SNBackgroundRejection::fRemoveTrackActivity
private

Enable/disable removing these hits.

Definition at line 103 of file SNBackgroundRejection_module.cc.

Referenced by produce().

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

ART module label for tracks.

Definition at line 76 of file SNBackgroundRejection_module.cc.

Referenced by produce().

int sn::SNBackgroundRejection::fTriggerTimeTotal
private

Definition at line 83 of file SNBackgroundRejection_module.cc.

Referenced by endJob(), and produce().

bool sn::SNBackgroundRejection::fVerbose
private

Enable/disable verbose output.

Definition at line 78 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 100 of file SNBackgroundRejection_module.cc.

Referenced by produce().

unsigned int sn::SNBackgroundRejection::fVetoT
private

Max. time after the.

Definition at line 101 of file SNBackgroundRejection_module.cc.

Referenced by produce().

int sn::SNBackgroundRejection::fVetoTimeTotal
private

Definition at line 84 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 113 of file SNBackgroundRejection_module.cc.

Referenced by produce().


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