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

Public Member Functions

 FlashMatchAna (const fhicl::ParameterSet &)
 
virtual ~FlashMatchAna ()
 
void beginJob ()
 
void analyze (const art::Event &)
 
- 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)
 

Private Attributes

std::string fOpFlashModuleLabel
 
std::string fOpHitModuleLabel
 
std::string fSignalLabel
 
std::string fGeantLabel
 
TTree * fFlashMatchTree
 
TTree * fLargestFlashTree
 
TTree * fSelectedFlashTree
 
TEfficiency * fRecoEfficiencyVsE
 
TEfficiency * fRecoEfficiencyVsX
 
TEfficiency * fRecoEfficiencyVsXandE
 
TEfficiency * fLargestEfficiencyVsE
 
TEfficiency * fLargestEfficiencyVsX
 
TEfficiency * fLargestEfficiencyVsXandE
 
TEfficiency * fSelectedEfficiencyVsE
 
TEfficiency * fSelectedEfficiencyVsX
 
TEfficiency * fSelectedEfficiencyVsXandE
 
int fNBinsE
 
float fLowE
 
float fHighE
 
int fNBinsX
 
float fLowX
 
float fHighX
 
float fDistanceCut
 
Int_t fEventID
 
Float_t fTrueX
 
Float_t fTrueY
 
Float_t fTrueZ
 
Float_t fTrueT
 
Float_t fDetectedT
 
Float_t fTrueE
 
Int_t fTruePDG
 
Float_t fRecoX
 
std::vector< Float_t > fTruePxallpart
 
std::vector< Float_t > fTruePyallpart
 
std::vector< Float_t > fTruePzallpart
 
std::vector< Float_t > fTrueEallpart
 
std::vector< Int_t > fTrueAllPDG
 
Int_t fNFlashes
 
std::vector< Int_t > fFlashIDVector
 
std::vector< Float_t > fYCenterVector
 
std::vector< Float_t > fZCenterVector
 
std::vector< Float_t > fYWidthVector
 
std::vector< Float_t > fZWidthVector
 
std::vector< Float_t > fTimeVector
 
std::vector< Float_t > fRecoXVector
 
std::vector< Float_t > fTimeWidthVector
 
std::vector< Float_t > fTimeDiffVector
 
std::vector< Int_t > fFlashFrameVector
 
std::vector< Bool_t > fInBeamFrameVector
 
std::vector< Int_t > fOnBeamTimeVector
 
std::vector< Float_t > fTotalPEVector
 
Float_t fSumPE
 
std::vector< Float_t > fPurityVector
 
std::vector< Float_t > fDistanceVector
 
Int_t fNOpDets
 
std::vector< Int_t > fNHitOpDetVector
 
Int_t fFlashID
 
Float_t fYCenter
 
Float_t fZCenter
 
Float_t fYWidth
 
Float_t fZWidth
 
Float_t fTime
 
Float_t fTimeWidth
 
Float_t fTimeDiff
 
Float_t fTotalPE
 
Float_t fPurity
 
Float_t fDistance
 
Int_t fNHitOpDets
 
std::vector< Float_t > fPEsPerOpDetVector
 
std::string fOpDetWaveformLabel
 
float fBaseline
 
float fPE
 
TTree * fCountTree
 
Int_t fnwaveforms1pe
 
Int_t fnwaveforms2pe
 
Int_t fnwaveforms3pe
 

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 51 of file FlashMatchAna_module.cc.

Constructor & Destructor Documentation

opdet::FlashMatchAna::FlashMatchAna ( const fhicl::ParameterSet )

Definition at line 174 of file FlashMatchAna_module.cc.

