Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes | List of all members
novaddt::ActivityTriggerAna Class Reference
Inheritance diagram for novaddt::ActivityTriggerAna:
art::EDFilter art::detail::Filter art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Types

using ModuleType = EDFilter
 
using WorkerType = WorkerT< EDFilter >
 
template<typename UserConfig >
using Table = Modifier::Table< UserConfig >
 

Public Member Functions

 ActivityTriggerAna (fhicl::ParameterSet const &p)
 
virtual ~ActivityTriggerAna ()
 
virtual bool filter (art::Event &e)
 
void beginJob () override
 
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 &)
 
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)
 

Static Public Attributes

static constexpr bool Pass {true}
 
static constexpr bool Fail {false}
 

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

std::string _hitsModuleLabel
 label of module making the HitList More...
 
std::string _hitsInstanceLabel
 instance label making the HitList More...
 
unsigned int _minHits
 Minimum number of hits in the slice. More...
 
unsigned int _minPlanesView
 Minimum planes (unique) on each view. More...
 
unsigned int _minPlanes
 Minimum planes (unique) the hits are spread in any view. More...
 
unsigned int _maxNearWindow
 Maximum window where to look for near planes. More...
 
unsigned int _minNearPlanes
 Minimum number of near planes. More...
 
unsigned int _prescale
 holds prescaling variable from fcl file More...
 
unsigned int _triggerCounts = 0
 
unsigned int _sliceCounts = 0
 
unsigned int _evtCounts = 0
 
art::ServiceHandle< art::TFileService > tfs
 
TTree * fTree
 
TH1I * fHisto
 
unsigned int fHits
 
unsigned int fXPlanes
 
unsigned int fYPlanes
 
unsigned int fPlanes
 
bool fContinuity
 

Detailed Description

Definition at line 38 of file ActivityTriggerAna_module.cc.

Member Typedef Documentation

Definition at line 19 of file EDFilter.h.

template<typename UserConfig >
using art::detail::Filter::Table = Modifier::Table<UserConfig>
inherited

Definition at line 29 of file Filter.h.

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

Definition at line 20 of file EDFilter.h.

Constructor & Destructor Documentation

novaddt::ActivityTriggerAna::ActivityTriggerAna ( fhicl::ParameterSet const &  p)
explicit

Definition at line 74 of file ActivityTriggerAna_module.cc.

75  : _hitsModuleLabel (p.get<std::string >("HitModuleLabel" ))
76  , _hitsInstanceLabel(p.get<std::string >("HitInstanceLabel"))
77  , _minHits (p.get<unsigned int>("MinHits" ))
78  , _minPlanesView (p.get<unsigned int>("MinPlanesView" ))
79  , _minPlanes (p.get<unsigned int>("MinPlanes" ))
80  , _maxNearWindow (p.get<unsigned int>("MaxNearWindow" ))
81  , _minNearPlanes (p.get<unsigned int>("MinNearPlanes" ))
82  , _prescale (p.get<unsigned int>("prescale" ))
83 {
84  produces< std::vector<novaddt::TriggerDecision> >();
85  //produces< art::Assns<novaddt::TriggerDecision, novaddt::HitList> >();
86 }
unsigned int _minPlanesView
Minimum planes (unique) on each view.
unsigned int _minHits
Minimum number of hits in the slice.
unsigned int _prescale
holds prescaling variable from fcl file
const char * p
Definition: xmltok.h:285
unsigned int _minPlanes
Minimum planes (unique) the hits are spread in any view.
std::string _hitsInstanceLabel
instance label making the HitList
std::string _hitsModuleLabel
label of module making the HitList
unsigned int _maxNearWindow
Maximum window where to look for near planes.
unsigned int _minNearPlanes
Minimum number of near planes.
enum BeamMode string
novaddt::ActivityTriggerAna::~ActivityTriggerAna ( )
virtual

Definition at line 89 of file ActivityTriggerAna_module.cc.

90 {
91  // Clean up dynamic memory and other resources here.
92 }

Member Function Documentation

void novaddt::ActivityTriggerAna::beginJob ( )
overridevirtual

Reimplemented from art::EDFilter.

Definition at line 94 of file ActivityTriggerAna_module.cc.

References fContinuity, fHisto, fHits, fPlanes, fTree, fXPlanes, fYPlanes, and tfs.

