11 |
|
#ifndef MITPROD_TREEFILLER_BASEFILLER_H |
12 |
|
#define MITPROD_TREEFILLER_BASEFILLER_H |
13 |
|
|
14 |
+ |
#include "DataFormats/Common/interface/Handle.h" |
15 |
|
#include "FWCore/Framework/interface/Event.h" |
16 |
|
#include "FWCore/Framework/interface/Frameworkfwd.h" |
17 |
|
#include "FWCore/ParameterSet/interface/ParameterSet.h" |
18 |
|
#include "FWCore/MessageLogger/interface/MessageLogger.h" |
18 |
– |
#include "DataFormats/Common/interface/Handle.h" |
19 |
|
#include "MitAna/DataUtil/interface/TreeWriter.h" |
20 |
– |
#include "MitProd/ObjectService/interface/ObjectService.h" |
21 |
– |
#include "MitProd/TreeFiller/interface/FillMitTree.h" |
20 |
|
#include <TString.h> |
21 |
|
|
22 |
|
namespace mithep |
23 |
|
{ |
24 |
+ |
class BranchTable; |
25 |
+ |
class ObjectService; |
26 |
+ |
|
27 |
|
class BaseFiller |
28 |
|
{ |
29 |
|
public: |
30 |
|
BaseFiller(const edm::ParameterSet &cfg, const char *name, bool active=true); |
31 |
|
virtual ~BaseFiller() {} |
32 |
|
|
33 |
< |
bool Active() const { return active_; } |
34 |
< |
virtual void BookDataBlock(TreeWriter &tws) = 0; |
33 |
> |
bool Active() const { return active_; } |
34 |
> |
void AddBranchDep(const char *n, const char *d); |
35 |
> |
void AddBranchDep(const std::string &n, const char *d) |
36 |
> |
{ AddBranchDep(n.c_str(), d); } |
37 |
> |
void AddBranchDep(const std::string &n, const std::string &d) |
38 |
> |
{ AddBranchDep(n.c_str(), d.c_str()); } |
39 |
> |
virtual void BookDataBlock(TreeWriter &tws, const edm::EventSetup &es) = 0; |
40 |
|
virtual void FillDataBlock(const edm::Event &e, const edm::EventSetup &es) = 0; |
41 |
< |
const std::string &Name() const { return name_; } |
41 |
> |
virtual void FillRunBlock(edm::Run const &r, edm::EventSetup const &es) {} |
42 |
> |
const std::string &Name() const { return name_; } |
43 |
|
virtual void ResolveLinks(const edm::Event &e, const edm::EventSetup &es) {} |
44 |
+ |
int Verbose() const { return verbose_; } |
45 |
+ |
bool Verify() const { return verify_; } |
46 |
|
|
47 |
|
protected: |
48 |
< |
const edm::ParameterSet &Conf() const { return config_; } |
48 |
> |
const edm::ParameterSet &Conf() const { return config_; } |
49 |
|
void PrintErrorAndExit(const char *msg) const; |
50 |
|
template <typename TYPE> |
51 |
|
void GetProduct(const std::string name, edm::Handle<TYPE> &prod, |
53 |
|
template <typename TYPE> |
54 |
|
bool GetProductSafe(const std::string name, edm::Handle<TYPE> &prod, |
55 |
|
const edm::Event &event) const; |
56 |
< |
|
48 |
< |
ObjectService *OS() { return FillMitTree::os(); } |
56 |
> |
ObjectService *OS(); |
57 |
|
|
58 |
|
const std::string name_; //name of this filler |
59 |
+ |
const std::string brtname_; //name of branch table (def = BranchTable) |
60 |
|
const edm::ParameterSet config_; //parameter set for this filler |
61 |
|
const bool active_; //=1 if active |
62 |
+ |
const bool verify_; //=1 if verificatin code is active |
63 |
+ |
const int verbose_; //verbosity level (do not introduce more than 0-4 levels) |
64 |
+ |
BranchTable *brtable_; //branch dependency table |
65 |
|
}; |
66 |
|
} |
67 |
|
|
77 |
|
event.getByLabel(edm::InputTag(edmname),prod); |
78 |
|
if (!prod.isValid()) |
79 |
|
throw edm::Exception(edm::errors::Configuration, "BaseFiller::GetProduct()\n") |
80 |
< |
<< "Cannot get collection with label " << edmname << std::endl; |
80 |
> |
<< "Cannot get collection with label " << edmname << " for " << Name() << std::endl; |
81 |
|
} catch (...) { |
82 |
|
edm::LogError("BaseFiller") << "Cannot get collection with label " |
83 |
< |
<< edmname << std::endl; |
84 |
< |
PrintErrorAndExit(Form("Cannot get collection with label %s", edmname.c_str())); |
83 |
> |
<< edmname << " for " << Name() << std::endl; |
84 |
> |
PrintErrorAndExit(Form("Cannot get collection with label %s for %s", |
85 |
> |
edmname.c_str(), name_.c_str())); |
86 |
|
} |
87 |
|
} |
88 |
|
|