LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
shower::TCShowerAnalysis Class Reference
Inheritance diagram for shower::TCShowerAnalysis:
art::EDAnalyzer art::EventObserverBase art::Consumer art::EngineCreator

Public Types

using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 TCShowerAnalysis (fhicl::ParameterSet const &pset)
 
virtual ~TCShowerAnalysis ()
 
void reconfigure (fhicl::ParameterSet const &pset)
 
void beginJob ()
 
void analyze (const art::Event &evt)
 
std::string workerType () const
 
bool modifiesEvent () const
 
void registerProducts (MasterProductRegistry &, ProductDescriptions &, ModuleDescription const &)
 
std::string const & processName () const
 
bool wantAllEvents () const
 
bool wantEvent (Event const &e)
 
fhicl::ParameterSetID selectorConfig () const
 
art::Handle< art::TriggerResultsgetTriggerResults (Event const &e) const
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > consumes (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< T > consumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > mayConsume (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< T > mayConsumeView (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

void reset ()
 
void truthMatcher (std::vector< art::Ptr< recob::Hit >>all_hits, std::vector< art::Ptr< recob::Hit >> shower_hits, const simb::MCParticle *&MCparticle, double &Efrac, double &Ecomplet)
 
CurrentProcessingContext const * currentContext () const
 
detail::CachedProducts & cachedProducts ()
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Private Attributes

TTree * fTree
 
int run
 
int subrun
 
int event
 
int nuPDG_truth
 
int ccnc_truth
 
int mode_truth
 
int nshws
 
int shwid [kMaxShowers]
 
float shwdcosx [kMaxShowers]
 
float shwdcosy [kMaxShowers]
 
float shwdcosz [kMaxShowers]
 
float shwstartx [kMaxShowers]
 
float shwstarty [kMaxShowers]
 
float shwstartz [kMaxShowers]
 
double shwdedx [kMaxShowers][2]
 
int shwbestplane [kMaxShowers]
 
int highestHitsPDG
 
double highestHitsFrac
 
std::string fHitModuleLabel
 
std::string fShowerModuleLabel
 
std::string fGenieGenModuleLabel
 
std::string fDigitModuleLabel
 
calo::CalorimetryAlg fCalorimetryAlg
 

Detailed Description

Definition at line 51 of file TCShowerAnalysis_module.cc.

Member Typedef Documentation

Definition at line 39 of file EDAnalyzer.h.

Definition at line 38 of file EDAnalyzer.h.

Constructor & Destructor Documentation

shower::TCShowerAnalysis::TCShowerAnalysis ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 104 of file TCShowerAnalysis_module.cc.

References reconfigure().

104  :
105  EDAnalyzer(pset),
106  fHitModuleLabel (pset.get< std::string >("HitModuleLabel", "trajcluster" ) ),
107  fShowerModuleLabel (pset.get< std::string >("ShowerModuleLabel", "tcshower" ) ),
108  fGenieGenModuleLabel (pset.get< std::string >("GenieGenModuleLabel", "generator") ),
109  fDigitModuleLabel (pset.get< std::string >("DigitModuleLabel", "largeant") ),
110  fCalorimetryAlg (pset.get< fhicl::ParameterSet >("CalorimetryAlg") ) {
111  this->reconfigure(pset);
112 } // TCShowerTemplateMaker
calo::CalorimetryAlg fCalorimetryAlg
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
void reconfigure(fhicl::ParameterSet const &pset)
shower::TCShowerAnalysis::~TCShowerAnalysis ( )
virtual

Definition at line 116 of file TCShowerAnalysis_module.cc.

116  {
117 } // ~TCShowerTemplateMaker

Member Function Documentation

void shower::TCShowerAnalysis::analyze ( const art::Event evt)

Definition at line 157 of file TCShowerAnalysis_module.cc.

References simb::MCNeutrino::CCNC(), ccnc_truth, art::EventID::event(), fDigitModuleLabel, fGenieGenModuleLabel, fHitModuleLabel, art::fill_ptr_vector(), fShowerModuleLabel, fTree, art::DataViewImpl::getByLabel(), simb::MCTruth::GetNeutrino(), highestHitsFrac, highestHitsPDG, art::Event::id(), art::Handle< T >::isValid(), kMaxShowers, min, simb::MCNeutrino::Mode(), mode_truth, simb::MCTruth::NeutrinoSet(), nshws, simb::MCNeutrino::Nu(), nuPDG_truth, simb::MCParticle::PdgCode(), run, art::Event::run(), shwbestplane, shwdcosx, shwdcosy, shwdcosz, shwdedx, shwid, shwstartx, shwstarty, shwstartz, subrun, art::Event::subRun(), and truthMatcher().

157  {
158 
159  run = evt.run();
160  subrun = evt.subRun();
161  event = evt.id().event();
162 
163  art::Handle< std::vector<recob::Hit> > hitListHandle;
164  std::vector<art::Ptr<recob::Hit> > hitlist;
165  if (evt.getByLabel(fHitModuleLabel,hitListHandle))
166  art::fill_ptr_vector(hitlist, hitListHandle);
167 
169  std::vector<art::Ptr<sim::SimChannel> > simchanlist;
170  if (evt.getByLabel(fDigitModuleLabel,scListHandle))
171  art::fill_ptr_vector(simchanlist, scListHandle);
172 
173  art::Handle< std::vector<recob::Shower> > showerListHandle;
174  std::vector<art::Ptr<recob::Shower> > showerlist;
175  if (evt.getByLabel(fShowerModuleLabel,showerListHandle))
176  art::fill_ptr_vector(showerlist, showerListHandle);
177 
178  art::Handle< std::vector<simb::MCTruth> > mctruthListHandle;
179  std::vector<art::Ptr<simb::MCTruth> > mclist;
180  if (evt.getByLabel(fGenieGenModuleLabel,mctruthListHandle))
181  art::fill_ptr_vector(mclist, mctruthListHandle);
182 
183  art::FindManyP<recob::Hit> shwfm(showerListHandle, evt, fShowerModuleLabel);
184 
185  //shower information
186  if (showerListHandle.isValid()) {
187  nshws = showerlist.size();
188 
189  for (int i = 0; i < std::min(int(showerlist.size()),kMaxShowers); ++i) {
190  shwid[i] = showerlist[i]->ID();
191  shwdcosx[i] = showerlist[i]->Direction().X();
192  shwdcosy[i] = showerlist[i]->Direction().Y();
193  shwdcosz[i] = showerlist[i]->Direction().Z();
194  shwstartx[i] = showerlist[i]->ShowerStart().X();
195  shwstarty[i] = showerlist[i]->ShowerStart().Y();
196  shwstartz[i] = showerlist[i]->ShowerStart().Z();
197  for (size_t j = 0; j<(showerlist[i]->dEdx()).size(); ++j){
198  shwdedx[i][j] = showerlist[i]->dEdx()[j];
199  }
200  shwbestplane[i] = showerlist[i]->best_plane();
201  }
202 
203  } // shower info
204 
205 
206  if (mclist.size()) {
207  art::Ptr<simb::MCTruth> mctruth = mclist[0];
208  if (mctruth->NeutrinoSet()) {
209 
210  nuPDG_truth = mctruth->GetNeutrino().Nu().PdgCode();
211  ccnc_truth = mctruth->GetNeutrino().CCNC();
212  mode_truth = mctruth->GetNeutrino().Mode();
213 
214  if (showerlist.size()) { // only looks at the first shower since this is for tcshower
215  std::vector< art::Ptr<recob::Hit> > showerhits = shwfm.at(0);
216  // get shower truth info
217  const simb::MCParticle *particle;
218  double tmpEfrac = 0.0;
219  double tmpEcomplet = 0;
220  truthMatcher(hitlist, showerhits, particle, tmpEfrac, tmpEcomplet);
221  if (particle) {
222  std::cout << "shower pdg: "<< particle->PdgCode() << " efrac " << tmpEfrac << std::endl;
223 
224  highestHitsPDG = particle->PdgCode();
225  highestHitsFrac = tmpEfrac;
226  }
227  }
228  }
229  }
230 
231  fTree->Fill();
232 
233 } // analyze
SubRunNumber_t subRun() const
Definition: Event.h:72
int PdgCode() const
Definition: MCParticle.h:216
int CCNC() const
Definition: MCNeutrino.h:152
double shwdedx[kMaxShowers][2]
const simb::MCNeutrino & GetNeutrino() const
Definition: MCTruth.h:74
const simb::MCParticle & Nu() const
Definition: MCNeutrino.h:150
bool isValid() const
Definition: Handle.h:190
void truthMatcher(std::vector< art::Ptr< recob::Hit >>all_hits, std::vector< art::Ptr< recob::Hit >> shower_hits, const simb::MCParticle *&MCparticle, double &Efrac, double &Ecomplet)
const int kMaxShowers
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Int_t min
Definition: plot.C:26
EventNumber_t event() const
Definition: EventID.h:117
bool NeutrinoSet() const
Definition: MCTruth.h:75
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
RunNumber_t run() const
Definition: Event.h:77
int Mode() const
Definition: MCNeutrino.h:153
EventID id() const
Definition: Event.h:56
void shower::TCShowerAnalysis::beginJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 126 of file TCShowerAnalysis_module.cc.

References ccnc_truth, fTree, highestHitsFrac, highestHitsPDG, art::TFileDirectory::make(), mode_truth, nshws, nuPDG_truth, run, shwbestplane, shwdcosx, shwdcosy, shwdcosz, shwdedx, shwid, shwstartx, shwstarty, shwstartz, and subrun.

126  {
127 
129 
130  fTree = tfs->make<TTree>("tcshowerana", "tcshowerana");
131  fTree->Branch("run",&run,"run/I");
132  fTree->Branch("subrun",&subrun,"subrun/I");
133  fTree->Branch("event",&event,"event/I");
134 
135  fTree->Branch("nuPDG_truth",&nuPDG_truth,"nuPDG_truth/I");
136  fTree->Branch("ccnc_truth",&ccnc_truth,"ccnc_truth/I");
137  fTree->Branch("mode_truth",&mode_truth,"mode_truth/I");
138 
139  fTree->Branch("nshws",&nshws,"nshws/I");
140  fTree->Branch("shwid",shwid,"shwid[nshws]/I");
141  fTree->Branch("shwdcosx",shwdcosx,"shwdcosx[nshws]/F");
142  fTree->Branch("shwdcosy",shwdcosy,"shwdcosy[nshws]/F");
143  fTree->Branch("shwdcosz",shwdcosz,"shwdcosz[nshws]/F");
144  fTree->Branch("shwstartx",shwstartx,"shwstartx[nshws]/F");
145  fTree->Branch("shwstarty",shwstarty,"shwstarty[nshws]/F");
146  fTree->Branch("shwstartz",shwstartz,"shwstartz[nshws]/F");
147  fTree->Branch("shwdedx",shwdedx,"shwdedx[nshws][2]/D");
148  fTree->Branch("shwbestplane",shwbestplane,"shwbestplane[nshws]/I");
149 
150  fTree->Branch("highestHitsPDG",&highestHitsPDG,"highestHitsPDG/I");
151  fTree->Branch("highestHitsFrac",&highestHitsFrac,"highestHitsFrac/D");
152 
153 } // beginJob
double shwdedx[kMaxShowers][2]
T * make(ARGS...args) const
Event finding and building.
detail::CachedProducts& art::EventObserverBase::cachedProducts ( )
inlineprotectedinherited

Definition at line 79 of file EventObserverBase.h.

References art::EventObserverBase::selectors_.

Referenced by art::EDAnalyzer::doEvent(), and art::OutputModule::doWriteEvent().

80  {
81  return selectors_;
82  }
detail::CachedProducts selectors_
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 147 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

148 {
149  if (!moduleContext_)
150  return ProductToken<T>::invalid();
151 
152  consumables_[BT].emplace_back(ConsumableType::Product,
153  TypeID{typeid(T)},
154  it.label(),
155  it.instance(),
156  it.process());
157  return ProductToken<T>{it};
158 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 162 of file Consumer.h.

163 {
164  if (!moduleContext_)
165  return;
166 
167  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
168 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
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 172 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

173 {
174  if (!moduleContext_)
175  return ViewToken<T>::invalid();
176 
177  consumables_[BT].emplace_back(ConsumableType::ViewElement,
178  TypeID{typeid(T)},
179  it.label(),
180  it.instance(),
181  it.process());
182  return ViewToken<T>{it};
183 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited

Definition at line 32 of file EngineCreator.cc.

References art::EngineCreator::rng().

34 {
35  return rng()->createEngine(
36  placeholder_schedule_id(), seed, kind_of_engine_to_make);
37 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited

Definition at line 40 of file EngineCreator.cc.

References art::EngineCreator::rng().

43 {
44  return rng()->createEngine(
45  placeholder_schedule_id(), seed, kind_of_engine_to_make, engine_label);
46 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
CurrentProcessingContext const * art::EDAnalyzer::currentContext ( ) const
protectedinherited

Definition at line 114 of file EDAnalyzer.cc.

References art::EDAnalyzer::current_context_.

Referenced by art::EDAnalyzer::workerType().

115  {
116  return current_context_.get();
117  }
CPC_exempt_ptr current_context_
Definition: EDAnalyzer.h:179
EngineCreator::seed_t EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited

Definition at line 49 of file EngineCreator.cc.

References fhicl::ParameterSet::get().

Referenced by art::MixFilter< T >::initEngine_().

52 {
53  auto const& explicit_seeds = pset.get<std::vector<int>>(key, {});
54  return explicit_seeds.empty() ? implicit_seed : explicit_seeds.front();
55 }
art::Handle<art::TriggerResults> art::EventObserverBase::getTriggerResults ( Event const &  e) const
inlineinherited

Definition at line 61 of file EventObserverBase.h.

References art::detail::CachedProducts::getOneTriggerResults(), and art::EventObserverBase::selectors_.

Referenced by art::OutputModule::doWriteEvent().

62  {
64  }
detail::CachedProducts selectors_
art::Handle< art::TriggerResults > getOneTriggerResults(Event const &) const
Float_t e
Definition: plot.C:34
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 190 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

191 {
192  if (!moduleContext_)
193  return ProductToken<T>::invalid();
194 
195  consumables_[BT].emplace_back(ConsumableType::Product,
196  TypeID{typeid(T)},
197  it.label(),
198  it.instance(),
199  it.process());
200  return ProductToken<T>{it};
201 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 205 of file Consumer.h.

206 {
207  if (!moduleContext_)
208  return;
209 
210  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
211 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
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 215 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

216 {
217  if (!moduleContext_)
218  return ViewToken<T>::invalid();
219 
220  consumables_[BT].emplace_back(ConsumableType::ViewElement,
221  TypeID{typeid(T)},
222  it.label(),
223  it.instance(),
224  it.process());
225  return ViewToken<T>{it};
226 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
bool art::EventObserverBase::modifiesEvent ( ) const
inlineinherited

Definition at line 25 of file EventObserverBase.h.

26  {
27  return false;
28  }
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited

Definition at line 89 of file Consumer.cc.

References fhicl::ParameterSet::get_if_present().

Referenced by art::EDProducer::doBeginJob(), art::EDFilter::doBeginJob(), and art::EDAnalyzer::doBeginJob().

90 {
91  if (!moduleContext_)
92  return;
93 
94  pset.get_if_present("errorOnMissingConsumes", requireConsumes_);
95  for (auto& consumablesPerBranch : consumables_) {
96  cet::sort_all(consumablesPerBranch);
97  }
98 }
bool requireConsumes_
Definition: Consumer.h:137
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
std::string const& art::EventObserverBase::processName ( ) const
inlineinherited
void shower::TCShowerAnalysis::reconfigure ( fhicl::ParameterSet const &  pset)

Definition at line 121 of file TCShowerAnalysis_module.cc.

Referenced by TCShowerAnalysis().

121  {
122 } // reconfigure
void art::EventObserverBase::registerProducts ( MasterProductRegistry ,
ProductDescriptions ,
ModuleDescription const &   
)
inlineinherited

Definition at line 33 of file EventObserverBase.h.

36  {}
void shower::TCShowerAnalysis::reset ( void  )
protected

Definition at line 237 of file TCShowerAnalysis_module.cc.

References ccnc_truth, highestHitsFrac, highestHitsPDG, kMaxShowers, mode_truth, nshws, nuPDG_truth, run, shwbestplane, shwdcosx, shwdcosy, shwdcosz, shwdedx, shwid, shwstartx, shwstarty, shwstartz, and subrun.

237  {
238 
239  run = -99999;
240  subrun = -99999;
241  event = -99999;
242 
243  nuPDG_truth = -99999;
244  ccnc_truth = -99999;
245  mode_truth = -99999;
246 
247  nshws = 0;
248  for (int i = 0; i < kMaxShowers; ++i){
249  shwid[i] = -99999;
250  shwdcosx[i] = -99999;
251  shwdcosy[i] = -99999;
252  shwdcosz[i] = -99999;
253  shwstartx[i] = -99999;
254  shwstarty[i] = -99999;
255  shwstartz[i] = -99999;
256  for (int j = 0; j < 2; ++j){
257  shwdedx[i][j] = -99999;
258  }
259  shwbestplane[i] = -99999;
260  }
261 
262  highestHitsPDG = -99999;
263  highestHitsFrac = -99999;
264 
265  return;
266 
267 } // reset
double shwdedx[kMaxShowers][2]
const int kMaxShowers
fhicl::ParameterSetID art::EventObserverBase::selectorConfig ( ) const
inlineinherited

Definition at line 56 of file EventObserverBase.h.

References art::EventObserverBase::selector_config_id_.

Referenced by art::RootOutputFile::writeOne().

57  {
58  return selector_config_id_;
59  }
fhicl::ParameterSetID selector_config_id_
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Definition at line 125 of file Consumer.cc.

Referenced by art::EDProducer::doEndJob(), art::EDFilter::doEndJob(), art::EDAnalyzer::doEndJob(), and art::RootOutput::endJob().

126 {
127  if (!moduleContext_)
128  return;
129 
130  // If none of the branches have missing consumes statements, exit early.
131  if (std::all_of(cbegin(missingConsumes_),
132  cend(missingConsumes_),
133  [](auto const& perBranch) { return perBranch.empty(); }))
134  return;
135 
136  constexpr cet::HorizontalRule rule{60};
137  mf::LogPrint log{"MTdiagnostics"};
138  log << '\n'
139  << rule('=') << '\n'
140  << "The following consumes (or mayConsume) statements are missing from\n"
141  << module_context(moduleDescription_) << '\n'
142  << rule('-') << '\n';
143 
144  cet::for_all_with_index(
145  missingConsumes_, [&log](std::size_t const i, auto const& perBranch) {
146  for (auto const& pi : perBranch) {
147  log << " "
148  << assemble_consumes_statement(static_cast<BranchType>(i), pi)
149  << '\n';
150  }
151  });
152  log << rule('=');
153 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139
void shower::TCShowerAnalysis::truthMatcher ( std::vector< art::Ptr< recob::Hit >>  all_hits,
std::vector< art::Ptr< recob::Hit >>  shower_hits,
const simb::MCParticle *&  MCparticle,
double &  Efrac,
double &  Ecomplet 
)
protected

Definition at line 271 of file TCShowerAnalysis_module.cc.

References DEFINE_ART_MODULE, cheat::BackTrackerService::HitToEveTrackIDEs(), cheat::ParticleInventoryService::TrackIdToParticle_P(), and recob::Hit::View().

Referenced by analyze().

271  {
272 
273  MCparticle=0;
274  Efrac=1.0;
275  Ecomplet=0;
276 
279  std::map<int,double> trkID_E;
280  for(size_t j = 0; j < shower_hits.size(); ++j){
281  art::Ptr<recob::Hit> hit = shower_hits[j];
282  //For know let's use collection plane to look at the shower reconstruction
283  if( hit->View() != 1) continue;
284  std::vector<sim::TrackIDE> TrackIDs = bt_serv->HitToEveTrackIDEs(hit);
285  for(size_t k = 0; k < TrackIDs.size(); k++){
286  if (trkID_E.find(std::abs(TrackIDs[k].trackID))==trkID_E.end()) trkID_E[std::abs(TrackIDs[k].trackID)] = 0;
287  trkID_E[std::abs(TrackIDs[k].trackID)] += TrackIDs[k].energy;
288  }
289  }
290  double max_E = -999.0;
291  double total_E = 0.0;
292  int TrackID = -999;
293  double partial_E=0.0;
294  //double noEM_E = 0.0; //non electromagnetic energy is defined as energy from charged pion and protons
295  if( !trkID_E.size() ) return; //Ghost shower???
296  for(std::map<int,double>::iterator ii = trkID_E.begin(); ii!=trkID_E.end(); ++ii){
297  total_E += ii->second;
298  if((ii->second)>max_E){
299  partial_E = ii->second;
300  max_E = ii->second;
301  TrackID = ii->first;
302  }
303  //int ID = ii->first;
304  // const simb::MCParticle *particle = pi_serv->TrackIDToParticle(ID);
305  //if( abs(particle->PdgCode()) == 211 || particle->PdgCode() == 2212 ){
306  //if( particle->PdgCode() != 22 && abs(particle->PdgCode()) != 11){
307  //noEM_E += ii->second;
308  //}
309 
310  }
311  MCparticle = pi_serv->TrackIdToParticle_P(TrackID);
312 
313  // Efrac = 1-(partial_E/total_E);
314  Efrac = partial_E/total_E;
315 
316  //completeness
317  double totenergy =0;
318  for(size_t k = 0; k < all_hits.size(); ++k){
319  art::Ptr<recob::Hit> hit = all_hits[k];
320  std::vector<sim::TrackIDE> TrackIDs = bt_serv->HitToEveTrackIDEs(hit);
321  for(size_t l = 0; l < TrackIDs.size(); ++l){
322  if(std::abs(TrackIDs[l].trackID)==TrackID) {
323  totenergy += TrackIDs[l].energy;
324  }
325  }
326  }
327  Ecomplet = partial_E/totenergy;
328 
329 } // truthMatcher
const simb::MCParticle * TrackIdToParticle_P(int const &id)
intermediate_table::iterator iterator
std::vector< TrackID > TrackIDs
geo::View_t View() const
View for the plane of the hit.
Definition: Hit.h:233
Detector simulation of raw signals on wires.
const std::vector< sim::TrackIDE > HitToEveTrackIDEs(recob::Hit const &hit)
void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Definition at line 101 of file Consumer.cc.

References art::errors::ProductRegistrationFailure.

103 {
104  // Early exits if consumes tracking has been disabled or if the
105  // consumed product is an allowed consumable.
106  if (!moduleContext_)
107  return;
108 
109  if (cet::binary_search_all(consumables_[bt], pi))
110  return;
111 
112  if (requireConsumes_) {
114  "Consumer: an error occurred during validation of a "
115  "retrieved product\n\n")
116  << "The following consumes (or mayConsume) statement is missing from\n"
117  << module_context(moduleDescription_) << ":\n\n"
118  << " " << assemble_consumes_statement(bt, pi) << "\n\n";
119  }
120 
121  missingConsumes_[bt].insert(pi);
122 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
bool requireConsumes_
Definition: Consumer.h:137
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139
bool art::EventObserverBase::wantAllEvents ( ) const
inlineinherited
bool art::EventObserverBase::wantEvent ( Event const &  e)
inlineinherited
std::string art::EDAnalyzer::workerType ( ) const
inlineinherited

Definition at line 109 of file EDAnalyzer.h.

References art::EDAnalyzer::currentContext().

110  {
111  return "WorkerT<EDAnalyzer>";
112  }

Member Data Documentation

int shower::TCShowerAnalysis::ccnc_truth
private

Definition at line 75 of file TCShowerAnalysis_module.cc.

Referenced by analyze(), beginJob(), and reset().

int shower::TCShowerAnalysis::event
private

Definition at line 73 of file TCShowerAnalysis_module.cc.

calo::CalorimetryAlg shower::TCShowerAnalysis::fCalorimetryAlg
private

Definition at line 96 of file TCShowerAnalysis_module.cc.

std::string shower::TCShowerAnalysis::fDigitModuleLabel
private

Definition at line 94 of file TCShowerAnalysis_module.cc.

Referenced by analyze().

std::string shower::TCShowerAnalysis::fGenieGenModuleLabel
private

Definition at line 93 of file TCShowerAnalysis_module.cc.

Referenced by analyze().

std::string shower::TCShowerAnalysis::fHitModuleLabel
private

Definition at line 91 of file TCShowerAnalysis_module.cc.

Referenced by analyze().

std::string shower::TCShowerAnalysis::fShowerModuleLabel
private

Definition at line 92 of file TCShowerAnalysis_module.cc.

Referenced by analyze().

TTree* shower::TCShowerAnalysis::fTree
private

Definition at line 70 of file TCShowerAnalysis_module.cc.

Referenced by analyze(), and beginJob().

double shower::TCShowerAnalysis::highestHitsFrac
private

Definition at line 89 of file TCShowerAnalysis_module.cc.

Referenced by analyze(), beginJob(), and reset().

int shower::TCShowerAnalysis::highestHitsPDG
private

Definition at line 88 of file TCShowerAnalysis_module.cc.

Referenced by analyze(), beginJob(), and reset().

int shower::TCShowerAnalysis::mode_truth
private

Definition at line 76 of file TCShowerAnalysis_module.cc.

Referenced by analyze(), beginJob(), and reset().

int shower::TCShowerAnalysis::nshws
private

Definition at line 77 of file TCShowerAnalysis_module.cc.

Referenced by analyze(), beginJob(), and reset().

int shower::TCShowerAnalysis::nuPDG_truth
private

Definition at line 74 of file TCShowerAnalysis_module.cc.

Referenced by analyze(), beginJob(), and reset().

int shower::TCShowerAnalysis::run
private

Definition at line 71 of file TCShowerAnalysis_module.cc.

Referenced by analyze(), beginJob(), and reset().

int shower::TCShowerAnalysis::shwbestplane[kMaxShowers]
private

Definition at line 86 of file TCShowerAnalysis_module.cc.

Referenced by analyze(), beginJob(), and reset().

float shower::TCShowerAnalysis::shwdcosx[kMaxShowers]
private

Definition at line 79 of file TCShowerAnalysis_module.cc.

Referenced by analyze(), beginJob(), and reset().

float shower::TCShowerAnalysis::shwdcosy[kMaxShowers]
private

Definition at line 80 of file TCShowerAnalysis_module.cc.

Referenced by analyze(), beginJob(), and reset().

float shower::TCShowerAnalysis::shwdcosz[kMaxShowers]
private

Definition at line 81 of file TCShowerAnalysis_module.cc.

Referenced by analyze(), beginJob(), and reset().

double shower::TCShowerAnalysis::shwdedx[kMaxShowers][2]
private

Definition at line 85 of file TCShowerAnalysis_module.cc.

Referenced by analyze(), beginJob(), and reset().

int shower::TCShowerAnalysis::shwid[kMaxShowers]
private

Definition at line 78 of file TCShowerAnalysis_module.cc.

Referenced by analyze(), beginJob(), and reset().

float shower::TCShowerAnalysis::shwstartx[kMaxShowers]
private

Definition at line 82 of file TCShowerAnalysis_module.cc.

Referenced by analyze(), beginJob(), and reset().

float shower::TCShowerAnalysis::shwstarty[kMaxShowers]
private

Definition at line 83 of file TCShowerAnalysis_module.cc.

Referenced by analyze(), beginJob(), and reset().

float shower::TCShowerAnalysis::shwstartz[kMaxShowers]
private

Definition at line 84 of file TCShowerAnalysis_module.cc.

Referenced by analyze(), beginJob(), and reset().

int shower::TCShowerAnalysis::subrun
private

Definition at line 72 of file TCShowerAnalysis_module.cc.

Referenced by analyze(), beginJob(), and reset().


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