NoiseAdder_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: NoiseAdder
3 // Plugin Type: producer (art v2_10_03)
4 // File: NoiseAdder_module.cc
5 //
6 // Generated at Thu May 31 08:35:23 2018 by Philip Rodrigues using cetskelgen
7 // from cetlib version v3_02_00.
8 ////////////////////////////////////////////////////////////////////////
9 
17 #include "fhiclcpp/ParameterSet.h"
19 
20 #include "CLHEP/Random/RandGauss.h"
21 #include "CLHEP/Random/JamesRandom.h"
22 
27 
29 
30 #include "cetlib/search_path.h"
31 
32 #include <memory>
33 
34 class NoiseAdder;
35 
36 
37 class NoiseAdder : public art::EDProducer {
38 public:
40  {
41  ElectronicsAddress(int _crate, int _slot, int _fiber, int _asic, int _asicChannel)
42  : crate(_crate), slot(_slot), fiber(_fiber), asic(_asic), asicChannel(_asicChannel)
43  {}
44  int crate;
45  int slot;
46  int fiber;
47  int asic;
49  };
50 
51  explicit NoiseAdder(fhicl::ParameterSet const & p);
52  // The compiler-generated destructor is fine for non-base
53  // classes without bare pointers or other resource use.
54 
55  // Plugins should not be copied or assigned.
56  NoiseAdder(NoiseAdder const &) = delete;
57  NoiseAdder(NoiseAdder &&) = delete;
58  NoiseAdder & operator = (NoiseAdder const &) = delete;
59  NoiseAdder & operator = (NoiseAdder &&) = delete;
60 
61  // Required functions.
62  void produce(art::Event & e) override;
63 
64 
65 private:
66 
67  // Declare member data here.
69  std::map<int, ElectronicsAddress> m_channelMap;
70 };
71 
72 
74 
75 // Initialize member data here.
76 {
77  produces< std::vector<raw::RawDigit> >();
78 
79  // The ProtoDUNE channel map lives in dune_raw_data:
80  //
81  // https://cdcvs.fnal.gov/redmine/projects/dune-raw-data/repository/revisions/develop/entry/dune-raw-data/Services/ChannelMap/protoDUNETPCChannelMap_v3.txt
82  //
83  // It's created by:
84  //
85  // https://cdcvs.fnal.gov/redmine/projects/dune-raw-data/repository/revisions/develop/entry/dune-raw-data/Services/ChannelMap/mapmakers/MakePdspChannelMap_v3.C
86  cet::search_path sp("FW_SEARCH_PATH");
87  std::string channelMapFile=sp.find_file("protoDUNETPCChannelMap_v3.txt");
88  std::ifstream fin(channelMapFile.c_str());
89 
90  int crateNo, slotNo, fiberNo, FEMBChannel,
91  StreamChannel, slotID, fiberID,
92  chipNo, chipChannel, asicNo,
93  asicChannel, planeType, offlineChannel;
94 
95  while(fin >> crateNo >> slotNo >> fiberNo >> FEMBChannel
96  >> StreamChannel >> slotID >> fiberID
97  >> chipNo >> chipChannel >> asicNo
98  >> asicChannel >> planeType >> offlineChannel){
99  m_channelMap.emplace(std::make_pair(offlineChannel,
100  ElectronicsAddress(crateNo, slotNo, fiberNo, asicNo, asicChannel)));
101  }
102 }
103 
105 {
106  // Implementation of required member function here.
107  auto& digits_in =
108  *e.getValidHandle<std::vector<raw::RawDigit>>("daq");
109  std::unique_ptr<std::vector<raw::RawDigit>> digits_out(new std::vector<raw::RawDigit>);
110 
111  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(e);
112  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(e, clockData);
113 
114  for(auto&& digit: digits_in){
115  if(digit.Compression()!=0){
116  // TODO: throw or just uncompress the stream and carry on
117  std::cout << "Compression type " << digit.Compression() << std::endl;
118  }
119  std::vector<short> samples_out(digit.NADC(), 0);
120  std::vector<float> samples_work(digit.NADC(), 0);
121  for(size_t i=0; i<digit.NADC(); ++i){
122  samples_out[i]=m_noiseService->addNoise(clockData, detProp, digit.Channel(), samples_work);
123  }
124  digits_out->push_back(raw::RawDigit(digit.Channel(),
125  digit.Samples(),
126  std::move(samples_out),
127  raw::kNone));
128  } // end loop over digits (=?channels)
129 
130  e.put(std::move(digits_out));
131 }
132 
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
void produce(art::Event &e) override
virtual int addNoise(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, Channel chan, AdcSignalVector &sigs) const =0
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
NoiseAdder & operator=(NoiseAdder const &)=delete
std::map< int, ElectronicsAddress > m_channelMap
NoiseAdder(fhicl::ParameterSet const &p)
no compression
Definition: RawTypes.h:9
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
def move(depos, offset)
Definition: depos.py:107
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
p
Definition: test.py:223
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
ElectronicsAddress(int _crate, int _slot, int _fiber, int _asic, int _asicChannel)
art::ServiceHandle< ChannelNoiseService > m_noiseService
QTextStream & endl(QTextStream &s)