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

 MRE (fhicl::ParameterSet const &pset)
 
 ~MRE ()
 
void produce (art::Event &evt)
 
void reconfigure (const fhicl::ParameterSet &pset)
 
void beginRun (art::Run &run)
 
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
 

Private Attributes

g4n::G4AlgfG4Alg
 G4Helper object. More...
 
fhicl::ParameterSet fG4AlgPSet
 parameter set to configure the G4Alg object More...
 
std::string fMCTruthLabel
 
std::string fMrccInfoLabel
 

Detailed Description

Definition at line 51 of file MRE_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

murem::MRE::MRE ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 84 of file MRE_module.cc.

References reconfigure().

85  : fG4Alg(0)
86  , fG4AlgPSet(pset.get< fhicl::ParameterSet >("G4AlgPSet") )
87  {
88  this->reconfigure(pset);
89 
90  produces< std::vector<simb::MCTruth> >();
91 
92  // association between mre electron truth
93  // and removed muon mcparticle
94  produces< art::Assns<simb::MCTruth, simb::MCParticle> >();
95 
96  // association between mre electron truth
97  // and electron sim particles
98  produces< art::Assns< simb::MCTruth, sim::Particle> >();
99 
100  produces< std::vector<sim::FLSHitList> >();
101  produces< std::vector<sim::Particle> >();
102 
103 
104  mf::LogInfo("MRE") << " MRE::MRE()\n";
105  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
fhicl::ParameterSet fG4AlgPSet
parameter set to configure the G4Alg object
Definition: MRE_module.cc:66
void reconfigure(const fhicl::ParameterSet &pset)
Definition: MRE_module.cc:118
g4n::G4Alg * fG4Alg
G4Helper object.
Definition: MRE_module.cc:65
murem::MRE::~MRE ( )

Definition at line 110 of file MRE_module.cc.

References fG4Alg.

111  {
112  if(fG4Alg) delete fG4Alg;
113  }
g4n::G4Alg * fG4Alg
G4Helper object.
Definition: MRE_module.cc:65

Member Function Documentation

void murem::MRE::beginRun ( art::Run run)
virtual

Reimplemented from art::EDProducer.

Definition at line 126 of file MRE_module.cc.

References fG4Alg, and fG4AlgPSet.

127  {
128 
130  return;
131  }
fhicl::ParameterSet fG4AlgPSet
parameter set to configure the G4Alg object
Definition: MRE_module.cc:66
g4n::G4Alg * fG4Alg
G4Helper object.
Definition: MRE_module.cc:65
An algorithm to pass interaction information to Geant4 and create hits and particle lists...
Definition: G4Alg.h:32
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 murem::MRE::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 133 of file MRE_module.cc.

References simb::MCTruth::Add(), simb::MCParticle::AddTrajectoryPoint(), ana::assert(), util::CreateAssn(), DEFINE_ART_MODULE(), e, simb::MCParticle::E(), art::Handle< T >::failedToGet(), fG4Alg, fMCTruthLabel, fMrccInfoLabel, art::DataViewImpl::getByLabel(), makeTrainCVSamples::int, simb::kSingleParticle, simb::MCParticle::Momentum(), part, art::Event::put(), g4n::G4Alg::RunGeant(), simb::MCTruth::SetOrigin(), ana::Sqrt(), simb::MCParticle::T(), simb::MCParticle::TrackId(), simb::MCParticle::Vx(), simb::MCParticle::Vy(), and simb::MCParticle::Vz().

134  {
135 
136  std::unique_ptr<std::vector<simb::MCTruth> >
137  mctcol (new std::vector<simb::MCTruth> );
138  std::unique_ptr<std::vector<sim::FLSHitList> >
139  flshlcol(new std::vector<sim::FLSHitList> );
140  std::unique_ptr<std::vector<sim::Particle> >
141  pcol (new std::vector<sim::Particle> );
142  std::unique_ptr< art::Assns<simb::MCTruth, simb::MCParticle> >
144  std::unique_ptr< art::Assns<simb::MCTruth, sim::Particle> >
146 
147 
149  evt.getByLabel(fMrccInfoLabel, muonDataCol);
150 
151  static TDatabasePDG* pdgt = TDatabasePDG::Instance();
152  TParticlePDG* pdgpm = pdgt->GetParticle(13);
153  assert(pdgpm);
154 
155  TParticlePDG* pdgpe = pdgt->GetParticle(11);
156  assert(pdgpe);
157  const double electronMass = pdgpe->Mass();
158 
159  // Set the trackID offset for the electron.
160  // If file is MC, electron trackID's will be offset by
161  // the highest pre-existing trackID in the event
162  // If data is real, trackID offset is just -1000.
163 
164  int trackidOffset = -1000;
165 
167  evt.getByLabel(fMCTruthLabel, pListHandle);
168 
169  if( pListHandle.failedToGet() )
170  trackidOffset = -1000;
171  else{
172  for( int p = 0; p < (int) pListHandle->size(); p++){
173  art::Ptr<sim::Particle> part(pListHandle, p);
174  int partId = part->TrackId();
175  if( partId > trackidOffset)
176  trackidOffset = partId+1;
177  }
178  }
179 
180  // Loop over all the removed muons
181  for( int mData = 0; mData < (int)muonDataCol->size(); mData++){
182 
183  art::Ptr<simb::MCParticle> muonData(muonDataCol, mData);
184 
185  simb::MCTruth truth;
187 
188  double muonE = muonData->E(0);
189  double electronE = muonE;
190  double electronMom = TMath::Sqrt((electronE*electronE) -
191  (electronMass*electronMass));
192  TVector3 muonDir = muonData->Momentum(0).Vect().Unit();
193 
194  // A nearly vertical track usually has unreasonable
195  // reconstructed length and energy. Do not introduce
196  // a Mr.E for it.
197  if(muonDir.Z() < 1e-6)
198  continue;
199  TLorentzVector electron4Momentum( electronMom*muonDir.X(),
200  electronMom*muonDir.Y(),
201  electronMom*muonDir.Z(),
202  electronE);
203  TLorentzVector origin(muonData->Vx(0), muonData->Vy(0),
204  muonData->Vz(0), muonData->T(0));
205 
206  int id = trackidOffset;
207  simb::MCParticle part(id, 11, "primary");
208  part.AddTrajectoryPoint(origin, electron4Momentum);
209  truth.Add(part);
210  mctcol->push_back(truth);
211 
212  util::CreateAssn(*this, evt, *mctcol, muonData, *assns);
213 
214  std::vector< sim::Particle > particles;
215  fG4Alg->RunGeant(&truth, *flshlcol, particles,
216  id+1);
217 
218  int first = pcol->size();
219  int last = pcol->size() + particles.size();
220 
221  for(int p = 0; p < (int) particles.size(); p++){
222  pcol->push_back(particles[p]);
223  int partId = particles[p].TrackId();
224  if( partId > trackidOffset)
225  trackidOffset = partId;
226  }
227 
228  util::CreateAssn(*this, evt, *mctcol,
229  *pcol, *assnspart, first, last);
230 
231 
232  }// end loop over muon data
233 
234 
235  evt.put(std::move(mctcol));
236  evt.put(std::move(flshlcol));
237  evt.put(std::move(pcol));
238  evt.put(std::move(assns));
239  evt.put(std::move(assnspart));
240  return;
241 
242  }// end of producer
void RunGeant(std::vector< art::Handle< std::vector< simb::MCTruth > > > &mclists, std::vector< sim::FLSHitList > &flshitlist, std::vector< sim::Particle > &particlelist, std::vector< std::vector< std::pair< size_t, size_t > > > &pListLimits)
Definition: G4Alg.cxx:280
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.
void SetOrigin(simb::Origin_t origin)
Definition: MCTruth.h:80
const char * p
Definition: xmltok.h:285
void Add(simb::MCParticle &part)
Definition: MCTruth.h:79
std::string fMrccInfoLabel
Definition: MRE_module.cc:69
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
TString part[npart]
Definition: Style.C:32
g4n::G4Alg * fG4Alg
G4Helper object.
Definition: MRE_module.cc:65
single particles thrown at the detector
Definition: MCTruth.h:26
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Var Sqrt(const Var &v)
Use to take sqrt of a var.
Definition: Var.cxx:326
std::string fMCTruthLabel
Definition: MRE_module.cc:68
assert(nhit_max >=nhit_nbins)
Event generator information.
Definition: MCTruth.h:32
Float_t e
Definition: plot.C:35
Definition: fwd.h:28
bool failedToGet() const
Definition: Handle.h:196
void murem::MRE::reconfigure ( const fhicl::ParameterSet pset)

Definition at line 118 of file MRE_module.cc.

References fMCTruthLabel, fMrccInfoLabel, fhicl::ParameterSet::get(), and string.

Referenced by MRE().

119  {
120  fMrccInfoLabel = pset.get< std::string >("MrccInfoLabel");
121  fMCTruthLabel = pset.get< std::string >("MCTruthLabel");
122  }
std::string fMrccInfoLabel
Definition: MRE_module.cc:69
T get(std::string const &key) const
Definition: ParameterSet.h:231
std::string fMCTruthLabel
Definition: MRE_module.cc:68
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

g4n::G4Alg* murem::MRE::fG4Alg
private

G4Helper object.

Definition at line 65 of file MRE_module.cc.

Referenced by beginRun(), produce(), and ~MRE().

fhicl::ParameterSet murem::MRE::fG4AlgPSet
private

parameter set to configure the G4Alg object

Definition at line 66 of file MRE_module.cc.

Referenced by beginRun().

std::string murem::MRE::fMCTruthLabel
private

Definition at line 68 of file MRE_module.cc.

Referenced by produce(), and reconfigure().

std::string murem::MRE::fMrccInfoLabel
private

Definition at line 69 of file MRE_module.cc.

Referenced by produce(), and reconfigure().


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