Public Member Functions | Public Attributes | Private Attributes | List of all members
MichelReco::MichelReco Class Reference
Inheritance diagram for MichelReco::MichelReco:
art::EDAnalyzer art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::detail::Analyzer art::detail::LegacyModule art::Observer art::Observer art::ModuleBase art::ModuleBase

Public Member Functions

 MichelReco (fhicl::ParameterSet const &p)
 
 MichelReco (MichelReco const &)=delete
 
 MichelReco (MichelReco &&)=delete
 
MichelRecooperator= (MichelReco const &)=delete
 
MichelRecooperator= (MichelReco &&)=delete
 
void analyze (art::Event const &e) override
 
void beginJob () override
 
void endJob () override
 
void beginRun (const art::Run &run) override
 
void reconfigure (fhicl::ParameterSet const &p)
 
bool insideFidVol (double pos[3])
 
bool hitCloseToTrackEnd (detinfo::DetectorPropertiesData const &detProp, double radius, double end[3], double end2D[2], recob::Hit hit, geo::GeometryCore const &geom)
 
int trackMatching (int trackIndex, art::FindManyP< recob::Hit > hitsFromTracks)
 
bool isMuonDecaying (simb::MCParticle particle, std::vector< simb::MCParticle > particles)
 
bool areHitsMichel (detinfo::DetectorClocksData const &clockData, const std::vector< recob::Hit > &hits)
 
 MichelReco (fhicl::ParameterSet const &p)
 
 MichelReco (MichelReco const &)=delete
 
 MichelReco (MichelReco &&)=delete
 
MichelRecooperator= (MichelReco const &)=delete
 
MichelRecooperator= (MichelReco &&)=delete
 
void analyze (art::Event const &e) override
 
void beginJob () override
 
void endJob () override
 
void beginRun (const art::Run &run) override
 
void reconfigure (fhicl::ParameterSet const &p)
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
fhicl::ParameterSetID selectorConfig () const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Public Attributes

calo::CalorimetryAlg fCalorimetryAlg
 

Private Attributes

size_t fEvNumber
 
TCanvas * c
 
double fRadiusThreshold
 
int fNumberThreshold
 
double fCNNThreshold
 
int fNumberCloseHitsStart [3]
 
int fNumberCloseHitsEnd [3]
 
double fYesSelected
 
double fNoSelected
 
int fNMichel
 
int fBestview
 
art::InputTag fTrackModuleLabel
 
art::InputTag fNNetModuleLabel
 
art::InputTag fParticleModuleLabel
 
double fFidVolCut
 
int fNMichelHits
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 63 of file MichelEventSelection_module.cc.

Constructor & Destructor Documentation

MichelReco::MichelReco::MichelReco ( fhicl::ParameterSet const &  p)
explicit

Definition at line 137 of file MichelEventSelection_module.cc.

138  :
139  EDAnalyzer(p),
140  fCalorimetryAlg(p.get<fhicl::ParameterSet>("CalorimetryAlg"))
141 {
142  reconfigure(p);
143 }
void reconfigure(fhicl::ParameterSet const &p)
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
p
Definition: test.py:223
MichelReco::MichelReco::MichelReco ( MichelReco const &  )
delete
MichelReco::MichelReco::MichelReco ( MichelReco &&  )
delete
MichelReco::MichelReco::MichelReco ( fhicl::ParameterSet const &  p)
explicit
MichelReco::MichelReco::MichelReco ( MichelReco const &  )
delete
MichelReco::MichelReco::MichelReco ( MichelReco &&  )
delete

Member Function Documentation

void MichelReco::MichelReco::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

void MichelReco::MichelReco::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 170 of file MichelEventSelection_module.cc.

