CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ROOTFileMerger.cc
Go to the documentation of this file.
4 
5 #include "RecoLuminosity/TCPReceiver/interface/LumiStructures.hh"
6 
7 #include <iomanip>
8 #include <cstdio>
9 
10 #include <TFile.h>
11 #include <TChain.h>
12 
13 HCAL_HLX::ROOTFileMerger::ROOTFileMerger():minSectionNumber_(99999)
14 {
15 
16  RFWriter_ = NULL;
17  RFReader_ = NULL;
19 
21  if( RFWriter_ == 0 ){
22  // Could not allocate memory.
23  // Do something.
24  }
25 
27  if( RFReader_ == 0 ){
28  // Could not allocate memory.
29  // Do something.
30  }
31 
33  if( lumiSection_ == 0 ){
34  // Could not allocate memory.
35  // Do something.
36  }
37 
38  RFWriter_->SetMerge(true);
39 }
40 
42 
43  if( RFWriter_ != 0){
44  delete RFWriter_;
45  }
46 
47  if( RFReader_ != 0){
48  delete RFReader_;
49  }
50 
51  if( lumiSection_ !=0 ){
52  delete lumiSection_;
53  }
54 }
55 
56 bool HCAL_HLX::ROOTFileMerger::Merge(const unsigned int runNumber, const unsigned int minSectionNumber ){
57 
58  /*
59  TChain::Merge and TTree::CloneTree leak because we used TTree::Bronch to create the tree.
60  */
61 
62  RFReader_->CreateFileNameList();
63 
64  // RFWriter_->SetFileName(runNumber, firstSectionNumber);
65  RFWriter_->OpenFile(runNumber, minSectionNumber);
66 
67  unsigned int nentries = RFReader_->GetEntries();
68  if( nentries == 0 ){
69  RFWriter_->CloseFile();
70  return false;
71  }
72 
73  for(unsigned int iEntry = 0; iEntry < nentries; ++iEntry ){
74  memset( lumiSection_, 0, sizeof(LUMI_SECTION));
75  RFReader_->GetEntry(iEntry);
76  RFReader_->GetLumiSection(*lumiSection_);
77 
78  // Must fill Threshold eventually right now it contains fake data.
79  RFWriter_->FillTree(*lumiSection_);
80  }
81 
82  return RFWriter_->CloseFile();
83 }
84 
86 
87  RFReader_->SetDir(dirName);
88 }
89 
91 
92  RFWriter_->SetDir(dirName);
93 }
94 
96 
97  return RFWriter_->GetFileName();
98 }
99 
101 
102  RFWriter_->SetEtSumOnly(bEtSumOnly);
103  RFReader_->SetEtSumOnly(bEtSumOnly);
104 }
105 
106 void HCAL_HLX::ROOTFileMerger::SetFileType( const std::string &fileType ){
107 
108  RFWriter_->SetFileType( fileType );
109  RFReader_->SetFileType( fileType );
110 }
111 
112 void HCAL_HLX::ROOTFileMerger::SetDate( const std::string &date ){
113 
114  RFWriter_->SetDate( date );
115  RFReader_->SetDate( date );
116 }
bool Merge(const unsigned int runNumber, const unsigned int minSecNum)
void SetInputDir(const std::string &inputDir)
void SetFileType(const std::string &fileType)
ROOTFileWriter * RFWriter_
void SetMerge(const bool bMerge)
#define NULL
Definition: scimark2.h:8
ROOTFileReader * RFReader_
void SetOutputDir(const std::string &outputDir)
void SetDate(const std::string &date)
std::string GetOutputFileName()
void SetEtSumOnly(const bool bEtSumOnly)
LUMI_SECTION * lumiSection_