diff --git a/Blinding/src/SConscript b/Blinding/src/SConscript index 4e950d9fbf..0ac5017312 100644 --- a/Blinding/src/SConscript +++ b/Blinding/src/SConscript @@ -8,6 +8,8 @@ Import('mu2e_helper') helper = mu2e_helper(env) mainlib = helper.make_mainlib([ + 'gmp', + 'gmpxx', ]) helper.make_plugins([ @@ -17,11 +19,21 @@ helper.make_plugins([ 'art_Framework_Principal', 'art_Persistency_Provenance', 'art_Utilities', + 'boost_math_tr1', 'canvas', 'cetlib', 'cetlib_except', + 'CLHEP', 'fhiclcpp', 'fhiclcpp_types', + 'gmp', + 'gmpxx', + 'KinKal_Trajectory', + 'mu2e_DataProducts', + 'mu2e_DbTables', + 'mu2e_ProditionsService', + 'mu2e_RecoDataProducts', + 'mu2e_SeedService', 'mu2e_DataProducts', 'mu2e_DbTables', 'mu2e_TrackerConditions', diff --git a/Blinding/src/TrackDigiExtractor_module.cc b/Blinding/src/TrackDigiExtractor_module.cc new file mode 100644 index 0000000000..8c2afe39ff --- /dev/null +++ b/Blinding/src/TrackDigiExtractor_module.cc @@ -0,0 +1,122 @@ +// Ed Callaghan +// Extract digis which participate in a prefit track +// September 2024 + +// stl +#include + +// art +#include "art/Framework/Core/EDProducer.h" +#include "art/Framework/Principal/Event.h" + +// cetlib_except +#include "cetlib_except/exception.h" + +// fhiclcpp +#include "fhiclcpp/types/Atom.h" +#include "fhiclcpp/types/Comment.h" +#include "fhiclcpp/types/Name.h" + +// mu2e +#include "Offline/RecoDataProducts/inc/KalSeed.hh" +#include "Offline/RecoDataProducts/inc/StrawHit.hh" +#include "Offline/RecoDataProducts/inc/StrawDigi.hh" +#include "Offline/RecoDataProducts/inc/TrkStrawHitSeed.hh" + +namespace mu2e{ + class TrackDigiExtractor: public art::EDProducer{ + public: + struct Config{ + // track + fhicl::Atom kalseed_tag{ + fhicl::Name("KalSeedCollection"), + fhicl::Comment("art::InputTag of KalSeeds to extract digis from") + }; + + // tracker + fhicl::Atom strawhit_tag{ + fhicl::Name("StrawHitCollection"), + fhicl::Comment("art::InputTag of StrawHits associated with KalSeed") + }; + fhicl::Atom strawdigi_tag{ + fhicl::Name("StrawDigiCollection"), + fhicl::Comment("art::InputTag of StrawDigis associated with StrawHits") + }; + + // calorimeter... + }; + + using Parameters = art::EDProducer::Table; + TrackDigiExtractor(const Parameters&); + + protected: + art::InputTag _kalseed_tag; + art::InputTag _strawhit_tag; + art::InputTag _strawdigi_tag; + + private: + void produce(art::Event&); + }; + + TrackDigiExtractor::TrackDigiExtractor(const Parameters& config): + art::EDProducer(config), + _kalseed_tag(config().kalseed_tag()), + _strawhit_tag(config().strawhit_tag()), + _strawdigi_tag(config().strawdigi_tag()){ + this->consumes(_kalseed_tag); + this->consumes(_strawhit_tag); + this->consumes(_strawdigi_tag); + this->consumes(_strawdigi_tag); + this->produces(); + this->produces(); + } + + void TrackDigiExtractor::produce(art::Event& event){ + // data-product lookups + auto kalseeds = event.getValidHandle(_kalseed_tag); + auto strawhits = event.getValidHandle(_strawhit_tag); + auto strawdigis = event.getValidHandle(_strawdigi_tag); + auto strawadcss = event.getValidHandle(_strawdigi_tag); + + // sanity checks + if (strawhits->size() != strawdigis->size()){ + std::string msg = "mismatched StrawHit and StrawDigi collection lengths"; + throw cet::exception("TrackDigiExtractor") << msg << std::endl; + } + if (strawdigis->size() != strawadcss->size()){ + std::string msg = "mismatched StrawDigi and StrawDigiADCWaveform collection lengths"; + throw cet::exception("TrackDigiExtractor") << msg << std::endl; + } + + // deep-copy digis underlying tracks + auto ext_strawdigis = std::make_unique(); + auto ext_strawadcss = std::make_unique(); + for (const auto& kalseed: *kalseeds){ + // tracker + auto seeds = kalseed.hits(); + for (const auto& seed: seeds){ + auto idx = seed.index(); + auto hit = (*strawhits)[idx]; + auto digi = (*strawdigis)[idx]; + auto adcs = (*strawadcss)[idx]; + + // sanity check + if (hit.strawId() != digi.strawId()){ + std::string msg = "mismatched StrawHit and StrawDigi StrawIDs"; + throw cet::exception("TrackDigiExtractor") << msg << std::endl; + } + + ext_strawdigis->push_back(digi); + ext_strawadcss->push_back(adcs); + } + + // calorimeter... + } + + // place into event + event.put(std::move(ext_strawdigis)); + event.put(std::move(ext_strawadcss)); + } +} // namespace mu2e + +DEFINE_ART_MODULE(mu2e::TrackDigiExtractor)