ChannelMapMaker_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: ChannelMapMaker
3 // Module Type: analyzer
4 // File: ChannelMapMaker_module.cc
5 //
6 // Generated at Fri Feb 24 17:38:07 2017 by Andrey Sheshukov using artmod
7 // from cetpkgsupport v1_10_02.
8 ////////////////////////////////////////////////////////////////////////
9 
17 #include "fhiclcpp/ParameterSet.h"
19 
23 
24 #include <sstream>
25 
26 namespace novaddt {
27  class ChannelMapMaker;
28 }
29 
31 public:
32  explicit ChannelMapMaker(fhicl::ParameterSet const & p);
33  // The destructor generated by the compiler is fine for classes
34  // without bare pointers or other resource use.
35 
36  // Plugins should not be copied or assigned.
37  ChannelMapMaker(ChannelMapMaker const &) = delete;
38  ChannelMapMaker(ChannelMapMaker &&) = delete;
39  ChannelMapMaker & operator = (ChannelMapMaker const &) = delete;
41 
42  // Required functions.
43  void analyze(art::Event const & e) override;
44 
45  void saveMap();
47  void reset();
48 
49 private:
50 
51  // Declare member data here.
53  //configuration parameters
54  art::InputTag fHitsTag; //where to read the hits for noise activity
55  std::string fOutputFile; //where to write map
56  std::string fWatchFile; //where to write map
57  uint32_t fEventsProcessed=0;
59 };
60 
61 
63  EDAnalyzer(p),
64  fHitsTag(p.get<std::string>("hits_tag")),
65  fOutputFile(p.get<std::string>("output")),
66  fWatchFile (p.get<std::string>("watch")),
68 {
69  //mf::SetModuleName("ChannelMapMaker");
70  mf::LogInfo("ChannelMapMaker")<<"input_hits:\""<<fHitsTag
71  <<"\nOutput map to: "<<fOutputFile
72  <<"\nWatch file: "<<fWatchFile
73  <<std::endl;
74 }
75 
77 {
78  //get the hits which we'll use to fill the map
80  //fill the map
81  for(const auto &hit: *hits)
82  fHitMap[hit]+=1;
83  //Increment events counter
85 
86  //check if we should do the rollover
88  mf::LogInfo("MapRollover")<<" Time to save the map file"<<std::endl;
89  saveMap();
90  reset();
92  }
93 }
94 
96 {
97  //normalize the map to 1 event
100 }
101 
103 {
104  fHitMap.reset(); //zero the map befor filling
105  fEventsProcessed=0; //zero the events counter
106 }
107 
108 
110 {
111  mf::LogInfo("Progress")<<"Saving NoiseMap with "
113  <<" events to file:"
114  <<filename << std::endl;
115  //save map to the file
116  std::ofstream s(filename.data(),std::ofstream::binary);
117  s<<fHitMap;
118 }
119 
bool isModified()
Definition: FileWatcher.h:15
novaddt::calib::FDHitMap fHitMap
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
void update()
Definition: FileWatcher.h:27
std::vector< DAQHit > HitList
Definition: HitList.h:15
const char * p
Definition: xmltok.h:285
ChannelMapMaker(fhicl::ParameterSet const &p)
string filename
Definition: shutoffs.py:106
DEFINE_ART_MODULE(TestTMapFile)
const XML_Char * s
Definition: expat.h:262
void hits()
Definition: readHits.C:15
void saveMapTo(std::string filename)
void analyze(art::Event const &e) override
ChannelMapMaker & operator=(ChannelMapMaker const &)=delete
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
void Scale(T koeff)
Definition: HitMap.h:37
Definition: structs.h:12
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Float_t e
Definition: plot.C:35
enum BeamMode string