MergeSubruns_module.cc
Go to the documentation of this file.
1 /////////////////////////////////////////////////////////////////////////
2 /// \brief Concatenate subrun files from same run
3 /// \author nowak@physics.umn.edu
4 /// \date
5 /////////////////////////////////////////////////////////////////////////
6 #include <cstdlib>
7 #include <iostream>
8 #include <fstream>
9 #include <string>
10 #include <vector>
11 
12 // Framework includes
16 
17 
18 namespace util {
19  class MergeSubruns : public art::EDFilter
20  {
21  public:
22  explicit MergeSubruns(fhicl::ParameterSet const& p);
23  virtual ~MergeSubruns();
24 
25  virtual void reconfigure(fhicl::ParameterSet const& p);
26 
27  virtual bool filter(art::Event& e);
28 
29  private:
30  int fMode; ///< 0- merge all provided files, 1 - merge only files from the same run
31  unsigned int fRun; ///< run number for the first file
32  bool fRunStatus; ///< Check is fRun was set.
33  };
34 }
35 
36 
37 ////////////////////////////////////////////////////////////////////////
38 namespace util {
39 
41  {
42  this->reconfigure(p);
43  }
44 
45  //......................................................................
46 
48  {
49  fMode = p.get<int>("Mode");
50  fRun = 0;
51  fRunStatus = false;
52  }
53 
54  //......................................................................
55 
57 
58  //......................................................................
59 
61  {
62 
63  //std::cout<<"EventID="<<evt.id() <<std::endl;
64  //std::cout<<"time= "<<evt.time() <<std::endl; ///time() doesn't work here
65  //std::cout<<"event= "<<evt.event() <<std::endl;
66  //std::cout<<"run= "<<evt.run() <<std::endl;
67  //std::cout<<"subRun= "<<evt.subRun()<<std::endl;
68 
69  if (fMode==1) {
70  std::cout<<"Mode 1 - only files for the same run"<<std::endl;
71 
72  if(! fRunStatus){
73  fRun = evt.run();
74  fRunStatus = true;
75  std::cout<<"First event:"<< evt.id()<<std::endl;
76  return true;
77  }
78  else if(evt.run() == fRun)
79  return true;
80  return false;
81  }
82 
83  return true; ///pass all events if fMode !=1
84  }
85 }
86 
87 
88 ////////////////////////////////////////////////////////////////////////
89 namespace util
90 {
92 }
93 ////////////////////////////////////////////////////////////////////////
Filter events based on their run/event numbers.
unsigned int fRun
run number for the first file
int fMode
0- merge all provided files, 1 - merge only files from the same run
const char * p
Definition: xmltok.h:285
virtual void reconfigure(fhicl::ParameterSet const &p)
DEFINE_ART_MODULE(TestTMapFile)
MergeSubruns(fhicl::ParameterSet const &p)
virtual bool filter(art::Event &e)
T get(std::string const &key) const
Definition: ParameterSet.h:231
bool fRunStatus
Check is fRun was set.
int evt
OStream cout
Definition: OStream.cxx:6
Float_t e
Definition: plot.C:35
RunNumber_t run() const
Definition: Event.h:77
EventID id() const
Definition: Event.h:56