175  : EDAnalyzer(pset)
176  {
177 
178  // Indicate that the Input Module comes from .fcl
179  fOpFlashModuleLabel = pset.get<std::string>("OpFlashModuleLabel");
180  fOpHitModuleLabel = pset.get<std::string>("OpHitModuleLabel");
181  fSignalLabel = pset.get<std::string>("SignalLabel");
182  fGeantLabel = pset.get<std::string>("GeantLabel");
183  fNBinsE = pset.get<int>("NBinsE");
184  fLowE = pset.get<float>("LowE");
185  fHighE = pset.get<float>("HighE");
186  fNBinsX = pset.get<int>("NBinsX");
187  fLowX = pset.get<float>("LowX");
188  fHighX = pset.get<float>("HighX");
189  fDistanceCut = pset.get<float>("DistanceCut");
190 
191  fOpDetWaveformLabel = pset.get<std::string>("OpDetWaveformLabel","");
192  fBaseline = pset.get<float>("Baseline", 1500.);
193  fPE = pset.get<float>("PE", 18.);
194 
196 
197  fFlashMatchTree = tfs->make<TTree>("FlashMatchTree","FlashMatchTree");
198  fFlashMatchTree->Branch("EventID", &fEventID, "EventID/I");
199  fFlashMatchTree->Branch("TrueX", &fTrueX, "TrueX/F");
200  fFlashMatchTree->Branch("TrueY", &fTrueY, "TrueY/F");
201  fFlashMatchTree->Branch("TrueZ", &fTrueZ, "TrueZ/F");
202  fFlashMatchTree->Branch("TrueT", &fTrueT, "TrueT/F");
203  fFlashMatchTree->Branch("DetectedT", &fDetectedT, "DetectedT/F");
204  fFlashMatchTree->Branch("TrueE", &fTrueE, "TrueE/F");
205  fFlashMatchTree->Branch("TruePDG", &fTruePDG, "TruePDG/I");
206  fFlashMatchTree->Branch("NFlashes", &fNFlashes, "NFlashes/I");
207  fFlashMatchTree->Branch("FlashIDVector", &fFlashIDVector);
208  fFlashMatchTree->Branch("YCenterVector", &fYCenterVector);
209  fFlashMatchTree->Branch("ZCenterVector", &fZCenterVector);
210  fFlashMatchTree->Branch("YWidthVector", &fYWidthVector);
211  fFlashMatchTree->Branch("ZWidthVector", &fZWidthVector);
212  fFlashMatchTree->Branch("TimeVector", &fTimeVector);
213  fFlashMatchTree->Branch("TimeWidthVector", &fTimeWidthVector);
214  fFlashMatchTree->Branch("TimeDiffVector", &fTimeDiffVector);
215  fFlashMatchTree->Branch("TotalPEVector", &fTotalPEVector);
216  fFlashMatchTree->Branch("SumPE", &fSumPE, "SumPE/F");
217  fFlashMatchTree->Branch("NOpDets", &fNOpDets, "NOpDets/I");
218  fFlashMatchTree->Branch("NHitOpDetVector", &fNHitOpDetVector);
219  fFlashMatchTree->Branch("Purity", &fPurityVector);
220  fFlashMatchTree->Branch("Distance", &fDistanceVector);
221  fFlashMatchTree->Branch("RecoXVector", &fRecoXVector);
222 
223 
224  fLargestFlashTree = tfs->make<TTree>("LargestFlashTree","LargestFlashTree");
225  fLargestFlashTree->Branch("EventID", &fEventID, "EventID/I");
226  fLargestFlashTree->Branch("TrueX", &fTrueX, "TrueX/F");
227  fLargestFlashTree->Branch("TrueY", &fTrueY, "TrueY/F");
228  fLargestFlashTree->Branch("TrueZ", &fTrueZ, "TrueZ/F");
229  fLargestFlashTree->Branch("TrueT", &fTrueT, "TrueT/F");
230  fLargestFlashTree->Branch("DetectedT", &fDetectedT, "DetectedT/F");
231  fLargestFlashTree->Branch("TrueE", &fTrueE, "TrueE/F");
232  fLargestFlashTree->Branch("TruePDG", &fTruePDG, "TruePDG/I");
233  fLargestFlashTree->Branch("NFlashes", &fNFlashes, "NFlashes/I");
234  fLargestFlashTree->Branch("FlashID", &fFlashID, "FlashID/I");
235  fLargestFlashTree->Branch("YCenter", &fYCenter, "YCenter/F");
236  fLargestFlashTree->Branch("ZCenter", &fZCenter, "ZCenter/F");
237  fLargestFlashTree->Branch("YWidth", &fYWidth, "YWidth/F");
238  fLargestFlashTree->Branch("ZWidth", &fZWidth, "ZWidth/F");
239  fLargestFlashTree->Branch("Time", &fTime, "Time/F");
240  fLargestFlashTree->Branch("TimeWidth", &fTimeWidth, "TimeWidth/F");
241  fLargestFlashTree->Branch("TimeDiff", &fTimeDiff, "TimeDiff/F");
242  fLargestFlashTree->Branch("TotalPE", &fTotalPE, "TotalPE/F");
243  fLargestFlashTree->Branch("NOpDets", &fNOpDets, "NOpDets/I");
244  fLargestFlashTree->Branch("NHitOpDets", &fNHitOpDets,"NHitOpDets/I");
245  fLargestFlashTree->Branch("PEsPerOpDetVector", &fPEsPerOpDetVector);
246  fLargestFlashTree->Branch("Purity", &fPurity, "Purity/F");
247  fLargestFlashTree->Branch("Distance", &fDistance, "Distance/F");
248  fLargestFlashTree->Branch("RecoX", &fRecoX, "RecoX/F");
249 
250 
251  fSelectedFlashTree = tfs->make<TTree>("SelectedFlashTree","SelectedFlashTree");
252  fSelectedFlashTree->Branch("EventID", &fEventID, "EventID/I");
253  fSelectedFlashTree->Branch("TrueX", &fTrueX, "TrueX/F");
254  fSelectedFlashTree->Branch("TrueY", &fTrueY, "TrueY/F");
255  fSelectedFlashTree->Branch("TrueZ", &fTrueZ, "TrueZ/F");
256  fSelectedFlashTree->Branch("TrueT", &fTrueT, "TrueT/F");
257  fSelectedFlashTree->Branch("DetectedT", &fDetectedT, "DetectedT/F");
258  fSelectedFlashTree->Branch("TrueE", &fTrueE, "TrueE/F");
259  fSelectedFlashTree->Branch("TruePDG", &fTruePDG, "TruePDG/I");
260  fSelectedFlashTree->Branch("NFlashes", &fNFlashes, "NFlashes/I");
261  fSelectedFlashTree->Branch("FlashID", &fFlashID, "FlashID/I");
262  fSelectedFlashTree->Branch("YCenter", &fYCenter, "YCenter/F");
263  fSelectedFlashTree->Branch("ZCenter", &fZCenter, "ZCenter/F");
264  fSelectedFlashTree->Branch("YWidth", &fYWidth, "YWidth/F");
265  fSelectedFlashTree->Branch("ZWidth", &fZWidth, "ZWidth/F");
266  fSelectedFlashTree->Branch("Time", &fTime, "Time/F");
267  fSelectedFlashTree->Branch("TimeWidth", &fTimeWidth, "TimeWidth/F");
268  fSelectedFlashTree->Branch("TimeDiff", &fTimeDiff, "TimeDiff/F");
269  fSelectedFlashTree->Branch("TotalPE", &fTotalPE, "TotalPE/F");
270  fSelectedFlashTree->Branch("NOpDets", &fNOpDets, "NOpDets/I");
271  fSelectedFlashTree->Branch("NHitOpDets", &fNHitOpDets,"NHitOpDets/I");
272  fSelectedFlashTree->Branch("PEsPerOpDetVector", &fPEsPerOpDetVector);
273  fSelectedFlashTree->Branch("Purity", &fPurity, "Purity/F");
274  fSelectedFlashTree->Branch("Distance", &fDistance, "Distance/F");
275  fSelectedFlashTree->Branch("RecoX", &fRecoX, "RecoX/F");
276  fSelectedFlashTree->Branch("TruePxallpart", &fTruePxallpart);
277  fSelectedFlashTree->Branch("TruePyallpart", &fTruePyallpart);
278  fSelectedFlashTree->Branch("TruePzallpart", &fTruePzallpart);
279  fSelectedFlashTree->Branch("TrueEallpart", &fTrueEallpart);
280  fSelectedFlashTree->Branch("TrueAllPDG", &fTrueAllPDG);
281 
282  if (!fOpDetWaveformLabel.empty()) {
283  fCountTree = tfs->make<TTree>("CountWaveforms","CountWaveforms");
284  fCountTree->Branch("EventID", &fEventID, "EventID/I");
285  fCountTree->Branch("nwaveforms1pe", &fnwaveforms1pe, "nwaveforms1pe/I");
286  fCountTree->Branch("nwaveforms2pe", &fnwaveforms2pe, "nwaveforms2pe/I");
287  fCountTree->Branch("nwaveforms3pe", &fnwaveforms3pe, "nwaveforms3pe/I");
288  }
289 
290 
291 
292  fRecoEfficiencyVsE = tfs->make<TEfficiency>("recoEfficiencyVsE", ";Energy (GeV);Efficiency", fNBinsE, fLowE, fHighE);
293  fRecoEfficiencyVsX = tfs->make<TEfficiency>("recoEfficiencyVsX", ";Position (cm);Efficiency", fNBinsX, fLowX, fHighX);
294  fRecoEfficiencyVsXandE = tfs->make<TEfficiency>("recoEfficiencyVsXandE", ";Position (cm);Energy (GeV);Efficiency", fNBinsX, fLowX, fHighX, fNBinsE, fLowE, fHighE);
295  fLargestEfficiencyVsE = tfs->make<TEfficiency>("largestEfficiencyVsE", ";Energy (GeV);Efficiency", fNBinsE, fLowE, fHighE);
296  fLargestEfficiencyVsX = tfs->make<TEfficiency>("largestEfficiencyVsX", ";Position (cm);Efficiency", fNBinsX, fLowX, fHighX);
297  fLargestEfficiencyVsXandE = tfs->make<TEfficiency>("largestEfficiencyVsXandE", ";Position (cm);Energy (GeV);Efficiency", fNBinsX, fLowX, fHighX, fNBinsE, fLowE, fHighE);
298  fSelectedEfficiencyVsE = tfs->make<TEfficiency>("selectedEfficiencyVsE", ";Energy (GeV);Efficiency", fNBinsE, fLowE, fHighE);
299  fSelectedEfficiencyVsX = tfs->make<TEfficiency>("selectedEfficiencyVsX", ";Position (cm);Efficiency", fNBinsX, fLowX, fHighX);
300  fSelectedEfficiencyVsXandE = tfs->make<TEfficiency>("selectedEfficiencyVsXandE", ";Position (cm);Energy (GeV);Efficiency", fNBinsX, fLowX, fHighX, fNBinsE, fLowE, fHighE);
301  }
std::vector< Int_t > fTrueAllPDG
std::vector< Float_t > fTrueEallpart
std::vector< Float_t > fPurityVector
std::string string
Definition: nybbler.cc:12
std::vector< Float_t > fDistanceVector
TEfficiency * fLargestEfficiencyVsXandE
std::vector< Int_t > fFlashIDVector
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
std::vector< Float_t > fTruePzallpart
TEfficiency * fLargestEfficiencyVsE
std::vector< Float_t > fTimeDiffVector
TEfficiency * fSelectedEfficiencyVsX
TEfficiency * fLargestEfficiencyVsX
std::vector< Float_t > fZCenterVector
TEfficiency * fRecoEfficiencyVsE
TEfficiency * fSelectedEfficiencyVsXandE
std::vector< Float_t > fZWidthVector
TEfficiency * fRecoEfficiencyVsXandE
std::vector< Float_t > fRecoXVector
std::vector< Float_t > fYWidthVector
TEfficiency * fSelectedEfficiencyVsE
std::vector< Float_t > fTimeVector
std::vector< Float_t > fTruePxallpart
std::vector< Float_t > fTruePyallpart
std::vector< Float_t > fYCenterVector
std::vector< Float_t > fPEsPerOpDetVector
std::vector< Float_t > fTotalPEVector
TEfficiency * fRecoEfficiencyVsX
std::vector< Float_t > fTimeWidthVector
std::vector< Int_t > fNHitOpDetVector
opdet::FlashMatchAna::~FlashMatchAna ( )
virtual

