234 fEvent =
event.id().event();
239 std::unique_ptr< std::vector<anab::T0> > T0col(
new std::vector<anab::T0>);
240 std::unique_ptr< art::Assns<recob::Track, anab::T0> > Trackassn(
new art::Assns<recob::Track, anab::T0>);
241 std::unique_ptr< art::Assns <sbn::crt::CRTHit, anab::T0> > t0_crthit_assn(
new art::Assns<sbn::crt::CRTHit, anab::T0> );
246 art::Handle<sbn::ExtraTriggerInfo> trigger_handle;
248 if( trigger_handle.isValid() ) {
254 m_trigger_gate_diff = trigger_handle->triggerTimestamp - trigger_handle->beamGateTimestamp;
258 mf::LogError(
"CRTT0Matching:") <<
"No raw::Trigger associated to label: " <<
fTriggerLabel.label() <<
"\n" ;
262 mf::LogError(
"CRTT0Matching:") <<
"Trigger Data product " <<
fTriggerLabel.label() <<
" not found!\n" ;
266 art::Handle<std::vector<sbn::crt::CRTHit>> crtListHandle;
267 std::vector<art::Ptr<sbn::crt::CRTHit>> crtList;
269 art::fill_ptr_vector(crtList, crtListHandle);
271 std::vector<sbn::crt::CRTHit> crtHits;
272 for (
auto const& crtHit : crtList){
273 crtHits.push_back(*crtHit);
279 auto it = &trackLabel - fTpcTrackModuleLabel.data();
281 art::Handle< std::vector<recob::Track> > trackListHandle;
282 std::vector<art::Ptr<recob::Track> > trackList;
283 if (event.getByLabel(trackLabel,trackListHandle))
284 art::fill_ptr_vector(trackList, trackListHandle);
289 mf::LogInfo(
"CRTT0Matching")
290 <<
"Number of reconstructed tracks = "<<trackList.size()<<
"\n"
291 <<
"Number of CRT hits = "<<crtList.size();
293 fntracks.push_back(trackList.size());
295 auto pfpListHandle =
event.getValidHandle<std::vector<recob::PFParticle> >(
fPFParticleLabel[it]);
296 if (!pfpListHandle.isValid())
continue;
299 art::FindManyP<recob::PFParticle> fmpfp(trackListHandle, event, trackLabel);
302 art::FindManyP<anab::T0> fmt0pandora(pfpListHandle, event,
fPFParticleLabel[it]);
305 if (trackListHandle.isValid() && crtListHandle.isValid() ){
307 auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(event);
308 art::FindManyP<recob::Hit> findManyHits(trackListHandle, event, trackLabel);
311 for(
size_t track_i = 0; track_i < trackList.size(); track_i++) {
313 double t0 = -99999999;
316 auto pfps = fmpfp.at(trackList[track_i]->ID());
320 auto t0s = fmt0pandora.at(pfps[0].key());
327 std::vector<art::Ptr<recob::Hit>> hits = findManyHits.at(trackList[track_i]->ID());
328 if (hits.size() == 0)
continue;
329 int const cryoNumber = hits[0]->WireID().Cryostat;
335 if(closest.dca >=0 ){
336 mf::LogInfo(
"CRTT0Matching")
337 <<
"Matched time = "<<closest.
t0<<
" [us] to track "<<trackList[track_i]->ID()<<
" with DCA = "<<closest.dca;
338 T0col->push_back(
anab::T0(closest.t0*1e3, trackList[track_i]->ID(), closest.thishit.plane, (int)closest.extrapLen, closest.dca));
342 double sin_angle = -99999;
343 if(closest.dca != -99999){
344 auto start = trackList[track_i]->Vertex<TVector3>();
346 hDCA[closest.thishit.tagger]->Fill(closest.dca);
348 sin_angle = closest.dca/closest.extrapLen;
349 hDoL[closest.thishit.tagger]->Fill(sin_angle);
351 hT0[closest.thishit.tagger]->Fill(closest.t0);
352 fDCA.push_back(closest.dca);
353 fDOL.push_back(sin_angle);
354 fT0.push_back(closest.t0);
355 fcryo.push_back(cryoNumber);
357 ftpcx.push_back(start.X());
358 ftpcy.push_back(start.Y());
359 ftpcz.push_back(start.Z());
360 fcrtx.push_back(closest.thishit.x_pos);
361 fcrty.push_back(closest.thishit.y_pos);
362 fcrtz.push_back(closest.thishit.z_pos);
368 unsigned CRThitIndex = std::numeric_limits<unsigned>::max();
369 for (
int ic=0; ic<(int)crtList.size(); ++ic){
370 if (crtList[ic]->ts0_ns==closest.thishit.ts0_ns && crtList[ic]->z_pos==closest.thishit.z_pos && crtList[ic]->peshit==closest.thishit.peshit)
374 if (CRThitIndex != std::numeric_limits<unsigned>::max()){
376 util::CreateAssn(*
this, event, *T0col, crtList[CRThitIndex], *t0_crthit_assn);
385 event.put(std::move(T0col));
386 event.put(std::move(Trackassn));
387 event.put(std::move(t0_crthit_assn));
vector< double > fpandorat0
Track T0 based on Pandora (Cathode Crossing Track)
std::map< std::string, TH1F * > hT0
int fEvent
number of the event being processed
std::map< std::string, TH1F * > hDoL
std::vector< art::InputTag > fTpcTrackModuleLabel
name of track producer
art::InputTag fCrtHitModuleLabel
name of crt producer
art::InputTag fTriggerLabel
labels for trigger
uint64_t m_gate_start_timestamp
int fRun
number of the run being processed
int AuxDetRegionNameToNum(string reg)
std::string bitName(triggerSource bit)
Returns a mnemonic short name of the beam type.
std::vector< art::InputTag > fPFParticleLabel
labels for source of PFParticle
icarus::crt::CRTCommonUtils * fCrtutils
vector< int > fntracks
total number of tracks
uint64_t m_trigger_timestamp
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.
matchCand GetClosestCRTHit(detinfo::DetectorPropertiesData const &detProp, recob::Track tpcTrack, std::pair< double, double > t0MinMax, std::vector< sbn::crt::CRTHit > crtHits, int driftDirection, uint64_t &trigger_timestamp)
vector< int > fcryo
cryo number
uint64_t m_trigger_gate_diff
triggerSource
Type of beam or beam gate or other trigger source.
std::map< std::string, TH1F * > hDCA
int fSubRun
number of the sub-run being processed