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

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

rb::Prong FitPhoton (art::Handle< std::vector< rb::CellHit > > chits, TVector3 vtx, int photId) 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 fGeantLabel
 
std::string fCellHitLabel
 

Detailed Description

Definition at line 30 of file TutProducer_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

tut::TutProducer::TutProducer ( const fhicl::ParameterSet pset)
explicit

Definition at line 55 of file TutProducer_module.cc.

References reconfigure().

56  {
57  reconfigure(pset);
58 
59  produces<std::vector<rb::Prong> >();
60  }
void reconfigure(const fhicl::ParameterSet &pset)
tut::TutProducer::~TutProducer ( )

Definition at line 63 of file TutProducer_module.cc.

64  {
65  }

Member Function Documentation

void tut::TutProducer::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 75 of file TutProducer_module.cc.

76  {
77  }
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
rb::Prong tut::TutProducer::FitPhoton ( art::Handle< std::vector< rb::CellHit > >  chits,
TVector3  vtx,
int  photId 
) const
protected

Definition at line 131 of file TutProducer_module.cc.

References rb::CellHit::Cell(), geo::GeometryBase::CellInfo(), DEFINE_ART_MODULE(), dir, util::frac(), geom(), cheat::BackTracker::HitToTrackIDE(), cheat::BackTracker::IsNoise(), geo::kX, geo::kY, geo::LinFitMinDperp(), rb::CellHit::PE(), rb::CellHit::Plane(), art::PtrVector< T >::push_back(), POTSpillRate::view, and rb::CellHit::View().

Referenced by produce().

134  {
135  // Services we're going to need
138 
139  // We're going to store all the constituent hits here
140  art::PtrVector<rb::CellHit> prongHits;
141 
142  // Fit each view seperately and store the gradients in here
143  double dvdz[2];
144  for(geo::View_t view: {geo::kX, geo::kY}){
145 
146  // We're going to accumulate information about all the matching hits
147  // to do a straight line fit with.
148  std::vector<double> zs, vs, pes;
149 
150  // go through hits and cheat to find what hits are from what photon
151  for(unsigned int chitIdx = 0; chitIdx < chits->size(); ++chitIdx){
152  art::Ptr<rb::CellHit> chit(chits, chitIdx);
153 
154  if(bt->IsNoise(chit)) continue; // if hit is noise, ignore
155 
156  if(chit->View() != view) continue; // Wrong view
157 
158  // Did this hit make any major contribution to the prong?
159  bool any = false;
160 
161  // get track IDs of tracks that made light in this cell
162  const std::vector<cheat::TrackIDE> ides = bt->HitToTrackIDE(chit);
163 
164  // go through IDs
165  for(unsigned int idIdx = 0; idIdx < ides.size(); ++idIdx){
166  const int id = ides[idIdx].trackID;
167 
168  // Did this ID contribute to the right photon?
169  if(id == photId){
170  // good, so what fraction of the total energy deposited came
171  // from this particle?
172  const double frac = ides[idIdx].energyFrac;
173 
174  // If it's the majority contributor, keep it
175  if(frac > 0.5) any = true;
176 
177  // Now find out the physical position of the cell
178  double xyz[3];
179  geo::View_t junk; // Already know the view
180  geom->CellInfo(chit->Plane(), chit->Cell(), &junk, xyz);
181 
182  zs.push_back(xyz[2]);
183  // The view we actually measure with this cell
184  vs.push_back(xyz[view]);
185  // Don't know where the track goes exactly yet so can't calibrate
186  pes.push_back(frac*chit->PE());
187  } // end if
188  } // end for idIdx
189 
190  if(any) prongHits.push_back(chit);
191  } // end for chitIdx
192 
193  // Not enough hits to do a fit
194  if(vs.size() < 2){
195  dvdz[view] = 0;
196  continue;
197  }
198 
199  double z1, v1, z2, v2;
200  geo::LinFitMinDperp(zs, vs, pes, &z1, &v1, &z2, &v2);
201 
202  dvdz[view] = (v2-v1)/(z2-z1);
203  } // end for view
204 
205  // Combine two fits into one 3D vector
206  const TVector3 dir(dvdz[0], dvdz[1], 1);
207 
208  // For the sake of the demo, use the known true vertex
209  return rb::Prong(prongHits, vtx, dir);
210  }
std::vector< TrackIDE > HitToTrackIDE(const rb::CellHit &hit, bool useBirksE=false) const
Convenience function. HitsToTrackIDE but for a single hit.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Vertical planes which measure X.
Definition: PlaneGeo.h:28
Horizontal planes which measure Y.
Definition: PlaneGeo.h:29
void CellInfo(unsigned int ip, unsigned int ic, View_t *view=0, double *pos=0, double *dpos=0) const
bool IsNoise(const art::Ptr< rb::CellHit > &hit) const
Is this hit not associated with any particles?
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
double LinFitMinDperp(const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &w, double *x1, double *y1, double *x2, double *y2)
Find the best-fit line to a collection of points in 2-D by minimizing the squared perpendicular dista...
Definition: Geo.cxx:449
double frac(double x)
Fractional part.
A Cluster with defined start position and direction.
Definition: Prong.h:19
TDirectory * dir
Definition: macro.C:5
void geom(int which=0)
Definition: geom.C:163
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 tut::TutProducer::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 80 of file TutProducer_module.cc.