Definition at line 305 of file FlashMatchAna_module.cc.

306  {}

Member Function Documentation

void opdet::FlashMatchAna::analyze ( const art::Event evt)

Definition at line 313 of file FlashMatchAna_module.cc.

314  {
315  // Get the required services
320  //pbt->Rebuild(evt);
321 
322 
323  // Record the event ID
324  fEventID = evt.id().event();
325 
326 
327 
328 
329  ///////////////////////////////////////////////////
330  // Count waveforms if a waveform label was given //
331  ///////////////////////////////////////////////////
332 
333  if (!fOpDetWaveformLabel.empty()) {
334  fnwaveforms1pe = 0;
335  fnwaveforms2pe = 0;
336  fnwaveforms3pe = 0;
337  auto wfHandle = evt.getHandle< std::vector< raw::OpDetWaveform > >(fOpDetWaveformLabel);
338  if (wfHandle) {
339  fnwaveforms1pe = wfHandle->size();
340 
341  for (auto wf: *wfHandle) {
342  auto it = max_element(std::begin(wf), std::end(wf));
343  double peak = *it - fBaseline;
344  if ( peak > (1.5*fPE)) {
345  ++fnwaveforms2pe;
346 
347  if ( peak > (2.5*fPE) )
348  ++fnwaveforms3pe;
349  }
350  }
351  fCountTree->Fill();
352  }
353  }
354 
355 
356 
357 
358  //////////////////////////////////////
359  // Access all the Flash Information //
360  //////////////////////////////////////
361 
362  // Get flashes from event
363  std::vector<art::Ptr<recob::OpFlash> > flashlist;
364  auto FlashHandle = evt.getHandle< std::vector< recob::OpFlash > >(fOpFlashModuleLabel);
365  if (FlashHandle) {
366  art::fill_ptr_vector(flashlist, FlashHandle);
367  std::sort(flashlist.begin(), flashlist.end(), recob::OpFlashPtrSortByPE);
368  }
369  else {
370  mf::LogWarning("FlashMatchAna") << "Cannot load any flashes. Failing";
371  return;
372  }
373 
374  std::vector<art::Ptr<recob::OpHit> > hitlist;
375  auto HitHandle = evt.getHandle< std::vector< recob::OpHit > >(fOpHitModuleLabel);
376  if (HitHandle) {
377  art::fill_ptr_vector(hitlist, HitHandle);
378  }
379 
380  // Get total PE in all hits
381  fSumPE = 0;
382  for (auto hit: hitlist)
383  fSumPE += hit->PE();
384 
385  // Get assosciations between flashes and hits
386  //art::FindManyP< recob::OpHit > Assns(flashlist, evt, fOpFlashModuleLabel);
387 
388 
389 
390  //////////////////////////////////////
391  // Access all the truth information //
392  //////////////////////////////////////
393 
394  std::set<int> signal_trackids;
395  geo::PlaneID planeid;
396 
397  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
398  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt, clockData);
399 
400  try {
401  auto MClistHandle = evt.getValidHandle<std::vector<simb::MCTruth> >(fSignalLabel);
402 
403  art::Ptr<simb::MCTruth> mctruth(MClistHandle, 0);
404  if (mctruth->NParticles() == 0) {
405  mf::LogError("FlashMatchAna") << "No MCTruth Particles";
406  }
407 
408  // Get all the track ids associated with the signal event.
409  art::FindManyP<simb::MCParticle> SignalGeantAssns(MClistHandle,evt,fGeantLabel);
410  for ( size_t i = 0; i < SignalGeantAssns.size(); i++) {
411  auto parts = SignalGeantAssns.at(i);
412  for (auto part = parts.begin(); part != parts.end(); part++) {
413  signal_trackids.emplace((*part)->TrackId());
414  }
415  }
416 
417  // Get just the neutrino, entry 0 from the list, and record its properties
418  const simb::MCParticle& part(mctruth->GetParticle(0));
419  fTrueX = part.Vx();
420  fTrueY = part.Vy();
421  fTrueZ = part.Vz();
422  fTrueT = part.T()*1000; // ns -> us
423  fTrueE = part.E();
424  fTruePDG = part.PdgCode();
425 
426  // Get all the paricle including neutrino, and record its properties
427  unsigned int const nParticles = mctruth->NParticles();
428  for (unsigned int i = 0; i < nParticles; ++i) {
429  simb::MCParticle const& particle = mctruth->GetParticle(i);
430  fTruePxallpart .emplace_back(particle.Px());
431  fTruePyallpart .emplace_back(particle.Py());
432  fTruePzallpart .emplace_back(particle.Pz());
433  fTrueEallpart .emplace_back(particle.E());
434  fTrueAllPDG .emplace_back(particle.PdgCode());
435  }
436 
437  // Get the PlaneID which describes the location of the true vertex
438  int plane = 0;
439  double loc[] = {part.Vx(), part.Vy(), part.Vz()};
440  geo::TPCID tpc = geom->FindTPCAtPosition(loc);
441  if (! geom->HasTPC(tpc) ) {
442  mf::LogInfo("FlashMatchAna") << "No valid TPC for " << tpc;
443  return;
444  }
445  geo::PlaneID tempid(tpc, plane);
446  planeid = tempid;
447 
448  // Convert true X to would-be charge arrival time, and convert from ticks to us, add to MC time
449  double deltaTicks = detProp.ConvertXToTicks(part.Vx(), planeid);
450  double deltaT = clockData.TPCTick2Time(deltaTicks);
451  fDetectedT = fTrueT + deltaT;
452  }
453  catch (art::Exception const& err)
454  {
455  // If the error isn't that a product wasn't found, throw it back up.
456  if ( err.categoryCode() != art::errors::ProductNotFound ) throw;
457 
458  // Otherwise, this event just doesn't have signal. Fill default values
459  fTrueX = 0;
460  fTrueY = 0;
461  fTrueZ = 0;
462  fTrueT = 0;
463  fTrueE = 0;
464  fTruePDG = 0;
465  fDetectedT = 0;
466  }
467 
468  // Get the maximum possible time difference by getting number of ticks corresponding to
469  // one full drift distance, and converting to time.
470  double maxT = clockData.TPCTick2Time(detProp.NumberTimeSamples());
471 
472 
473 
474  /////////////////////////
475  // Analyze the flashes //
476  /////////////////////////
477 
478 
479  // Set up some flags to fill as we loop
480  // through flashes. These will control
481  // filling of efficiency plots after the loop.
482  bool AnyReconstructed = false;
483  bool LargestFound = false;
484  bool LargestRight = false;
485  bool SelectedFound = false;
486  bool SelectedRight = false;
487 
488 
489  // For every OpFlash in the vector
490  fNOpDets = geom->NOpDets();
491  fNFlashes = flashlist.size();
492  for(unsigned int i = 0; i < flashlist.size(); ++i)
493  {
494  // Get OpFlash and associated hits
495  recob::OpFlash TheFlash = *flashlist[i];
496  art::Ptr<recob::OpFlash> FlashP = flashlist[i];
497  std::vector< art::Ptr<recob::OpHit> > hitFromFlash = pbt->OpFlashToOpHits_Ps(FlashP);
498  std::vector< art::Ptr<recob::OpHit> > matchedHits = pbt->OpFlashToOpHits_Ps(FlashP);
499  //std::vector< art::Ptr<recob::OpHit> > matchedHits = Assns.at(i);
500 
501  // Calculate the flash purity
502  double purity = pbt->OpHitCollectionPurity(signal_trackids, matchedHits);
503 
504  // Calcuate relative detection time
505  double timeDiff = fDetectedT - TheFlash.Time();
506 
507  if (!planeid) {
508  // planeid isn't valid
509  fRecoX = 0;
510  }
511  else {
512  double ticks = clockData.Time2Tick(timeDiff);
513  fRecoX = detProp.ConvertTicksToX(ticks, planeid);
514  }
515 
516  // Check if this is a possible flash (w/in 1 drift window)
517  // Otherwise, skip it
518  if (timeDiff < -10 || timeDiff > maxT)
519  continue;
520 
521  // Put flash info into variables
522  fFlashID = i;
523  fYCenter = TheFlash.YCenter();
524  fZCenter = TheFlash.ZCenter();
525  fYWidth = TheFlash.YWidth();
526  fZWidth = TheFlash.ZWidth();
527  fTime = TheFlash.Time();
528  fTimeWidth = TheFlash.TimeWidth();
529  fTimeDiff = timeDiff;
530  fTotalPE = TheFlash.TotalPE();
531  fPurity = purity;
532 
533  // Calculate distance from MC truth vertex in the Y-Z plane
534  fDistance = sqrt( pow(fTrueY-fYCenter,2) + pow(fTrueZ-fZCenter,2) );
535 
536 
537 
538  // Loop through all the opdets with hits in this flash
539  fPEsPerOpDetVector.clear();
540  for(unsigned int iOD = 0; iOD < geom->NOpDets(); ++iOD){
541  fPEsPerOpDetVector.emplace_back(0);
542  }
543  for(unsigned int iC=0; iC < geom->NOpChannels(); ++iC)
544  {
545  unsigned int iOD = geom->OpDetFromOpChannel(iC);
546  fPEsPerOpDetVector[iOD] += TheFlash.PE(iC);
547  }
548 
549  fNHitOpDets = 0;
550  for(unsigned int iOD = 0; iOD < geom->NOpDets(); ++iOD){
551  if (fPEsPerOpDetVector[iOD] > 0) ++fNHitOpDets;
552  }
553  fNHitOpDetVector.emplace_back(fNHitOpDets);
554 
555 
556  // Add flash info to the tree of all possible flashes
557  fFlashIDVector .emplace_back(fFlashID);
558  fYCenterVector .emplace_back(fYCenter);
559  fZCenterVector .emplace_back(fZCenter);
560  fYWidthVector .emplace_back(fYWidth);
561  fZWidthVector .emplace_back(fZWidth);
562  fTimeVector .emplace_back(fTime);
563  fTimeWidthVector .emplace_back(fTimeWidth);
564  fTimeDiffVector .emplace_back(fTimeDiff);
565  fTotalPEVector .emplace_back(fTotalPE);
566  fPurityVector .emplace_back(fPurity);
567  fDistanceVector .emplace_back(fDistance);
568  fRecoXVector .emplace_back(fRecoX);
569 
570 
571  // Did we reconstruct any flashes with signal in them?
572  if (fPurity > 0) AnyReconstructed = true;
573 
574 
575  // First == Largest, so if this is the first flash it is also the largest.
576  // So, fill the LargestFlash tree and the LargestFlash efficiency plots
577  if (!LargestFound) {
578 
579  // Write out the info into the tree for the largest flash
580  fLargestFlashTree->Fill();
581 
582  // Record that we found the largest flash
583  // and if we got it right
584  LargestFound = true;
585  if (fPurity > 0) LargestRight = true;
586  }
587 
588 
589  // The first time we get into here we have the largest flash that is
590  // within the distance cut. So, fill the SelectedFlash tree and the
591  // selected flash efficiency plots
592  if (!SelectedFound && fDistance < fDistanceCut) {
593 
594  // Write out the info for the selected flash
595  fSelectedFlashTree->Fill();
596 
597  // Record that we found the selected flash
598  // and if we got it right
599  SelectedFound = true;
600  if (fPurity > 0) SelectedRight = true;
601  }
602 
603  }
604 
605  // Fill these TEfficiencies once for every event
606  // but use the booleans to decide if it was
607  // "selected" or not.
608  fRecoEfficiencyVsE->Fill(AnyReconstructed, fTrueE);
609  fRecoEfficiencyVsX->Fill(AnyReconstructed, fTrueX);
610  fRecoEfficiencyVsXandE->Fill(AnyReconstructed, fTrueX, fTrueE);
611 
612  fLargestEfficiencyVsE->Fill(LargestRight, fTrueE);
613  fLargestEfficiencyVsX->Fill(LargestRight, fTrueX);
614  fLargestEfficiencyVsXandE->Fill(LargestRight, fTrueX, fTrueE);
615 
616  fSelectedEfficiencyVsE->Fill(SelectedRight, fTrueE);
617  fSelectedEfficiencyVsX->Fill(SelectedRight, fTrueX);
618  fSelectedEfficiencyVsXandE->Fill(SelectedRight, fTrueX, fTrueE);
619 
620 
621 
622 
623  ///////////////////////////////////////////////
624  // Write out the FlashMatchTree and clean up //
625  ///////////////////////////////////////////////
626 
627  fFlashMatchTree->Fill();
628  fFlashIDVector .clear();
629  fYCenterVector .clear();
630  fZCenterVector .clear();
631  fYWidthVector .clear();
632  fZWidthVector .clear();
633  fTimeVector .clear();
634  fTimeWidthVector .clear();
635  fTimeDiffVector .clear();
636  fTotalPEVector .clear();
637  fNHitOpDetVector .clear();
638  fPurityVector .clear();
639  fDistanceVector .clear();
640  fRecoXVector .clear();
641  fTruePxallpart .clear();
642  fTruePyallpart .clear();
643  fTruePzallpart .clear();
644  fTrueEallpart .clear();
645  fTrueAllPDG .clear();
646  }
double E(const int i=0) const
Definition: MCParticle.h:233
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
int PdgCode() const
Definition: MCParticle.h:212
std::vector< Int_t > fTrueAllPDG
std::vector< Float_t > fTrueEallpart
double Py(const int i=0) const
Definition: MCParticle.h:231
std::vector< Float_t > fPurityVector
const std::vector< art::Ptr< recob::OpHit > > OpFlashToOpHits_Ps(art::Ptr< recob::OpFlash > &flash_P)
double TimeWidth() const
Definition: OpFlash.h:107
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::vector< Float_t > fDistanceVector
TEfficiency * fLargestEfficiencyVsXandE
constexpr T pow(T x)
Definition: pow.h:72
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
double Px(const int i=0) const
Definition: MCParticle.h:230
std::vector< Int_t > fFlashIDVector
double PE(unsigned int i) const
Definition: OpFlash.h:110
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
std::vector< Float_t > fTruePzallpart
const double OpHitCollectionPurity(std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit > > const &opHits_Ps)
unsigned int NOpChannels() const
Number of electronics channels for all the optical detectors.
tick ticks
Alias for common language habits.
Definition: electronics.h:78
TEfficiency * fLargestEfficiencyVsE
unsigned int OpDetFromOpChannel(int opChannel) const
Convert unique channel to detector number.
std::vector< Float_t > fTimeDiffVector
TEfficiency * fSelectedEfficiencyVsX
geo::TPCID FindTPCAtPosition(double const worldLoc[3]) const
Returns the ID of the TPC at specified location.
double ZCenter() const
Definition: OpFlash.h:117
double Time() const
Definition: OpFlash.h:106
TEfficiency * fLargestEfficiencyVsX
std::vector< Float_t > fZCenterVector
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
struct recob::OpFlashPtrSortByPE_t OpFlashPtrSortByPE
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
TEfficiency * fRecoEfficiencyVsE
TEfficiency * fSelectedEfficiencyVsXandE
void err(const char *fmt,...)
Definition: message.cpp:226
unsigned int NOpDets() const
Number of OpDets in the whole detector.
Detector simulation of raw signals on wires.
std::vector< Float_t > fZWidthVector
bool HasTPC(geo::TPCID const &tpcid) const
Returns whether we have the specified TPC.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
double YWidth() const
Definition: OpFlash.h:116
TEfficiency * fRecoEfficiencyVsXandE
std::vector< Float_t > fRecoXVector
std::vector< Float_t > fYWidthVector
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
double Pz(const int i=0) const
Definition: MCParticle.h:232
TEfficiency * fSelectedEfficiencyVsE
EventNumber_t event() const
Definition: EventID.h:116
std::vector< Float_t > fTimeVector
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
std::vector< Float_t > fTruePxallpart
double TotalPE() const
Definition: OpFlash.cxx:68
std::vector< Float_t > fTruePyallpart
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
std::vector< Float_t > fYCenterVector
double YCenter() const
Definition: OpFlash.h:115
EventID id() const
Definition: Event.cc:34
std::vector< Float_t > fPEsPerOpDetVector
std::vector< Float_t > fTotalPEVector
double ZWidth() const
Definition: OpFlash.h:118
TEfficiency * fRecoEfficiencyVsX
std::vector< Float_t > fTimeWidthVector
std::vector< Int_t > fNHitOpDetVector
void opdet::FlashMatchAna::beginJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 309 of file FlashMatchAna_module.cc.

