ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeService/src/TreeService.cc
(Generate patch)

Comparing UserCode/MitProd/TreeService/src/TreeService.cc (file contents):
Revision 1.9 by loizides, Wed Jul 30 11:30:02 2008 UTC vs.
Revision 1.15 by loizides, Wed Nov 4 16:59:22 2009 UTC

# Line 3 | Line 3
3   #include "MitProd/TreeService/interface/TreeService.h"
4   #include "DataFormats/Provenance/interface/ModuleDescription.h"
5   #include "FWCore/ParameterSet/interface/ParameterSet.h"
6 < #include "FWCore/ServiceRegistry/interface/ActivityRegistry.h"
6 > #include "FWCore/ServiceRegistry/interface/ActivityRegistry.h"  
7   #include "FWCore/ServiceRegistry/interface/Service.h"
8   #include "FWCore/MessageLogger/interface/JobReport.h"
9 + #include "FWCore/MessageLogger/interface/MessageLogger.h"
10   #include "MitAna/DataUtil/interface/TreeWriter.h"
11   #include "MitAna/DataTree/interface/Names.h"
12 + #include "MitCommon/OptIO/interface/OptInt.h"
13  
14   using namespace edm;
15   using namespace std;
# Line 15 | Line 17 | using namespace mithep;
17  
18   //--------------------------------------------------------------------------------------------------
19   TreeService::TreeService(const ParameterSet &cfg, ActivityRegistry &ar) :
20 <  tws_(0)
20 >  tws_(0),
21 >  zipMode_(1),
22 >  bZipThres_(1),
23 >  gZipThres_(1),
24 >  lzoThres_(1),
25 >  lzmaThres_(1),
26 >  optIOVerbose_(1),
27 >  fDoReset_(cfg.getUntrackedParameter<bool>("doReset",1)),
28 >  fActivate_(cfg.getUntrackedParameter<bool>("doActivate",0))
29   {
30    // Constructor.
31  
# Line 52 | Line 62 | TreeService::TreeService(const Parameter
62    if (cfg.exists("brSizes"))
63      brSizes_=cfg.getUntrackedParameter<vector<unsigned> >("brSizes");
64    else
65 <    brSizes_.push_back(32*1024);
65 >    brSizes_.push_back(16*1024);
66  
67    if (treeNames_.size()!=fileNames_.size()) {
68      throw edm::Exception(edm::errors::Configuration, "TreeService::TreeService()\n")
# Line 61 | Line 71 | TreeService::TreeService(const Parameter
71      return;
72    }
73  
74 +  if (OptInt::IsActivated()) {
75 +    if (cfg.exists("zipMode"))
76 +      zipMode_=cfg.getUntrackedParameter<unsigned>("zipMode");
77 +    else
78 +      zipMode_ = 99;
79 +
80 +    if (cfg.exists("bZipThres"))
81 +      bZipThres_=cfg.getUntrackedParameter<double>("bZipThres");
82 +    else
83 +      bZipThres_ = -1.0;
84 +
85 +    if (cfg.exists("gZipThres"))
86 +      gZipThres_=cfg.getUntrackedParameter<double>("gZipThres");
87 +    else
88 +      gZipThres_ = 1.0;
89 +
90 +    if (cfg.exists("lzoThres"))
91 +      lzoThres_=cfg.getUntrackedParameter<double>("lzoThres");
92 +    else
93 +      lzoThres_ = -1.0;
94 +
95 +    if (cfg.exists("lzmaThres"))
96 +      lzmaThres_=cfg.getUntrackedParameter<double>("lzmaThres");
97 +    else
98 +      lzmaThres_ = 0.95;
99 +
100 +    if (cfg.exists("optIOVerbose"))
101 +      optIOVerbose_=cfg.getUntrackedParameter<unsigned>("optIOVerbose");
102 +    else
103 +      optIOVerbose_ = 0;
104 +
105 +    OptInt::SetZipMode(zipMode_);
106 +    OptInt::SetGzipFraction(gZipThres_);
107 +    OptInt::SetBzipFraction(bZipThres_);
108 +    OptInt::SetLzoFraction(lzoThres_);
109 +    OptInt::SetLzmaFraction(lzmaThres_);
110 +    OptInt::SetVerbose(optIOVerbose_);
111 +
112 +  } else {
113 +
114 +    if (cfg.exists("zipMode")   || cfg.exists("bZipThres") ||
115 +        cfg.exists("gZipThres") || cfg.exists("lzoThres")  ||
116 +        cfg.exists("lzmaThres")) {
117 +      edm::LogError("TreeService") << "OptIO interface not properly pre-loaded, "
118 +        "ignoring given settings." << std::endl;
119 +    }
120 +  }
121 +
122    // setup tw array
123    tws_.SetOwner(kTRUE);
124    tws_.Expand(treeNames_.size());
# Line 68 | Line 126 | TreeService::TreeService(const Parameter
126    // init tree writers
127    for (unsigned int i=0; i<treeNames_.size(); ++i) {
128  
129 <    TreeWriter *t = new TreeWriter(treeNames_.at(i).c_str(),1);
129 >    TreeWriter *t = new TreeWriter(treeNames_.at(i).c_str(),0);
130      t->SetPrefix(fileNames_.at(i).c_str());
131  
132      if (i<pathNames_.size())
# Line 101 | Line 159 | TreeService::TreeService(const Parameter
159    }
160  
161    // set watchers
162 <  ar.watchPreProcessEvent (this,&TreeService::preEventProcessing);
163 <  ar.watchPostProcessEvent(this,&TreeService::postEventProcessing);
164 <  ar.watchPostBeginJob    (this,&TreeService::postBeginJob);
165 <  ar.watchPostEndJob      (this,&TreeService::postEndJob);
162 >  if (fActivate_) {
163 >    ar.watchPreProcessEvent (this,&TreeService::preEventProcessing);
164 >    ar.watchPostProcessEvent(this,&TreeService::postEventProcessing);
165 >    ar.watchPostBeginJob    (this,&TreeService::postBeginJob);
166 >    ar.watchPostEndJob      (this,&TreeService::postEndJob);
167 >  }
168   }
169  
170   //--------------------------------------------------------------------------------------------------
# Line 150 | Line 210 | void TreeService::postEventProcessing(co
210  
211    for (int i=0; i<tws_.GetEntries(); ++i) {
212      TreeWriter *tw=dynamic_cast<TreeWriter*>(tws_.At(i));
213 <    if (tw)
214 <      tw->EndEvent();
213 >    if (tw) {
214 >      if (i<tws_.GetEntries()-1)
215 >        tw->EndEvent();
216 >      else // make sure objects are only reset at the end (if at all)
217 >        tw->EndEvent(fDoReset_);
218 >    }
219    }
220   }
221  
# Line 162 | Line 226 | void TreeService::preEventProcessing(con
226  
227    for (int i=0; i<tws_.GetEntries(); ++i) {
228      TreeWriter *tw=dynamic_cast<TreeWriter*>(tws_.At(i));
229 <    if (tw)
230 <      tw->BeginEvent();
229 >    if (tw) {
230 >      if (i==0) // make sure objects are only reset at the beginning (if at all)
231 >        tw->BeginEvent(fDoReset_);
232 >      else
233 >        tw->BeginEvent();
234 >    }
235    }
236   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines