CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
StatisticsFilter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: StatisticsFilter
4 // Class: StatisticsFilter
5 //
13 //
14 // Original Author: Gordon Kaussen,40 1-A15,+41227671647,
15 // Created: Mon Nov 15 10:48:54 CET 2010
16 // $Id$
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
30 
32 
34 
37 
38 //
39 // class declaration
40 //
41 
43  public:
44  explicit StatisticsFilter(const edm::ParameterSet&);
46 
47  private:
48  virtual void beginJob() override ;
49  virtual bool filter(edm::Event&, const edm::EventSetup&) override;
50  virtual void endJob() override ;
51 
52  // ----------member data ---------------------------
53 
55 
59 
60 };
61 
62 //
63 // constants, enums and typedefs
64 //
65 
66 //
67 // static data member definitions
68 //
69 
70 //
71 // constructors and destructor
72 //
73 StatisticsFilter::StatisticsFilter(const edm::ParameterSet& iConfig) : filename(iConfig.getUntrackedParameter<std::string>("rootFilename","")),
74  dirpath(iConfig.getUntrackedParameter<std::string>("histoDirPath","")),
75  MinNumberOfEvents(iConfig.getUntrackedParameter<int>("minNumberOfEvents"))
76 {
77  //now do what ever initialization is needed
78 
80  dqmStore_->open(filename.c_str(), false);
81 }
82 
83 
85 {
86 
87  // do anything here that needs to be done at desctruction time
88  // (e.g. close files, deallocate resources etc.)
89 
90 }
91 
92 
93 //
94 // member functions
95 //
96 
97 // ------------ method called on each new Event ------------
98 bool
100 {
101  TotNumberOfEvents = 0;
102 
103  std::vector<MonitorElement*> MEs = dqmStore_->getAllContents(dirpath);
104 
105  std::vector<MonitorElement*>::const_iterator iter=MEs.begin();
106  std::vector<MonitorElement*>::const_iterator iterEnd=MEs.end();
107 
108  for (; iter!=iterEnd;++iter)
109  {
110  std::string me_name = (*iter)->getName();
111 
112  if ( strstr(me_name.c_str(),"TotalNumberOfCluster__T")!=NULL && strstr(me_name.c_str(),"Profile")==NULL )
113  {
114  TotNumberOfEvents = ((TH1F*)(*iter)->getTH1F())->GetEntries();
115 
116  break;
117  }
118  }
119 
121  {
122  edm::LogInfo("StatisticsFilter") << "Only " << TotNumberOfEvents << " events in the run. Run will not be analyzed!";
123 
124  return false;
125  }
126 
127  return true;
128 }
129 
130 // ------------ method called once each job just before starting event loop ------------
131 void
133 {
134 }
135 
136 // ------------ method called once each job just after ending the event loop ------------
137 void
139 }
140 
141 //define this as a plug-in
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void endJob() override
#define NULL
Definition: scimark2.h:8
std::vector< MonitorElement * > getAllContents(const std::string &path, uint32_t runNumber=0, uint32_t lumi=0) const
Definition: DQMStore.cc:1961
int iEvent
Definition: GenABIO.cc:230
std::string filename
virtual bool filter(edm::Event &, const edm::EventSetup &) override
StatisticsFilter(const edm::ParameterSet &)
virtual void beginJob() override
tuple filename
Definition: lut2db_cfg.py:20
bool open(const std::string &filename, bool overwrite=false, const std::string &path="", const std::string &prepend="", OpenRunDirs stripdirs=KeepRunDirs, bool fileMustExist=true)
Definition: DQMStore.cc:2959