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

 TruthContain (const fhicl::ParameterSet &pset)
 
 TruthContain (TruthContain const &)=delete
 
 TruthContain (TruthContain &&)=delete
 
TruthContainoperator= (TruthContain const &)=delete
 
TruthContainoperator= (TruthContain &&)=delete
 
bool filter (art::Event &e) override
 
void ResetTree ()
 
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

CurrentProcessingContext const * currentContext () const
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Private Attributes

std::string fGeantLabel
 label for module running G4 and making particles, etc More...
 

Detailed Description

Definition at line 39 of file TruthContain_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

filter::TruthContain::TruthContain ( const fhicl::ParameterSet pset)
explicit

Definition at line 71 of file TruthContain_module.cc.

71  :
72  fGeantLabel(pset.get< std::string >("G4ModuleLabel")) //from TrueEnergy_module.cc
73  {
74  /*
75  art::ServiceHandle<art::TFileService> tfs;
76  fMyTree = tfs->make<TTree>("ContTree", "ContTree");
77  fMyTree->Branch( "PartEn" , &fPartEn );
78  fMyTree->Branch( "TrackID" , &fTrackID );
79  fMyTree->Branch( "PDGCode" , &fPDGCode );
80 
81  fMyTree->Branch( "StartX" , &fStartX );
82  fMyTree->Branch( "StartY" , &fStartY );
83  fMyTree->Branch( "StartZ" , &fStartZ );
84  fMyTree->Branch( "EndX" , &fEndX );
85  fMyTree->Branch( "EndY" , &fEndY );
86  fMyTree->Branch( "EndZ" , &fEndZ );
87 
88  fMyTree->Branch( "MomX" , &fMomX );
89  fMyTree->Branch( "MomY" , &fMomY );
90  fMyTree->Branch( "MomZ" , &fMomZ );
91  fMyTree->Branch( "NormMomX", &fNormMomX );
92  fMyTree->Branch( "NormMomY", &fNormMomY );
93  fMyTree->Branch( "NormMomZ", &fNormMomZ );
94  fMyTree->Branch( "TotMom" , &fTotMom );
95 
96  fMyTree->Branch( "EnterEn" , &fEnterEn );
97  fMyTree->Branch( "EscapeEn", &fEscapeEn );
98  fMyTree->Branch( "TotEscEn", &fTotEscEn );
99  fMyTree->Branch( "TotDepEn", &fTotDepEn );
100  fMyTree->Branch( "CorEscEn", &fCorEscEn );
101  */
102  }
std::string fGeantLabel
label for module running G4 and making particles, etc
T get(std::string const &key) const
Definition: ParameterSet.h:231
enum BeamMode string
filter::TruthContain::TruthContain ( TruthContain const &  )
delete
filter::TruthContain::TruthContain ( TruthContain &&  )
delete

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::EDFilter::currentContext ( ) const
protectedinherited
bool filter::TruthContain::filter ( art::Event e)
overridevirtual

Implements art::EDFilter.

Definition at line 117 of file TruthContain_module.cc.

References simb::MCParticle::Daughter(), DEFINE_ART_MODULE(), simb::MCParticle::EndX(), simb::MCParticle::EndY(), simb::MCParticle::EndZ(), sim::TrueEnergy::EnteringEnergy(), sim::TrueEnergy::EscapingEnergy(), stan::math::fabs(), fGeantLabel, art::DataViewImpl::getByLabel(), MECModelEnuComparisons::i, simb::MCParticle::NumberDaughters(), par, simb::MCParticle::PdgCode(), ResetTree(), sim::TrueEnergy::TrackId(), simb::MCParticle::TrackId(), cheat::BackTracker::TrackIDToParticle(), simb::MCParticle::Vx(), simb::MCParticle::Vy(), and simb::MCParticle::Vz().

