ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/BaseFiller.cc
Revision: 1.7
Committed: Sun Mar 15 11:20:41 2009 UTC (16 years, 1 month ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_009a, Mit_009, Mit_008, Mit_008pre2
Changes since 1.6: +36 -2 lines
Log Message:
Introduced BranchTable plus general cleanup.

File Contents

# Content
1 // $Id: BaseFiller.cc,v 1.6 2008/09/14 15:37:43 loizides Exp $
2
3 #include "MitProd/TreeFiller/interface/BaseFiller.h"
4 #include "MitAna/DataTree/interface/BranchName.h"
5 #include "MitAna/DataTree/interface/BranchTable.h"
6 #include "MitAna/DataTree/interface/Names.h"
7 #include <TSystem.h>
8 #include <TError.h>
9
10 using namespace std;
11 using namespace edm;
12 using namespace mithep;
13
14 //--------------------------------------------------------------------------------------------------
15 BaseFiller::BaseFiller(const ParameterSet &cfg, const char *name, bool active) :
16 name_(name),
17 brtname_(cfg.getUntrackedParameter<string>("brTabName",Names::gkBranchTable)),
18 config_(cfg.exists(name) ? cfg.getUntrackedParameter<ParameterSet>(name) : ParameterSet()),
19 active_(config_.getUntrackedParameter<bool>("active",active)),
20 verify_(config_.getUntrackedParameter<bool>("verify",false)),
21 verbose_(config_.getUntrackedParameter<int>("verbose",0)),
22 brtable_(0)
23 {
24 // Constructor.
25 }
26
27 //--------------------------------------------------------------------------------------------------
28 void BaseFiller::AddBranchDep(const char *n, const char *d)
29 {
30 // Add dependency between to given branch names to branch table if present.
31
32 if (!n || !d)
33 return;
34
35 if (!brtable_) {
36 brtable_ = OS()->mod<BranchTable>(brtname_.c_str());
37 if (!brtable_)
38 return;
39 }
40
41 std::string nstr(n);
42 if (nstr.empty())
43 return;
44
45 std::string dstr(d);
46 if (dstr.empty())
47 return;
48
49 if (!brtable_->Find(n,d))
50 brtable_->Add(new BranchName(n,d));
51 }
52
53 //--------------------------------------------------------------------------------------------------
54 void BaseFiller::PrintErrorAndExit(const char *msg) const
55 {
56 // Print error message, and then terminate.
57
58 Error("PrintErrorAndExit", msg);
59 gSystem->Exit(1);
60 }