References simb::MCParticle::Daughter(), fCellHitLabel, FitPhoton(), art::DataViewImpl::getByLabel(), simb::MCParticle::NumberDaughters(), sim::ParticleNavigator::NumberOfPrimaries(), cheat::BackTracker::ParticleNavigator(), simb::MCParticle::PdgCode(), simb::MCParticle::Position(), sim::ParticleNavigator::Primary(), art::Event::put(), and simb::MCParticle::TrackId().

81  {
82  // Declare a container for Prong objects to be stored in the art::event
83  std::unique_ptr<std::vector<rb::Prong> > prongcol(new std::vector<rb::Prong>);
84 
85  // This bit is all duplicated out of TutFilter. Need to find that pi0
86  // again. In a non-demo context we probably wouldn't bother with the filter
87  // at all.
88 
90  evt.getByLabel(fCellHitLabel, chits);
91 
92  // get the particle navigator from the BackTracker
94  const sim::ParticleNavigator& nav = bt->ParticleNavigator();
95 
96  // pizero should be a primary
97  for(int primIdx = 0; primIdx < nav.NumberOfPrimaries(); ++primIdx){
98  const sim::Particle* pizero = nav.Primary(primIdx);
99  // look for pi0's only
100  if(pizero->PdgCode() != 111) continue;
101 
102  if(pizero->NumberDaughters() != 2) continue;
103 
104  // Check the daughters are what they should be
105  const sim::Particle* phot0 = nav[pizero->Daughter(0)];
106  if(phot0->PdgCode() != 22) continue;
107  const sim::Particle* phot1 = nav[pizero->Daughter(1)];
108  if(phot1->PdgCode() != 22) continue;
109 
110  // New code starts here
111 
112  // True vertex
113  const TVector3 vtx = phot0->Position(0).Vect();
114 
115  // Stick photons in an array so we can loop over them
116  const sim::Particle* phots[2] = {phot0, phot1};
117 
118  for(int photIdx = 0; photIdx < 2; ++photIdx){
119  // This function is getting long, so do all the actual work in
120  // FitPhoton(). Put the result in the prongs collection
121  const int photId = phots[photIdx]->TrackId();
122  prongcol->push_back(FitPhoton(chits, vtx, photId));
123  } // end for photIdx
124  } // end for primIdx
125 
126  // Don't forget to save our prongs...
127  evt.put(std::move(prongcol));
128  }
const TLorentzVector & Position(const int i=0) const
Definition: MCParticle.h:218
int PdgCode() const
Definition: MCParticle.h:211
rb::Prong FitPhoton(art::Handle< std::vector< rb::CellHit > > chits, TVector3 vtx, int photId) const
const sim::ParticleNavigator & ParticleNavigator() const
Get a reference to the ParticleNavigator.
Definition: BackTracker.h:744
int NumberDaughters() const
Definition: MCParticle.h:216
int TrackId() const
Definition: MCParticle.h:209
int Daughter(const int i) const
Definition: MCParticle.cxx:112
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
const sim::Particle * Primary(const int) const
std::string fCellHitLabel
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
void tut::TutProducer::reconfigure ( const fhicl::ParameterSet pset)

Definition at line 68 of file TutProducer_module.cc.

References fCellHitLabel, fGeantLabel, fhicl::ParameterSet::get(), and string.

Referenced by TutProducer().

69  {
70  fGeantLabel = pset.get<std::string>("GeantLabel");
71  fCellHitLabel = pset.get<std::string>("CellHitLabel");
72  }
T get(std::string const &key) const
Definition: ParameterSet.h:231
std::string fCellHitLabel
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

std::string tut::TutProducer::fCellHitLabel
protected

Definition at line 43 of file TutProducer_module.cc.

Referenced by produce(), and reconfigure().

std::string tut::TutProducer::fGeantLabel
protected

Definition at line 43 of file TutProducer_module.cc.

Referenced by reconfigure().


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