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.1 by loizides, Tue May 27 20:09:09 2008 UTC vs.
Revision 1.2 by paus, Tue Jun 3 07:21:45 2008 UTC

# Line 14 | Line 14 | using namespace edm;
14   using namespace std;
15   using namespace mithep;
16  
17 < //-------------------------------------------------------------------------------------------------
17 > //--------------------------------------------------------------------------------------------------
18   TreeService::TreeService(const ParameterSet &cfg, ActivityRegistry &r)
19    : tws_(0),
20 <    treeNames_(cfg.getUntrackedParameter<std::vector<std::string> >("treeNames")),
21 <    fileNames_(cfg.getUntrackedParameter<std::vector<std::string> >("fileNames")),
22 <    pathNames_(cfg.getUntrackedParameter<std::vector<std::string> >("pathNames")),
23 <    maxSizes_(cfg.getUntrackedParameter<std::vector<unsigned> >("maxSizes")),
24 <    compLevels_(cfg.getUntrackedParameter<std::vector<unsigned> >("compLevels")),
25 <    splitLevels_(cfg.getUntrackedParameter<std::vector<unsigned> >("splitLevels")),
26 <    brSizes_(cfg.getUntrackedParameter<std::vector<unsigned> >("brSizes"))
20 >    treeNames_  (cfg.getUntrackedParameter<vector<string>   >("treeNames")),
21 >    fileNames_  (cfg.getUntrackedParameter<vector<string>   >("fileNames")),
22 >    pathNames_  (cfg.getUntrackedParameter<vector<string>   >("pathNames")),
23 >    maxSizes_   (cfg.getUntrackedParameter<vector<unsigned> >("maxSizes")),
24 >    compLevels_ (cfg.getUntrackedParameter<vector<unsigned> >("compLevels")),
25 >    splitLevels_(cfg.getUntrackedParameter<vector<unsigned> >("splitLevels")),
26 >    brSizes_    (cfg.getUntrackedParameter<vector<unsigned> >("brSizes"))
27   {
28 <  if(treeNames_.size()!=treeNames_.size()) {
28 >  if (treeNames_.size()!=treeNames_.size()) {
29      //todo throw !!!
30    }
31  
# Line 34 | Line 34 | TreeService::TreeService(const Parameter
34    tws_.Expand(treeNames_.size());
35  
36    // init tree writers
37 <  for(unsigned int i=0;i<treeNames_.size();++i) {
37 >  for (unsigned int i=0; i<treeNames_.size(); ++i) {
38  
39      TreeWriter *t = new TreeWriter(treeNames_.at(i).c_str(),1);
40  
41      t->SetPrefix(fileNames_.at(i).c_str());
42 <    if(i<pathNames_.size()) t->SetBaseURL(pathNames_.at(i).c_str());
43 <    else if (pathNames_.size()>0) t->SetBaseURL(pathNames_.at(0).c_str());
44 <    if(i<maxSizes_.size()) t->SetMaxSize(maxSizes_.at(i)*1024*1024);
45 <    else if (maxSizes_.size()>0) t->SetMaxSize(maxSizes_.at(0)*1024*1024);
46 <    if(i<compLevels_.size()) t->SetCompressLevel(compLevels_.at(i));
47 <    else if (compLevels_.size()>0) t->SetCompressLevel(compLevels_.at(0));
48 <    if(i<splitLevels_.size()) t->SetDefaultSL(splitLevels_.at(i));
49 <    else if (splitLevels_.size()>0) t->SetDefaultSL(splitLevels_.at(0));
50 <    if(i<brSizes_.size()) t->SetDefaultBrSize(brSizes_.at(i));
51 <    else if (brSizes_.size()>0) t->SetDefaultBrSize(brSizes_.at(0));
42 >
43 >    if      (i<pathNames_.size())
44 >      t->SetBaseURL(pathNames_.at(i).c_str());
45 >    else if (pathNames_.size()>0)
46 >      t->SetBaseURL(pathNames_.at(0).c_str());
47 >
48 >    if      (i<maxSizes_.size())
49 >      t->SetMaxSize(maxSizes_.at(i)*1024*1024);
50 >    else if (maxSizes_.size()>0)
51 >      t->SetMaxSize(maxSizes_.at(0)*1024*1024);
52 >
53 >    if      (i<compLevels_.size())
54 >      t->SetCompressLevel(compLevels_.at(i));
55 >    else if (compLevels_.size()>0)
56 >      t->SetCompressLevel(compLevels_.at(0));
57 >
58 >    if      (i<splitLevels_.size())
59 >      t->SetDefaultSL(splitLevels_.at(i));
60 >    else if (splitLevels_.size()>0)
61 >      t->SetDefaultSL(splitLevels_.at(0));
62 >
63 >    if      (i<brSizes_.size())
64 >      t->SetDefaultBrSize(brSizes_.at(i));
65 >    else if (brSizes_.size()>0)
66 >      t->SetDefaultBrSize(brSizes_.at(0));
67  
68      //t->Print();
69      tws_.Add(t);
70    }
71  
72    // set watchers
73 <  r.watchPreProcessEvent(this,&TreeService::preEventProcessing);
73 >  r.watchPreProcessEvent (this,&TreeService::preEventProcessing);
74    r.watchPostProcessEvent(this,&TreeService::postEventProcessing);
75 <  r.watchPostBeginJob(this,&TreeService::postBeginJob);
76 <  r.watchPostEndJob(this,&TreeService::postEndJob);
75 >  r.watchPostBeginJob    (this,&TreeService::postBeginJob);
76 >  r.watchPostEndJob      (this,&TreeService::postEndJob);
77   }
78  
79 < //-------------------------------------------------------------------------------------------------
79 > //--------------------------------------------------------------------------------------------------
80   TreeService::~TreeService()
81   {
82   }
83  
84 < //-------------------------------------------------------------------------------------------------
84 > //--------------------------------------------------------------------------------------------------
85   TreeWriter* TreeService::get(const char *name)
86   {
87 <  if(tws_.GetEntries()<=0) return 0;
87 >  if (tws_.GetEntries()<=0)
88 >    return 0;
89  
90 <  if(name==0)
90 >  if (name==0)
91      return dynamic_cast<TreeWriter*>(tws_.At(0));
92  
93    TObject *ret = tws_.FindObject(name);
94 +
95    return dynamic_cast<TreeWriter*>(ret);
96   }
97  
98 < //-------------------------------------------------------------------------------------------------
98 > //--------------------------------------------------------------------------------------------------
99   void TreeService::postBeginJob()
100   {
101    // nothing to be done for now
102   }
103  
104 < //-------------------------------------------------------------------------------------------------
104 > //--------------------------------------------------------------------------------------------------
105   void TreeService::postEndJob()
106   {
107    tws_.Clear();
108   }
109  
110 < //-------------------------------------------------------------------------------------------------
110 > //--------------------------------------------------------------------------------------------------
111   void TreeService::postEventProcessing(const Event&, const EventSetup&)
112   {
113 <  for(int i=0;i<tws_.GetEntries();++i) {
113 >  for (int i=0; i<tws_.GetEntries(); ++i) {
114      TreeWriter *tw=dynamic_cast<TreeWriter*>(tws_.At(i));
115 <    if(tw)
115 >    if (tw)
116        tw->EndEvent();
117    }
118   }
119  
120 < //-------------------------------------------------------------------------------------------------
120 > //--------------------------------------------------------------------------------------------------
121   void TreeService::preEventProcessing(const EventID&, const Timestamp&)
122   {
123 <  for(int i=0;i<tws_.GetEntries();++i) {
123 >  for (int i=0; i<tws_.GetEntries(); ++i) {
124      TreeWriter *tw=dynamic_cast<TreeWriter*>(tws_.At(i));
125 <    if(tw)
125 >    if (tw)
126        tw->BeginEvent();
127    }
128   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines