|
141 | 141 | #include "sbnanaobj/StandardRecord/Flat/FlatRecord.h" |
142 | 142 | #include "lardataobj/RawData/ExternalTrigger.h" |
143 | 143 | #include "lardataobj/RawData/TriggerData.h" |
| 144 | +#include "lardataobj/Simulation/AuxDetSimChannel.h" |
144 | 145 |
|
145 | 146 | // // CAFMaker |
146 | 147 | #include "sbncode/CAFMaker/AssociationUtil.h" |
@@ -288,6 +289,11 @@ class CAFMaker : public art::EDProducer { |
288 | 289 | std::vector<std::vector<geo::BoxBoundedGeo>> fTPCVolumes; |
289 | 290 | std::vector<geo::BoxBoundedGeo> fActiveVolumes; |
290 | 291 |
|
| 292 | + // CRT geometry info |
| 293 | + // |
| 294 | + // ICARUS |
| 295 | + std::map<std::pair<int, int>, int> fFEBChannel2AuxDetID; |
| 296 | + |
291 | 297 | // random number generator for fake reco |
292 | 298 | CLHEP::HepRandomEngine& fFakeRecoRandomEngine; |
293 | 299 |
|
@@ -316,6 +322,7 @@ class CAFMaker : public art::EDProducer { |
316 | 322 | double GetBlindPOTScale() const; |
317 | 323 |
|
318 | 324 | void InitVolumes(); ///< Initialize volumes from Gemotry service |
| 325 | + void InitCRTMapping(); ///< Initialize CRT mapping |
319 | 326 |
|
320 | 327 | void FixPMTReferenceTimes(StandardRecord &rec, double PMT_reference_time); |
321 | 328 | void FixCRTReferenceTimes(StandardRecord &rec, double CRTT0_reference_time, double CRTT1_reference_time); |
@@ -424,6 +431,9 @@ class CAFMaker : public art::EDProducer { |
424 | 431 | // setup volume definitions |
425 | 432 | InitVolumes(); |
426 | 433 |
|
| 434 | + // setup CRT mapping |
| 435 | + InitCRTMapping(); |
| 436 | + |
427 | 437 | fSaveGENIEEventRecord = fParams.SaveGENIEEventRecord(); |
428 | 438 |
|
429 | 439 | } |
@@ -597,6 +607,36 @@ void CAFMaker::FixCRTReferenceTimes(StandardRecord &rec, double CRTT0_reference_ |
597 | 607 |
|
598 | 608 | } |
599 | 609 |
|
| 610 | +void CAFMaker::InitCRTMapping() { |
| 611 | + |
| 612 | + // ICARUS |
| 613 | + cet::search_path searchPath("FW_SEARCH_PATH"); |
| 614 | + std::string fullFileName; |
| 615 | + searchPath.find_file("feb_map.txt",fullFileName); |
| 616 | + std::ifstream fin; |
| 617 | + fin.open(fullFileName, std::ios::in); |
| 618 | + |
| 619 | + if (fin.good()) { |
| 620 | + std::string line; |
| 621 | + |
| 622 | + while(std::getline(fin,line)) { |
| 623 | + std::vector<std::string> row; |
| 624 | + std::string word; |
| 625 | + |
| 626 | + std::stringstream s(line); |
| 627 | + while (std::getline(s, word, ',')) { |
| 628 | + row.push_back(word); |
| 629 | + } |
| 630 | + int auxDetID = std::stoi(row[0]); // auxDetID |
| 631 | + int mac5 = std::stoi(row[1]); // FEB ID |
| 632 | + int chan = std::stoi(row[2]); // FEB channel |
| 633 | + fFEBChannel2AuxDetID[std::make_pair(mac5, chan)] = auxDetID; |
| 634 | + } |
| 635 | + |
| 636 | + fin.close(); |
| 637 | + } |
| 638 | +} |
| 639 | + |
600 | 640 | void CAFMaker::InitVolumes() { |
601 | 641 | const geo::GeometryCore *geometry = lar::providerFrom<geo::Geometry>(); |
602 | 642 |
|
@@ -1676,16 +1716,36 @@ void CAFMaker::produce(art::Event& evt) noexcept { |
1676 | 1716 | caf::SRSBNDFrameShiftInfo srsbndframeshiftinfo; |
1677 | 1717 | caf::SRSBNDTimingInfo srsbndtiminginfo; |
1678 | 1718 |
|
| 1719 | + // Mapping of (feb, channel) to truth information (AuxDetSimChannel) -- filled for ICARUS |
| 1720 | + std::map<std::pair<int, int>, sim::AuxDetSimChannel> crtsimchanmap; |
| 1721 | + |
1679 | 1722 | if(fDet == kICARUS) |
1680 | 1723 | { |
1681 | 1724 | art::Handle<std::vector<sbn::crt::CRTHit>> crthits_handle; |
1682 | 1725 | GetByLabelStrict(evt, fParams.CRTHitLabel(), crthits_handle); |
| 1726 | + |
| 1727 | + art::Handle<std::vector<sim::AuxDetSimChannel>> auxdetsimchan_handle; |
| 1728 | + GetByLabelStrict(evt, fParams.CRTSimChanLabel(), auxdetsimchan_handle); |
| 1729 | + |
1683 | 1730 | // fill into event |
1684 | 1731 | if (crthits_handle.isValid()) { |
1685 | 1732 | const std::vector<sbn::crt::CRTHit> &crthits = *crthits_handle; |
| 1733 | + |
| 1734 | + std::vector<sim::AuxDetSimChannel> empty; |
| 1735 | + const std::vector<sim::AuxDetSimChannel> &crtsimchanvec = (auxdetsimchan_handle.isValid()) ? *auxdetsimchan_handle : empty; |
| 1736 | + // Turn the AuxDetSimChannel's into a map that can be looked up from a CRT Hit |
| 1737 | + for (const sim::AuxDetSimChannel &crtsimchan: crtsimchanvec) { |
| 1738 | + for (auto const &map_pair: fFEBChannel2AuxDetID) { |
| 1739 | + if (map_pair.second == (int)crtsimchan.AuxDetID()) { |
| 1740 | + crtsimchanmap[map_pair.first] = crtsimchan; |
| 1741 | + break; |
| 1742 | + } |
| 1743 | + } |
| 1744 | + } |
| 1745 | + |
1686 | 1746 | for (unsigned i = 0; i < crthits.size(); i++) { |
1687 | 1747 | srcrthits.emplace_back(); |
1688 | | - FillCRTHit(crthits[i], fParams.CRTUseTS0(), CRT_T0_reference_time, CRT_T1_reference_time, srcrthits.back()); |
| 1748 | + FillCRTHit(crthits[i], fParams.CRTUseTS0(), CRT_T0_reference_time, CRT_T1_reference_time, crtsimchanmap, srcrthits.back()); |
1689 | 1749 | } |
1690 | 1750 | } |
1691 | 1751 |
|
@@ -2383,7 +2443,7 @@ void CAFMaker::produce(art::Event& evt) noexcept { |
2383 | 2443 | crthittagginginfo = fmCRTHitMatchInfo.at(iPart); |
2384 | 2444 | } |
2385 | 2445 |
|
2386 | | - FillTrackCRTHit(fmCRTHitMatch.at(iPart), crthitmatch, crthittagginginfo, fParams.CRTUseTS0(), CRT_T0_reference_time, CRT_T1_reference_time, trk); |
| 2446 | + FillTrackCRTHit(fmCRTHitMatch.at(iPart), crthitmatch, crthittagginginfo, fParams.CRTUseTS0(), CRT_T0_reference_time, CRT_T1_reference_time, crtsimchanmap, trk); |
2387 | 2447 | } |
2388 | 2448 | // NOTE: SEE TODO AT fmCRTTrackMatch |
2389 | 2449 | if (fmCRTTrackMatch.isValid() && fDet == kICARUS) { |
|
0 commit comments