Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
lem::Preselection Class Reference
Inheritance diagram for lem::Preselection:
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

 Preselection (const fhicl::ParameterSet &pset)
 
virtual ~Preselection ()
 
virtual void produce (art::Event &evt)
 
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
 

Protected Attributes

std::string fSlicerLabel
 
bool fTruthMode
 
bool fSkipTrackCut
 
bool fSkipEnergyCut
 
double fSliceNCellLow
 
double fSliceNCellHigh
 
double fSliceExtentPlane
 
double fTrackLengthCut
 
double fRecoELow
 
double fRecoEHigh
 
bool fInFidCut
 

Detailed Description

Definition at line 36 of file Preselection_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

lem::Preselection::Preselection ( const fhicl::ParameterSet pset)
explicit

Definition at line 60 of file Preselection_module.cc.

60  :
61  fSlicerLabel(pset.get<std::string>("SlicerLabel")),
62  fTruthMode(pset.get<bool>("TruthMode")),
63  fSkipTrackCut(pset.get<bool>("SkipTrackCut")),
64  fSkipEnergyCut(pset.get<bool>("SkipEnergyCut")),
65  fSliceNCellLow(pset.get<double>("SliceNCellLow")),
66  fSliceNCellHigh(pset.get<double>("SliceNCellHigh")),
67  fSliceExtentPlane(pset.get<double>("SliceExtentPlane")),
68  fTrackLengthCut(pset.get<double>("TrackLengthCut")),
69  fRecoELow(pset.get<double>("RecoELow")),
70  fRecoEHigh(pset.get<double>("RecoEHigh")),
71  fInFidCut(pset.get<bool>("InFidCut"))
72  {
73 
74  produces<rb::FilterList<rb::Cluster> >();
75  produces<std::vector<rb::PID> >();
76  produces<art::Assns<rb::PID, rb::Cluster> >();
77 
78  }
T get(std::string const &key) const
Definition: ParameterSet.h:231
enum BeamMode string
lem::Preselection::~Preselection ( )
virtual

Definition at line 81 of file Preselection_module.cc.

82  {
83  }

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
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
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
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
void lem::Preselection::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 86 of file Preselection_module.cc.

References rb::Cluster::Cell(), om::cout, util::CreateAssn(), DEFINE_ART_MODULE(), allTimeWatchdog::endl, rb::Cluster::ExtentPlane(), fInFidCut, PandAna.Demos.pi0_spectra::fmt, fRecoEHigh, fSkipEnergyCut, fSkipTrackCut, fSliceExtentPlane, fSliceNCellHigh, fSlicerLabel, fTrackLengthCut, geom(), art::Ptr< T >::get(), art::DataViewImpl::getByLabel(), rb::RecoHit::GeV(), rb::RecoHit::IsCalibrated(), rb::IsFiltered(), geo::GeometryBase::isInsideFiducialVolume(), rb::Cluster::IsNoise(), geo::kX, CLHEP::L, calib::Calibrator::MakeRecoHit(), extractScale::mean, rb::Cluster::MeanXYZ(), getGoodRuns4SAM::n, rb::Cluster::NCell(), rb::Cluster::NXCell(), rb::Cluster::NYCell(), art::Event::put(), string, rb::CellHit::View(), rb::Cluster::W(), rb::Cluster::XCell(), and rb::Cluster::YCell().

