16 #include "art_root_io/RootIOPolicy.h" 33 #include <unordered_map> 60 #include "TTreeReader.h" 97 std::vector< T > & output,
101 std::vector<raw::RawDigit> & output,
237 std::stringstream err_str;
238 err_str <<
"ERROR! Really sorry, but we can only do mixing for one collection right now! ";
239 err_str <<
"\nYep. We're gonna throw an exception now. You should change your fcl to set 'EventsToMix' to 1";
267 &OverlayRawDataDetailDUNE35t::MixSimpleCopy<simb::MCTruth>,
273 &OverlayRawDataDetailDUNE35t::MixSimpleCopy<simb::MCParticle>,
281 &OverlayRawDataDetailDUNE35t::MixSimpleCopy<sim::SimChannel>,
285 &OverlayRawDataDetailDUNE35t::MixSimpleCopy<sim::AuxDetSimChannel>,
290 &OverlayRawDataDetailDUNE35t::MixSimpleCopy<raw::ExternalTrigger>,
295 &OverlayRawDataDetailDUNE35t::MixSimpleCopy<raw::RawDigit>,
312 &OverlayRawDataDetailDUNE35t::MixSimpleCopy<raw::RawDigit>,
329 helper.
produces< std::vector<dunemix::EventMixingSummary> >();
348 const char*
c =
getenv(
"SAM_STATION");
349 if(c == 0 || *c == 0)
360 throw cet::exception(
"OverlayRawDataDUNE35t") <<
"Failed to find project uri.";
365 gethostname(hostname,
sizeof hostname);
372 const char*
c =
getenv(
"SAM_USER");
373 if(c == 0 || *c == 0)
375 if(c != 0 && *c != 0)
382 std::cout <<
"Mix SAM: fSamProjectURI = " <<
fSamProjectURI <<
"\n" 383 <<
"Mix SAM: fSamAppName = " <<
fSamAppName <<
"\n" 385 <<
"Mix SAM: hostname = " << hostname <<
"\n" 386 <<
"Mix SAM: fSamUser = " <<
fSamUser <<
"\n" 390 <<
"Mix SAM: fSamSchema = " <<
fSamSchema <<
"\n";
406 throw cet::exception(
"OverlayRawDataDUNE35t") <<
"Failed to start sam process.";
432 std::cout <<
"Mix SAM: End process." <<
std::endl;
440 throw cet::exception(
"OverlayRawDataDUNE35t") <<
"Input file claimed to be data/not data, but it's not." <<
std::endl; ;
469 for (
auto const&
id : seq)
481 std::vector< T > & output,
496 std::map<raw::ChannelID_t,double> channelgains;
501 if (gainsfile && !gainsfile->IsZombie())
503 TTreeReader reader(
"channelgains",gainsfile);
504 TTreeReaderValue<Double_t> changain(reader,
"changain");
505 TTreeReaderValue<Int_t>
channel(reader,
"channel");
506 TTreeReaderValue<Double_t> datampverr(reader,
"datampverr");
507 TTreeReaderValue<Double_t> datawidtherr(reader,
"datawidtherr");
508 TTreeReaderValue<Double_t> simmpverr(reader,
"simmpverr");
509 TTreeReaderValue<Double_t> simwidtherr(reader,
"simwidtherr");
510 while (reader.Next())
514 if (*datampverr < 200 && *datawidtherr < 400 && *simmpverr < 200 && *simwidtherr < 400)
522 channelgains[chanid] = gain;
528 std::cout <<
"Can't open gains file, setting channelgains all equal to 1" <<
std::endl;
531 channelgains[chan] = 1.0;
542 for(
auto const&
d : dataDigitVector) {
543 if(chanStatus.
IsBad(
d.Channel()))
548 else if (channelgains.find(
d.Channel()) == channelgains.end())
562 std::vector<raw::RawDigit> & output,
567 std::stringstream err_str;
568 err_str <<
"ERROR! We have the wrong number of collections of raw digits we are adding! " <<
inputs.size();
569 throw std::runtime_error(err_str.str());
575 for(
auto const& icol :
inputs)
701 throw cet::exception(
"OverlayRawDataDUNE35t") <<
"Failed to get next mix file.";
bool fForceStuckBitRetention
virtual bool IsBad(raw::ChannelID_t channel) const =0
Returns whether the specified channel is bad in the current run.
void registerSecondaryFileNameProvider(ProviderFunc_ func)
~OverlayRawDataDetailDUNE35t()
std::vector< EventID > EventIDSequence
fhicl::ParameterSet fpset
std::string fGeneratorInputModuleLabel
std::string fRawDigitMCModuleLabel
std::string fSamAppVersion
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::string fSamProjectURI
std::string fMCRecoInputModuleLabel
void FillRawDigitOutput(std::vector< raw::RawDigit > &output)
const std::string instance
Definition of basic mixing information.
Definition of basic raw digits.
void startEvent(const art::Event &)
std::string fSamCurrentFileURI
Mixer function for putting together two raw digit collections.
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
short fDefaultRawDigitSatPoint
std::string fChannelGainFile
void produces(std::string const &instanceName={})
std::string fRawDigitDataModuleLabel
art::Handle< std::vector< raw::RawDigit > > inputDigitHandle
std::string fSamProcessID
void SetMCMixTicks(size_t start, size_t end)
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
void processEventIDs(art::EventIDSequence const &seq)
void flattenCollections(std::vector< COLLECTION const * > const &in, COLLECTION &out)
contains objects relating to OpDet hits
object containing MC truth information necessary for making RawDigits and doing back tracking ...
#define DEFINE_ART_MODULE(klass)
void declareMixOp(InputTag const &inputTag, MixFunc< PROD, OPROD > mixFunc, bool outputProduct=true)
std::string fSamCurrentFileName
std::string getenv(std::string const &name)
T get(std::string const &key) const
std::string fTriggerInputModuleLabel
bool get_if_present(std::string const &key, T &value) const
Class providing information about the quality of channels.
void SetStuckBitRetentionMethod(bool b)
Class def header for mctrack data container.
Definition of data types for geometry description.
std::string fSamDescription
bool MixSimpleCopy(std::vector< std::vector< T > const * > const &inputs, std::vector< T > &output, art::PtrRemapper const &)
std::unique_ptr< std::vector< dunemix::EventMixingSummary > > fEventMixingSummary
bool MixRawDigits(std::vector< std::vector< raw::RawDigit > const * > const &inputs, std::vector< raw::RawDigit > &output, art::PtrRemapper const &)
std::string fSamAppFamily
std::string fG4InputModuleLabel
void Mix(std::vector< raw::RawDigit > const &mcVector, std::unordered_map< raw::ChannelID_t, float > const &map)
object containing MC truth information necessary for making RawDigits and doing back tracking ...
Interface for experiment-specific channel quality info provider.
Class def header for MCShower data container.
void DeclareData(std::vector< raw::RawDigit > const &dataVector)
std::string fRawDigitMixerSourceModuleLabel
std::unordered_map< raw::ChannelID_t, float > fMCRawDigitScaleMap
float fDefaultMCRawDigitScale
unsigned int ChannelID_t
Type representing the ID of a readout channel.
auto const & get(AssnsNode< L, R, D > const &r)
Interface for experiment-specific service for channel quality info.
void GenerateMCRawDigitScaleMap(std::vector< raw::RawDigit > const &)
void SetDataMixTicks(size_t start, size_t end)
constexpr bool noncopyable()
OverlayRawDataDetailDUNE35t(fhicl::ParameterSet const &p, art::MixHelper &helper)
art::MixFilter< OverlayRawDataDetailDUNE35t, art::RootIOPolicy > OverlayRawDataDUNE35t
std::string fRawDigitInputSourceModuleLabel
void finalizeEvent(art::Event &)
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
Event finding and building.
Signal from collection planes.