00001 #ifndef EVENT_LOOP_ALGS__NTUPLE_SVC_H
00002 #define EVENT_LOOP_ALGS__NTUPLE_SVC_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00017
00018
00019
00020 #include <EventLoopAlgs/Global.h>
00021
00022 #include <set>
00023 #include <EventLoop/Algorithm.h>
00024
00025 class TBranch;
00026 class TFile;
00027 class TTree;
00028
00029 namespace EL
00030 {
00038 NTupleSvc *getNTupleSvc (Worker *worker,
00039 const std::string& outputStream,
00040 const std::string& treeName = "");
00041
00042
00043
00044 class NTupleSvc : public EL::Algorithm
00045 {
00046
00047
00048
00049
00052 public:
00053 void testInvariant () const;
00054
00055
00060 public:
00061 NTupleSvc (const std::string& val_outputName = "output");
00062
00063
00066 public:
00067 ~NTupleSvc ();
00068
00069
00074 public:
00075 void copyBranch (const std::string& name);
00076
00077
00085 public:
00086 void copyBranchList (const std::string& fileName);
00087
00088
00092 public:
00093 void addWhiteFloat (const std::string& varName);
00094
00095
00099 public:
00100 void addWhiteArray (const std::string& varName);
00101
00102
00107 public:
00108 TTree *tree () const;
00109
00110
00113 public:
00114 bool getFilterPassed () const;
00115
00116
00120 public:
00121 void setFilterPassed (bool passed = true);
00122
00123
00128 public:
00129 const std::string& treeName () const;
00130 void treeName (const std::string& val_treeName);
00131
00132
00133
00134
00135
00136
00139 public:
00140 virtual const char *GetName () const;
00141
00142
00151 private:
00152 virtual StatusCode setupJob (Job& job);
00153
00154
00160 private:
00161 virtual StatusCode changeInput (bool firstFile);
00162
00163
00174 private:
00175 virtual StatusCode initialize ();
00176
00177
00182 private:
00183 virtual StatusCode execute ();
00184
00185
00193 private:
00194 virtual StatusCode postExecute ();
00195
00196
00203 private:
00204 virtual bool hasName (const std::string& name) const;
00205
00206
00207
00208
00209
00210
00211
00213 private:
00214 std::string m_outputName;
00215
00217 private:
00218 std::string m_treeName;
00219
00221 private:
00222 std::string m_tree_title;
00223
00225 private:
00226 std::set<std::string> m_copyBranches;
00227 typedef std::set<std::string>::iterator m_copyBranchesIter;
00228
00230 private:
00231 std::set<std::string> m_whiteFloat;
00232 typedef std::set<std::string>::iterator m_whiteFloatIter;
00233
00235 private:
00236 std::set<std::string> m_whiteArray;
00237 typedef std::set<std::string>::iterator m_whiteArrayIter;
00238
00240 private:
00241 TFile *m_file;
00242
00244 private:
00245 TTree *m_tree;
00246
00248 private:
00249 bool m_initialized;
00250
00252 private:
00253 bool m_taken;
00254
00257 private:
00258 bool m_connected;
00259
00261 private:
00262 WhiteBoardSvc *m_whiteboard;
00263
00265 private:
00266 struct CopyInfo
00267 {
00269 public:
00270 std::string name;
00271
00273 public:
00274 TBranch *source;
00275
00277 public:
00278 TBranch *target;
00279
00281 public:
00282 std::vector<char> buffer;
00283 };
00284 std::vector<CopyInfo> m_copyInfo;
00285 typedef std::vector<CopyInfo>::iterator copyInfoMIter;
00286
00288 private:
00289 struct WhiteInfo
00290 {
00292 public:
00293 std::string name;
00294
00296 public:
00297 bool array;
00298
00300 public:
00301 std::vector<float> buffer;
00302
00305 public:
00306 std::vector<float> *pointer;
00307 };
00308 std::vector<WhiteInfo> m_whiteInfo;
00309 typedef std::vector<WhiteInfo>::iterator whiteInfoMIter;
00310
00311
00316 private:
00317 void initBranches ();
00318
00319
00324 private:
00325 void findBranches (std::set<std::string>& branchList);
00326
00327
00336 private:
00337 void initOutput (const std::string& branchName);
00338
00339
00345 private:
00346 void initOutput (const std::set<std::string>& branchList);
00347
00348
00352 private:
00353 void copyInput ();
00354
00355
00356 ClassDef(NTupleSvc, 1);
00357 };
00358 }
00359
00360 #endif