171 {
172 
173  fEvNumber = evt.id().event();
174  std::cout << "Michel event selection is on event " << fEvNumber << std::endl;
175 
176  // find all decaying muons in truth
177  auto const & particles = *evt.getValidHandle<std::vector<simb::MCParticle>>( fParticleModuleLabel );
178  for ( auto const & particle : particles ) {
179  if ( abs(particle.PdgCode()) == 13 ) {
180  double mcEnd[3] = { particle.EndX(), particle.EndY(), particle.EndZ() };
181  if ( isMuonDecaying( particle, particles ) && insideFidVol( mcEnd ) ) {
182  fNMichel += 1;
183  }
184  }
185  }
186 
187  // Get the reconstructed objects, tracks and hits
188  auto const & trackHandle = evt.getValidHandle<std::vector<recob::Track>>( fTrackModuleLabel );
189  auto const & tracks = * trackHandle;
190  art::FindManyP<recob::Hit> hitsFromTracks( trackHandle, evt, fTrackModuleLabel );
191 
192  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService>()->DataFor(evt);
193  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService>()->DataFor(evt, clockData);
194 
195  // loop over tracks
196  for (auto const & track : tracks) {
197 
198  // find best true trask ID for this track
199  //int bestTrackId = trackMatching( &track - &tracks[0], hitsFromTracks );
200 
201  // find track start and end
202  auto const & trackStart = track.Vertex<TVector3>();
203  double start[3] = { trackStart.X(), trackStart.Y(), trackStart.Z() };
204  auto const & trackEnd = track.End<TVector3>();
205  double end[3] = { trackEnd.X(), trackEnd.Y(), trackEnd.Z() };
206 
207  // Check if the track starts or ends in the fiducial volume
208  bool startInFidVol = insideFidVol( start );
209  bool endInFidVol = insideFidVol( end );
210  if ( startInFidVol || endInFidVol ) {
211 
212  // reset hit counts
213  for (int plane = 0; plane < 3; plane++) {
214  fNumberCloseHitsStart[ plane ] = 0; fNumberCloseHitsEnd[ plane ] = 0;
215  }
216 
217  // get the hit results helper
219 
220  // loop over hits store the selected hits
221  std::vector< recob::Hit > taggedHitsStart;
222  std::vector< recob::Hit > taggedHitsEnd;
223  for ( size_t h = 0; h < hitResults.size(); ++h ) {
224 
225  // cnn output vector: [em,trk,none,michel]
226  std::array<float,4> cnn_out = hitResults.getOutput( h );
227 
228  // keep hits with large CNN values
229  if ( cnn_out[hitResults.getIndex("michel")] > fCNNThreshold ) {
230 
231  // need to check at both ends of the track
232  if ( startInFidVol ) {
233 
234  // In each plane check if the michel tagged hits are close to the end of the track
235  for ( int plane = 0; plane < 3; plane++ ) {
236 
237  // project the track onto the plane
239  auto const & trackStart2D = pma::GetProjectionToPlane( trackStart, plane, geom.FindTPCAtPosition( start ).TPC, geom.FindCryostatAtPosition( start ) );
240  double start2D[2] = {trackStart2D.X(), trackStart2D.Y()};
241 
242  // get the hit itself
243  const recob::Hit & hit = hitResults.item(h);
244  if (hit.View() == plane) {
245 
246  // check that the hit is close to the track endpoint
247  // and add to tagged hits if so
248  if ( hitCloseToTrackEnd( detProp, fRadiusThreshold, start, start2D, hit, geom ) ) {
249  fNumberCloseHitsStart[ plane ] += 1;
250  if ( plane == 2 ) { taggedHitsStart.push_back( hit ); };
251  }
252 
253  }
254 
255  }
256 
257  }
258  if ( endInFidVol ) {
259 
260  // In each plane check if the michel tagged hits are close to the end of the track
261  for ( int plane = 0; plane < 3; plane++ ) {
262 
263  // project the track onto the plane
265  auto const & trackEnd2D = pma::GetProjectionToPlane( trackEnd, plane, geom.FindTPCAtPosition( end ).TPC, geom.FindCryostatAtPosition( end ) );
266  double end2D[2] = {trackEnd2D.X(), trackEnd2D.Y()};
267 
268  // get the hit itself
269  const recob::Hit & hit = hitResults.item(h);
270  if (hit.View() == plane) {
271 
272  // check that the hit is close to the track endpoint
273  // and add to tagged hits if so
274  if ( hitCloseToTrackEnd( detProp, fRadiusThreshold, end, end2D, hit, geom ) ) {
275  fNumberCloseHitsEnd[ plane ] += 1;
276  if ( plane == 2 ) { taggedHitsEnd.push_back( hit ); }
277  }
278 
279  }
280 
281  }
282 
283  }
284 
285  }
286 
287  } // end of loop over hits
288 
289  // event selection decision: clusters of hits in all planes at one end of the track
292  bool eventSelected = ( startSelected || endSelected );
293  if ( startSelected && endSelected ) { eventSelected = false; }
294 
295  // check if the event was correclty tagged
296  // i.e. do the tagged hits correspond to a michel
297  bool particleIsMichel(false);
298  if (eventSelected) {
299  if ( startSelected ) { particleIsMichel = areHitsMichel(clockData, taggedHitsStart); }
300  if ( endSelected ) { particleIsMichel = areHitsMichel(clockData, taggedHitsEnd); }
301  }
302 
303  // update purity and efficiecny numbers and draw example events
304  if ( particleIsMichel && eventSelected ) {
305 
306  fYesSelected += 1;
307 
308  // plot the region around track end to see what the event is
309  // if ( startSelected ) {
310  //
311  // for (int plane = 0; plane < 3; plane++) {
312  //
313  // geo::GeometryCore const & geom = *art::ServiceHandle<geo::Geometry>();
314  // auto const & trackStart2D = pma::GetProjectionToPlane(trackStart, plane, geom.FindTPCAtPosition(start).TPC, geom.FindCryostatAtPosition(start));
315  // double start2D[2] = {trackStart2D.X(), trackStart2D.Y()};
316 
317  // TH2D * histCNN = new TH2D("cnn", "Correctly Tagged", 200, start2D[0] - 20.0, start2D[0] +20.0, 200, start2D[1] - 20.0, start2D[1] + 20.0);
318  // TH2D * histCharge = new TH2D("charge", "Correctly Tagged", 200, start2D[0] - 20.0, start2D[0] + 20.0, 200, start2D[1] - 20.0, start2D[1] + 20.0);
319  // histCNN -> SetStats(0);
320  // histCharge -> SetStats(0);
321 
322  // for ( size_t h = 0; h< hitResults.size(); ++h ) {
323  // const recob::Hit & hit = hitResults.item(h);
324  // auto const & hitLocation = pma::WireDriftToCm(hit.WireID().Wire, hit.PeakTime(), plane, geom.FindTPCAtPosition(start).TPC, geom.FindCryostatAtPosition(start));
325  //
326  // if (hit.View() == plane) {
327  // histCNN -> Fill(hitLocation.X(), hitLocation.Y(), hitResults.getOutput(h)[hitResults.getIndex("michel")]);
328  // histCharge -> Fill(hitLocation.X(), hitLocation.Y(), hit.Integral());
329  // }
330  // }
331  //
332  // histCNN -> Draw("colz");
333  // c->SaveAs(Form("imgs/correctCNN%d_plane%d.png",bestTrackId, plane));
334  // histCharge-> Draw("colz");
335  // c->SaveAs(Form("imgs/correctCharge%d_plane%d.png",bestTrackId, plane));
336  //
337  // }
338  // }
339  // if ( endSelected ) {
340  //
341  // for (int plane = 0; plane < 3; plane++) {
342  //
343  // geo::GeometryCore const & geom = *art::ServiceHandle<geo::Geometry>();
344  // auto const & trackEnd2D = pma::GetProjectionToPlane(trackEnd, plane, geom.FindTPCAtPosition(end).TPC, geom.FindCryostatAtPosition(end));
345  // double end2D[2] = {trackEnd2D.X(), trackEnd2D.Y()};
346 
347  // TH2D * histCNN = new TH2D("cnn", "Correctly Tagged", 200, end2D[0] - 20.0, end2D[0] +20.0, 200, end2D[1] - 20.0, end2D[1] + 20.0);
348  // TH2D * histCharge = new TH2D("charge", "Correctly Tagged", 200, end2D[0] - 20.0, end2D[0] + 20.0, 200, end2D[1] - 20.0, end2D[1] + 20.0);
349  // histCNN -> SetStats(0);
350  // histCharge -> SetStats(0);
351 
352  // for ( size_t h = 0; h< hitResults.size(); ++h ) {
353  // const recob::Hit & hit = hitResults.item(h);
354  // auto const & hitLocation = pma::WireDriftToCm(hit.WireID().Wire, hit.PeakTime(), plane, geom.FindTPCAtPosition(end).TPC, geom.FindCryostatAtPosition(end));
355  //
356  // if (hit.View() == plane) {
357  // histCNN -> Fill(hitLocation.X(), hitLocation.Y(), hitResults.getOutput(h)[hitResults.getIndex("michel")]);
358  // histCharge -> Fill(hitLocation.X(), hitLocation.Y(), hit.Integral());
359  // }
360  // }
361  //
362  // histCNN -> Draw("colz");
363  // c->SaveAs(Form("imgs/correctCNN%d_plane%d.png",bestTrackId, plane));
364  // histCharge-> Draw("colz");
365  // c->SaveAs(Form("imgs/correctCharge%d_plane%d.png",bestTrackId, plane));
366  //
367  // }
368 
369  // }
370 
371  }
372  if ( !particleIsMichel && eventSelected ) {
373 
374  fNoSelected += 1;
375 
376  // plot the region around track end to see what the event is
377  // if ( startSelected ) {
378  //
379  // for (int plane = 0; plane < 3; plane++) {
380  //
381  // geo::GeometryCore const & geom = *art::ServiceHandle<geo::Geometry>();
382  // auto const & trackStart2D = pma::GetProjectionToPlane(trackStart, plane, geom.FindTPCAtPosition(start).TPC, geom.FindCryostatAtPosition(start));
383  // double start2D[2] = {trackStart2D.X(), trackStart2D.Y()};
384 
385  // TH2D * histCNN = new TH2D("cnn", "Incorrectly Tagged", 200, start2D[0] - 20.0, start2D[0] +20.0, 200, start2D[1] - 20.0, start2D[1] + 20.0);
386  // TH2D * histCharge = new TH2D("charge", "Incorrectly Tagged", 200, start2D[0] - 20.0, start2D[0] + 20.0, 200, start2D[1] - 20.0, start2D[1] + 20.0);
387  // histCNN -> SetStats(0);
388  // histCharge -> SetStats(0);
389 
390  // for ( size_t h = 0; h< hitResults.size(); ++h ) {
391  // const recob::Hit & hit = hitResults.item(h);
392  // auto const & hitLocation = pma::WireDriftToCm(hit.WireID().Wire, hit.PeakTime(), plane, geom.FindTPCAtPosition(start).TPC, geom.FindCryostatAtPosition(start));
393  //
394  // if (hit.View() == plane) {
395  // histCNN -> Fill(hitLocation.X(), hitLocation.Y(), hitResults.getOutput(h)[hitResults.getIndex("michel")]);
396  // histCharge -> Fill(hitLocation.X(), hitLocation.Y(), hit.Integral());
397  // }
398  // }
399  //
400  // histCNN -> Draw("colz");
401  // c->SaveAs(Form("imgs/incorrectCNN%d_plane%d.png",bestTrackId, plane));
402  // histCharge-> Draw("colz");
403  // c->SaveAs(Form("imgs/incorrectCharge%d_plane%d.png",bestTrackId, plane));
404  //
405  // }
406  // }
407  // if ( endSelected ) {
408  //
409  // for (int plane = 0; plane < 3; plane++) {
410  //
411  // geo::GeometryCore const & geom = *art::ServiceHandle<geo::Geometry>();
412  // auto const & trackEnd2D = pma::GetProjectionToPlane(trackEnd, plane, geom.FindTPCAtPosition(end).TPC, geom.FindCryostatAtPosition(end));
413  // double end2D[2] = {trackEnd2D.X(), trackEnd2D.Y()};
414 
415  // TH2D * histCNN = new TH2D("cnn", "Incorrectly Tagged", 200, end2D[0] - 20.0, end2D[0] +20.0, 200, end2D[1] - 20.0, end2D[1] + 20.0);
416  // TH2D * histCharge = new TH2D("charge", "Incorrectly Tagged", 200, end2D[0] - 20.0, end2D[0] + 20.0, 200, end2D[1] - 20.0, end2D[1] + 20.0);
417  // histCNN -> SetStats(0);
418  // histCharge -> SetStats(0);
419 
420  // for ( size_t h = 0; h< hitResults.size(); ++h ) {
421  // const recob::Hit & hit = hitResults.item(h);
422  // auto const & hitLocation = pma::WireDriftToCm(hit.WireID().Wire, hit.PeakTime(), plane, geom.FindTPCAtPosition(end).TPC, geom.FindCryostatAtPosition(end));
423  //
424  // if (hit.View() == plane) {
425  // histCNN -> Fill(hitLocation.X(), hitLocation.Y(), hitResults.getOutput(h)[hitResults.getIndex("michel")]);
426  // histCharge -> Fill(hitLocation.X(), hitLocation.Y(), hit.Integral());
427  // }
428  // }
429  //
430  // histCNN -> Draw("colz");
431  // c->SaveAs(Form("imgs/incorrectCNN%d_plane%d.png",bestTrackId, plane));
432  // histCharge-> Draw("colz");
433  // c->SaveAs(Form("imgs/incorrectCharge%d_plane%d.png",bestTrackId, plane));
434  //
435  // }
436  //
437  // }
438 
439  }
440 
441  }
442 
443  } // end of loop over tracks
444 
445 }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
bool isMuonDecaying(simb::MCParticle particle, std::vector< simb::MCParticle > particles)
unsigned int event
Definition: DataStructs.h:636
geo::View_t View() const
View for the plane of the hit.
Definition: Hit.h:232
bool hitCloseToTrackEnd(detinfo::DetectorPropertiesData const &detProp, double radius, double end[3], double end2D[2], recob::Hit hit, geo::GeometryCore const &geom)
bool areHitsMichel(detinfo::DetectorClocksData const &clockData, const std::vector< recob::Hit > &hits)
geo::TPCID FindTPCAtPosition(double const worldLoc[3]) const
Returns the ID of the TPC at specified location.
T abs(T value)
Description of geometry of one entire detector.
Detector simulation of raw signals on wires.
Definition: tracks.py:1
TVector2 GetProjectionToPlane(const TVector3 &p, unsigned int plane, unsigned int tpc, unsigned int cryo)
Definition: Utilities.cxx:270
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
TCEvent evt
Definition: DataStructs.cxx:7
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
geo::CryostatID::CryostatID_t FindCryostatAtPosition(geo::Point_t const &worldLoc) const
Returns the index of the cryostat at specified location.
QTextStream & endl(QTextStream &s)
bool MichelReco::MichelReco::areHitsMichel ( detinfo::DetectorClocksData const &  clockData,
const std::vector< recob::Hit > &  hits 
)

