Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
calib::StopperSelection Class Reference

Selects stopping cosmics. More...

Inheritance diagram for calib::StopperSelection:
art::EDFilter art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

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

Public Member Functions

 StopperSelection (const fhicl::ParameterSet &pset)
 
 ~StopperSelection ()
 
virtual bool filter (art::Event &evt)
 
void reconfigure (const fhicl::ParameterSet &pset)
 
void beginJob ()
 
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 ()
 

Static Public Attributes

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

Protected Member Functions

bool IsContainedStopper (const rb::Track *trk, const bool isData) const
 
bool IsTrulyContainedStopper (const rb::Track *trk) const
 
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 fMichelLabel
 
std::string fTrackLabel
 
bool fApplyFilter
 
double fMinDistToEdge
 minimum distance in cm to edge of detector More...
 
double fMaxElectronEnergy
 maximum energy for the electron More...
 
int fTable [2][2]
 
art::ServiceHandle< geo::GeometryfGeom
 
art::ServiceHandle< geo::LiveGeometryfLiveGeom
 

Detailed Description

Selects stopping cosmics.

Definition at line 27 of file StopperSelection_module.cc.

Member Typedef Documentation

using art::EDFilter::ModuleType = EDFilter
inherited

Definition at line 37 of file EDFilter.h.

template<typename UserConfig >
using art::EDFilter::Table = ProducerBase::Table<UserConfig>
inherited

Definition at line 46 of file EDFilter.h.

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

Definition at line 38 of file EDFilter.h.

Constructor & Destructor Documentation

calib::StopperSelection::StopperSelection ( const fhicl::ParameterSet pset)
explicit

Definition at line 57 of file StopperSelection_module.cc.

References fTable, MECModelEnuComparisons::i, calib::j, and reconfigure().

58  {
59  produces< std::vector<rb::Track> >();
60  produces< art::Assns<rb::Track, rb::Cluster> >();
61 
62  reconfigure(pset);
63 
64  for(int i = 0; i < 2; ++i) for(int j = 0; j < 2; ++j) fTable[i][j] = 0;
65  }
void reconfigure(const fhicl::ParameterSet &pset)
const double j
Definition: BetheBloch.cxx:29
calib::StopperSelection::~StopperSelection ( )

Definition at line 68 of file StopperSelection_module.cc.

69  {
70  }

Member Function Documentation

void calib::StopperSelection::beginJob ( )
virtual

Reimplemented from art::EDFilter.

Definition at line 85 of file StopperSelection_module.cc.

86  {
87  }
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::EDFilter::currentContext ( ) const
protectedinherited
void calib::StopperSelection::endJob ( )
virtual

Reimplemented from art::EDFilter.

Definition at line 127 of file StopperSelection_module.cc.

References om::cout, allTimeWatchdog::endl, fTable, and IsContainedStopper().

128  {
129  // Ensure all the denominators are non-zero
130  if(fTable[0][0]+fTable[1][0] == 0 ||
131  fTable[0][1]+fTable[1][1] == 0 ||
132  fTable[0][0]+fTable[0][1] == 0 ||
133  fTable[1][0]+fTable[1][1] == 0) return;
134 
135  std::cout << "Stopper efficiency table. x-axis selection, y-axis truth:" << std::endl
136  << fTable[0][0] << "\t" << fTable[1][0] << "\t" << .1*(1000*fTable[0][0]/(fTable[0][0]+fTable[1][0])) << "%" << std::endl
137  << fTable[0][1] << "\t" << fTable[1][1] << "\t" << .1*(1000*fTable[1][1]/(fTable[0][1]+fTable[1][1])) << "%" << std::endl
138  << .1*(1000*fTable[0][0]/(fTable[0][0]+fTable[0][1])) << "%\t" << .1*(1000*fTable[1][1]/(fTable[1][0]+fTable[1][1])) << "%" << std::endl
139  << "Purity = " << .1*(1000*fTable[1][1]/(fTable[1][0]+fTable[1][1])) << "%" << std::endl
140  << "Efficieny = " << .1*(1000*fTable[1][1]/(fTable[0][1]+fTable[1][1])) << "%" << std::endl;
141  }
OStream cout
Definition: OStream.cxx:6
bool calib::StopperSelection::filter ( art::Event evt)
virtual

Implements art::EDFilter.

Definition at line 90 of file StopperSelection_module.cc.

References ana::assert(), util::CreateAssn(), fApplyFilter, fMichelLabel, fTable, fTrackLabel, art::DataViewImpl::getByLabel(), IsContainedStopper(), art::Event::isRealData(), IsTrulyContainedStopper(), art::Event::put(), and runNovaSAM::ret.

