OverlayRawDataDUNE35t_module.cc
Go to the documentation of this file.
1 /////////////////////////////////////////////////////////////////////////
2 // Class: OverlayRawDataDetailDUNE35t
3 // Module Type: producer
4 // File: OverlayRawDataDetailDUNE35t_module.cc
5 //
6 // This borrows a lot from the microboone mixing module:
7 // OverlayRawDataMicroBooNE_module.cc
8 ////////////////////////////////////////////////////////////////////////
9 
10 /*
11 
12  TODO: Implement mixing for OpDetWaveforms in 35t (I have no idea how). What about AuxDet stuff???
13 
14  */
15 
16 #include "art_root_io/RootIOPolicy.h"
26 #include "fhiclcpp/ParameterSet.h"
28 #include "IFDH_service.h"
29 
30 #include <memory>
31 #include <string>
32 #include <vector>
33 #include <unordered_map>
34 #include <exception>
35 #include <sstream>
36 #include <unistd.h>
37 
40 
43 
46 
50 
53 
58 
59 #include "TFile.h"
60 #include "TTreeReader.h"
61 
62 //#include "DataOverlay/OpDetWaveformMixer.h"
63 //#include "lardataobj/RawData/OpDetWaveform.h"
64 
66 
67 namespace mix {
70 }
71 
73 public:
74 
76  art::MixHelper &helper);
78 
79  void startEvent(const art::Event&); //called at the start of every event
80  void finalizeEvent(art::Event &); //called at the end of every event
81 
82  size_t nSecondaries() {
83  return fEventsToMix;
84  }
85 
86  void processEventIDs(art::EventIDSequence const& seq); //bookkepping for event IDs
87 
88  // Mixing Functions
89 
90  // For now, allow exactly one input. Assume MC inputs have been merged
91  // previously and one detsim output created if needed. This could be changed
92  // but would require mixing functions for MC here.
93 
94  //a lot of MC collections are just simple copies of the collections...
95  template<typename T>
96  bool MixSimpleCopy( std::vector< std::vector<T> const*> const& inputs,
97  std::vector< T > & output,
98  art::PtrRemapper const &);
99 
100  bool MixRawDigits( std::vector< std::vector<raw::RawDigit> const* > const& inputs,
101  std::vector<raw::RawDigit> & output,
102  art::PtrRemapper const &);
103 
104  //bool MixOpDetWaveforms_HighGain( std::vector< std::vector<raw::OpDetWaveform> const* > const& inputs,
105  // std::vector<raw::OpDetWaveform> & output,
106  // art::PtrRemapper const &);
107  //bool MixOpDetWaveforms_LowGain( std::vector< std::vector<raw::OpDetWaveform> const* > const& inputs,
108  // std::vector<raw::OpDetWaveform> & output,
109  // art::PtrRemapper const &);
110 
111  // Choose mix file.
112 
114 
115 
116 private:
117 
118  // Declare member data here.
120  //OpDetWaveformMixer fODMixer;
121 
124  //short fDefaultOpDetSatPoint;
125  //size_t fOpDetMinSampleSize;
127 
129  //std::string fOpDetDataModuleLabel;
131  //std::string fOpDetMCModuleLabel;
132 
134  //std::string fOpDetInputSourceModuleLabel;
136  //std::string fOpDetMixerSourceModuleLabel;
137 
141 
142  bool fDoMCReco;
144 
145  size_t fEventsToMix;
147  //float fDefaultMCOpDetScale;
148 
154 
165 
170 
172 
174  //art::Handle< std::vector<raw::OpDetWaveform> > inputOpDetHandle_HighGain;
175  //art::Handle< std::vector<raw::OpDetWaveform> > inputOpDetHandle_LowGain;
176 
177  void GenerateMCRawDigitScaleMap(std::vector<raw::RawDigit> const&);
178  std::unordered_map<raw::ChannelID_t,float> fMCRawDigitScaleMap;
179 
180  //void GenerateMCOpDetHighGainScaleMap(std::vector<raw::OpDetWaveform> const&);
181  //std::unordered_map<raw::Channel_t,float> fMCOpDetHighGainScaleMap;
182 
183  //void GenerateMCOpDetLowGainScaleMap(std::vector<raw::OpDetWaveform> const&);
184  //std::unordered_map<raw::Channel_t,float> fMCOpDetLowGainScaleMap;
185 
186  std::unique_ptr< std::vector<dunemix::EventMixingSummary> > fEventMixingSummary;
187 
188 };
189 
190 
192  art::MixHelper &helper)
193  :
194  fRDMixer(false), //print warnings turned off
195  //fODMixer(false), //print warnings turned off
196  fpset(p.get<fhicl::ParameterSet>("detail")),
197  fDefaultRawDigitSatPoint(fpset.get<short>("DefaultRawDigitSaturationPoint",4096)),
198  //fDefaultOpDetSatPoint(fpset.get<short>("DefaultOpDetSaturationPoint",4096)),
199  //fOpDetMinSampleSize(fpset.get<size_t>("OpDetMinSampleSize",100)),
200  fInputFileIsData(fpset.get<bool>("InputFileIsData")),
201  fRawDigitDataModuleLabel(fpset.get<std::string>("RawDigitDataModuleLabel")),
202  //fOpDetDataModuleLabel(fpset.get<std::string>("OpDetMCModuleLabel")),
203  fRawDigitMCModuleLabel(fpset.get<std::string>("RawDigitMCModuleLabel")),
204  //fOpDetMCModuleLabel(fpset.get<std::string>("OpDetMCModuleLabel")),
205  fEventsToMix(fpset.get<size_t>("EventsToMix",1)),
206  fDefaultMCRawDigitScale(fpset.get<float>("DefaultMCRawDigitScale",1)),
207  //fDefaultMCOpDetScale(fpset.get<float>("DefaultMCOpDetScale",1)),
208 
209  fForceStuckBitRetention(fpset.get<bool>("ForceStuckBitRetention",false)),
210  fDataMixStartTick(fpset.get<size_t>("DataMixStartTick",9800)),
211  fDataMixEndTick(fpset.get<size_t>("DataMixEndTick",15000)),
212  fMCMixStartTick(fpset.get<size_t>("MCMixStartTick",0)),
213  fMCMixEndTick(fpset.get<size_t>("MCMixEndTick",5200)),
214 
215 // Get sam related parameters.
216 // These parameters should normally be set by the work flow.
217 // Usually, the only ones that should need to be set are "SamDefname" and "SamProject."
218 
219  fSamDefname(fpset.get<std::string>("SamDefname", "")),
220  fSamProject(fpset.get<std::string>("SamProject", "")),
221  fSamStation(fpset.get<std::string>("SamStation", "")),
222  fSamAppFamily(fpset.get<std::string>("SamAppFamily", "art")),
223  fSamAppName(fpset.get<std::string>("SamAppName", "mix")),
224  fSamAppVersion(fpset.get<std::string>("SamAppVersion", "1")),
225  fSamUser(fpset.get<std::string>("SamUser", "")),
226  fSamDescription(fpset.get<std::string>("SamDescription", "")),
227  fSamFileLimit(fpset.get<int>("SamFileLimit", 100)),
228  fSamSchema(fpset.get<std::string>("SamSchema", "root")), // xrootd by default.
229 
230  // if desired, give a path to a root file containing a ttree described below in the function
231  fChannelGainFile(fpset.get<std::string>("ChannelGainFile","")),
232 
233  fEventMixingSummary(nullptr)
234 {
235 
236  if(fEventsToMix!=1) {
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";
240  throw cet::exception("OverlayRawDataDUNE35t") << err_str.str() << std::endl;
241  }
242 
243  if(fInputFileIsData) {
245  //fOpDetInputSourceModuleLabel = fOpDetDataModuleLabel;
247  //fOpDetMixerSourceModuleLabel = fOpDetMCModuleLabel;
248  }
249  else if(!fInputFileIsData) {
251  //fOpDetInputSourceModuleLabel = fOpDetMCModuleLabel;
253  //fOpDetMixerSourceModuleLabel = fOpDetDataModuleLabel;
254  }
255 
256  if(fInputFileIsData) {
258  fG4InputModuleLabel = fpset.get<std::string>("G4InputModuleLabel");
259  fGeneratorInputModuleLabel = fpset.get<std::string>("GeneratorInputModuleLabel");
260  fTriggerInputModuleLabel = fpset.get<std::string>("TriggerInputModuleLabel");
261 
262  std::string instance = "MC";
263 
264  //MC generator info is a simple copy
265  helper.declareMixOp( art::InputTag(fGeneratorInputModuleLabel),
266  instance,
267  &OverlayRawDataDetailDUNE35t::MixSimpleCopy<simb::MCTruth>,
268  *this );
269 
270  //Simple copies of G4 SimPhotons, MCParticles, SimChannels, and SimAuxDetChannel
271  helper.declareMixOp( art::InputTag(fG4InputModuleLabel),
272  instance,
273  &OverlayRawDataDetailDUNE35t::MixSimpleCopy<simb::MCParticle>,
274  *this );
275  //helper.declareMixOp( art::InputTag(fG4InputModuleLabel),
276  // instance,
277  // &OverlayRawDataDetailDUNE35t::MixSimpleCopy<sim::SimPhotons>,
278  // *this );
279  helper.declareMixOp( art::InputTag(fG4InputModuleLabel),
280  instance,
281  &OverlayRawDataDetailDUNE35t::MixSimpleCopy<sim::SimChannel>,
282  *this );
283  helper.declareMixOp( art::InputTag(fG4InputModuleLabel),
284  instance,
285  &OverlayRawDataDetailDUNE35t::MixSimpleCopy<sim::AuxDetSimChannel>,
286  *this );
287 
288  helper.declareMixOp( art::InputTag(fTriggerInputModuleLabel),
289  instance,
290  &OverlayRawDataDetailDUNE35t::MixSimpleCopy<raw::ExternalTrigger>,
291  *this );
292 
294  instance,
295  &OverlayRawDataDetailDUNE35t::MixSimpleCopy<raw::RawDigit>,
296  *this );
297 
298  /*
299  //Associations of MCParticles to MCTruth...hopefully a simple copy is enough
300  helper.declareMixOp( art::InputTag(fG4InputModuleLabel),
301  &OverlayRawDataDetailDUNE35t::MixSimpleCopy
302  < art::Assns<simb::MCTruth,simb::MCParticle,void> >,
303  *this );
304  */
305 
306  } //end if file is input data
307 
308  if (!fInputFileIsData)
309  {
311  "DATA",
312  &OverlayRawDataDetailDUNE35t::MixSimpleCopy<raw::RawDigit>,
313  *this );
314  }
315 
317  "MIXED",
319  *this );
320 
321  //helper.declareMixOp( art::InputTag(fOpDetMixerSourceModuleLabel,"OpdetBeamHighGain"),
322  // &OverlayRawDataDetailDUNE35t::MixOpDetWaveforms_HighGain,
323  // *this );
324  //helper.declareMixOp( art::InputTag(fOpDetMixerSourceModuleLabel,"OpdetBeamLowGain"),
325  // &OverlayRawDataDetailDUNE35t::MixOpDetWaveforms_LowGain,
326  // *this );
327 
328  //If it produces something on its own, declare it here
329  helper.produces< std::vector<dunemix::EventMixingSummary> >();
330 
331  // Following block handles case of mix input from sam.
332 
333  if(!fSamDefname.empty()) {
334 
335  // Register getMixFile method with MixHelper.
336 
338 
339  // Get IFDH art service.
340 
342 
343  // Get sam station.
344  // If the station was not specified by a fcl parameter, use environment variable
345  // $SAM_STATION, or else use a default value of "dune."
346 
347  if(fSamStation.empty()) {
348  const char* c = getenv("SAM_STATION");
349  if(c == 0 || *c == 0)
350  c = "dune";
351  fSamStation = c;
352  std::cout << "Mix SAM: Station = " << fSamStation << std::endl;
353  }
354 
355  // Find project uri.
356 
357  fSamProjectURI = ifdh->findProject(fSamProject, fSamStation);
358  std::cout << "Mix SAM: project uri = " << fSamProjectURI << std::endl;
359  if(fSamProjectURI.empty())
360  throw cet::exception("OverlayRawDataDUNE35t") << "Failed to find project uri.";
361 
362  // Get hostname.
363 
364  char hostname[256];
365  gethostname(hostname, sizeof hostname);
366 
367  // Get user.
368  // If the user was not specified by a fcl parameter, use environment variable
369  // $SAM_USER (this should work on grid), or else use environment variable $LOGNAME.
370 
371  if(fSamUser.empty()) {
372  const char* c = getenv("SAM_USER");
373  if(c == 0 || *c == 0)
374  c = getenv("LOGNAME");
375  if(c != 0 && *c != 0)
376  fSamUser = c;
377  std::cout << "Mix SAM: User = " << fSamUser << std::endl;
378  }
379 
380  // Join project.
381 
382  std::cout << "Mix SAM: fSamProjectURI = " << fSamProjectURI << "\n"
383  << "Mix SAM: fSamAppName = " << fSamAppName << "\n"
384  << "Mix SAM: fSamAppVersion = " << fSamAppVersion << "\n"
385  << "Mix SAM: hostname = " << hostname << "\n"
386  << "Mix SAM: fSamUser = " << fSamUser << "\n"
387  << "Mix SAM: fSamAppFamily = " << fSamAppFamily << "\n"
388  << "Mix SAM: fSamDescription = " << fSamDescription << "\n"
389  << "Mix SAM: fSamFileLimit = " << fSamFileLimit << "\n"
390  << "Mix SAM: fSamSchema = " << fSamSchema << "\n";
391 
392  fSamProcessID = ifdh->establishProcess(fSamProjectURI,
393  fSamAppName,
395  hostname,
396  fSamUser,
400  fSamSchema);
401  mf::LogInfo("OverlayRawDigitDUNE35t") << "Overlay sam definition: " << fSamDefname << "\n"
402  << "Overlay sam project: " << fSamProject;
403 
404  std::cout << "Mix SAM: process id = " << fSamProcessID << std::endl;
405  if(fSamProcessID.empty())
406  throw cet::exception("OverlayRawDataDUNE35t") << "Failed to start sam process.";
407  }
408 }
409 
410 // Destructor.
412 {
413  if(!fSamProcessID.empty()) {
414 
415  // Get IFDH art service.
416 
418 
419  // Mark current file as consumed.
420 
421  if(!fSamCurrentFileName.empty()) {
422  ifdh->updateFileStatus(fSamProjectURI,
425  "consumed");
426  std::cout << "Mix SAM: File " << fSamCurrentFileName << " status changed to consumed." << std::endl;
427  }
428 
429  // Stop process.
430 
431  ifdh->endProcess(fSamProjectURI, fSamProcessID);
432  std::cout << "Mix SAM: End process." << std::endl;
433  }
434 }
435 
436 //Initialize for each event
438 
439  if(!( (event.isRealData() && fInputFileIsData) || (!event.isRealData() && !fInputFileIsData)))
440  throw cet::exception("OverlayRawDataDUNE35t") << "Input file claimed to be data/not data, but it's not." << std::endl; ;
441 
442 
445  throw cet::exception("OverlayRawDataDUNE35t") << "Bad input digit handle." << std::endl; ;
446  //fRDMixer.SetSaturationPoint(fDefaultRawDigitSatPoint);
447 
451 
452  //event.getByLabel(fOpDetInputSourceModuleLabel,"OpdetBeamLowGain",inputOpDetHandle_LowGain);
453  //if(!inputOpDetHandle_LowGain.isValid())
454  // throw cet::exception("OverlayRawDataDUNE35t") << "Bad input opdet lowgain handle." << std::endl;;
455 
456  //event.getByLabel(fOpDetInputSourceModuleLabel,"OpdetBeamHighGain",inputOpDetHandle_HighGain);
457  //if(!inputOpDetHandle_HighGain.isValid())
458  // throw cet::exception("OverlayRawDataDUNE35t") << "Bad input opdet highgain handle." << std::endl;;
459 
460  //fODMixer.SetSaturationPoint(fDefaultOpDetSatPoint);
461  //fODMixer.SetMinSampleSize(fOpDetMinSampleSize);
462 
463 
464  fEventMixingSummary.reset(new std::vector<dunemix::EventMixingSummary>);
465 }
466 
467 //For each of the mixed in events...bookkepping for event IDs
469  for (auto const& id : seq)
470  fEventMixingSummary->emplace_back(id.event(),id.subRun(),id.run());
471 }
472 
473 
474 //End each event
476  event.put(std::move(fEventMixingSummary));
477 }
478 
479 template<typename T>
481  std::vector< T > & output,
482  art::PtrRemapper const &){
484  return true;
485 }
486 
487 void mix::OverlayRawDataDetailDUNE35t::GenerateMCRawDigitScaleMap(std::vector<raw::RawDigit> const& dataDigitVector){
488 
489  // read in data file which contains a TTree with all of the channel gain corrections,
490  // calculated using normal (unscaled) MC and real data
491  // NOTE: implementing this channel gain factors must be done in a two-step process:
492  // 1. Run full data overlay and reconstruction (without additional gain corrections)
493  // 2. Calculate channel gain correction factors, then re-run the entire dataoverlay
494  // process (and necessarily, the rest of the reco/ana as well) with this method
495  // implementing the new gains
496  std::map<raw::ChannelID_t,double> channelgains;
498  try
499  {
500  TFile * gainsfile = TFile::Open(fChannelGainFile.c_str(),"READ");
501  if (gainsfile && !gainsfile->IsZombie())
502  {
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())
511  {
512  raw::ChannelID_t chanid = *channel;
513  double gain;
514  if (*datampverr < 200 && *datawidtherr < 400 && *simmpverr < 200 && *simwidtherr < 400)
515  {
516  gain = *changain;
517  }
518  else
519  {
520  gain = 1.0;
521  }
522  channelgains[chanid] = gain;
523  }
524  }
525  }
526  catch (...)
527  {
528  std::cout << "Can't open gains file, setting channelgains all equal to 1" << std::endl;
529  for (raw::ChannelID_t chan = 0; chan < fGeom->Nchannels(); ++chan)
530  {
531  channelgains[chan] = 1.0;
532  }
533  }
534 
535  //right now, assume the number of channels is the number in the collection
536  //and, loop through the channels one by one to get the right channel number
537  //note: we will put here access to the channel database to determine dead channels
538  fMCRawDigitScaleMap.clear();
539 
541 
542  for(auto const& d : dataDigitVector) {
543  if(chanStatus.IsBad(d.Channel()))
544  {
545  if (fGeom->SignalType(d.Channel()) == geo::kCollection) std::cout << "Channel " << d.Channel() << " IN BAD CHANNEL LIST. Scale=0.0" << std::endl;
546  fMCRawDigitScaleMap[d.Channel()] = 0.0;
547  }
548  else if (channelgains.find(d.Channel()) == channelgains.end())
549  {
550  if (fGeom->SignalType(d.Channel()) == geo::kCollection) std::cout << "Channel " << d.Channel() << " NOT IN channelgains. Scale=" << fDefaultMCRawDigitScale << std::endl;
552  }
553  else
554  {
555  if (fGeom->SignalType(d.Channel()) == geo::kCollection) std::cout << "Channel " << d.Channel() << " GOOD. Scale=" << fDefaultMCRawDigitScale * channelgains[d.Channel()] << std::endl;
556  fMCRawDigitScaleMap[d.Channel()] = fDefaultMCRawDigitScale * channelgains[d.Channel()];
557  }
558  }
559 }
560 
561 bool mix::OverlayRawDataDetailDUNE35t::MixRawDigits( std::vector< std::vector<raw::RawDigit> const* > const& inputs,
562  std::vector<raw::RawDigit> & output,
563  art::PtrRemapper const & remap) {
564 
565  //make sure we only have two collections for now
566  if(inputs.size()!=fEventsToMix || (inputs.size()!=1 && !fInputFileIsData)) {
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());
570  }
571 
572  if(fInputFileIsData) {
575  for(auto const& icol : inputs)
577  }
578  else if(!fInputFileIsData) {
580  fRDMixer.DeclareData(*(inputs[0]));
582  }
583 
585 
586  return true;
587 }
588 
589 /*
590  void mix::OverlayRawDataDetailDUNE35t::GenerateMCOpDetHighGainScaleMap(std::vector<raw::OpDetWaveform> const& dataVector){
591  //right now, assume the number of channels is the number in the collection
592  //and, loop through the channels one by one to get the right channel number
593  //note: we will put here access to the channel database to determine dead channels
594  fMCOpDetHighGainScaleMap.clear();
595  for(auto const& d : dataVector)
596  fMCOpDetHighGainScaleMap[d.ChannelNumber()] = fDefaultMCOpDetScale;
597  }
598 
599  void mix::OverlayRawDataDetailDUNE35t::GenerateMCOpDetLowGainScaleMap(std::vector<raw::OpDetWaveform> const& dataVector){
600  //right now, assume the number of channels is the number in the collection
601  //and, loop through the channels one by one to get the right channel number
602  //note: we will put here access to the channel database to determine dead channels
603  fMCOpDetLowGainScaleMap.clear();
604  for(auto const& d : dataVector)
605  fMCOpDetLowGainScaleMap[d.ChannelNumber()] = fDefaultMCOpDetScale;
606  }
607 
608  bool mix::OverlayRawDataDetailDUNE35t::MixOpDetWaveforms_HighGain( std::vector< std::vector<raw::OpDetWaveform> const* > const& inputs,
609  std::vector<raw::OpDetWaveform> & output,
610  art::PtrRemapper const & remap) {
611 
612  //make sure we only have two collections for now
613  if(inputs.size()!=fEventsToMix || (inputs.size()!=1 && !fInputFileIsData)){
614  std::stringstream err_str;
615  err_str << "ERROR! We have the wrong number of collections of raw digits we are adding! " << inputs.size();
616  throw std::runtime_error(err_str.str());
617  }
618 
619 
620  if(fInputFileIsData){
621  GenerateMCOpDetHighGainScaleMap(*inputOpDetHandle_HighGain);
622  fODMixer.DeclareData(*inputOpDetHandle_HighGain,output);
623  for(auto const& icol : inputs)
624  fODMixer.Mix(*icol,fMCOpDetHighGainScaleMap,output);
625  }
626  else if(!fInputFileIsData){
627  GenerateMCOpDetHighGainScaleMap(*(inputs[0]));
628  fODMixer.DeclareData(*(inputs[0]),output);
629  fODMixer.Mix(*inputOpDetHandle_HighGain,fMCOpDetHighGainScaleMap,output);
630  }
631 
632  return true;
633  }
634 
635  bool mix::OverlayRawDataDetailDUNE35t::MixOpDetWaveforms_LowGain( std::vector< std::vector<raw::OpDetWaveform> const* > const& inputs,
636  std::vector<raw::OpDetWaveform> & output,
637  art::PtrRemapper const & remap) {
638 
639  //make sure we only have two collections for now
640  if(inputs.size()!=fEventsToMix || (inputs.size()!=1 && !fInputFileIsData)){
641  std::stringstream err_str;
642  err_str << "ERROR! We have the wrong number of collections of raw digits we are adding! " << inputs.size();
643  throw std::runtime_error(err_str.str());
644  }
645 
646 
647  if(fInputFileIsData){
648  GenerateMCOpDetLowGainScaleMap(*inputOpDetHandle_LowGain);
649  fODMixer.DeclareData(*inputOpDetHandle_LowGain,output);
650  for(auto const& icol : inputs)
651  fODMixer.Mix(*icol,fMCOpDetLowGainScaleMap,output);
652  }
653  else if(!fInputFileIsData){
654  GenerateMCOpDetLowGainScaleMap(*(inputs[0]));
655  fODMixer.DeclareData(*(inputs[0]),output);
656  fODMixer.Mix(*inputOpDetHandle_LowGain,fMCOpDetLowGainScaleMap,output);
657  }
658 
659  return true;
660  }
661  */
662 
663 // Return next file to mix.
664 
666 {
668 
669  if(!fSamProcessID.empty()) {
670 
671  // Get IFDH art service.
672 
674 
675  // Update status of current file, if any, to "consumed."
676 
677  if(!fSamCurrentFileName.empty()) {
678  ifdh->updateFileStatus(fSamProjectURI,
681  "consumed");
682 
683  std::cout << "Mix SAM: File " << fSamCurrentFileName << " status changed to consumed." << std::endl;
686  }
687 
688  // Get next file uri.
689 
691  unsigned int n = fSamCurrentFileURI.find_last_of('/') + 1;
693  std::cout << "Mix SAM: Next file uri = " << fSamCurrentFileURI << std::endl;
694  std::cout << "Mix SAM: Next file name = " << fSamCurrentFileName << std::endl;
695  mf::LogInfo("OverlayRawDigitDUNE35t") << "Next mix file uri: " << fSamCurrentFileURI << "\n"
696  << "Next mix file name: " << fSamCurrentFileName;
697 
698  // Throw an exception if we didn't get a next file.
699 
700  if(fSamCurrentFileURI.empty() || fSamCurrentFileName.empty())
701  throw cet::exception("OverlayRawDataDUNE35t") << "Failed to get next mix file.";
702 
703  // Here is where we would copy the file to the local node, if that were necessary.
704  // Since we are using schema "root" (i.e. xrootd) to stream files, copying the
705  // file is not necessary.
706  // Note further that we should not update the file status to "transferred" for
707  // streaming files, since that can in principle allow the file to be deleted from
708  // disk cache.
709 
710  // Update metadata.
711 
713  md->addMetadataString("mixparent", fSamCurrentFileName);
714 
715  // Done.
716 
717  result = fSamCurrentFileURI;
718  }
719 
720  return result;
721 }
722 
723 
virtual bool IsBad(raw::ChannelID_t channel) const =0
Returns whether the specified channel is bad in the current run.
void registerSecondaryFileNameProvider(ProviderFunc_ func)
Definition: MixHelper.cc:140
std::vector< EventID > EventIDSequence
Definition: MixTypes.h:26
static QCString result
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
struct vector vector
void FillRawDigitOutput(std::vector< raw::RawDigit > &output)
const std::string instance
Definition of basic mixing information.
STL namespace.
Definition of basic raw digits.
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.
Particle class.
void produces(std::string const &instanceName={})
Definition: MixHelper.h:436
art::Handle< std::vector< raw::RawDigit > > inputDigitHandle
void addMetadataString(std::string const &key, std::string const &value)
void SetMCMixTicks(size_t start, size_t end)
Definition: RawDigitMixer.h:61
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
void processEventIDs(art::EventIDSequence const &seq)
bool isValid() const
Definition: Handle.h:183
bool isRealData() const
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)
Definition: ModuleMacros.h:69
void declareMixOp(InputTag const &inputTag, MixFunc< PROD, OPROD > mixFunc, bool outputProduct=true)
Definition: MixHelper.h:452
std::void_t< T > n
parameter set interface
std::string getenv(std::string const &name)
Definition: getenv.cc:15
def move(depos, offset)
Definition: depos.py:107
T get(std::string const &key) const
Definition: ParameterSet.h:231
bool get_if_present(std::string const &key, T &value) const
Definition: ParameterSet.h:208
Class providing information about the quality of channels.
void SetStuckBitRetentionMethod(bool b)
Definition: RawDigitMixer.h:59
Class def header for mctrack data container.
Definition of data types for geometry description.
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
p
Definition: test.py:223
bool MixRawDigits(std::vector< std::vector< raw::RawDigit > const * > const &inputs, std::vector< raw::RawDigit > &output, art::PtrRemapper const &)
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::unordered_map< raw::ChannelID_t, float > fMCRawDigitScaleMap
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:27
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
Interface for experiment-specific service for channel quality info.
void GenerateMCRawDigitScaleMap(std::vector< raw::RawDigit > const &)
void SetDataMixTicks(size_t start, size_t end)
Definition: RawDigitMixer.h:60
constexpr bool noncopyable()
int bool
Definition: qglobal.h:345
OverlayRawDataDetailDUNE35t(fhicl::ParameterSet const &p, art::MixHelper &helper)
art::MixFilter< OverlayRawDataDetailDUNE35t, art::RootIOPolicy > OverlayRawDataDUNE35t
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
Event finding and building.
Signal from collection planes.
Definition: geo_types.h:142
unsigned int run