Definition at line 576 of file MichelEventSelection_module.cc.

577  {
578 
579  const simb::MCParticle * mcParticle = 0;
580 
583  std::unordered_map< int, double > trkIDE;
584  for ( auto const & hit : hits ) {
585  for ( auto const & ide : bt_serv->HitToTrackIDEs(clockData, hit) ) { trkIDE[ide.trackID] += ide.energy; }
586  }
587 
588  int best_id(0);
589  double tot_e(0), max_e(0);
590  for ( auto const & contrib : trkIDE ) {
591 
592  tot_e += contrib.second;
593  if ( contrib.second > max_e ) {
594  max_e = contrib.second;
595  best_id = contrib.first;
596  }
597  }
598 
599  if ( (max_e > 0) && (tot_e > 0) ) {
600  if ( best_id < 0 ) {
601  best_id = -best_id;
602  }
603  mcParticle = pi_serv->TrackIdToParticle_P( best_id );
604  }
605 
606  if (mcParticle != 0) {
607  return ( abs(mcParticle->PdgCode()) && ( mcParticle->Process() == "Decay" || mcParticle->Process() == "muMinusCaptureAtRest") ) ;
608  }
609  else {
610  std::cout << "No match found" << hits.size() << std::endl;
611  return false;
612  }
613 
614 }
int PdgCode() const
Definition: MCParticle.h:212
std::vector< sim::TrackIDE > HitToTrackIDEs(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
const simb::MCParticle * TrackIdToParticle_P(int id) const
std::string Process() const
Definition: MCParticle.h:215
T abs(T value)
Detector simulation of raw signals on wires.
QTextStream & endl(QTextStream &s)
void MichelReco::MichelReco::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

void MichelReco::MichelReco::beginJob ( )
overridevirtual
void MichelReco::MichelReco::beginRun ( const art::Run run)
override
void MichelReco::MichelReco::beginRun ( const art::Run run)
override

Definition at line 165 of file MichelEventSelection_module.cc.

void MichelReco::MichelReco::endJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

void MichelReco::MichelReco::endJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 150 of file MichelEventSelection_module.cc.

151 {
152  mf::LogVerbatim("MichelReco") << "MichelReco finished job";
153 
154  std::ofstream michelRecoOut;
155  michelRecoOut.open("test.txt");
156  michelRecoOut << "nMichel Purity Efficiency" << std::endl;
157 
158  double purity = fYesSelected / ( fYesSelected + fNoSelected );
159  double efficiency = fYesSelected/ fNMichel;
160 
161  michelRecoOut << fNMichel << " " << purity << " " << efficiency << std::endl;
162  michelRecoOut.close();
163 }
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
QTextStream & endl(QTextStream &s)
bool MichelReco::MichelReco::hitCloseToTrackEnd ( detinfo::DetectorPropertiesData const &  detProp,
double  radius,
double  end[3],
double  end2D[2],
recob::Hit  hit,
geo::GeometryCore const &  geom 
)

Definition at line 556 of file MichelEventSelection_module.cc.

557  {
558 
559  bool close = false;
560 
561  auto const & hitLocation = pma::WireDriftToCm(detProp,
562  hit.WireID().Wire, hit.PeakTime(), hit.View(), geom.FindTPCAtPosition(end).TPC, geom.FindCryostatAtPosition(end));
563 
564  double deltaXToHit = hitLocation.X() - end2D[0];
565  double deltaYToHit = hitLocation.Y() - end2D[1];
566 
567  double displacementToHit = pow(pow(deltaXToHit,2)+pow(deltaYToHit,2),0.5);
568 
569  if (displacementToHit < radius) close = true;
570 
571  return close;
572 
573 }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
geo::WireID WireID() const
Definition: Hit.h:233
constexpr T pow(T x)
Definition: pow.h:72
TVector2 WireDriftToCm(detinfo::DetectorPropertiesData const &detProp, unsigned int wire, float drift, unsigned int plane, unsigned int tpc, unsigned int cryo)
Definition: Utilities.cxx:294
geo::View_t View() const
View for the plane of the hit.
Definition: Hit.h:232
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
int close(int)
Closes the file descriptor fd.
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:218
bool MichelReco::MichelReco::insideFidVol ( double  pos[3])

Definition at line 507 of file MichelEventSelection_module.cc.

507  {
508 
510  bool inside = false;
511 
512  geo::TPCID idtpc = geom.FindTPCAtPosition(pos);
513 
514  if (geom.HasTPC(idtpc)) {
515 
516  const geo::TPCGeo& tpcgeo = geom.GetElement(idtpc);
517  double minx = tpcgeo.MinX(); double maxx = tpcgeo.MaxX();
518  double miny = tpcgeo.MinY(); double maxy = tpcgeo.MaxY();
519  double minz = tpcgeo.MinZ(); double maxz = tpcgeo.MaxZ();
520 
521  for (size_t cryo = 0; cryo < geom.Ncryostats(); cryo++) {
522  const geo::CryostatGeo& cryostat = geom.Cryostat(cryo);
523  for (size_t tpc = 0; tpc < cryostat.NTPC(); tpc++) {
524  const geo::TPCGeo& tpcg = cryostat.TPC(tpc);
525  if (tpcg.MinX() < minx) minx = tpcg.MinX();
526  if (tpcg.MaxX() > maxx) maxx = tpcg.MaxX();
527  if (tpcg.MinY() < miny) miny = tpcg.MinY();
528  if (tpcg.MaxY() > maxy) maxy = tpcg.MaxY();
529  if (tpcg.MinZ() < minz) minz = tpcg.MinZ();
530  if (tpcg.MaxZ() > maxz) maxz = tpcg.MaxZ();
531  }
532  }
533 
534  double dista = fabs(minx - pos[0]);
535  double distb = fabs(pos[0] - maxx);
536  if ((pos[0] > minx) && (pos[0] < maxx) &&
537  (dista > fFidVolCut) && (distb > fFidVolCut)) inside = true;
538 
539  dista = fabs(miny - pos[1]);
540  distb = fabs(pos[1]-maxy);
541  if (inside && (pos[1] > miny) && (pos[1] < maxy) &&
542  (dista > fFidVolCut) && (distb > fFidVolCut)) inside = true;
543  else inside = false;
544 
545  dista = fabs(minz - pos[2]);
546  distb = fabs(pos[2] - maxz);
547  if (inside && (pos[2] > minz) && (pos[2] < maxz) &&
548  (dista > fFidVolCut) && (distb > fFidVolCut)) inside = true;
549  else inside = false;
550 
551  }
552  return inside;
553 }
CryostatGeo const & GetElement(geo::CryostatID const &cryoid) const
double MinX() const
Returns the world x coordinate of the start of the box.
Definition: BoxBoundedGeo.h:88
Geometry information for a single TPC.
Definition: TPCGeo.h:38
double MaxX() const
Returns the world x coordinate of the end of the box.
Definition: BoxBoundedGeo.h:91
Geometry information for a single cryostat.
Definition: CryostatGeo.h:43
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
geo::TPCID FindTPCAtPosition(double const worldLoc[3]) const
Returns the ID of the TPC at specified location.
double MinZ() const
Returns the world z coordinate of the start of the box.
unsigned int NTPC() const
Number of TPCs in this cryostat.
Definition: CryostatGeo.h:181
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
Description of geometry of one entire detector.
double MaxY() const
Returns the world y coordinate of the end of the box.
bool HasTPC(geo::TPCID const &tpcid) const
Returns whether we have the specified TPC.
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc&#39;th TPC in the cryostat.
Definition: CryostatGeo.cxx:93
double MaxZ() const
Returns the world z coordinate of the end of the box.
double MinY() const
Returns the world y coordinate of the start of the box.
bool MichelReco::MichelReco::isMuonDecaying ( simb::MCParticle  particle,
std::vector< simb::MCParticle particles 
)

Definition at line 484 of file MichelEventSelection_module.cc.

484  {
485 
486  bool hasElectron = false, hasNuMu = false, hasNuE = false;
487 
488  unsigned int nSec = particle.NumberDaughters();
489  for (size_t d = 0; d < nSec; ++d)
490  {
491  for (auto const & daughter : particles)
492  {
493  if (daughter.Mother() == particle.TrackId())
494  {
495  int d_pdg = abs(daughter.PdgCode());
496  if (d_pdg == 11) hasElectron = true;
497  else if (d_pdg == 14) hasNuMu = true;
498  else if (d_pdg == 12) hasNuE = true;
499  }
500  }
501  }
502  return (hasElectron && hasNuMu && hasNuE);
503 
504 }
int NumberDaughters() const
Definition: MCParticle.h:217
int TrackId() const
Definition: MCParticle.h:210
T abs(T value)
MichelReco& MichelReco::MichelReco::operator= ( MichelReco const &  )
delete
MichelReco& MichelReco::MichelReco::operator= ( MichelReco &&  )
delete
MichelReco& MichelReco::MichelReco::operator= ( MichelReco const &  )
delete
MichelReco& MichelReco::MichelReco::operator= ( MichelReco &&  )
delete
void MichelReco::MichelReco::reconfigure ( fhicl::ParameterSet const &  p)
void MichelReco::MichelReco::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 616 of file MichelEventSelection_module.cc.

616  {
617 
618  c = new TCanvas( "canv", "canv" );
619 
620  fTrackModuleLabel = p.get<std::string>("TrackModuleLabel");
621  fNNetModuleLabel = p.get<std::string>("NNetModuleLabel");
622  fParticleModuleLabel = p.get<std::string>("ParticleModuleLabel");
623 
624  fBestview = p.get<int>("Bestview");
625 
626  fRadiusThreshold = p.get<double>("MichelCloseHitRadius");
627  fNumberThreshold = p.get<int>("CloseHitsThreshold");
628  fCNNThreshold = p.get<double>("CNNThreshSelect");
629  fFidVolCut = p.get<double>("FidVolCut");
630 
631  for ( int plane = 0; plane < 3; plane++ ) {
632  fNumberCloseHitsStart[ plane ] = 0; fNumberCloseHitsEnd[ plane ] = 0;
633  }
634 
635  fYesSelected = 0;
636  fNoSelected = 0;
637  fNMichel = 0;
638 
639  return;
640 }
std::string string
Definition: nybbler.cc:12
p
Definition: test.py:223
int MichelReco::MichelReco::trackMatching ( int  trackIndex,
art::FindManyP< recob::Hit hitsFromTracks 
)

Member Data Documentation

TCanvas* MichelReco::MichelReco::c
private

Definition at line 113 of file MichelEventSelection_module.cc.

int MichelReco::MichelReco::fBestview
private

Definition at line 129 of file MichelEventSelection_module.cc.

calo::CalorimetryAlg MichelReco::MichelReco::fCalorimetryAlg

Definition at line 108 of file MichelEventSelection_module.cc.

double MichelReco::MichelReco::fCNNThreshold
private

Definition at line 118 of file MichelEventSelection_module.cc.

size_t MichelReco::MichelReco::fEvNumber
private

Definition at line 111 of file MichelEventSelection_module.cc.

double MichelReco::MichelReco::fFidVolCut
private

Definition at line 133 of file MichelEventSelection_module.cc.

int MichelReco::MichelReco::fNMichel
private

Definition at line 126 of file MichelEventSelection_module.cc.

int MichelReco::MichelReco::fNMichelHits
private

Definition at line 68 of file MichelHitCounter_module.cc.

art::InputTag MichelReco::MichelReco::fNNetModuleLabel
private

Definition at line 131 of file MichelEventSelection_module.cc.

double MichelReco::MichelReco::fNoSelected
private

Definition at line 125 of file MichelEventSelection_module.cc.

int MichelReco::MichelReco::fNumberCloseHitsEnd[3]
private

Definition at line 121 of file MichelEventSelection_module.cc.

int MichelReco::MichelReco::fNumberCloseHitsStart[3]
private

Definition at line 120 of file MichelEventSelection_module.cc.

int MichelReco::MichelReco::fNumberThreshold
private

Definition at line 117 of file MichelEventSelection_module.cc.

art::InputTag MichelReco::MichelReco::fParticleModuleLabel
private

Definition at line 132 of file MichelEventSelection_module.cc.

double MichelReco::MichelReco::fRadiusThreshold
private

Definition at line 116 of file MichelEventSelection_module.cc.

art::InputTag MichelReco::MichelReco::fTrackModuleLabel
private

Definition at line 130 of file MichelEventSelection_module.cc.

double MichelReco::MichelReco::fYesSelected
private

Definition at line 124 of file MichelEventSelection_module.cc.


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