91  {
92  std::unique_ptr<std::vector<rb::Track> > outTracks(new std::vector<rb::Track>);
93  std::unique_ptr<art::Assns<rb::Track, rb::Cluster> > assns(new art::Assns<rb::Track, rb::Cluster>);
94 
96  evt.getByLabel(fTrackLabel, trkInfo);
97 
98  art::FindManyP<rb::Cluster> fmpslc(trkInfo, evt, fTrackLabel);
99  art::FindManyP<me::TrkME> fmpMEs(trkInfo, evt, fMichelLabel);
100 
101  for (unsigned int trkIdx = 0; trkIdx < trkInfo->size(); ++trkIdx){
102  const rb::Track* track = &(trkInfo->at(trkIdx));
103  bool isStopper = IsContainedStopper(track, evt.isRealData());
104  bool hasME = !fmpMEs.at(trkIdx).empty();
105  if (!isStopper) continue;
106  if (hasME)
107  outTracks->push_back(*track);
108  if (!evt.isRealData()){
109  const bool trueStopper = IsTrulyContainedStopper(track);
110  ++fTable[hasME][trueStopper];
111  }
112  // Find the slice the original track was associated to
113  if (hasME){
114  const std::vector<art::Ptr<rb::Cluster> > slices = fmpslc.at(trkIdx);
115  assert(slices.size() == 1);
116  util::CreateAssn(*this, evt, *outTracks, slices[0], *assns);
117  }
118  }
119 
120  const bool ret = !outTracks->empty();
121  evt.put(std::move(outTracks));
122  evt.put(std::move(assns));
123  if(fApplyFilter) return ret; else return true;
124  }
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.
Definition: event.h:19
A rb::Prong with full reconstructed trajectory.
Definition: Track.h:20
bool isRealData() const
Definition: Event.h:83
bool IsTrulyContainedStopper(const rb::Track *trk) const
bool IsContainedStopper(const rb::Track *trk, const bool isData) const
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
assert(nhit_max >=nhit_nbins)
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::EDFilter::getProductID ( std::string const &  instanceName = {}) const
inlineinherited

Definition at line 131 of file EDFilter.h.

References art::EDFilter::moduleDescription_.

Referenced by novaddt::HoughTrackMaker::create_associations().

132  {
133  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
134  instanceName);
135  }
ModuleDescription moduleDescription_
Definition: EDFilter.h:124
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  }
bool calib::StopperSelection::IsContainedStopper ( const rb::Track trk,
const bool  isData 
) const
protected

Definition at line 145 of file StopperSelection_module.cc.

References geo::GeometryBase::DetId(), geo::LiveGeometry::DistToBack(), geo::LiveGeometry::DistToEdgeXY(), geo::LiveGeometry::DistToEdgeZ(), geo::LiveGeometry::DistToFront(), fGeom, fLiveGeom, fMinDistToEdge, geo::LiveGeometry::InstrumentedDetLength(), novadaq::cnv::kTESTBEAM, rb::Prong::Start(), and rb::Track::Stop().

Referenced by endJob(), and filter().

146  {
147  // Start and end don't mean much, pick whichever is lowest in y.
148  const TVector3 v1 = trk->Start();
149  const TVector3 v2 = trk->Stop();
150  const TVector3 stop = (v1.Y() < v2.Y()) ? v1 : v2;
151 
152 
153  //For TB manual stopping selection, half instrumented det
154  if(fGeom->DetId()==novadaq::cnv::kTESTBEAM && isData){
155  if( fLiveGeom->DistToEdgeXY(stop) < fMinDistToEdge ||
156  ((fLiveGeom->DistToFront(stop) < fMinDistToEdge) ||
157  (fLiveGeom->DistToBack(stop) < ((fLiveGeom->InstrumentedDetLength())*(32/63) + fMinDistToEdge)))){
158  return false;
159  }
160  }
161  else if(fLiveGeom->DistToEdgeXY(stop) < fMinDistToEdge ||
162  fLiveGeom->DistToEdgeZ(stop) < fMinDistToEdge ) return false;
163  if(v1.X() == v2.X() || v1.Y() == v2.Y()) return false; // dx or dy = 0 means bad fit
164 
165  return true;
166  }
double DistToEdgeXY(TVector3 vertex)
double fMinDistToEdge
minimum distance in cm to edge of detector
double DistToFront(TVector3 vertex)
double DistToBack(TVector3 vertex)
virtual TVector3 Start() const
Definition: Prong.h:73
double InstrumentedDetLength()
get instrumented detector length of downstream part
double DistToEdgeZ(TVector3 vertex)
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
art::ServiceHandle< geo::Geometry > fGeom
art::ServiceHandle< geo::LiveGeometry > fLiveGeom
TVector3 Stop() const
Position of the final trajectory point.
Definition: Track.cxx:186
bool calib::StopperSelection::IsTrulyContainedStopper ( const rb::Track trk) const
protected