310  {}

Member Data Documentation

float opdet::FlashMatchAna::fBaseline
private

Definition at line 157 of file FlashMatchAna_module.cc.

TTree* opdet::FlashMatchAna::fCountTree
private

Definition at line 159 of file FlashMatchAna_module.cc.

Float_t opdet::FlashMatchAna::fDetectedT
private

Definition at line 106 of file FlashMatchAna_module.cc.

Float_t opdet::FlashMatchAna::fDistance
private

Definition at line 150 of file FlashMatchAna_module.cc.

float opdet::FlashMatchAna::fDistanceCut
private

Definition at line 98 of file FlashMatchAna_module.cc.

std::vector< Float_t > opdet::FlashMatchAna::fDistanceVector
private

Definition at line 133 of file FlashMatchAna_module.cc.

Int_t opdet::FlashMatchAna::fEventID
private

Definition at line 100 of file FlashMatchAna_module.cc.

std::vector< Int_t > opdet::FlashMatchAna::fFlashFrameVector
private

Definition at line 127 of file FlashMatchAna_module.cc.

Int_t opdet::FlashMatchAna::fFlashID
private

Definition at line 137 of file FlashMatchAna_module.cc.

std::vector< Int_t > opdet::FlashMatchAna::fFlashIDVector
private

Definition at line 118 of file FlashMatchAna_module.cc.

