Public Member Functions | Private Member Functions | Private Attributes | List of all members
T0RecoAnodePiercers Class Reference
Inheritance diagram for T0RecoAnodePiercers:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 T0RecoAnodePiercers (fhicl::ParameterSet const &p)
 
 T0RecoAnodePiercers (T0RecoAnodePiercers const &)=delete
 
 T0RecoAnodePiercers (T0RecoAnodePiercers &&)=delete
 
T0RecoAnodePiercersoperator= (T0RecoAnodePiercers const &)=delete
 
T0RecoAnodePiercersoperator= (T0RecoAnodePiercers &&)=delete
 
void produce (art::Event &event)
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
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::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- 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 Member Functions

void SortTrackPoints (const recob::Track &track, std::vector< TVector3 > &sorted_trk)
 
size_t FlashMatch (const double reco_time, std::vector< double > op_times_v)
 

Private Attributes

std::string fPFPProducer
 
std::string fTrackProducer
 
std::string fHitProducer
 
std::string fTriggerProducer
 
std::string fFlashProducer
 
std::string fFlashProducerMC
 
std::string fFlashProducerData
 
double fEdgeWidth
 
int fReadoutEdgeTicks
 
int fMinPE
 
double fMinTrackLength
 
double fFlashScaleFactor
 
double fFlashTPCOffset
 
bool fDebug
 
double fMinDtData
 
double fMaxDtData
 
double fMinDtMC
 
double fMaxDtMC
 
double DriftVelocity
 
unsigned int ReadoutWindow
 
double det_top
 
double det_bottom
 
double det_front
 
double det_back
 
double det_width
 
std::vector< double > op_times
 
std::vector< size_t > flash_id_v
 
art::Handle< std::vector< recob::OpFlash > > flash_h
 
bool MC
 
double anode_rc_time
 
double length
 
double rc_xs
 
double rc_xe
 
double rc_ys
 
double rc_ye
 
double rc_zs
 
double rc_ze
 
double matched_flash_time
 
double corrected_matched_flash_time
 
double matched_flash_pe
 
double dt_flash_reco
 
bool readout_edge
 
bool TPC_entering_candidate
 
bool TPC_exiting_candidate
 
bool anode_piercing_candidate
 
double dtMin
 
double dtMax
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- 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 47 of file T0RecoAnodePiercers_module.cc.

Constructor & Destructor Documentation

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

Definition at line 151 of file T0RecoAnodePiercers_module.cc.

152  :
153  EDProducer(fcl) {
154 
155  fDebug = fcl.get<bool> ("Debug" );
156 
157  fPFPProducer = fcl.get<std::string> ("PFPProducer" );
158  fTrackProducer = fcl.get<std::string> ("TrackProducer" );
159  fHitProducer = fcl.get<std::string> ("HitProducer" );
160 
161  fTriggerProducer = fcl.get<std::string> ("TriggerProducer" );
162 
163  fFlashProducerData = fcl.get<std::string> ("DataFlashProducer" );
164  fFlashProducerMC = fcl.get<std::string> ("MCFlashProducer" );
165 
166  fEdgeWidth = fcl.get<double> ("EdgeWidth" );
167  fReadoutEdgeTicks = fcl.get<int> ("ReadoutEdgeTicks" );
168 
169  fMinPE = fcl.get<double> ("MinPE" );
170  fMinTrackLength = fcl.get<double> ("MinTrackLength" );
171 
172  fMinDtData = fcl.get<double> ("MinDtFlashRecoData" );
173  fMaxDtData = fcl.get<double> ("MaxDtFlashRecoData" );
174 
175  fMinDtMC = fcl.get<double> ("MinDtFlashRecoMC" );
176  fMaxDtMC = fcl.get<double> ("MaxDtFlashRecoMC" );
177 
178  fFlashScaleFactor = fcl.get<double> ("FlashScaleFactor" );
179  fFlashTPCOffset = fcl.get<double> ("FlashTPCOffset" );
180 
181  // get boundaries based on detector bounds
182  auto const* geom = lar::providerFrom<geo::Geometry>();
183 
188 
189  for (geo::TPCID const& tID: geom->IterateTPCIDs()) {
190  geo::TPCGeo const& TPC = geom->TPC(tID);
191 
192  if(TPC.DriftDistance() < 25.0) continue;
193 
194  double origin[3] = {0.};
195  double center[3] = {0.};
196  TPC.LocalToWorld(origin, center);
197 
198  double tpc_top = center[1] + TPC.HalfHeight();
199  double tpc_bottom = center[1] - TPC.HalfHeight();
200  double tpc_front = center[2] - TPC.HalfLength();
201  double tpc_back = center[2] + TPC.HalfLength();
202 
203  if (tpc_top > det_top) det_top = tpc_top;
204  if (tpc_bottom < det_bottom) det_bottom = tpc_bottom;
205  if (tpc_front < det_front) det_front = tpc_front;
206  if (tpc_back > det_back) det_back = tpc_back;
207 
208  det_width = TPC.DriftDistance();
209  }
210 
211  // Use 'detp' to find 'efield' and 'temp'
212  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataForJob();
213  double efield = detProp.Efield();
214  if(fDebug) std::cout << "Nominal electric field is: " << efield << " V/cm" << std::endl;
215 
216  double temp = detProp.Temperature();
217  if(fDebug) std::cout << "LAr temperature is: " << temp << " K" << std::endl;
218 
219  // Determine the drift velocity from 'efield' and 'temp'
220  DriftVelocity = detProp.DriftVelocity(efield,temp);
221  if(fDebug) std::cout << "Drift velocity is: " << DriftVelocity << " cm/us" << std::endl;
222 
223  // Get Readout window length
224 
225  ReadoutWindow = detProp.ReadOutWindowSize();
226  if(fDebug) std::cout << "Readout window is: " << ReadoutWindow << " us" << std::endl;
227 
228  // Declare what the module produces
229 
230  produces < std::vector<anab::T0> >();
231  produces < art::Assns<recob::PFParticle, anab::T0> >();
232  }
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
Geometry information for a single TPC.
Definition: TPCGeo.h:38
double HalfLength() const
Length is associated with z coordinate [cm].
Definition: TPCGeo.h:117
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
double HalfHeight() const
Height is associated with y coordinate [cm].
Definition: TPCGeo.h:111
double DriftDistance() const
Definition: TPCGeo.h:155
def center(depos, point)
Definition: depos.py:117
void LocalToWorld(const double *tpc, double *world) const
Transform point from local TPC frame to world frame.
Definition: TPCGeo.h:563
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:227
QTextStream & endl(QTextStream &s)
T0RecoAnodePiercers::T0RecoAnodePiercers ( T0RecoAnodePiercers const &  )
delete
T0RecoAnodePiercers::T0RecoAnodePiercers ( T0RecoAnodePiercers &&  )
delete

Member Function Documentation

size_t T0RecoAnodePiercers::FlashMatch ( const double  reco_time,
std::vector< double >  op_times_v 
)
private

Definition at line 650 of file T0RecoAnodePiercers_module.cc.

651 {
652  // loop through all reco'd flash times and see if one matches
653  // the time from the track/particle
654 
655  double dt_min = 9999999.;
656  size_t matched_op_id = 99999;
657 
658  for (size_t i=0; i < op_times_v.size(); i++){
659  double op_time_i = op_times_v[i];
660  double corrected_op_time_i = op_time_i*fFlashScaleFactor + fFlashTPCOffset;
661  double corrected_flash_reco_time_diff = corrected_op_time_i - reco_time;
662  if (fabs(corrected_flash_reco_time_diff) < dt_min){
663  dt_min = fabs(corrected_flash_reco_time_diff);
664  matched_op_id = flash_id_v[i];
665  }
666  }
667 
668  return matched_op_id;
669  }
std::vector< size_t > flash_id_v
T0RecoAnodePiercers& T0RecoAnodePiercers::operator= ( T0RecoAnodePiercers const &  )
delete
T0RecoAnodePiercers& T0RecoAnodePiercers::operator= ( T0RecoAnodePiercers &&  )
delete
void T0RecoAnodePiercers::produce ( art::Event event)
virtual

Implements art::EDProducer.

Definition at line 234 of file T0RecoAnodePiercers_module.cc.

234  {
235 
236  MC = !(event.isRealData());
237 
238  if(MC) {
239  dtMin = fMinDtMC; //us
240  dtMax = fMaxDtMC; //us
241  }
242  else {
243  dtMin = fMinDtData; //us
244  dtMax = fMaxDtData; //us
245  }
246 
247  if(fDebug) std::cout << "\tAnode piercing tracks selected by cuts.\n\t\t Min length: "
248  << fMinTrackLength << ", Min PE: " << fMinPE <<
249  " and flash-reco time difference between " << dtMin << " and "
250  << dtMax << " us." << std::endl;
251 
252  auto t0_v = std::make_unique<std::vector<anab::T0>>();
253  auto pfp_t0 = std::make_unique<art::Assns<recob::PFParticle, anab::T0>>();
254 
255  int track_number = 0;
256 
257  // Load detector clocks for later
258  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(event);;
259 
260  double TPC_trigger_offset = 0.0;
261 
262  //std::cout << "Event number: " << event.event() << std::endl;
263  if(fDebug) std::cout << "Set event number: " << event.event() << "\nTop: "
264  << det_top << "\nBottom: " << det_bottom << "\nFront: " << det_front
265  << "\nBack: " << det_back << "\nEdge width: " << fEdgeWidth << std::endl;
266 
267  op_times.clear();
268  flash_id_v.clear();
269  flash_h.clear();
270 
271  //Set flash producer to MC or data
272 
275 
276  // load Flashes
277  if (fDebug) std::cout << "Loading flash from producer " << fFlashProducer << std::endl;
278 
279  flash_h = event.getHandle<std::vector<recob::OpFlash> >(fFlashProducer);
280 
281  // make sure flashes look good
282  if(!flash_h.isValid()) {
283  std::cerr<<"\033[93m[ERROR]\033[00m ... could not locate Flash!"<<std::endl;
284  throw std::exception();
285  }
286 
287  double trigger_time = 0;
288 
289  if(!MC){
290  auto trigger_h = event.getHandle<std::vector<recob::OpFlash> >(fTriggerProducer);
291 
292  if( (!trigger_h) || trigger_h->empty()) {
293  if(fDebug) std::cout << "\tTrigger not found. Skipping." << std::endl;
294  event.put(std::move(t0_v));
295  event.put(std::move(pfp_t0));
296  return;
297  }
298 
299  if(fDebug) std::cout << "Loading trigger time from producer "
301 
302  trigger_time = trigger_h->at(0).Time();
303  }
304 
305 
306  // load PFParticles
307 
308  auto reco_particles_h = event.getValidHandle<std::vector<recob::PFParticle>>(fPFPProducer);
309  const art::FindManyP<recob::Track> findTracks(reco_particles_h,event,fTrackProducer);
310  auto reco_tracks_h = event.getValidHandle<std::vector<recob::Track>>(fTrackProducer);
311  art::FindManyP<recob::Hit> findHits(reco_tracks_h, event, fTrackProducer);
312 
313  if(!reco_particles_h.isValid()) {
314  std::cerr<<"\033[93m[ERROR]\033[00m ... could not locate PFParticles!"<<std::endl;
315  throw std::exception();
316  }
317 
318  // Utilities for PFParticles and tracks
319  //protoana::ProtoDUNEPFParticleUtils pfpUtil;
320  //protoana::ProtoDUNETrackUtils trackUtil;
321 
322  // Get trigger to TPC Offset
323 
324  TPC_trigger_offset = clockData.TriggerOffsetTPC();
325  if(fDebug) std::cout << "TPC time offset from trigger: "
326  << TPC_trigger_offset << " us" << std::endl;
327 
328  // Prepare a vector of optical flash times, if flash above some PE cut value
329 
330  size_t flash_ctr = 0;
331  for (auto const& flash : *flash_h){
332  if (flash.TotalPE() > fMinPE){
333  double op_flash_time;
334  if(!MC) op_flash_time = flash.Time() - trigger_time;
335  if(MC) op_flash_time = flash.Time() - trigger_time - TPC_trigger_offset;
336  op_times.push_back(op_flash_time);
337  flash_id_v.push_back(flash_ctr);
338  if (fDebug) std::cout << "\t Flash: " << flash_ctr << " has time : "
339  << op_flash_time << ", PE : " << flash.TotalPE() << std::endl;
340  }
341  flash_ctr++;
342  } // for all flashes
343 
344  if(fDebug) std::cout << "Selected a total of " << op_times.size() << " OpFlashes" << std::endl;
345 
346  // LOOP THROUGH RECONSTRUCTED PFPARTICLES
347 
348  size_t ev_particle_ctr = 0;
349 
350  for(unsigned int particle = 0; particle < reco_particles_h->size(); ++particle){
351 
352  const recob::PFParticle &pfparticle = (*reco_particles_h)[particle];
353 
354  // Only consider primary particles
355  if(!pfparticle.IsPrimary()) continue;
356 
357  ev_particle_ctr++;
358 
359 
360  //Replacing this with the hardcoded method to remove util dependency
361  //const recob::Track* track = pfpUtil.GetPFParticleTrack(pfparticle,event,fPFPProducer,fTrackProducer);
362  const recob::Track* track = 0x0;
363  const std::vector<art::Ptr<recob::Track>> pfpTracks = findTracks.at(pfparticle.Self());
364  if( pfpTracks.size() != 0 ){
365  track = (pfpTracks.at(0)).get();
366  }
367  if(track == 0x0) {
368  if(fDebug) std::cout << "\tPFParticle " << ev_particle_ctr << " is not track like" << std::endl;
369  continue;
370  }
371 
372  if (fDebug) std::cout << "\tLooping through reco PFParticle " << ev_particle_ctr << std::endl;
373 
374  //Replacing this with the hardcoded method to remove util dependency
375  //const std::vector<const recob::Hit*>& hit_v = trackUtil.GetRecoTrackHits(*track,event,fTrackProducer);
376  std::vector<art::Ptr<recob::Hit>> inputHits = findHits.at(track->ID());
377  std::vector<const recob::Hit*> hit_v;
378  for(const art::Ptr<recob::Hit> hit : inputHits){
379  hit_v.push_back(hit.get());
380  }
381 
382 
384 
385  length = 0.;
386  rc_xs = ReadoutWindow/10.;
387  rc_xe = -ReadoutWindow/10.;
388  //rc_xs_corr = 399.;
389  //rc_xe_corr = -399.;
390  rc_ys = -99.;
391  rc_ye = -99.;
392  rc_zs = -99.;
393  rc_ze = -99.;
394 
397  //matched_flash_time_width = -1.;
398 
399  matched_flash_pe = 0.;
400  //matched_flash_centre_y = -99.;
401  //matched_flash_centre_z = -99.;
402  //matched_flash_width_y = -99.;
403  //matched_flash_width_z = -99.;
404  //matched_flash_max_pe_det_x = 0.;
405  //matched_flash_max_pe_det_y = -99.;
406  //matched_flash_max_pe_det_z = -99.;
407 
408  dt_flash_reco = 999;
409 
410  anode_piercing_candidate = false;
411  //cathode_crossing_track = false;
412 
413  // Get sorted points for the track object [assuming downwards going]
414 
415  std::vector<TVector3> sorted_trk;
416  SortTrackPoints(*track,sorted_trk);
417 
418  TVector3 track_start = sorted_trk.at(0);
419  TVector3 track_end = sorted_trk.at(sorted_trk.size() - 1);
420 
421  if(fDebug) std::cout << "\t\tTrack goes from (" << track_start.X() << ", "
422  << track_start.Y() << ", " << track_start.Z() << ") --> (" << track_end.X() << ", "
423  << track_end.Y() << ", " << track_end.Z() << ")" << std::endl;
424 
425  if(track->Length() < fMinTrackLength ) {
426  if(fDebug) std::cout << "\t\t\tParticle track too short. Skipping." << std::endl;
427  continue;
428  }
429 
430  auto const* geom = lar::providerFrom<geo::Geometry>();
431  auto const* first_hit = hit_v.at(0);
432  const geo::WireID wireID_start = first_hit->WireID();
433  const auto TPCGeoObject_start = geom->TPC(wireID_start.TPC,wireID_start.Cryostat);
434  short int driftDir_start = TPCGeoObject_start.DetectDriftDirection();
435 
436  short int driftDir_end = 0;
437  //cathode_crossing_track = false;
438 
439  for (size_t ii = 1; ii < hit_v.size(); ii++) {
440  const geo::WireID wireID_end = hit_v.at(ii)->WireID();
441  const auto TPCGeoObject_end = geom->TPC(wireID_end.TPC,wireID_end.Cryostat);
442  driftDir_end = TPCGeoObject_end.DetectDriftDirection();
443 
444  if(driftDir_end + driftDir_start == 0){
445  //cathode_crossing_track = true;
446  ii = hit_v.size();
447  }
448  }
449  // ------------------------------------------------------------------------------------
450  // ANODE PIERCERS
451 
452  if(fDebug) std::cout << "\t\tThis track starts in TPC " << wireID_start.TPC
453  << " which has a drift direction of " << driftDir_start << std::endl;
454 
455  // create root trees variables
456 
457  rc_xs = track_start.X();
458  rc_ys = track_start.Y();
459  rc_zs = track_start.Z();
460  rc_xe = track_end.X();
461  rc_ye = track_end.Y();
462  rc_ze = track_end.Z();
463  length = track->Length();
464 
465  // Determine if track hits edge of readout window
466  // NECESSARY TO REMOVE TRACKS THAT AREN'T FINISHED WHEN WINDOW CLOSES
467  // AS WELL AS TRACKS THAT WERE BEING COLLECTED BEFORE THE WINDOW OPENED
468 
469  readout_edge = false;
470  for (auto& hits : hit_v) {
471  auto hit_tick = hits->PeakTime();
472  if(hit_tick < fReadoutEdgeTicks || hit_tick > (ReadoutWindow - fReadoutEdgeTicks)){
473  readout_edge = true;
474  if(fDebug) std::cout << "\tTrack hits edge of readout window. "
475  "Skipping." << std::endl;
476  continue;
477  }
478 
479  double hit_time = clockData.TPCTick2TrigTime(hit_tick);
480 
481  // If track within window, get reco time from earliest hit time
482  if (hit_time < anode_rc_time) anode_rc_time = hit_time;
483  }
484 
485  if(readout_edge) continue;
486 
487  TPC_entering_candidate = false;
488  TPC_exiting_candidate = false;
489 
490  // Tracks which may enter TPC through an APA
491  if (rc_ys < (det_top - fEdgeWidth) && rc_zs > (det_front + fEdgeWidth)
492  && rc_zs < (det_back - fEdgeWidth)) {
493 
494  // reconstruct track T0 w.r.t. trigger time
495  if( ( rc_xs > rc_xe && driftDir_start>0 ) ||
496  ( rc_xs < rc_xe && driftDir_start<0 ) ) {
497  TPC_entering_candidate = true;
498  if(fDebug) std::cout << "\t\tTrack may enter TPC through "
499  "anode. Reco t0: " << anode_rc_time << " us" << std::endl;
500  }
501  }
502 
503  // Tracks which may exit TPC through an APA
505  && rc_ze < (det_back - fEdgeWidth)) {
506 
507  // reconstruct track T0 w.r.t. trigger time
508  if( ( rc_xe > rc_xs && driftDir_end>0 ) ||
509  ( rc_xe < rc_xs && driftDir_end<0 ) ) {
510  TPC_exiting_candidate = true;
511  if(fDebug) std::cout << "\t\tTrack may exit TPC through "
512  "anode. Reco t0:" << anode_rc_time << " us" << std::endl;
513  }
514  }
515 
518 
520  if(fDebug) std::cout << "\t\tTrack does not pierce anode." << std::endl;
521  continue;
522  }
523 
525  if(fDebug) std::cout << "\t\tTrack neither enters nor exits"
526  " through non-anode TPC face. No useful end point for SCE"
527  " measurement." << std::endl;
528  continue;
529  }
530 
531  //rc_xs_corr = rc_xs + driftDir_start*anode_rc_time*DriftVelocity;
532  //rc_xe_corr = rc_xe + driftDir_end*anode_rc_time*DriftVelocity;
533 
534  // FLASH MATCHING
535 
536  size_t op_match_result = FlashMatch((anode_rc_time),op_times);
537 
538  if(op_match_result==99999) {
539  if(fDebug) std::cout << "Unable to match flash to track." << std::endl;
540  continue;
541  }
542 
543  const art::Ptr<recob::OpFlash> flash_ptr(flash_h, op_match_result);
544 
545  matched_flash_time = flash_ptr->Time() - trigger_time;
547  if(MC) corrected_matched_flash_time = fFlashScaleFactor*matched_flash_time + fFlashTPCOffset - TPC_trigger_offset;
548  //matched_flash_time_width = flash_ptr->TimeWidth();
549 
551 
552  matched_flash_pe = flash_ptr->TotalPE();
553 
554  //matched_flash_centre_y = flash_ptr->YCenter();
555  //matched_flash_centre_z = flash_ptr->ZCenter();
556  //matched_flash_width_y = flash_ptr->YWidth();
557  //matched_flash_width_z = flash_ptr->ZWidth();
558 
559  /*unsigned int max_pe_channel = 9999;
560  double max_pe = 0;
561  unsigned int pd_ch;
562  for(pd_ch = 0; pd_ch <= geom->MaxOpChannel(); pd_ch++) {
563  double channel_i_pe = flash_ptr->PE(pd_ch);
564  if(channel_i_pe > max_pe) {
565  max_pe = channel_i_pe;
566  max_pe_channel = pd_ch;
567  }
568  }
569 
570  if(max_pe_channel==9999||max_pe==0) continue;
571 
572  matched_flash_max_pe_det_x = -det_width;
573  if(max_pe_channel>143) matched_flash_max_pe_det_x = det_width;
574  */
575  /*double max_pe_det_v[3];
576  geom->OpDetGeoFromOpChannel(max_pe_channel).GetCenter(max_pe_det_v);
577  matched_flash_max_pe_det_x = max_pe_det_v[0];
578  matched_flash_max_pe_det_y = max_pe_det_v[1];
579  matched_flash_max_pe_det_z = max_pe_det_v[2];
580  */
581 
582  /*if(fDebug) std::cout << "\t\tOpChannel " << max_pe_channel <<
583  " has maximum PE, and is located at: (" <<
584  matched_flash_max_pe_det_x << ", " <<
585  matched_flash_max_pe_det_y << ", " <<
586  matched_flash_max_pe_det_z << ")" << std::endl; */
587 
588  if(fDebug) std::cout << "\t\t Matched to flash w/ index " << op_match_result
589  << " w/ PE " << matched_flash_pe << ", corrected time " <<
590  corrected_matched_flash_time << " us vs corrected reco time " <<
591  anode_rc_time << " us" << std::endl;
592 
593  // ---------------------------------------------------------------
594  // CREATE T0 OBJECT AND ASSIGN TO PFPARTICLE
595 
598  if(fDebug) std::cout << "\t\tPFParticle: " << particle <<
599  " has a matched flash and passes cuts. Assigning T0: "
600  << anode_rc_time << " us." << std::endl;
601 
602  anab::T0 anode_t0 = anab::T0((anode_rc_time*1000), 0, 1, flash_ptr.key());
603  t0_v->push_back(anode_t0);
604 
605  // Use the association utility
606  // Need to convert our recob::PFParticle to an art::Ptr<recob::PFParticle
607  art::Ptr<recob::PFParticle> pfp_ptr(reco_particles_h,particle);
608 
609  util::CreateAssn(*this, event, *t0_v, pfp_ptr, *pfp_t0);
610  }
611 
612 
613  track_number++;
614 
615  }
616 
617  event.put(std::move(t0_v));
618  event.put(std::move(pfp_t0));
619 
620  }
void SortTrackPoints(const recob::Track &track, std::vector< TVector3 > &sorted_trk)
std::vector< size_t > flash_id_v
size_t Self() const
Returns the index of this particle.
Definition: PFParticle.h:92
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:212
Definition: T0.h:16
bool isValid() const noexcept
Definition: Handle.h:191
timescale_traits< TriggerTimeCategory >::time_point_t trigger_time
A point in time on the trigger time scale.
double Length(size_t p=0) const
Access to various track properties.
Definition: Track.h:167
def move(depos, offset)
Definition: depos.py:107
bool IsPrimary() const
Returns whether the particle is the root of the flow.
Definition: PFParticle.h:86
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
Detector simulation of raw signals on wires.
int ID() const
Definition: Track.h:198
Hierarchical representation of particle flow.
Definition: PFParticle.h:44
art::Handle< std::vector< recob::OpFlash > > flash_h
void clear()
Definition: Handle.h:236
std::vector< double > op_times
constexpr WireID()=default
Default constructor: an invalid TPC ID.
size_t FlashMatch(const double reco_time, std::vector< double > op_times_v)
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
Definition: Track.h:49
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
void T0RecoAnodePiercers::SortTrackPoints ( const recob::Track track,
std::vector< TVector3 > &  sorted_trk 
)
private

Definition at line 622 of file T0RecoAnodePiercers_module.cc.

623 {
624  sorted_trk.clear();
625 
626  TVector3 track_start, track_end;
627  double start_y = det_bottom - fEdgeWidth;
628  double end_y = det_top + fEdgeWidth;
629 
630  for (size_t ii = 0; ii < track.NumberTrajectoryPoints(); ii++){
631  auto const& trk_loc = track.LocationAtPoint(ii);
632 
633  if ((trk_loc.X() < -998.)||(trk_loc.Y() < -998.)||(trk_loc.Z() < -998)) continue;
634 
635  if (trk_loc.Y() < end_y){
636  end_y = trk_loc.Y();
637  track_end = {trk_loc.X(), trk_loc.Y(), trk_loc.Z()};
638  }
639 
640  if (trk_loc.Y() > start_y){
641  start_y = trk_loc.Y();
642  track_start = {trk_loc.X(), trk_loc.Y(), trk_loc.Z()};
643  }
644  }
645 
646  sorted_trk.push_back(track_start);
647  sorted_trk.push_back(track_end);
648  }
Point_t const & LocationAtPoint(size_t i) const
Definition: Track.h:126
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
Definition: Track.h:102

Member Data Documentation

bool T0RecoAnodePiercers::anode_piercing_candidate
private

Definition at line 144 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::anode_rc_time
private

Definition at line 116 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::corrected_matched_flash_time
private

Definition at line 125 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::det_back
private

Definition at line 105 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::det_bottom
private

Definition at line 103 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::det_front
private

Definition at line 104 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::det_top
private

Definition at line 102 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::det_width
private

Definition at line 106 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::DriftVelocity
private

Definition at line 99 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::dt_flash_reco
private

Definition at line 138 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::dtMax
private

Definition at line 148 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::dtMin
private

Definition at line 147 of file T0RecoAnodePiercers_module.cc.

bool T0RecoAnodePiercers::fDebug
private

Definition at line 91 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::fEdgeWidth
private

Definition at line 82 of file T0RecoAnodePiercers_module.cc.

std::string T0RecoAnodePiercers::fFlashProducer
private

Definition at line 78 of file T0RecoAnodePiercers_module.cc.

std::string T0RecoAnodePiercers::fFlashProducerData
private

Definition at line 80 of file T0RecoAnodePiercers_module.cc.

std::string T0RecoAnodePiercers::fFlashProducerMC
private

Definition at line 79 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::fFlashScaleFactor
private

Definition at line 88 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::fFlashTPCOffset
private

Definition at line 89 of file T0RecoAnodePiercers_module.cc.

