Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "RecoLuminosity/ROOTSchema/interface/ROOTSchema.h"
00016 #include "RecoLuminosity/ROOTSchema/interface/ROOTFileWriter.h"
00017 #include "RecoLuminosity/ROOTSchema/interface/HTMLGenerator.hh"
00018 #include "RecoLuminosity/ROOTSchema/interface/ROOTFileMerger.h"
00019 #include "RecoLuminosity/ROOTSchema/interface/ROOTFileTransfer.h"
00020
00021 #include "RecoLuminosity/TCPReceiver/interface/LumiStructures.hh"
00022
00023 #include <iomanip>
00024
00025 HCAL_HLX::ROOTSchema::ROOTSchema():RFMerger_(NULL), RFTransfer_(NULL),
00026 LumiHTML_(NULL), RFWriter_(NULL),
00027 previousRun_(0), firstSectionNumber_(0),
00028 startTime_(0),
00029 bMerge_(0), bWBM_(0), bTransfer_(0),
00030 bEtSumOnly_(false),
00031 fileType_("RAW"),
00032 lsDir_(""),
00033 mergeDir_(""),
00034 dateDir_(""),
00035 runDir_("")
00036 {
00037
00038
00039 RFWriter_ = new ROOTFileWriter;
00040 if( !RFWriter_ ){
00041
00042 }
00043 RFMerger_ = new ROOTFileMerger;
00044 if( !RFMerger_ ){
00045
00046 }
00047 RFTransfer_ = new ROOTFileTransfer;
00048 if( !RFTransfer_ ){
00049
00050 }
00051 LumiHTML_ = new HTMLGenerator;
00052 if( !LumiHTML_ ){
00053
00054 }
00055 }
00056
00057 HCAL_HLX::ROOTSchema::~ROOTSchema(){
00058
00059
00060 EndRun();
00061
00062 if( RFWriter_ ){
00063 delete RFWriter_;
00064 RFWriter_ = 0;
00065 }
00066
00067 if( RFMerger_ ){
00068 delete RFMerger_;
00069 RFMerger_ = 0;
00070 }
00071
00072 if( RFTransfer_ ){
00073 delete RFTransfer_;
00074 RFTransfer_ = 0;
00075 }
00076
00077 if( LumiHTML_ ){
00078 delete LumiHTML_;
00079 LumiHTML_ = 0;
00080 }
00081 }
00082
00083
00084
00085
00086
00087 void HCAL_HLX::ROOTSchema::SetEtSumOnly(const bool bEtSumOnly){
00088
00089 bEtSumOnly_ = bEtSumOnly;
00090 }
00091
00092 void HCAL_HLX::ROOTSchema::SetFileType( const std::string &fileType ){
00093
00094 if( fileType_ != fileType ){
00095 fileType_ = fileType;
00096 if( (fileType_ != "RAW") && (fileType_ != "VDM") && (fileType_ != "ET") ){
00097 fileType_ = "RAW";
00098 }
00099
00100 if( fileType_ != "ET" && bEtSumOnly_ ){
00101 bEtSumOnly_ = false;
00102 }
00103 if( fileType_ == "ET" && !bEtSumOnly_ ){
00104 bEtSumOnly_ = true;
00105 }
00106
00107 RFWriter_->SetEtSumOnly( bEtSumOnly_ );
00108 LumiHTML_->SetEtSumOnly( bEtSumOnly_ );
00109 RFMerger_->SetEtSumOnly( bEtSumOnly_ );
00110 RFTransfer_->SetEtSumOnly( bEtSumOnly_ );
00111
00112 RFWriter_->SetFileType(fileType_);
00113 LumiHTML_->SetFileType(fileType_);
00114 RFMerger_->SetFileType(fileType_);
00115 RFTransfer_->SetFileType(fileType_);
00116
00117 }
00118
00119 }
00120
00121
00122
00123 void HCAL_HLX::ROOTSchema::SetLSDir(const std::string &lsDir ){
00124
00125 lsDir_ = lsDir;
00126 if( lsDir_.substr( lsDir_.size() - 1) != "/" ){
00127 lsDir_ += "/";
00128 }
00129 }
00130
00131
00132
00133 void HCAL_HLX::ROOTSchema::SetMergeFiles(bool bMerge){
00134
00135 bMerge_ = bMerge;
00136 if( !bMerge_ ){
00137 bTransfer_ = false;
00138 }
00139 }
00140
00141 void HCAL_HLX::ROOTSchema::SetMergeDir(const std::string &mergeDir ){
00142
00143 mergeDir_ = mergeDir;
00144 if( mergeDir_.substr( mergeDir_.size() - 1) != "/" ){
00145 mergeDir_ += "/";
00146 }
00147 }
00148
00149
00150
00151 void HCAL_HLX::ROOTSchema::SetTransferFiles(const bool bTransfer){
00152
00153 bTransfer_ = bTransfer;
00154 if( bTransfer_ ){
00155 bMerge_ = true;
00156 }
00157 }
00158
00159
00160
00161 void HCAL_HLX::ROOTSchema::SetCreateWebPage(const bool bWBM){
00162
00163 bWBM_ = bWBM;
00164 }
00165
00166 void HCAL_HLX::ROOTSchema::SetWebDir(const std::string &webDir){
00167
00168 LumiHTML_->SetOutputDir( webDir );
00169 }
00170
00171 void HCAL_HLX::ROOTSchema::SetHistoBins(const int NBins, const double XMin, const double XMax){
00172
00173 LumiHTML_->SetHistoBins( NBins, XMin, XMax );
00174 }
00175
00176
00177
00178 bool HCAL_HLX::ROOTSchema::ProcessSection(const HCAL_HLX::LUMI_SECTION &lumiSection){
00179
00180 if( (previousRun_) != (lumiSection.hdr.runNumber) ){
00181 EndRun();
00182
00183
00184 previousRun_ = lumiSection.hdr.runNumber;
00185 firstSectionNumber_ = lumiSection.hdr.sectionNumber;
00186 startTime_ = lumiSection.hdr.timestamp;
00187
00188 RFWriter_->SetDate( TimeStampYYYYMMDD( startTime_ ));
00189 RFMerger_->SetDate( TimeStampYYYYMMDD( startTime_ ));
00190
00191
00192 std::stringstream runDirss;
00193 runDirss.str(std::string(""));
00194 dateDir_ = TimeStampYYYYMM( startTime_ ) + "/";
00195 runDirss << std::setw(9) << std::setfill('0') << previousRun_ << "/";
00196 runDir_ = runDirss.str();
00197
00198 MakeDir( lsDir_ + dateDir_ + runDir_ , 0775);
00199 RFWriter_->SetDir( lsDir_ + dateDir_ + runDir_ );
00200
00201 RFMerger_->SetInputDir( lsDir_ + dateDir_ + runDir_ );
00202 MakeDir( mergeDir_ + dateDir_ , 0775);
00203 RFMerger_->SetOutputDir( mergeDir_ + dateDir_ );
00204
00205 LumiHTML_->SetInputDir( lsDir_ + dateDir_ + runDir_ );
00206 RFTransfer_->SetInputDir( mergeDir_ + dateDir_ );
00207 }
00208
00209
00210 RFWriter_->OpenFile( lumiSection );
00211 RFWriter_->FillTree( lumiSection );
00212 RFWriter_->CloseFile();
00213
00214
00215 if( bWBM_ ){
00216 LumiHTML_->CreateWebPage( RFWriter_->GetFileName(), 0 );
00217 }
00218 return true;
00219 }
00220
00221 void HCAL_HLX::ROOTSchema::EndRun(){
00222
00223 if( previousRun_ != 0 ){
00224 if( bMerge_ ){
00225 RFMerger_->Merge( previousRun_, firstSectionNumber_ );
00226
00227 if( bTransfer_ ){
00228 RFTransfer_->SetFileName( RFMerger_->GetOutputFileName());
00229 RFTransfer_->TransferFile();
00230 }
00231 }
00232 previousRun_ = 0;
00233 }
00234 }