All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
sbnd::CRTT0Matching Class Reference
Inheritance diagram for sbnd::CRTT0Matching:

Public Member Functions

 CRTT0Matching (fhicl::ParameterSet const &p)
 
 CRTT0Matching (CRTT0Matching const &)=delete
 
 CRTT0Matching (CRTT0Matching &&)=delete
 
CRTT0Matchingoperator= (CRTT0Matching const &)=delete
 
CRTT0Matchingoperator= (CRTT0Matching &&)=delete
 
void produce (art::Event &e) override
 
void beginJob () override
 
void endJob () override
 
void reconfigure (fhicl::ParameterSet const &p)
 

Private Attributes

art::InputTag fTpcTrackModuleLabel
 name of track producer More...
 
art::InputTag fCrtHitModuleLabel
 name of crt producer More...
 
CRTT0MatchAlg t0Alg
 

Detailed Description

Definition at line 61 of file sbndcode/sbndcode/CRT/CRTTools/CRTT0Matching_module.cc.

Constructor & Destructor Documentation

sbnd::CRTT0Matching::CRTT0Matching ( fhicl::ParameterSet const &  p)
explicit

Definition at line 96 of file sbndcode/sbndcode/CRT/CRTTools/CRTT0Matching_module.cc.

97  : EDProducer(p), t0Alg(p.get<fhicl::ParameterSet>("T0Alg"))
98  // Initialize member data here, if know don't want to reconfigure on the fly
99  {
100 
101  // Call appropriate produces<>() functions here.
102  produces< std::vector<anab::T0> >();
103  produces< art::Assns<recob::Track , anab::T0> >();
104  produces< art::Assns<sbn::crt::CRTHit, anab::T0> >();
105 
106  reconfigure(p);
107 
108  } // CRTT0Matching()
pdgs p
Definition: selectors.fcl:22
sbnd::CRTT0Matching::CRTT0Matching ( CRTT0Matching const &  )
delete
sbnd::CRTT0Matching::CRTT0Matching ( CRTT0Matching &&  )
delete

Member Function Documentation

void sbnd::CRTT0Matching::beginJob ( )
override

Definition at line 120 of file sbndcode/sbndcode/CRT/CRTTools/CRTT0Matching_module.cc.

121  {
122 
123  } // CRTT0Matching::beginJob()
void sbnd::CRTT0Matching::endJob ( )
override

Definition at line 192 of file sbndcode/sbndcode/CRT/CRTTools/CRTT0Matching_module.cc.

193  {
194 
195  } // CRTT0Matching::endJob()
CRTT0Matching& sbnd::CRTT0Matching::operator= ( CRTT0Matching const &  )
delete
CRTT0Matching& sbnd::CRTT0Matching::operator= ( CRTT0Matching &&  )
delete
void sbnd::CRTT0Matching::produce ( art::Event &  e)
override

Definition at line 125 of file sbndcode/sbndcode/CRT/CRTTools/CRTT0Matching_module.cc.

126  {
127 
128  // Create anab::T0 objects and make association with recob::Track
129  std::unique_ptr< std::vector<anab::T0> > T0col( new std::vector<anab::T0>);
130  std::unique_ptr< art::Assns<recob::Track, anab::T0> > Trackassn( new art::Assns<recob::Track, anab::T0>);
131  std::unique_ptr< art::Assns <sbn::crt::CRTHit, anab::T0> > t0_crthit_assn( new art::Assns<sbn::crt::CRTHit, anab::T0> );
132 
133  // Retrieve CRT hit list
134  art::Handle<std::vector<sbn::crt::CRTHit>> crtListHandle;
135  std::vector<art::Ptr<sbn::crt::CRTHit>> crtList;
136  if(event.getByLabel(fCrtHitModuleLabel, crtListHandle))
137  art::fill_ptr_vector(crtList, crtListHandle);
138 
139  std::vector<sbn::crt::CRTHit> crtHits;
140  for (auto const& crtHit : crtList){
141  crtHits.push_back(*crtHit);
142  }
143 
144  // Retrieve track list
145  art::Handle< std::vector<recob::Track> > trackListHandle;
146  std::vector<art::Ptr<recob::Track> > trackList;
147  if (event.getByLabel(fTpcTrackModuleLabel,trackListHandle))
148  art::fill_ptr_vector(trackList, trackListHandle);
149 
150  mf::LogInfo("CRTT0Matching")
151  <<"Number of reconstructed tracks = "<<trackList.size()<<"\n"
152  <<"Number of CRT hits = "<<crtList.size();
153 
154  if (trackListHandle.isValid() && crtListHandle.isValid() ){
155 
156  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(event);
157  // Loop over all the reconstructed tracks
158  for(size_t track_i = 0; track_i < trackList.size(); track_i++) {
159 
160  // std::pair<double, double> matchedTime = t0Alg.T0AndDCAFromCRTHits(detProp, *trackList[track_i], crtHits, event);
161  matchCand closest = t0Alg.GetClosestCRTHit(detProp, *trackList[track_i], crtHits, event);
162 
163  if(closest.dca >=0 ){
164  mf::LogInfo("CRTT0Matching")
165  <<"Matched time = "<<closest.t0<<" [us] to track "<<trackList[track_i]->ID()<<" with DCA = "<<closest.dca;
166  T0col->push_back(anab::T0(closest.t0*1e3, trackList[track_i]->ID(), closest.thishit.plane, (int)closest.extrapLen, closest.dca));
167  util::CreateAssn(*this, event, *T0col, trackList[track_i], *Trackassn);
168 
169  //find this CRThit in the collection
170  // note this does not work (both the loop and the assoc !!)
171  unsigned CRThitIndex = std::numeric_limits<unsigned>::max();
172  for (int ic=0; ic<(int)crtList.size(); ++ic){
173  if (crtList[ic]->ts0_ns==closest.thishit.ts0_ns && crtList[ic]->z_pos==closest.thishit.z_pos && crtList[ic]->peshit==closest.thishit.peshit)
174  CRThitIndex=ic;
175  }
176  if (CRThitIndex != std::numeric_limits<unsigned>::max())
177  util::CreateAssn(*this, event, *T0col, crtList[CRThitIndex], *t0_crthit_assn);
178 
179  } // DCA check
180 
181  } // Loop over tracks
182 
183  } // Validity check
184 
185  event.put(std::move(T0col));
186  event.put(std::move(Trackassn));
187  event.put(std::move(t0_crthit_assn));
188 
189  } // CRTT0Matching::produce()
art::InputTag fCrtHitModuleLabel
name of crt producer
matchCand GetClosestCRTHit(detinfo::DetectorPropertiesData const &detProp, recob::Track tpcTrack, std::pair< double, double > t0MinMax, std::vector< sbn::crt::CRTHit > crtHits, int driftDirection)
art::InputTag fTpcTrackModuleLabel
name of track producer
Definition: T0.h:16
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
auto const detProp
void sbnd::CRTT0Matching::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 111 of file sbndcode/sbndcode/CRT/CRTTools/CRTT0Matching_module.cc.

112  {
113 
114  fTpcTrackModuleLabel = (p.get<art::InputTag> ("TpcTrackModuleLabel"));
115  fCrtHitModuleLabel = (p.get<art::InputTag> ("CrtHitModuleLabel"));
116 
117  } // CRTT0Matching::reconfigure()
art::InputTag fCrtHitModuleLabel
name of crt producer
art::InputTag fTpcTrackModuleLabel
name of track producer
pdgs p
Definition: selectors.fcl:22

Member Data Documentation

art::InputTag sbnd::CRTT0Matching::fCrtHitModuleLabel
private

name of crt producer

Definition at line 89 of file sbndcode/sbndcode/CRT/CRTTools/CRTT0Matching_module.cc.

art::InputTag sbnd::CRTT0Matching::fTpcTrackModuleLabel
private

name of track producer

Definition at line 88 of file sbndcode/sbndcode/CRT/CRTTools/CRTT0Matching_module.cc.

CRTT0MatchAlg sbnd::CRTT0Matching::t0Alg
private

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