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.6 by loizides, Fri Jun 20 17:52:24 2008 UTC vs.
Revision 1.10 by loizides, Mon Oct 6 15:56:51 2008 UTC

# Line 14 | Line 14 | using namespace std;
14   using namespace mithep;
15  
16   //--------------------------------------------------------------------------------------------------
17 < TreeService::TreeService(const ParameterSet &cfg, ActivityRegistry &r) :
18 <  tws_        (0)
17 > TreeService::TreeService(const ParameterSet &cfg, ActivityRegistry &ar) :
18 >  tws_(0),
19 >  fDoReset_(cfg.getUntrackedParameter<bool>("doReset",1))
20   {
21 +  // Constructor.
22 +
23    if (cfg.exists("treeNames"))
24      treeNames_=cfg.getUntrackedParameter<vector<string>   >("treeNames");
25    else
# Line 66 | Line 69 | TreeService::TreeService(const Parameter
69    // init tree writers
70    for (unsigned int i=0; i<treeNames_.size(); ++i) {
71  
72 <    TreeWriter *t = new TreeWriter(treeNames_.at(i).c_str(),1);
70 <
72 >    TreeWriter *t = new TreeWriter(treeNames_.at(i).c_str(),0);
73      t->SetPrefix(fileNames_.at(i).c_str());
74  
75 <    if      (i<pathNames_.size())
75 >    if (i<pathNames_.size())
76        t->SetBaseURL(pathNames_.at(i).c_str());
77      else if (pathNames_.size()>0)
78        t->SetBaseURL(pathNames_.at(0).c_str());
79  
80 <    if      (i<maxSizes_.size())
80 >    if (i<maxSizes_.size())
81        t->SetMaxSize((Long64_t)maxSizes_.at(i)*1024*1024);
82      else if (maxSizes_.size()>0)
83        t->SetMaxSize((Long64_t)maxSizes_.at(0)*1024*1024);
84  
85 <    if      (i<compLevels_.size())
85 >    if (i<compLevels_.size())
86        t->SetCompressLevel(compLevels_.at(i));
87      else if (compLevels_.size()>0)
88        t->SetCompressLevel(compLevels_.at(0));
89  
90 <    if      (i<splitLevels_.size())
90 >    if (i<splitLevels_.size())
91        t->SetDefaultSL(splitLevels_.at(i));
92      else if (splitLevels_.size()>0)
93        t->SetDefaultSL(splitLevels_.at(0));
94  
95 <    if      (i<brSizes_.size())
95 >    if (i<brSizes_.size())
96        t->SetDefaultBrSize(brSizes_.at(i));
97      else if (brSizes_.size()>0)
98        t->SetDefaultBrSize(brSizes_.at(0));
# Line 100 | Line 102 | TreeService::TreeService(const Parameter
102    }
103  
104    // set watchers
105 <  r.watchPreProcessEvent (this,&TreeService::preEventProcessing);
106 <  r.watchPostProcessEvent(this,&TreeService::postEventProcessing);
107 <  r.watchPostBeginJob    (this,&TreeService::postBeginJob);
108 <  r.watchPostEndJob      (this,&TreeService::postEndJob);
105 >  ar.watchPreProcessEvent (this,&TreeService::preEventProcessing);
106 >  ar.watchPostProcessEvent(this,&TreeService::postEventProcessing);
107 >  ar.watchPostBeginJob    (this,&TreeService::postBeginJob);
108 >  ar.watchPostEndJob      (this,&TreeService::postEndJob);
109   }
110  
111   //--------------------------------------------------------------------------------------------------
112   TreeService::~TreeService()
113   {
114 +  // Destructor.
115   }
116  
117   //--------------------------------------------------------------------------------------------------
118 < TreeWriter* TreeService::get(const char *name)
118 > TreeWriter *TreeService::get(const char *name)
119   {
120 +  // Get TreeWriter by name. If no name given, first one will be returned.
121 +
122    if (tws_.GetEntries()<=0)
123      return 0;
124  
# Line 128 | Line 133 | TreeWriter* TreeService::get(const char
133   //--------------------------------------------------------------------------------------------------
134   void TreeService::postBeginJob()
135   {
136 <  // nothing to be done for now
136 >  // Nothing to be done for now
137   }
138  
139   //--------------------------------------------------------------------------------------------------
140   void TreeService::postEndJob()
141   {
142 +  // Clear all TreeWriter objects.
143 +
144    tws_.Clear();
145   }
146  
147   //--------------------------------------------------------------------------------------------------
148   void TreeService::postEventProcessing(const Event&, const EventSetup&)
149   {
150 +  // Loop over all TreeWriter objects before processing of an event.
151 +
152    for (int i=0; i<tws_.GetEntries(); ++i) {
153      TreeWriter *tw=dynamic_cast<TreeWriter*>(tws_.At(i));
154 <    if (tw)
155 <      tw->EndEvent();
154 >    if (tw) {
155 >      if (i<tws_.GetEntries()-1)
156 >        tw->EndEvent();
157 >      else // make sure objects are only reset at the end (if at all)
158 >        tw->EndEvent(fDoReset_);
159 >    }
160    }
161   }
162  
163   //--------------------------------------------------------------------------------------------------
164   void TreeService::preEventProcessing(const EventID&, const Timestamp&)
165   {
166 +  // Loop over all TreeWriter objects after processing of a events.
167 +
168    for (int i=0; i<tws_.GetEntries(); ++i) {
169      TreeWriter *tw=dynamic_cast<TreeWriter*>(tws_.At(i));
170 <    if (tw)
171 <      tw->BeginEvent();
170 >    if (tw) {
171 >      if (i==0) // make sure objects are only reset at the beginning (if at all)
172 >        tw->BeginEvent(fDoReset_);
173 >      else
174 >        tw->BeginEvent();
175 >    }
176    }
177   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines