Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | List of all members
murem::MergeTruth Class Reference
Inheritance diagram for murem::MergeTruth:
art::EDProducer art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

using Parameters = art::EDProducer::Table< MergeTruthParams >
 
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = ProducerBase::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 MergeTruth (const Parameters &params)
 
 ~MergeTruth ()
 
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
 

Private Attributes

MergeTruthParams fParams
 

Detailed Description

Definition at line 77 of file MergeTruth_module.cc.

Member Typedef Documentation

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

Definition at line 81 of file MergeTruth_module.cc.

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::MergeTruth::MergeTruth ( const Parameters params)
explicit

Definition at line 100 of file MergeTruth_module.cc.

101  :fParams(params())
102  {
103  produces< std::vector <sim::FLSHitList> >();
104  produces< std::vector <sim::PhotonSignal> >();
105  produces< std::vector <sim::Particle> >();
106 
107  mf::LogInfo("MergeTruth") <<"MergeTruth::MergeTruth()\n";
108 
109  }
MergeTruthParams fParams
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
murem::MergeTruth::~MergeTruth ( )

Definition at line 114 of file MergeTruth_module.cc.

115  {
116 
117  }

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 murem::MergeTruth::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 122 of file MergeTruth_module.cc.

References DEFINE_ART_MODULE(), e, MakeMiniprodValidationCuts::f, art::Handle< T >::failedToGet(), sim::FLSHitList::fHits, fParams, art::DataViewImpl::getByLabel(), hits(), makeTrainCVSamples::int, submit_hadd::l, m, simb::MCParticle::Mother(), simb::MCParticle::P(), part, demo::particleList, art::Event::put(), sim::PhotonSignal::TrackId(), simb::MCParticle::TrackId(), cheat::BackTracker::TrackIDToMotherParticle(), simb::MCParticle::Vx(), simb::MCParticle::Vy(), and simb::MCParticle::Vz().