std::string T0RecoAnodePiercers::fHitProducer
private

Definition at line 75 of file T0RecoAnodePiercers_module.cc.

art::Handle<std::vector<recob::OpFlash> > T0RecoAnodePiercers::flash_h
private

Definition at line 111 of file T0RecoAnodePiercers_module.cc.

std::vector<size_t> T0RecoAnodePiercers::flash_id_v
private

Definition at line 110 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::fMaxDtData
private

Definition at line 94 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::fMaxDtMC
private

Definition at line 97 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::fMinDtData
private

Definition at line 93 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::fMinDtMC
private

Definition at line 96 of file T0RecoAnodePiercers_module.cc.

int T0RecoAnodePiercers::fMinPE
private

Definition at line 85 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::fMinTrackLength
private

Definition at line 86 of file T0RecoAnodePiercers_module.cc.

std::string T0RecoAnodePiercers::fPFPProducer
private

Definition at line 73 of file T0RecoAnodePiercers_module.cc.

int T0RecoAnodePiercers::fReadoutEdgeTicks
private

Definition at line 83 of file T0RecoAnodePiercers_module.cc.

std::string T0RecoAnodePiercers::fTrackProducer
private

Definition at line 74 of file T0RecoAnodePiercers_module.cc.

std::string T0RecoAnodePiercers::fTriggerProducer
private