87  {
88  std::unique_ptr<rb::FilterList<rb::Cluster> > filtcol(new rb::FilterList<rb::Cluster>);
89 
90  std::unique_ptr<std::vector<rb::PID> > pidcol(new std::vector<rb::PID>);
91  std::unique_ptr<art::Assns<rb::PID, rb::Cluster> > assns(new art::Assns<rb::PID, rb::Cluster>);
92 
95 
96  // TODO: break truth selection out into its own module
97  /*
98  if(fTruthMode){
99  art::Handle<std::vector<simb::MCTruth> > truths;
100  evt.getByLabel("generator", truths);
101  if(truths->empty()) return false;
102  if(truths->size() > 1) return true;
103 
104  const simb::MCTruth& truth = (*truths)[0];
105 
106  const simb::MCNeutrino& nu = truth.GetNeutrino();
107  const double trueE = nu.Nu().E();
108  // These cuts are empirically observed to remove almost nothing that
109  // would survive the preselection below. Approximately 0.1% lost to the
110  // low cuts and 0.5% to the high cuts.
111  if(nu.CCNC() == simb::kCC){
112  return (trueE > 1 && trueE < 3.5);
113  }
114  else{
115  const double hadY = nu.Y();
116  return (trueE*hadY > .75 && trueE*hadY < 4.5);
117  }
118 
119  assert(0 && "Not reached");
120  }
121  */
122 
124  evt.getByLabel(fSlicerLabel, slices);
125 
126  const int sliceMax = slices->size();
127  for(int sliceIdx = 0; sliceIdx < sliceMax; ++sliceIdx){
128  if(rb::IsFiltered(evt, slices, sliceIdx)) continue;
129 
130  const rb::Cluster& slice = (*slices)[sliceIdx];
131 
132  if(slice.IsNoise()) continue;
133 
134  double longestTrack = 0;
135  if(!fSkipTrackCut){
136  // This is maybe inefficient, but for now FindManyP throws an exception
137  // on finding no assns. We don't want that.
138  art::FindManyP<rb::Track> fmt(slices, evt, std::string("discretetrack"));
139  // Get all the tracks associated with this slice
140  std::vector<art::Ptr<rb::Track> > tracks = fmt.at(sliceIdx);
141 
142  for(unsigned int n = 0; n < tracks.size(); ++n){
143  const double L = tracks[n]->TotalLength();
144  if(L > longestTrack) longestTrack = L;
145  }
146  }
147 
148  const double nCells = slice.NCell();
149  const int lengthPlanes = slice.ExtentPlane();
150 
151  const TVector3 mean = slice.MeanXYZ();
152  const bool inFid = geom->isInsideFiducialVolume(mean.X(), mean.Y(), mean.Z());
153 
154  const double wx = (slice.NXCell() > 0) ? slice.W(slice.XCell(0).get()) : 0;
155  const double wy = (slice.NYCell() > 0) ? slice.W(slice.YCell(0).get()) : 0;
156 
157  double totalRecoGeV = 0;
158  for(unsigned int hitIdx = 0; hitIdx < slice.NCell(); ++hitIdx){
159  // This is slow because we have to keep recalculating the mean
160  // positions. The manual version below is much better.
161  // const rb::RecoHit rhit = slice.RecoHit(hitIdx);
162 
163  const art::Ptr<rb::CellHit>& chit = slice.Cell(hitIdx);
164  const rb::RecoHit rhit = cal->MakeRecoHit(*chit,
165  chit->View() == geo::kX ? wx : wy);
166  if(!rhit.IsCalibrated()){
167  std::cout << "Not calibrated?!" << std::endl;
168  continue;
169  }
170  totalRecoGeV += rhit.GeV();
171  }
172 
173  bool sel = true;
174  if(nCells < fSliceNCellLow || nCells > fSliceNCellHigh) sel = false;
175  if(longestTrack > fTrackLengthCut) sel = false;
176  if(lengthPlanes > fSliceExtentPlane) sel = false;
177  if(!fSkipEnergyCut) {
178  if(2*totalRecoGeV < fRecoELow || 2*totalRecoGeV > fRecoEHigh) sel = false;
179  }
180  if(!inFid && fInFidCut == true) sel = false;
181 
182  if(!sel) filtcol->Add(slices, sliceIdx);
183 
184  // We're a nue preselection
185  pidcol->push_back(rb::PID(12, sel));
186 
187  util::CreateAssn(*this, evt, *pidcol, art::Ptr<rb::Cluster>(slices, sliceIdx), *assns);
188  } // end for sliceIdx
189 
190  evt.put(std::move(pidcol));
191  evt.put(std::move(assns));
192  evt.put(std::move(filtcol));
193  }
A simple list of products that have been marked "filtered out".
Definition: FilterList.h:74
A pid value and corresponding pdg code.
Definition: PID.h:13
static bool CreateAssn(art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
Create a 1 to 1 association between a new product and one already in the event.
virtual double W(const rb::CellHit *chit) const
Estimate the unmeasured coordinate of chit.
Definition: Cluster.cxx:121
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
Definition: Cluster.cxx:134
art::Ptr< rb::CellHit > XCell(unsigned int xIdx) const
Get the ith cell in the x-view.
Definition: Cluster.cxx:157
geo::View_t View() const
Definition: CellHit.h:41
Vertical planes which measure X.
Definition: PlaneGeo.h:28
rb::RecoHit MakeRecoHit(rb::CellHit const &cellhit, double w)
A collection of associated CellHits.
Definition: Cluster.h:47
TVector3 MeanXYZ(rb::AveragingScheme=kDefaultScheme) const
Definition: Cluster.cxx:538
Calibrated quantities relying on position in the orthogonal view. To generate a rb::CellHit from a rb...
Definition: RecoHit.h:19
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
static constexpr double L
art::Ptr< rb::CellHit > YCell(unsigned int yIdx) const
Get the ith cell in the y-view.
Definition: Cluster.cxx:165
bool IsCalibrated() const
You MUST check here before accessing PECorr, MIP or GeV.
Definition: RecoHit.cxx:35
bool IsFiltered(const art::Event &evt, art::Ptr< T > x, const std::vector< std::string > &labels)
Is this Ptr marked "filtered out"?
Definition: FilterList.h:96
OStream cout
Definition: OStream.cxx:6
unsigned int NYCell() const
Number of cells in the y-view.
Definition: Cluster.h:108
art::Ptr< rb::CellHit > Cell(geo::View_t view, unsigned int viewIdx) const
Get the ith cell from view view.
Definition: Cluster.cxx:145
float GeV() const
Definition: RecoHit.cxx:69
T const * get() const
Definition: Ptr.h:321
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
unsigned int NXCell() const
Number of cells in the x-view.
Definition: Cluster.h:106
void geom(int which=0)
Definition: geom.C:163
unsigned int ExtentPlane(geo::View_t view=geo::kXorY) const
Definition: Cluster.h:250
bool IsNoise() const
Is the noise flag set?
Definition: Cluster.h:163
bool isInsideFiducialVolume(const double x_cm, const double y_cm, const double z_cm) const
Is the particle inside the detector Fiducial Volume?
enum BeamMode string
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

bool lem::Preselection::fInFidCut
protected

Definition at line 56 of file Preselection_module.cc.

Referenced by produce().

double lem::Preselection::fRecoEHigh
protected

Definition at line 55 of file Preselection_module.cc.

Referenced by produce().

double lem::Preselection::fRecoELow
protected

Definition at line 54 of file Preselection_module.cc.

bool lem::Preselection::fSkipEnergyCut
protected

Definition at line 49 of file Preselection_module.cc.

Referenced by produce().

bool lem::Preselection::fSkipTrackCut
protected

Definition at line 48 of file Preselection_module.cc.

Referenced by produce().

double lem::Preselection::fSliceExtentPlane
protected

Definition at line 52 of file Preselection_module.cc.

Referenced by produce().

double lem::Preselection::fSliceNCellHigh
protected

Definition at line 51 of file Preselection_module.cc.

Referenced by produce().

double lem::Preselection::fSliceNCellLow
protected

Definition at line 50 of file Preselection_module.cc.

std::string lem::Preselection::fSlicerLabel
protected

Definition at line 45 of file Preselection_module.cc.

Referenced by produce().

double lem::Preselection::fTrackLengthCut
protected

Definition at line 53 of file Preselection_module.cc.

Referenced by produce().

bool lem::Preselection::fTruthMode
protected

Definition at line 47 of file Preselection_module.cc.


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