123  {
124 
125  std::unique_ptr< std::vector<sim::FLSHitList> > flsHits(new std::vector<sim::FLSHitList>);
126  std::unique_ptr< std::vector<sim::Particle> > particleList(new std::vector<sim::Particle>);
127  std::unique_ptr< std::vector<sim::PhotonSignal> > photonSignal(new std::vector<sim::PhotonSignal>);
128  //std::unique_ptr< std::vector<simb::MCTruth> > mcTruth(new std::vector<simb::MCTruth>);
129 
131 
132  // The following handle has no use but to indicate if the muon
133  // was removed my truth. If not, there's not much sense in producing
134  // merged truth. Exit asap- don't waste time!
135 
137  evt.getByLabel(fParams.mrccInfoLabel(), mrccFlsHandle);
138  if( mrccFlsHandle.failedToGet() ) return;
139 
140  // Grab the Electron Truth Info saved to the
141  // file by the MRE modeule. They live under
142  // label "mregen". Photons live under "elecphotrans"
143 
144 
146  evt.getByLabel(fParams.mreTruthLabel(), elecTruthHandle);
147  if( elecTruthHandle.failedToGet() ) return;
148 
150  evt.getByLabel(fParams.mreTruthLabel(), elecFlsHandle);
151  if( elecFlsHandle.failedToGet() ) return;
152 
153  art::Handle< std::vector<sim::Particle> > elecPlistHandle;
154  evt.getByLabel(fParams.mreTruthLabel(), elecPlistHandle);
155  if( elecPlistHandle.failedToGet() ) return;
156 
158  evt.getByLabel(fParams.mrePhotonLabel(), elecSigHandle);
159  if( elecSigHandle.failedToGet() ) return;
160 
161  // Get the original truth information.
162 
164  evt.getByLabel(fParams.mcTruthLabel(), truthHandle);
165  if( truthHandle.failedToGet() ) return;
166 
168  evt.getByLabel(fParams.particleLabel(), flslistHandle);
169  if( flslistHandle.failedToGet() ) return;
170 
172  evt.getByLabel(fParams.particleLabel(), plistHandle);
173  if( plistHandle.failedToGet() ) return;
174 
176  evt.getByLabel(fParams.photonLabel(), photSigHandle);
177  if( photSigHandle.failedToGet() ) return;
178 
179 
180  ////////////////////////////////////////////////////////////////
181 
182  // Grab the removed muon info and map the muon trackID to electron
183 
185  evt.getByLabel(fParams.mrccInfoLabel(), muInfoHandle);
186 
187  std::map< unsigned int, unsigned int> muToElec;
188  std::set <int> muonID;
189 
190  int nMuInfoHandles = muInfoHandle->size();
191  for( int m = 0; m < nMuInfoHandles; m++){
192  simb::MCParticle muon = (*muInfoHandle)[m];
193  muonID.insert(muon.TrackId());
194 
195  int nElecHandles = elecTruthHandle->size();
196  for(int e = 0; e < nElecHandles; e++){
197  simb::MCParticle elec = (*elecTruthHandle)[e].GetParticle(0);
198 
199  if( (elec.Vx(0) == muon.Vx(0)) && (elec.Vy(0) == muon.Vy(0)) && (elec.Vz(0) == muon.Vz(0)) && (elec.P(0) && muon.P(0))){
200  muToElec[ muon.TrackId()] = elec.TrackId();
201  }
202  }// end loop over electron MCTruths
203  }// end loop over removed muons
204 
205 
206  ////////////////////////////////////////////////////////////////
207 
208  int nFlsHandles = flslistHandle->size();
209  for( int l = 0; l < nFlsHandles; ++l){
210  int matchedElecID = 0;
211  sim::FLSHitList newFLSList;
212 
213  const std::vector<sim::FLSHit> &hits = flslistHandle->at(l).fHits;
214 
215  for( int f = 0; f < (int)hits.size(); ++f){
216  bool hitIsFromMuon = false;
217  int hitID = hits[f].GetTrackID();
218  int motherID = bt->TrackIDToMotherParticle(hitID)->TrackId();
219 
220  if( (muonID.find(motherID) != muonID.end())){
221  matchedElecID = muToElec[ motherID ];
222  hitIsFromMuon = true;
223  }
224  else if (muonID.find(hitID) != muonID.end()){
225  matchedElecID = muToElec[ hitID ];
226  hitIsFromMuon = true;
227  }
228 
229  if(!hitIsFromMuon)
230  newFLSList.fHits.push_back(hits[f]);
231  }// end loop over flshits in this FLSHitList
232 
233 
234  int nElecFlsHandles = elecFlsHandle->size();
235  for( int e = 0; e < nElecFlsHandles; e++){
236  int matchedElecList = -1;
237  const std::vector<sim::FLSHit> &elechits = elecFlsHandle->at(e).fHits;
238  for(int f = 0; f < (int)elechits.size(); f++){
239  if( elechits[f].GetTrackID() == matchedElecID ){
240  matchedElecList = e;
241  break;
242  }
243  if(matchedElecList)
244  break;
245  }//end loop over elec fls hits
246 
247  if(matchedElecList != -1){
248  const std::vector<sim::FLSHit> &elechits = elecFlsHandle->at(matchedElecList).fHits;
249  int nElecFlsHits = elechits.size();
250  for(int el = 0; el < nElecFlsHits; el++)
251  newFLSList.fHits.push_back(elechits[el]);
252  }
253  }// end loop over elecflslists
254 
255  flsHits->push_back(newFLSList);
256 
257  }// end loop over flshit lists
258 
259 
260  ////////////////////////////////////////////////////////////////
261 
262  int nPhots = photSigHandle->size();
263  for( int l = 0; l < nPhots; ++l){
264  sim::PhotonSignal phot = (*photSigHandle)[l];
265  bool photIsFromMuon = false;
266  int photID = phot.TrackId();
267  int motherID = bt->TrackIDToMotherParticle( photID )->TrackId() ;
268 
269  if( (muonID.find(motherID) != muonID.end()) || (muonID.find(photID) != muonID.end()) )
270  photIsFromMuon = true;
271 
272  if(!photIsFromMuon)
273  photonSignal->push_back(phot);
274 
275  }// end loop over photons
276 
277  int nElecPhots = elecSigHandle->size();
278  for( int e = 0; e < nElecPhots; e++){
279  sim::PhotonSignal phot = (*elecSigHandle)[e];
280  photonSignal->push_back(phot);
281  }
282 
283 
284  ////////////////////////////////////////////////////////////////
285 
286 
287  for( size_t l = 0; l < plistHandle->size(); ++l){
288  sim::Particle part = (*plistHandle)[l];
289  bool partIsFromMuon = false;
290 
291  int partID = part.TrackId();
292  int motherID = part.Mother();
293 
294  if( (muonID.find(motherID) != muonID.end()) || (muonID.find(partID) != muonID.end()) ) {
295  partIsFromMuon = true;
296  }
297 
298  if(!partIsFromMuon)
299  particleList->push_back(part);
300  }// end loop over photons
301 
302  for( int e = 0; e < (int)elecPlistHandle->size(); e++){
303  sim::Particle elec = (*elecPlistHandle)[e];
304  particleList->push_back(elec);
305  }
306 
307 
308  ////////////////////////////////////////////////////////////////
309 
310  // Write the objects to the events
311 
312  evt.put(std::move(flsHits));
313  evt.put(std::move(photonSignal));
314  evt.put(std::move(particleList));
315 
316  return;
317 
318  } // End of producer
MergeTruthParams fParams
std::vector< sim::FLSHit > fHits
Definition: FLSHitList.h:21
const sim::Particle * TrackIDToMotherParticle(int const &id) const
int TrackId() const
Definition: PhotonSignal.h:33
int Mother() const
Definition: MCParticle.h:212
int TrackId() const
Definition: MCParticle.h:209
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
TString part[npart]
Definition: Style.C:32
void hits()
Definition: readHits.C:15
double P(const int i=0) const
Definition: MCParticle.h:233
double Vx(const int i=0) const
Definition: MCParticle.h:220
A vector of FLSHit from single neutrino interaction.
Definition: FLSHitList.h:13
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
double Vz(const int i=0) const
Definition: MCParticle.h:222
particleList
Definition: demo.py:41
Float_t e
Definition: plot.C:35
double Vy(const int i=0) const
Definition: MCParticle.h:221
bool failedToGet() const
Definition: Handle.h:196
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

MergeTruthParams murem::MergeTruth::fParams
private

Definition at line 90 of file MergeTruth_module.cc.

Referenced by produce().


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