95 {
96  // Output Histogram
97  fHisto = tfs->make<TH1I>("fHisto","Histogram;ADCs;Entries",400,0,4000);
98  fTree = tfs->make<TTree>("fTree","Output tree");
99  fTree->Branch("Hits",&fHits);
100  fTree->Branch("XPlanes",&fXPlanes);
101  fTree->Branch("YPlanes",&fYPlanes);
102  fTree->Branch("Planes",&fPlanes);
103  fTree->Branch("Continuity",&fContinuity);
104 }
art::ServiceHandle< art::TFileService > tfs
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::Filter::doBeginJob ( )
inherited
bool art::detail::Filter::doBeginRun ( RunPrincipal rp,
ModuleContext const &   
)
inherited
bool art::detail::Filter::doBeginSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited
void art::detail::Filter::doEndJob ( )
inherited
bool art::detail::Filter::doEndRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited
bool art::detail::Filter::doEndSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited
bool art::detail::Filter::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::Filter::doRespondToCloseInputFile ( FileBlock const &  fb)
inherited
void art::detail::Filter::doRespondToCloseOutputFiles ( FileBlock const &  fb)
inherited
void art::detail::Filter::doRespondToOpenInputFile ( FileBlock const &  fb)
inherited
void art::detail::Filter::doRespondToOpenOutputFiles ( FileBlock const &  fb)
inherited
bool novaddt::ActivityTriggerAna::filter ( art::Event e)
virtual

Implements art::EDFilter.

Definition at line 107 of file ActivityTriggerAna_module.cc.

References _evtCounts, _hitsInstanceLabel, _hitsModuleLabel, _maxNearWindow, _minHits, _minNearPlanes, _minPlanes, _minPlanesView, _sliceCounts, _triggerCounts, art::Handle< T >::clear(), om::cout, DEFINE_ART_MODULE(), allTimeWatchdog::endl, fContinuity, fHisto, fHits, fPlanes, fTree, fXPlanes, fYPlanes, art::DataViewImpl::getByLabel(), hits(), MECModelEnuComparisons::i, calib::j, art::DataViewImpl::put(), std::sqrt(), daqchannelmap::X_VIEW, and daqchannelmap::Y_VIEW.

108 {
109  //std::cout << "--- ActivityTriggerAna filter\n";
110  ++_evtCounts;
111 
112  // Retrieve the (grouped) hit list for this event
115  //std::cout << "\tgot " << hits->n_groups()
116  // << " groups.\n";
117 
118  // Allocate the vector for the trigger decisions that we may make (and write to the event)
119  std::unique_ptr<std::vector<novaddt::TriggerDecision>> td(new std::vector<novaddt::TriggerDecision>);
120 
121  std::unordered_set<int> XplaneList;
122  std::unordered_set<int> YplaneList;
123  std::unordered_set<int> planeList;
124 
125  // Loop over the slices in the event
126  for(unsigned int i=0; i<hits->n_groups(); ++i){
127 
128  // Get the hits for the current slice
129  novaddt::HitList theSliceHits = hits->get(i);
130 
131  XplaneList.clear();
132  YplaneList.clear();
133  planeList.clear();
134  fContinuity = false;
135  // Safety checks in case we mess up the fickle file
137  if(!(_maxNearWindow * _minNearPlanes)) fContinuity = true;
138 
139  ++_sliceCounts;
140 
141  fHits = theSliceHits.size();
142  for(unsigned int j=0; j < theSliceHits.size(); ++j){
143  auto thePlane = theSliceHits.at(j).Plane().val;
144  // Push the plane into the list of unique planes
145  auto theView = theSliceHits.at(j).View().val;
146  if(theView == daqchannelmap::X_VIEW) XplaneList.insert(thePlane);
147  else if(theView == daqchannelmap::Y_VIEW) YplaneList.insert(thePlane);
148  planeList.insert(thePlane);
149 
150  fHisto->Fill(theSliceHits.at(j).ADC().val);
151  } // endfor j
152 
153  fXPlanes = XplaneList.size();
154  fYPlanes = YplaneList.size();
156 
157  for(auto iPlane=planeList.begin(); iPlane!=planeList.end(); ++iPlane)
158  {
159  if(!fContinuity)
160  {
161  unsigned int fNearPlanes = 0;
162  for(unsigned int j=1; j<=_maxNearWindow; ++j)
163  fNearPlanes += planeList.count(*iPlane+j);
164 
165  if(fNearPlanes >= _minNearPlanes)
166  fContinuity = true;
167  }
168  } // end of continuity check
169 
170  // Now the trigger requirements
171  if(fHits >= _minHits)
172  if(fPlanes >= _minPlanes)
173  if(fXPlanes >= _minPlanesView)
174  if(fYPlanes >= _minPlanesView)
175  if(fContinuity)
176  ++_triggerCounts;
177 
178  fTree->Fill();
179  } // end loop on hit groups
180 
181  bool goodTrigger = (td->size() > 0);
182 
183  e.put(std::move(td));
184 
185  std::cout << "Frequency: " << _triggerCounts*1./(_evtCounts*5.e-3) << " pm "
186  << sqrt(_triggerCounts*(_evtCounts-_triggerCounts)*1./_evtCounts)/(_evtCounts*5.e-3) << " Hz" << std::endl; // Binomial Error
187 
188  return goodTrigger;
189 }
unsigned int _minPlanesView
Minimum planes (unique) on each view.
unsigned int _minHits
Minimum number of hits in the slice.
std::vector< DAQHit > HitList
Definition: HitList.h:15
T sqrt(T number)
Definition: d0nt_math.hpp:156
unsigned int _minPlanes
Minimum planes (unique) the hits are spread in any view.
std::string _hitsInstanceLabel
instance label making the HitList
Identifier for the Y measuring view of the detector (side)
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:446
void hits()
Definition: readHits.C:15
Identifier for the X measuring view of the detector (top)
const double j
Definition: BetheBloch.cxx:29
OStream cout
Definition: OStream.cxx:6
std::string _hitsModuleLabel
label of module making the HitList
unsigned int _maxNearWindow
Maximum window where to look for near planes.
void clear()
Definition: Handle.h:230
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
Definition: DataViewImpl.h:730
unsigned int _minNearPlanes
Minimum number of near planes.
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
ModuleDescription const& art::ModuleBase::moduleDescription ( ) const
inherited
void art::ModuleBase::setModuleDescription ( ModuleDescription const &  )
inherited
void art::ModuleBase::sortConsumables ( std::string const &  current_process_name)
inherited
std::string art::EDFilter::workerType ( ) const
inherited

