|
| 1 | +// requires a minimum number of steps in online straws |
| 2 | + |
| 3 | +#include "art/Framework/Core/EDFilter.h" |
| 4 | +#include "art/Framework/Principal/Event.h" |
| 5 | +#include "art/Framework/Principal/Handle.h" |
| 6 | +#include "fhiclcpp/ParameterSet.h" |
| 7 | +#include "Offline/MCDataProducts/inc/StrawGasStep.hh" |
| 8 | +#include "Offline/ProditionsService/inc/ProditionsHandle.hh" |
| 9 | +#include "Offline/TrackerConditions/inc/TrackerStatus.hh" |
| 10 | + |
| 11 | +#include <string> |
| 12 | + |
| 13 | +using namespace std; |
| 14 | + |
| 15 | +namespace mu2e{ |
| 16 | + |
| 17 | + class StrawGasStepFilter : public art::EDFilter { |
| 18 | + public: |
| 19 | + using Name=fhicl::Name; |
| 20 | + using Comment=fhicl::Comment; |
| 21 | + |
| 22 | + struct Config { |
| 23 | + fhicl::Atom<art::InputTag> stepstag { Name("StrawGasStepTag"), Comment("StrawGasStep tag")}; |
| 24 | + fhicl::Atom<unsigned> minsteps { Name("MinSteps"), Comment("Minimum number of SGS")}; |
| 25 | + }; |
| 26 | + using Parameters = art::EDFilter::Table<Config>; |
| 27 | + explicit StrawGasStepFilter(const Parameters& config); |
| 28 | + virtual bool filter(art::Event& e); |
| 29 | + |
| 30 | + private: |
| 31 | + art::InputTag _stepsTag; |
| 32 | + size_t _minSteps; |
| 33 | + |
| 34 | + ProditionsHandle<TrackerStatus> _trackerStatus_h; |
| 35 | + |
| 36 | + |
| 37 | + }; |
| 38 | + |
| 39 | + StrawGasStepFilter::StrawGasStepFilter(const Parameters& config) : |
| 40 | + art::EDFilter{config}, |
| 41 | + _stepsTag(config().stepstag()), |
| 42 | + _minSteps(config().minsteps()) |
| 43 | + { |
| 44 | + } |
| 45 | + |
| 46 | + bool StrawGasStepFilter::filter(art::Event& event) { |
| 47 | + auto const& trackerStatus = _trackerStatus_h.getPtr(event.id()); |
| 48 | + |
| 49 | + size_t count = 0; |
| 50 | + auto steps = event.getValidHandle<StrawGasStepCollection>(_stepsTag); |
| 51 | + for (size_t i=0;i<steps->size();i++){ |
| 52 | + if (!trackerStatus->noSignal(steps->at(i).strawId())) |
| 53 | + count += 1; |
| 54 | + } |
| 55 | + return count >= _minSteps; |
| 56 | + } |
| 57 | +} |
| 58 | + |
| 59 | +DEFINE_ART_MODULE(mu2e::StrawGasStepFilter) |
0 commit comments