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

# User Rev Content
1 loizides 1.7 // $Id: BaseFiller.cc,v 1.6 2008/09/14 15:37:43 loizides Exp $
2 paus 1.1
3     #include "MitProd/TreeFiller/interface/BaseFiller.h"
4 loizides 1.7 #include "MitAna/DataTree/interface/BranchName.h"
5     #include "MitAna/DataTree/interface/BranchTable.h"
6     #include "MitAna/DataTree/interface/Names.h"
7 loizides 1.5 #include <TSystem.h>
8     #include <TError.h>
9 paus 1.1
10     using namespace std;
11     using namespace edm;
12     using namespace mithep;
13    
14 loizides 1.3 //--------------------------------------------------------------------------------------------------
15 loizides 1.4 BaseFiller::BaseFiller(const ParameterSet &cfg, const char *name, bool active) :
16 loizides 1.3 name_(name),
17 loizides 1.7 brtname_(cfg.getUntrackedParameter<string>("brTabName",Names::gkBranchTable)),
18 loizides 1.3 config_(cfg.exists(name) ? cfg.getUntrackedParameter<ParameterSet>(name) : ParameterSet()),
19 loizides 1.6 active_(config_.getUntrackedParameter<bool>("active",active)),
20     verify_(config_.getUntrackedParameter<bool>("verify",false)),
21 loizides 1.7 verbose_(config_.getUntrackedParameter<int>("verbose",0)),
22     brtable_(0)
23 paus 1.1 {
24 loizides 1.7 // 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 paus 1.1 }
52 loizides 1.5
53     //--------------------------------------------------------------------------------------------------
54     void BaseFiller::PrintErrorAndExit(const char *msg) const
55     {
56 loizides 1.7 // Print error message, and then terminate.
57    
58 loizides 1.5 Error("PrintErrorAndExit", msg);
59     gSystem->Exit(1);
60     }