TTree* opdet::FlashMatchAna::fFlashMatchTree
private

Definition at line 76 of file FlashMatchAna_module.cc.

std::string opdet::FlashMatchAna::fGeantLabel
private

Definition at line 74 of file FlashMatchAna_module.cc.

float opdet::FlashMatchAna::fHighE
private

Definition at line 94 of file FlashMatchAna_module.cc.

float opdet::FlashMatchAna::fHighX
private

Definition at line 97 of file FlashMatchAna_module.cc.

std::vector< Bool_t > opdet::FlashMatchAna::fInBeamFrameVector
private

Definition at line 128 of file FlashMatchAna_module.cc.

TEfficiency* opdet::FlashMatchAna::fLargestEfficiencyVsE
private

Definition at line 84 of file FlashMatchAna_module.cc.

TEfficiency* opdet::FlashMatchAna::fLargestEfficiencyVsX
private

Definition at line 85 of file FlashMatchAna_module.cc.

TEfficiency* opdet::FlashMatchAna::fLargestEfficiencyVsXandE
private

Definition at line 86 of file FlashMatchAna_module.cc.

TTree* opdet::FlashMatchAna::fLargestFlashTree
private

Definition at line 77 of file FlashMatchAna_module.cc.

float opdet::FlashMatchAna::fLowE
private

Definition at line 93 of file FlashMatchAna_module.cc.

float opdet::FlashMatchAna::fLowX
private

Definition at line 96 of file FlashMatchAna_module.cc.

int opdet::FlashMatchAna::fNBinsE
private

Definition at line 92 of file FlashMatchAna_module.cc.

int opdet::FlashMatchAna::fNBinsX
private

Definition at line 95 of file FlashMatchAna_module.cc.

Int_t opdet::FlashMatchAna::fNFlashes
private

Definition at line 117 of file FlashMatchAna_module.cc.

Int_t opdet::FlashMatchAna::fNHitOpDets
private

Definition at line 151 of file FlashMatchAna_module.cc.

std::vector<Int_t> opdet::FlashMatchAna::fNHitOpDetVector
private

Definition at line 135 of file FlashMatchAna_module.cc.

Int_t opdet::FlashMatchAna::fNOpDets
private

Definition at line 134 of file FlashMatchAna_module.cc.

Int_t opdet::FlashMatchAna::fnwaveforms1pe
private

Definition at line 160 of file FlashMatchAna_module.cc.

Int_t opdet::FlashMatchAna::fnwaveforms2pe
private

Definition at line 161 of file FlashMatchAna_module.cc.

Int_t opdet::FlashMatchAna::fnwaveforms3pe
private

Definition at line 162 of file FlashMatchAna_module.cc.

std::vector< Int_t > opdet::FlashMatchAna::fOnBeamTimeVector
private

Definition at line 129 of file FlashMatchAna_module.cc.

std::string opdet::FlashMatchAna::fOpDetWaveformLabel
private

Definition at line 156 of file FlashMatchAna_module.cc.

std::string opdet::FlashMatchAna::fOpFlashModuleLabel
private

Definition at line 71 of file FlashMatchAna_module.cc.

std::string opdet::FlashMatchAna::fOpHitModuleLabel
private

Definition at line 72 of file FlashMatchAna_module.cc.

float opdet::FlashMatchAna::fPE
private

Definition at line 158 of file FlashMatchAna_module.cc.

std::vector< Float_t > opdet::FlashMatchAna::fPEsPerOpDetVector
private

Definition at line 152 of file FlashMatchAna_module.cc.

Float_t opdet::FlashMatchAna::fPurity
private

Definition at line 149 of file FlashMatchAna_module.cc.

std::vector< Float_t > opdet::FlashMatchAna::fPurityVector
private

Definition at line 132 of file FlashMatchAna_module.cc.

TEfficiency* opdet::FlashMatchAna::fRecoEfficiencyVsE
private

Definition at line 81 of file FlashMatchAna_module.cc.