118  {
119  ResetTree();
121  evt.getByLabel(fGeantLabel, firstParticles);
122 
123  art::Handle< std::vector<sim::TrueEnergy> > firstTrueEnergies;
124  evt.getByLabel(fGeantLabel, firstTrueEnergies);
125 
127 
128  bool fPass = false;
129  for(unsigned int i = 0; i < firstTrueEnergies->size(); ++i){
130  sim::TrueEnergy trueE = ((*firstTrueEnergies)[i]);
131  if (trueE.TrackId() == 1) {
132  const sim::Particle *TruePart = bt->TrackIDToParticle(trueE.TrackId());
133 
134  // -- Make some Vars for the TrueEnergy::EscapingEnergy and the End Position of the Primary.
135  float CorEscEn = trueE.EscapingEnergy();
136  float EndX = TruePart->EndX();
137  float EndY = TruePart->EndY();
138  float EndZ = TruePart->EndZ();
139  // -- Loop through the daughters.
140  for (int par=0; par<TruePart->NumberDaughters(); ++par) {
141  const sim::Particle *Daught = bt->TrackIDToParticle(TruePart->Daughter(par));
142  // -- Loop through the TrueEnergies.
143  for(unsigned int te = 0; te < firstTrueEnergies->size(); ++te){
144  // -- If found the TrueEnergy
145  sim::TrueEnergy DaughtTE = ((*firstTrueEnergies)[te]);
146  if ( DaughtTE.TrackId() == Daught->TrackId() ) {
147  float DaughtStX = Daught->Vx();
148  float DaughtStY = Daught->Vy();
149  float DaughtStZ = Daught->Vz();
150  // -- Check that it is a hard scatter.
151  if ( Daught->PdgCode() == TruePart->PdgCode() &&
152  fabs( DaughtStX - EndX ) < 1.0 &&
153  fabs( DaughtStY - EndY ) < 1.0 &&
154  fabs( DaughtStZ - EndZ ) < 1.0 ) {
155  CorEscEn += DaughtTE.EscapingEnergy();
156  }
157  break;
158  } // if hard-scatter
159  } // loop over te
160  } // loop over par
161 
162  // Do the cut - for rational see DocDB 45934.
163  if ( trueE.EnteringEnergy() > 0.0 && CorEscEn < 0.1 ) {
164  fPass = true;
165  }
166 
167  // Fill MyTree.
168  /*
169  fPartEn = TruePart->E();
170  fTrackID = TruePart->TrackId();
171  fPDGCode = TruePart->PdgCode();
172  // Pos
173  fStartX = TruePart->Vx();
174  fStartY = TruePart->Vy();
175  fStartZ = TruePart->Vz();
176  fEndX = TruePart->EndX();
177  fEndY = TruePart->EndY();
178  fEndZ = TruePart->EndZ();
179  // Mom
180  fMomX = TruePart->Px();
181  fMomY = TruePart->Py();
182  fMomZ = TruePart->Pz();
183  fTotMom = TruePart->P();
184  TVector3 UnitMom = TruePart->Momentum().Vect().Unit();
185  fNormMomX = UnitMom.X();
186  fNormMomY = UnitMom.Y();
187  fNormMomZ = UnitMom.Z();
188  // sim::TrueEnergy
189  fEnterEn = trueE.EnteringEnergy();
190  fEscapeEn = trueE.EscapingEnergy();
191  fTotEscEn = trueE.TotalEscEnergy();
192  fTotDepEn = trueE.TotalDepEnergy();
193  fCorEscEn = CorEscEn;
194  // Fill the tree
195  fMyTree->Fill();
196 
197  std::cout << "\n Primary particle with TrackId " << trueE.TrackId() << " is a " << TruePart->PdgCode() << " with " << TruePart->NumberDaughters() << " daughters."
198  << " It had StartingE " << TruePart->E() << ", and EndE " << TruePart->E(TruePart->NumberTrajectoryPoints()-1)
199  << "\n\t It finished at position " << fEndX << ", " << fEndY << ", " << fEndZ
200  << "\n\t It had EnterE " << trueE.EnteringEnergy() << ", EscapeE " << trueE.EscapingEnergy() << ", TotEscE " << trueE.TotalEscEnergy()
201  << std::endl;
202  */
203 
204  // No point looping all the way through the TrueEnergy vector
205  break;
206  } // if Primary
207  } // loop through TrueEnergy
208  return fPass;
209  } // filter
std::string fGeantLabel
label for module running G4 and making particles, etc
int PdgCode() const
Definition: MCParticle.h:211
int TrackId() const
Definition: TrueEnergy.h:36
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
double EndZ() const
Definition: MCParticle.h:227
Int_t par
Definition: SimpleIterate.C:24
double EndY() const
Definition: MCParticle.h:226
float EscapingEnergy() const
Definition: TrueEnergy.h:38
int NumberDaughters() const
Definition: MCParticle.h:216
float EnteringEnergy() const
Definition: TrueEnergy.h:37
int TrackId() const
Definition: MCParticle.h:209
int Daughter(const int i) const
Definition: MCParticle.cxx:112
int evt
const sim::Particle * TrackIDToParticle(int const &id) const
Returns a pointer to the sim::Particle object corresponding to the given TrackID. ...
double Vx(const int i=0) const
Definition: MCParticle.h:220
double Vz(const int i=0) const
Definition: MCParticle.h:222
double EndX() const
Definition: MCParticle.h:225
double Vy(const int i=0) const
Definition: MCParticle.h:221
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  }
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
TruthContain& filter::TruthContain::operator= ( TruthContain const &  )
delete
TruthContain& filter::TruthContain::operator= ( TruthContain &&  )
delete
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
void filter::TruthContain::ResetTree ( )

Definition at line 105 of file TruthContain_module.cc.

Referenced by filter().

105  {
106  /*
107  fPartEn = fTrackID = fPDGCode = -5;
108  fStartX = fStartY = fStartZ = -5;
109  fEndX = fEndY = fEndZ = -5;
110  fNormMomX= fNormMomY= fNormMomZ = -5;
111  fMomX = fMomY = fMomZ = fTotMom = -5;
112  fEnterEn = fEscapeEn= fTotEscEn = fTotDepEn = fCorEscEn = -5;
113  */
114  }
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().

std::string filter::TruthContain::fGeantLabel
private

label for module running G4 and making particles, etc

Definition at line 56 of file TruthContain_module.cc.

Referenced by filter().

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: