-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement first-pass digi mixing for the tracker:
- extend Mu2eProductMixer to include digital data products - implement module for exclusively mixing in such products - propagate those products through to simulated StrawDigi creation - define structure for resolving situations where simulated digis overlap with preexisting digis in time (for now, just choosing the earliest)
- Loading branch information
1 parent
15c45d3
commit 13d5837
Showing
12 changed files
with
759 additions
and
7 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
CommonMC/src/ProtonBunchTimeMCFromProtonBunchTime_module.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Convert proton bunch time marker from data to MC data product | ||
// To be used for mixing simulated signal into real data from detector | ||
// | ||
// Ed Callaghan, 2024 | ||
|
||
// art | ||
#include <art/Framework/Core/EDProducer.h> | ||
#include <art/Framework/Principal/Event.h> | ||
|
||
// canvas | ||
#include <canvas/Utilities/InputTag.h> | ||
|
||
// fhiclcpp | ||
#include <fhiclcpp/types/Atom.h> | ||
|
||
// mu2e | ||
#include <Offline/MCDataProducts/inc/ProtonBunchTimeMC.hh> | ||
#include <Offline/RecoDataProducts/inc/ProtonBunchTime.hh> | ||
|
||
namespace mu2e{ | ||
class ProtonBunchTimeMCFromProtonBunchTime: public art::EDProducer{ | ||
public: | ||
struct Config{ | ||
fhicl::Atom<art::InputTag> pbttag{ | ||
fhicl::Name("PBTTag"), | ||
fhicl::Comment("ProtonBunchTime provenance"), | ||
"" // default, eventually to specify "from data" | ||
}; | ||
}; | ||
|
||
using Parameters = art::EDProducer::Table<Config>; | ||
explicit ProtonBunchTimeMCFromProtonBunchTime(Parameters const& config); | ||
protected: | ||
/**/ | ||
private: | ||
void produce(art::Event& event) override; | ||
art::InputTag pbttag_; | ||
}; | ||
|
||
ProtonBunchTimeMCFromProtonBunchTime::ProtonBunchTimeMCFromProtonBunchTime(Parameters const& config): EDProducer(config), pbttag_(config().pbttag()){ | ||
this->produces<ProtonBunchTimeMC>(); | ||
} | ||
|
||
void ProtonBunchTimeMCFromProtonBunchTime::produce(art::Event& event){ | ||
auto pbt = event.getHandle<ProtonBunchTime>(pbttag_); | ||
std::unique_ptr<ProtonBunchTimeMC> pbtmc(new ProtonBunchTimeMC); | ||
pbtmc->pbtime_ = pbt->pbtime_; | ||
event.put(std::move(pbtmc)); | ||
} | ||
} | ||
|
||
DEFINE_ART_MODULE(mu2e::ProtonBunchTimeMCFromProtonBunchTime); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
// Mix digi-level data products, as opposed to simulation-level data products, | ||
// into art events | ||
// | ||
// Ed Callaghan, 2023 | ||
|
||
// stl | ||
|
||
// art | ||
#include "art/Framework/Principal/Event.h" | ||
#include "art/Framework/Principal/SubRun.h" | ||
#include "art/Framework/IO/ProductMix/MixHelper.h" | ||
#include "art/Framework/Modules/MixFilter.h" | ||
#include "art_root_io/RootIOPolicy.h" | ||
#include "fhiclcpp/types/Atom.h" | ||
#include "fhiclcpp/types/Comment.h" | ||
#include "fhiclcpp/types/Name.h" | ||
#include "fhiclcpp/types/Sequence.h" | ||
#include "fhiclcpp/types/Table.h" | ||
#include "fhiclcpp/types/TupleAs.h" | ||
|
||
// cetlib_except | ||
#include "cetlib_except/exception.h" | ||
|
||
// mu2e | ||
#include "Offline/EventMixing/inc/Mu2eProductMixer.hh" | ||
|
||
namespace mu2e{ | ||
// detail class for art::MixFilter<> | ||
class MixDigisDetail{ | ||
public: | ||
struct Mu2eConfig{ | ||
// configuration is simple --- which data products to mix in | ||
fhicl::Table<Mu2eProductMixer::Config> products{ | ||
fhicl::Name("products"), | ||
fhicl::Comment("Products to be mixed, as form of a mixingMap, i.e. tuples of InputTags to output instance names.") | ||
|
||
}; | ||
}; | ||
|
||
struct Config{ | ||
fhicl::Table<Mu2eConfig> mu2e{ fhicl::Name("mu2e") }; | ||
}; | ||
|
||
using Parameters = art::MixFilterTable<Config>; | ||
explicit MixDigisDetail(const Parameters& parameters, | ||
art::MixHelper& helper); | ||
size_t nSecondaries(); | ||
|
||
void processEventIDs(const art::EventIDSequence& seq); | ||
void beginSubRun(const art::SubRun& subrun); | ||
void endSubRun(art::SubRun& subrun); | ||
void startEvent(const art::Event& event); | ||
void finalizeEvent(art::Event& event); | ||
|
||
protected: | ||
/**/ | ||
|
||
private: | ||
Mu2eProductMixer mixer; | ||
art::EventIDSequence evids; | ||
}; | ||
|
||
// implementation | ||
MixDigisDetail::MixDigisDetail(const Parameters& parameters, | ||
art::MixHelper& helper) | ||
: mixer{parameters().mu2e().products(), helper}{ | ||
helper.produces<art::EventIDSequence>(); | ||
} | ||
|
||
// always overlay simulated event onto one event window | ||
size_t MixDigisDetail::nSecondaries(){ | ||
size_t rv = 1; | ||
return rv; | ||
} | ||
|
||
// always keep track of secondary EventIDs | ||
void MixDigisDetail::processEventIDs(const art::EventIDSequence& seq){ | ||
// intent is to overlay signals onto a nominally-complete event, | ||
// so we should only mix in one event | ||
if (seq.size() != 1){ | ||
throw cet::exception("MIX") << "mu2e::DixDigisDetail: mixing more than one digi frame" << std::endl; | ||
} | ||
mixer.processEventIDs(seq); | ||
evids = seq; | ||
} | ||
|
||
// forward beginSubRun | ||
void MixDigisDetail::beginSubRun(const art::SubRun& subrun){ | ||
mixer.beginSubRun(subrun); | ||
} | ||
|
||
// forward endSubRun | ||
void MixDigisDetail::endSubRun(art::SubRun& subrun){ | ||
mixer.endSubRun(subrun); | ||
} | ||
|
||
// forward startEvent | ||
void MixDigisDetail::startEvent(const art::Event& event){ | ||
mixer.startEvent(event); | ||
} | ||
|
||
void MixDigisDetail::finalizeEvent(art::Event& event){ | ||
// "manually" mix in EventIDs, as these do not preexist as data products | ||
auto seq = std::make_unique<art::EventIDSequence>(); | ||
seq->swap(evids); | ||
event.put(std::move(seq)); | ||
} | ||
|
||
// define the module | ||
typedef art::MixFilter<MixDigisDetail,art::RootIOPolicy> MixDigis; | ||
} | ||
|
||
DEFINE_ART_MODULE(mu2e::MixDigis); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Bundle together references to various StrawDigi products, to circumvent | ||
// triplicated-loops which pop up when iterating over digis | ||
// | ||
// Ed Callaghan, 2023 | ||
|
||
#ifndef TrackerMC_StrawDigiBundle_hh | ||
#define TrackerMC_StrawDigiBundle_hh | ||
|
||
// mu2e | ||
#include <Offline/RecoDataProducts/inc/StrawDigi.hh> | ||
#include <Offline/MCDataProducts/inc/StrawDigiMC.hh> | ||
|
||
namespace mu2e{ | ||
class StrawDigiBundle{ | ||
public: | ||
StrawDigiBundle(const StrawDigi digi, const StrawDigiADCWaveform adcs, const StrawDigiMC mc); | ||
StrawDigiBundle(const StrawDigi digi, const StrawDigiADCWaveform adcs); | ||
StrawDigiBundle(const StrawDigiBundle& bundle); | ||
|
||
const StrawDigi GetStrawDigi() const; | ||
const StrawDigiADCWaveform GetStrawDigiADCWaveform() const; | ||
const StrawDigiMC GetStrawDigiMC() const; | ||
|
||
// interface for sorting into buckets of overlapping digitization windows | ||
const double time() const; | ||
protected: | ||
const StrawDigi digi; | ||
const StrawDigiADCWaveform adcs; | ||
const StrawDigiMC mc; | ||
private: | ||
/**/ | ||
}; | ||
} | ||
|
||
#endif |
Oops, something went wrong.