Definition at line 76 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::length
private

Definition at line 117 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::matched_flash_pe
private

Definition at line 128 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::matched_flash_time
private

Definition at line 124 of file T0RecoAnodePiercers_module.cc.

bool T0RecoAnodePiercers::MC
private

Definition at line 113 of file T0RecoAnodePiercers_module.cc.

std::vector<double> T0RecoAnodePiercers::op_times
private

Definition at line 108 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::rc_xe
private

Definition at line 118 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::rc_xs
private

Definition at line 118 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::rc_ye
private

Definition at line 120 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::rc_ys
private

Definition at line 120 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::rc_ze
private

Definition at line 121 of file T0RecoAnodePiercers_module.cc.

double T0RecoAnodePiercers::rc_zs
private

Definition at line 121 of file T0RecoAnodePiercers_module.cc.

bool T0RecoAnodePiercers::readout_edge
private

Definition at line 141 of file T0RecoAnodePiercers_module.cc.

unsigned int T0RecoAnodePiercers::ReadoutWindow
private

Definition at line 100 of file T0RecoAnodePiercers_module.cc.

bool T0RecoAnodePiercers::TPC_entering_candidate
private

Definition at line 142 of file T0RecoAnodePiercers_module.cc.

bool T0RecoAnodePiercers::TPC_exiting_candidate
private

Definition at line 143 of file T0RecoAnodePiercers_module.cc.


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