Referenced by art::EDFilter::EDFilter().

Member Data Documentation

unsigned int novaddt::ActivityTriggerAna::_evtCounts = 0
private

Definition at line 61 of file ActivityTriggerAna_module.cc.

Referenced by filter().

std::string novaddt::ActivityTriggerAna::_hitsInstanceLabel
private

instance label making the HitList

Definition at line 51 of file ActivityTriggerAna_module.cc.

Referenced by filter().

std::string novaddt::ActivityTriggerAna::_hitsModuleLabel
private

label of module making the HitList

Definition at line 50 of file ActivityTriggerAna_module.cc.

Referenced by filter().

unsigned int novaddt::ActivityTriggerAna::_maxNearWindow
private

Maximum window where to look for near planes.

Definition at line 55 of file ActivityTriggerAna_module.cc.

Referenced by filter().

unsigned int novaddt::ActivityTriggerAna::_minHits
private

Minimum number of hits in the slice.

Definition at line 52 of file ActivityTriggerAna_module.cc.

Referenced by filter().

unsigned int novaddt::ActivityTriggerAna::_minNearPlanes
private

Minimum number of near planes.

Definition at line 56 of file ActivityTriggerAna_module.cc.

Referenced by filter().

unsigned int novaddt::ActivityTriggerAna::_minPlanes
private

Minimum planes (unique) the hits are spread in any view.

Definition at line 54 of file ActivityTriggerAna_module.cc.

Referenced by filter().

unsigned int novaddt::ActivityTriggerAna::_minPlanesView
private

Minimum planes (unique) on each view.

Definition at line 53 of file ActivityTriggerAna_module.cc.

Referenced by filter().

unsigned int novaddt::ActivityTriggerAna::_prescale
private

holds prescaling variable from fcl file

Definition at line 57 of file ActivityTriggerAna_module.cc.

unsigned int novaddt::ActivityTriggerAna::_sliceCounts = 0
private

Definition at line 60 of file ActivityTriggerAna_module.cc.

Referenced by filter().

unsigned int novaddt::ActivityTriggerAna::_triggerCounts = 0
private

Definition at line 59 of file ActivityTriggerAna_module.cc.

Referenced by filter().

constexpr bool art::detail::Filter::Fail {false}
staticinherited

Definition at line 26 of file Filter.h.

Referenced by evgen::GENIEFilter::filter().

bool novaddt::ActivityTriggerAna::fContinuity
private

Definition at line 70 of file ActivityTriggerAna_module.cc.

Referenced by beginJob(), and filter().

TH1I* novaddt::ActivityTriggerAna::fHisto
private

Definition at line 65 of file ActivityTriggerAna_module.cc.

Referenced by beginJob(), and filter().

unsigned int novaddt::ActivityTriggerAna::fHits
private

Definition at line 66 of file ActivityTriggerAna_module.cc.

Referenced by beginJob(), and filter().

unsigned int novaddt::ActivityTriggerAna::fPlanes
private

Definition at line 69 of file ActivityTriggerAna_module.cc.

Referenced by beginJob(), and filter().

TTree* novaddt::ActivityTriggerAna::fTree
private

Definition at line 64 of file ActivityTriggerAna_module.cc.

Referenced by beginJob(), and filter().

unsigned int novaddt::ActivityTriggerAna::fXPlanes
private

Definition at line 67 of file ActivityTriggerAna_module.cc.

Referenced by beginJob(), and filter().

unsigned int novaddt::ActivityTriggerAna::fYPlanes
private

Definition at line 68 of file ActivityTriggerAna_module.cc.

Referenced by beginJob(), and filter().

constexpr bool art::detail::Filter::Pass {true}
staticinherited

Definition at line 25 of file Filter.h.

Referenced by evgen::GENIEFilter::filter().

art::ServiceHandle<art::TFileService> novaddt::ActivityTriggerAna::tfs
private

Definition at line 63 of file ActivityTriggerAna_module.cc.

Referenced by beginJob().


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