280 auto const& mctruths =
281 *
e.getValidHandle<vector<simb::MCTruth>>(
fGenLabel);
288 auto const&
nu = mctruths[0].GetNeutrino();
289 const TLorentzVector xyzt =
nu.Nu().Position(0);
297 for(
int i=0; i<3; i++) point[i] =
fNuXYZT[i];
315 for(
int i=0; i<4; i++)
319 auto const& simparticles =
320 *
e.getValidHandle<vector<simb::MCParticle>>(
fSimLabel);
323 map<int,const simb::MCParticle*> particleMap;
324 for(
auto const& particle : simparticles){
326 particleMap[particle.TrackId()] = &particle;
331 art::Handle< std::vector<recob::OpHit> > opHitListHandle;
332 std::vector< art::Ptr<recob::OpHit> > opHitList;
334 art::fill_ptr_vector(opHitList, opHitListHandle);
336 fNHit = opHitList.size();
337 for(
auto const&
ophit : opHitList){
343 vector<double> xyzt = {pos[0],pos[1],pos[2],t};
350 map<int, art::Handle< std::vector<recob::OpFlash> > > flashHandles;
351 std::map<int,std::vector< art::Ptr<recob::OpFlash> >> opFlashLists;
353 for(
int i=0; i<4; i++) {
355 art::fill_ptr_vector(opFlashLists[i], flashHandles[i]);
358 for(
auto const& flashList : opFlashLists) {
359 fNFlash += flashList.second.size();
361 for(
size_t iflash=0; iflash<flashList.second.size(); iflash++) {
362 auto const& flash = flashList.second[iflash];
366 xyzt.push_back(flash->YCenter());
367 xyzt.push_back(flash->ZCenter());
368 xyzt.push_back(flash->Time()*1e3-
fOpDelay);
370 fFlashPE.push_back(flash->TotalPE());
372 auto const& pes = flash->PEs();
376 for(
auto const& pe : pes)
380 vector<double> delta = {0., flash->YWidth(),flash->ZWidth(),flash->TimeWidth()};
411 art::Handle< std::vector<sbn::crt::CRTTrack> > crtTrackListHandle;
412 std::vector< art::Ptr<sbn::crt::CRTTrack> > crtTrackList;
414 art::fill_ptr_vector(crtTrackList, crtTrackListHandle);
416 art::FindManyP<CRTHit> findManyHits(
421 std::vector<std::vector<art::Ptr<CRTHit>>> trackhits;
422 for(
size_t itrk=0; itrk<crtTrackList.size(); itrk++){
424 std::vector<art::Ptr<CRTHit>> trkhits = findManyHits.at(itrk);
425 std::sort(trkhits.begin(),trkhits.end(),
426 [](
const art::Ptr<CRTHit>&
a,
const art::Ptr<CRTHit>& b)->
bool
428 return a->ts0_ns < b->ts0_ns;
431 trackhits.push_back(trkhits);
437 art::Handle< std::vector<CRTHit> > crtHitListHandle;
438 std::vector< art::Ptr<CRTHit> > crtHitList;
440 art::fill_ptr_vector(crtHitList, crtHitListHandle);
442 fNCrt = crtHitList.size();
444 for(
auto const&
crt : crtHitList){
446 bool trackfilt=
false;
447 for(
auto const& trkhits: trackhits){
448 for(
size_t ihit=1; ihit<trkhits.size(); ihit++) {
459 vector<double> xyzt, xyzerr;
460 TVector3 rcrt(
crt->x_pos,
crt->y_pos,
crt->z_pos);
462 xyzt.push_back(rcrt.X());
463 xyzt.push_back(rcrt.Y());
464 xyzt.push_back(rcrt.Z());
466 xyzt.push_back(tcrt);
469 xyzerr.push_back(
crt->x_err);
470 xyzerr.push_back(
crt->y_err);
471 xyzerr.push_back(
crt->z_err);
480 bool firstIV=
false, firstAV=
false, firstFV=
false;
483 if(particleMap.find(
abs(trackID))!=particleMap.end()){
484 auto const& particle = particleMap[
abs(trackID)];
485 fHitPDG.push_back(particle->PdgCode());
486 for(
size_t i=0; i<particle->NumberTrajectoryPoints(); i++){
487 const TLorentzVector& pos = particle->Position(i);
488 double point[3] = {pos.X(),pos.Y(),pos.Z()};
495 double ddirect = sqrt(pow(opDetPos[0]-rcrt.X(),2)
496 + pow(opDetPos[1]-rcrt.Y(),2)
497 + pow(opDetPos[2]-rcrt.Z(),2));
498 double dprop = sqrt(pow(opDetPos[0]-pos[0],2)
499 + pow(opDetPos[1]-pos[1],2)
500 + pow(opDetPos[2]-pos[2],2));
504 vector<double> tmp1 = {pos.X(),pos.Y(),pos.Z(),pos.T()};
505 vector<double> tmp2 = {opDetPos[0],opDetPos[1],opDetPos[2],tprop};
518 double ddirect = sqrt(pow(opDetPos[0]-rcrt.X(),2)
519 + pow(opDetPos[1]-rcrt.Y(),2)
520 + pow(opDetPos[2]-rcrt.Z(),2));
521 double dprop = sqrt(pow(opDetPos[0]-pos[0],2)
522 + pow(opDetPos[1]-pos[1],2)
523 + pow(opDetPos[2]-pos[2],2));
527 vector<double> tmp1 = {pos.X(),pos.Y(),pos.Z(),pos.T()};
528 vector<double> tmp2 = {opDetPos[0],opDetPos[1],opDetPos[2],tprop};
540 std::cout <<
"CRTHit trackID " << trackID <<
" not found in particle map!" << std::endl;
544 fEnterXYZT.push_back({DBL_MAX,DBL_MAX,DBL_MAX,DBL_MAX});
545 fPMTXYZT.push_back({DBL_MAX,DBL_MAX,DBL_MAX,DBL_MAX});
547 fIV.push_back(firstIV);
548 fAV.push_back(firstAV);
549 fFV.push_back(firstFV);
550 if(!firstAV&&
fHitPDG.back()!=INT_MAX){
553 fEnterXYZT.push_back({DBL_MAX,DBL_MAX,DBL_MAX,DBL_MAX});
554 fPMTXYZT.push_back({DBL_MAX,DBL_MAX,DBL_MAX,DBL_MAX});
559 double tdiff = DBL_MAX, rdiff=DBL_MAX, peflash=DBL_MAX;
562 double flashHitT = DBL_MAX, flashHitPE=DBL_MAX, flashHitDiff=DBL_MAX;
563 vector<double> flashHitxyzt;
565 for(
auto const& flashList : opFlashLists) {
567 art::FindManyP<recob::OpHit> findManyHits(
568 flashHandles[flashList.first],
e,
fFlashLabels[flashList.first]);
570 for(
size_t iflash=0; iflash<flashList.second.size(); iflash++) {
572 auto const& flash = flashList.second[iflash];
577 double tflash = flash->Time()*1e3-
fOpDelay;
578 TVector3 rflash(0,flash->YCenter(),flash->ZCenter());
579 TVector3 vdiff = rcrt-rflash;
580 if(
abs(tcrt-tflash)<
abs(tdiff)) {
581 peflash = flash->TotalPE();
585 xyzt.push_back(rflash.X());
586 xyzt.push_back(rflash.Y());
587 xyzt.push_back(rflash.Z());
588 xyzt.push_back(tflash);
590 matchtpc = flashList.first;
592 vector<art::Ptr<recob::OpHit>> hits = findManyHits.at(iflash);
593 for(
auto const&
hit : hits) {
595 if( tPmt < flashHitT) {
597 flashHitPE =
hit->PE();
602 flashHitxyzt.clear();
603 for(
int i=0; i<3; i++) flashHitxyzt.push_back(pos[i]);
604 flashHitxyzt.push_back(flashHitT);
607 TVector3 rflashHit(pos[0],pos[1],pos[2]);
608 TVector3 vdiffHit = rcrt-rflashHit;
609 flashHitDiff = vdiffHit.Mag();
618 for(
int i=0; i<4; i++) xyzt.push_back(DBL_MAX);
640 for(
auto const&
hit : opHitList) {
655 TVector3 rhit (pos[0],pos[1],pos[2]);
656 TVector3 vdiff = rcrt-rhit;
665 for(
int i=0; i<3; i++) xyzt.push_back(pos[i]);
666 xyzt.push_back(thit);
677 for(
int i=0; i<4; i++) xyzt.push_back(DBL_MAX);
unsigned int GetClosestOpDet(geo::Point_t const &point) const
vector< double > fDistHit
vector< vector< double > > fPMTXYZT
Geometry information for a single TPC.
vector< double > fTrueDist
vector< vector< double > > fCrtXYZErr
art::InputTag fCrtHitModuleLabel
Geometry information for a single cryostat.
vector< vector< double > > fHitXYZT
const double LAR_PROP_DELAY
int AuxDetRegionNameToNum(string reg)
vector< double > fTrueTOF
vector< bool > fTrackFilt
vector< double > fFlashPE
vector< double > fDistFlash
vector< double > fTofFlashHit
const OpDetGeo & OpDet(unsigned int iopdet) const
Return the iopdet'th optical detector in the cryostat.
vector< double > fTofPeFlash
map< int, art::InputTag > fFlashLabels
vector< double > fDistFlashHit
vector< double > fFlashMeanPE
bool HitCompare(const art::Ptr< CRTHit > &h1, const art::Ptr< CRTHit > &h2)
vector< vector< double > > fTofXYZTHit
art::InputTag fCrtTrackModuleLabel
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
vector< double > fTofFlash
vector< vector< double > > fCrtXYZT
vector< vector< double > > fEnterXYZT
vector< vector< double > > fTofXYZTFlashHit
vector< vector< double > > fFlashDelta
art::InputTag fOpHitModuleLabel
BEGIN_PROLOG opflashCryoW opflashCryoW triggerfilterBNB triggerfilterNuMI triggerfilterOffbeamBNB triggerfilterOffbeamNuMI triggerfilterUnknown roifinder roifinder2d gaushitTPCEE gaushitTPCWE purityana1 ophit
vector< vector< double > > fFlashXYZT
vector< double > fTofPeFlashHit
vector< double > fTofPeHit
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc'th TPC in the cryostat.
static double tdiff(const art::Timestamp &ts1, const art::Timestamp &ts2)
int TrueIdFromTotalEnergy(const art::Event &event, const CRTData &data)
vector< bool > fMatchFlash
geo::GeometryCore const * fGeometryService
pointer to Geometry provider
vector< double > fFlashRmsPE
OpDetGeo const & OpDetGeoFromOpChannel(unsigned int OpChannel) const
Returns the geo::OpDetGeo object for the given channel number.
vector< vector< double > > fTofXYZTFlash
bool ContainsPosition(geo::Point_t const &point, double wiggle=1.0) const
Returns whether this volume contains the specified point.
vector< int > fTofTpcFlash
BEGIN_PROLOG could also be cout