|
140 | 140 | #include "sbnanaobj/StandardRecord/Flat/FlatRecord.h" |
141 | 141 | #include "lardataobj/RawData/ExternalTrigger.h" |
142 | 142 | #include "lardataobj/RawData/TriggerData.h" |
| 143 | +#include "lardataobj/Simulation/AuxDetSimChannel.h" |
143 | 144 |
|
144 | 145 | // // CAFMaker |
145 | 146 | #include "sbncode/CAFMaker/AssociationUtil.h" |
@@ -287,6 +288,11 @@ class CAFMaker : public art::EDProducer { |
287 | 288 | std::vector<std::vector<geo::BoxBoundedGeo>> fTPCVolumes; |
288 | 289 | std::vector<geo::BoxBoundedGeo> fActiveVolumes; |
289 | 290 |
|
| 291 | + // CRT geometry info |
| 292 | + // |
| 293 | + // ICARUS |
| 294 | + std::map<std::pair<int, int>, int> fFEBChannel2AuxDetID; |
| 295 | + |
290 | 296 | // random number generator for fake reco |
291 | 297 | CLHEP::HepRandomEngine& fFakeRecoRandomEngine; |
292 | 298 |
|
@@ -315,6 +321,7 @@ class CAFMaker : public art::EDProducer { |
315 | 321 | double GetBlindPOTScale() const; |
316 | 322 |
|
317 | 323 | void InitVolumes(); ///< Initialize volumes from Gemotry service |
| 324 | + void InitCRTMapping(); ///< Initialize CRT mapping |
318 | 325 |
|
319 | 326 | void FixPMTReferenceTimes(StandardRecord &rec, double PMT_reference_time); |
320 | 327 | void FixCRTReferenceTimes(StandardRecord &rec, double CRTT0_reference_time, double CRTT1_reference_time); |
@@ -423,6 +430,9 @@ class CAFMaker : public art::EDProducer { |
423 | 430 | // setup volume definitions |
424 | 431 | InitVolumes(); |
425 | 432 |
|
| 433 | + // setup CRT mapping |
| 434 | + InitCRTMapping(); |
| 435 | + |
426 | 436 | fSaveGENIEEventRecord = fParams.SaveGENIEEventRecord(); |
427 | 437 |
|
428 | 438 | } |
@@ -596,6 +606,36 @@ void CAFMaker::FixCRTReferenceTimes(StandardRecord &rec, double CRTT0_reference_ |
596 | 606 |
|
597 | 607 | } |
598 | 608 |
|
| 609 | +void CAFMaker::InitCRTMapping() { |
| 610 | + |
| 611 | + // ICARUS |
| 612 | + cet::search_path searchPath("FW_SEARCH_PATH"); |
| 613 | + std::string fullFileName; |
| 614 | + searchPath.find_file("feb_map.txt",fullFileName); |
| 615 | + std::ifstream fin; |
| 616 | + fin.open(fullFileName, std::ios::in); |
| 617 | + |
| 618 | + if (fin.good()) { |
| 619 | + std::string line; |
| 620 | + |
| 621 | + while(std::getline(fin,line)) { |
| 622 | + std::vector<std::string> row; |
| 623 | + std::string word; |
| 624 | + |
| 625 | + std::stringstream s(line); |
| 626 | + while (std::getline(s, word, ',')) { |
| 627 | + row.push_back(word); |
| 628 | + } |
| 629 | + int auxDetID = std::stoi(row[0]); // auxDetID |
| 630 | + int mac5 = std::stoi(row[1]); // FEB ID |
| 631 | + int chan = std::stoi(row[2]); // FEB channel |
| 632 | + fFEBChannel2AuxDetID[std::make_pair(mac5, chan)] = auxDetID; |
| 633 | + } |
| 634 | + |
| 635 | + fin.close(); |
| 636 | + } |
| 637 | +} |
| 638 | + |
599 | 639 | void CAFMaker::InitVolumes() { |
600 | 640 | const geo::GeometryCore *geometry = lar::providerFrom<geo::Geometry>(); |
601 | 641 |
|
@@ -1649,16 +1689,36 @@ void CAFMaker::produce(art::Event& evt) noexcept { |
1649 | 1689 | caf::SRSBNDFrameShiftInfo srsbndframeshiftinfo; |
1650 | 1690 | caf::SRSBNDTimingInfo srsbndtiminginfo; |
1651 | 1691 |
|
| 1692 | + // Mapping of (feb, channel) to truth information (AuxDetSimChannel) -- filled for ICARUS |
| 1693 | + std::map<std::pair<int, int>, sim::AuxDetSimChannel> crtsimchanmap; |
| 1694 | + |
1652 | 1695 | if(fDet == kICARUS) |
1653 | 1696 | { |
1654 | 1697 | art::Handle<std::vector<sbn::crt::CRTHit>> crthits_handle; |
1655 | 1698 | GetByLabelStrict(evt, fParams.CRTHitLabel(), crthits_handle); |
| 1699 | + |
| 1700 | + art::Handle<std::vector<sim::AuxDetSimChannel>> auxdetsimchan_handle; |
| 1701 | + GetByLabelStrict(evt, fParams.CRTSimChanLabel(), auxdetsimchan_handle); |
| 1702 | + |
1656 | 1703 | // fill into event |
1657 | 1704 | if (crthits_handle.isValid()) { |
1658 | 1705 | const std::vector<sbn::crt::CRTHit> &crthits = *crthits_handle; |
| 1706 | + |
| 1707 | + std::vector<sim::AuxDetSimChannel> empty; |
| 1708 | + const std::vector<sim::AuxDetSimChannel> &crtsimchanvec = (auxdetsimchan_handle.isValid()) ? *auxdetsimchan_handle : empty; |
| 1709 | + // Turn the AuxDetSimChannel's into a map that can be looked up from a CRT Hit |
| 1710 | + for (const sim::AuxDetSimChannel &crtsimchan: crtsimchanvec) { |
| 1711 | + for (auto const &map_pair: fFEBChannel2AuxDetID) { |
| 1712 | + if (map_pair.second == (int)crtsimchan.AuxDetID()) { |
| 1713 | + crtsimchanmap[map_pair.first] = crtsimchan; |
| 1714 | + break; |
| 1715 | + } |
| 1716 | + } |
| 1717 | + } |
| 1718 | + |
1659 | 1719 | for (unsigned i = 0; i < crthits.size(); i++) { |
1660 | 1720 | srcrthits.emplace_back(); |
1661 | | - FillCRTHit(crthits[i], fParams.CRTUseTS0(), CRT_T0_reference_time, CRT_T1_reference_time, srcrthits.back()); |
| 1721 | + FillCRTHit(crthits[i], fParams.CRTUseTS0(), CRT_T0_reference_time, CRT_T1_reference_time, crtsimchanmap, srcrthits.back()); |
1662 | 1722 | } |
1663 | 1723 | } |
1664 | 1724 |
|
@@ -2318,7 +2378,7 @@ void CAFMaker::produce(art::Event& evt) noexcept { |
2318 | 2378 | crthittagginginfo = fmCRTHitMatchInfo.at(iPart); |
2319 | 2379 | } |
2320 | 2380 |
|
2321 | | - FillTrackCRTHit(fmCRTHitMatch.at(iPart), crthitmatch, crthittagginginfo, fParams.CRTUseTS0(), CRT_T0_reference_time, CRT_T1_reference_time, trk); |
| 2381 | + FillTrackCRTHit(fmCRTHitMatch.at(iPart), crthitmatch, crthittagginginfo, fParams.CRTUseTS0(), CRT_T0_reference_time, CRT_T1_reference_time, crtsimchanmap, trk); |
2322 | 2382 | } |
2323 | 2383 | // NOTE: SEE TODO AT fmCRTTrackMatch |
2324 | 2384 | if (fmCRTTrackMatch.isValid() && fDet == kICARUS) { |
|
0 commit comments