TEfficiency* opdet::FlashMatchAna::fRecoEfficiencyVsX
private

Definition at line 82 of file FlashMatchAna_module.cc.

TEfficiency* opdet::FlashMatchAna::fRecoEfficiencyVsXandE
private

Definition at line 83 of file FlashMatchAna_module.cc.

Float_t opdet::FlashMatchAna::fRecoX
private

Definition at line 109 of file FlashMatchAna_module.cc.

std::vector< Float_t > opdet::FlashMatchAna::fRecoXVector
private

Definition at line 124 of file FlashMatchAna_module.cc.

TEfficiency* opdet::FlashMatchAna::fSelectedEfficiencyVsE
private

Definition at line 87 of file FlashMatchAna_module.cc.

TEfficiency* opdet::FlashMatchAna::fSelectedEfficiencyVsX
private

Definition at line 88 of file FlashMatchAna_module.cc.

TEfficiency* opdet::FlashMatchAna::fSelectedEfficiencyVsXandE
private

Definition at line 89 of file FlashMatchAna_module.cc.

TTree* opdet::FlashMatchAna::fSelectedFlashTree
private

Definition at line 78 of file FlashMatchAna_module.cc.

std::string opdet::FlashMatchAna::fSignalLabel
private

Definition at line 73 of file FlashMatchAna_module.cc.

Float_t opdet::FlashMatchAna::fSumPE
private

Definition at line 131 of file FlashMatchAna_module.cc.

Float_t opdet::FlashMatchAna::fTime
private

Definition at line 142 of file FlashMatchAna_module.cc.

Float_t opdet::FlashMatchAna::fTimeDiff
private

Definition at line 144 of file FlashMatchAna_module.cc.

std::vector< Float_t > opdet::FlashMatchAna::fTimeDiffVector
private

Definition at line 126 of file FlashMatchAna_module.cc.

std::vector< Float_t > opdet::FlashMatchAna::fTimeVector
private

Definition at line 123 of file FlashMatchAna_module.cc.

Float_t opdet::FlashMatchAna::fTimeWidth
private

Definition at line 143 of file FlashMatchAna_module.cc.

std::vector< Float_t > opdet::FlashMatchAna::fTimeWidthVector
private

Definition at line 125 of file FlashMatchAna_module.cc.

Float_t opdet::FlashMatchAna::fTotalPE
private

Definition at line 148 of file FlashMatchAna_module.cc.

std::vector< Float_t > opdet::FlashMatchAna::fTotalPEVector
private

Definition at line 130 of file FlashMatchAna_module.cc.

std::vector< Int_t > opdet::FlashMatchAna::fTrueAllPDG
private

Definition at line 115 of file FlashMatchAna_module.cc.

Float_t opdet::FlashMatchAna::fTrueE
private

Definition at line 107 of file FlashMatchAna_module.cc.

std::vector< Float_t > opdet::FlashMatchAna::fTrueEallpart
private

Definition at line 114 of file FlashMatchAna_module.cc.

Int_t opdet::FlashMatchAna::fTruePDG
private

Definition at line 108 of file FlashMatchAna_module.cc.

std::vector< Float_t > opdet::FlashMatchAna::fTruePxallpart
private

Definition at line 111 of file FlashMatchAna_module.cc.

std::vector< Float_t > opdet::FlashMatchAna::fTruePyallpart
private

Definition at line 112 of file FlashMatchAna_module.cc.

std::vector< Float_t > opdet::FlashMatchAna::fTruePzallpart
private

Definition at line 113 of file FlashMatchAna_module.cc.

Float_t opdet::FlashMatchAna::fTrueT
private

Definition at line 105 of file FlashMatchAna_module.cc.

Float_t opdet::FlashMatchAna::fTrueX
private

Definition at line 102 of file FlashMatchAna_module.cc.

Float_t opdet::FlashMatchAna::fTrueY
private

Definition at line 103 of file FlashMatchAna_module.cc.

Float_t opdet::FlashMatchAna::fTrueZ
private

Definition at line 104 of file FlashMatchAna_module.cc.

Float_t opdet::FlashMatchAna::fYCenter
private

Definition at line 138 of file FlashMatchAna_module.cc.

std::vector< Float_t > opdet::FlashMatchAna::fYCenterVector
private

Definition at line 119 of file FlashMatchAna_module.cc.

Float_t opdet::FlashMatchAna::fYWidth
private

Definition at line 140 of file FlashMatchAna_module.cc.

std::vector< Float_t > opdet::FlashMatchAna::fYWidthVector
private

Definition at line 121 of file FlashMatchAna_module.cc.

Float_t opdet::FlashMatchAna::fZCenter
private

Definition at line 139 of file FlashMatchAna_module.cc.

std::vector< Float_t > opdet::FlashMatchAna::fZCenterVector
private

Definition at line 120 of file FlashMatchAna_module.cc.

Float_t opdet::FlashMatchAna::fZWidth
private

Definition at line 141 of file FlashMatchAna_module.cc.

std::vector< Float_t > opdet::FlashMatchAna::fZWidthVector
private

Definition at line 122 of file FlashMatchAna_module.cc.


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