Definition at line 169 of file StopperSelection_module.cc.

References std::abs(), rb::Cluster::AllCells(), DEFINE_ART_MODULE(), geo::LiveGeometry::DistToEdgeXY(), geo::LiveGeometry::DistToEdgeZ(), simb::MCParticle::EndPosition(), fLiveGeom, cheat::BackTracker::HitsToParticle(), part, submit_concat_project::parts, and simb::MCParticle::PdgCode().

Referenced by filter().

170  {
172 
173  std::vector<const sim::Particle*> parts = bt->HitsToParticle(trk->AllCells());
174  if(parts.empty()) return false;
175 
176  const sim::Particle* part = parts.front();
177 
178  const TVector3 stop = part->EndPosition().Vect();
179 
180  if(fLiveGeom->DistToEdgeXY(stop) < 0.1 ||
181  fLiveGeom->DistToEdgeZ(stop) < 0.1 ) return false;
182  if(std::abs(part->PdgCode())!=13) return false;
183 
184  return true;
185  }
int PdgCode() const
Definition: MCParticle.h:211
const TLorentzVector & EndPosition() const
Definition: MCParticle.h:224
double DistToEdgeXY(TVector3 vertex)
float abs(float number)
Definition: d0nt_math.hpp:39
art::PtrVector< rb::CellHit > AllCells() const
Get all cells from both views.
Definition: Cluster.cxx:180
TString part[npart]
Definition: Style.C:32
double DistToEdgeZ(TVector3 vertex)
art::ServiceHandle< geo::LiveGeometry > fLiveGeom
std::vector< const sim::Particle * > HitsToParticle(const std::vector< const rb::CellHit * > &hits) const
Returns vector of sim::Particle objects contributing to the given collection of hits.
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 calib::StopperSelection::reconfigure ( const fhicl::ParameterSet pset)

Definition at line 73 of file StopperSelection_module.cc.

References fApplyFilter, fMaxElectronEnergy, fMichelLabel, fMinDistToEdge, fTrackLabel, fhicl::ParameterSet::get(), and string.

Referenced by StopperSelection().

74  {
75  fMichelLabel = pset.get< std::string >("MichelLabel" );
76  fTrackLabel = pset.get< std::string >("TrackLabel" );
77  fApplyFilter = pset.get< bool >("ApplyFilter" );
78  fMinDistToEdge = pset.get< double >("MinDistToEdge", 50. );
79  fMaxElectronEnergy = pset.get< double >("MaxElectronEnergy", 0.035);
80 
81  return;
82  }
double fMaxElectronEnergy
maximum energy for the electron
double fMinDistToEdge
minimum distance in cm to edge of detector
T get(std::string const &key) const
Definition: ParameterSet.h:231
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

constexpr bool art::EDFilter::Fail {false}
staticinherited

Definition at line 33 of file EDFilter.h.

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

bool calib::StopperSelection::fApplyFilter
protected

Definition at line 46 of file StopperSelection_module.cc.

Referenced by filter(), and reconfigure().

art::ServiceHandle<geo::Geometry> calib::StopperSelection::fGeom
protected

Definition at line 51 of file StopperSelection_module.cc.

Referenced by IsContainedStopper().

art::ServiceHandle<geo::LiveGeometry> calib::StopperSelection::fLiveGeom
protected

Definition at line 52 of file StopperSelection_module.cc.

Referenced by IsContainedStopper(), and IsTrulyContainedStopper().

double calib::StopperSelection::fMaxElectronEnergy
protected

maximum energy for the electron

Definition at line 48 of file StopperSelection_module.cc.

Referenced by reconfigure().

std::string calib::StopperSelection::fMichelLabel
protected

Definition at line 44 of file StopperSelection_module.cc.

Referenced by filter(), and reconfigure().

double calib::StopperSelection::fMinDistToEdge
protected

minimum distance in cm to edge of detector

Definition at line 47 of file StopperSelection_module.cc.

Referenced by IsContainedStopper(), and reconfigure().

int calib::StopperSelection::fTable[2][2]
protected

Definition at line 49 of file StopperSelection_module.cc.

Referenced by endJob(), filter(), and StopperSelection().

std::string calib::StopperSelection::fTrackLabel
protected

Definition at line 45 of file StopperSelection_module.cc.

Referenced by filter(), and reconfigure().

constexpr bool art::EDFilter::Pass {true}
staticinherited

Definition at line 32 of file EDFilter.h.

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


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