16 #include "art_root_io/TFileService.h" 25 #include "NovaTimingUtilities/TimingUtilities.h" 40 #include "DAQDataFormats/RawDataBlock.h" 41 #include "DAQDataFormats/RawEvent.h" 50 class SNBackgroundRejection;
62 float FOM(std::vector<rb::CellHit>
hits);
157 produces<std::vector<rb::CellHit>>();
169 (
hit.IsMC()) ? ++s : ++b;
178 uint64_t maxTimingMarker = 0x0;
179 uint64_t minTimingMarker = 0xFFFFFFFFFFFFFFFF;
186 size_t nDataBlocks = rawEvt.getDataBlockNumber();
187 for (
size_t idxDB=0; idxDB<nDataBlocks; ++idxDB) {
188 rawEvt.setFloatingDataBlock(idxDB);
192 size_t nMicroBlocks = dataBlock.getNumMicroBlocks();
193 for (
size_t idxMB=0; idxMB<nMicroBlocks; ++idxMB) {
194 dataBlock.setFloatingMicroBlock(idxMB);
197 uint64_t tm = dataBlock.getFloatingMicroBlock()->getMicroSlice()->getTimingMarker()->getTime();
198 if (tm > maxTimingMarker) {
199 maxTimingMarker = tm;
201 if (tm < minTimingMarker) {
202 minTimingMarker = tm;
214 std::unique_ptr<std::vector<rb::CellHit>> product_cellhits(
new std::vector<rb::CellHit>);
215 std::unique_ptr<int> product_livetime(
new int);
233 std::vector<art::Ptr<rawdata::RawDigit>> digits;
234 digits.reserve(hdlDigits->size());
235 int nHitSigBefore = 0;
236 int nHitBkgBefore = 0;
237 for (
unsigned int idx=0;
idx<hdlDigits->size(); ++
idx){
239 digits.push_back(digit);
240 (digit->
IsMC()) ? ++nHitSigBefore : ++nHitBkgBefore;
246 std::vector<art::Ptr<rb::CellHit>>
hits;
247 hits.reserve(hdlHits->size());
248 for (
unsigned int idx=0;
idx<hdlHits->size(); ++
idx){
276 std::vector<art::Ptr<rb::Cluster>> cleanupClusters;
283 std::vector<art::Ptr<rb::Track>> tracks;
301 std::cout <<
"• Remove hits between times: [" << microsliceMarkers.first <<
", " << microsliceMarkers.first+3200 <<
"]" <<
std::endl;
305 if (
hit->TDC() + triggerStartTime > microsliceMarkers.first + 3200)
break;
316 coldHotChanRemover->
remove(digits);
326 delete coldHotChanRemover;
333 flashRemover->
remove(digits);
345 adcRemover->
remove(digits);
359 trackActivityRemover->
remove(hits, hdlTracks);
366 delete trackActivityRemover;
373 sliceRemover->
remove(hits, cleanupClusters);
376 <<
" hits associated with " << cleanupClusters.size()
384 uint32_t TDCVetoed = 0;
390 highEnergyRemover->
remove(hits);
395 <<
" / " << triggerLengthTDC <<
" TDC (" 397 <<
"%)" << std::endl;
400 delete highEnergyRemover;
403 *product_livetime = triggerLengthTDC - TDCVetoed;
407 int nHitSigAfter = 0;
408 int nHitBkgAfter = 0;
413 product_cellhits->push_back(*
hit);
414 (
hit->IsMC()) ? ++nHitSigAfter : ++nHitBkgAfter;
427 std::cout <<
"Hits filtered: " << hits.size() - product_cellhits->size() <<
std::endl;
429 std::cout <<
"Signal loss: " << nHitSigBefore - nHitSigAfter
430 <<
" (" << (
float)(nHitSigBefore-nHitSigAfter)/(
float)nHitSigBefore * 100.0 <<
"%)" << std::endl;
431 std::cout <<
"Bkgrnd loss: " << nHitBkgBefore - nHitBkgAfter
432 <<
" (" << (
float)(nHitBkgBefore-nHitBkgAfter)/(
float)nHitBkgBefore * 100.0 <<
"%)" << std::endl;
433 std::cout <<
"Rejection power: " << ((
float)(hits.size() - product_cellhits->size()) / (
float)hits.size()) * 100.0
434 <<
"%" << std::endl << std::endl;
439 float fom = this->
FOM(*product_cellhits);
441 std::cout <<
"==============================================" << std::endl <<
std::endl;
444 e.
put(std::move(product_livetime));
445 e.
put(std::move(product_cellhits));
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.
fhicl::ParameterSet const fParams
std::string fCleanupClusterLabel
ART module label for cleanup clusters.
bool fRemoveFirstMicroslice
Enable/disable removing hits from first microslice.
art::ServiceHandle< geo::Geometry > fGeom
EDProducer(fhicl::ParameterSet const &pset)
void IncrementDuration(float i)
void SetVetoWindowPadding(float val)
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
void SortByTime(std::vector< art::Ptr< rb::CellHit > > &c)
Sort c in time order (earliest to latest).
SNBackgroundRejection(fhicl::ParameterSet const &p)
DEFINE_ART_MODULE(TestTMapFile)
SNBackgroundRejection & operator=(SNBackgroundRejection const &)=delete
void * getRawBufferPointer() const
bool ContainsHit(rawdata::RawDigit h)
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.
sn::DaqChannelMask * fChannelMask
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
void SortTracksByTime(std::vector< art::Ptr< rb::Track >> &t)
Sort t in time order (earliest to latest).
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)
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)
Remove hits from hot and cold channels.
void produce(art::Event &e)
void remove(std::vector< art::Ptr< rb::CellHit >> &hits)
float FOM(std::vector< rb::CellHit > hits)
bool fRemoveColdHotChannels
Enable/disable removing these hits.
A rawdata::RawDigit with channel information decoded.
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
bool fRemoveHighEnergyActivity
Enable/disable removing hits from time windows with HE activity.
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
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)
int fHighADCThresh
Max. acceptable ADC.
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
std::string fTrackLabel
ART module label for tracks.
float fVetoWindowPadding
Fraction of peak width that should added to either side of TDC veto window.
Encapsulate the geometry of one entire detector (near, far, ndos)
int fLowADCThresh
Min. acceptable ADC.
std::string fRawDataLabel
ART module label for raw data.