CMS 3D CMS Logo

HCAL_HLX::ROOTFileBase Class Reference

#include <RecoLuminosity/ROOTSchema/interface/ROOTFileBase.h>

Inheritance diagram for HCAL_HLX::ROOTFileBase:

HCAL_HLX::TimeStamp HCAL_HLX::ROOTFileMerger HCAL_HLX::ROOTSchema

List of all members.

Public Member Functions

std::string CreateLSFileName (const unsigned int runNumber, const unsigned int sectionNumber)
std::string CreateRunFileName (const unsigned int runNumber, const unsigned int firstSection)
std::string GetFileName ()
std::string GetOutputDir ()
 ROOTFileBase ()
void SetFileName (const std::string &fileName)
void SetOutputDir (std::string dir)
 ~ROOTFileBase ()

Protected Member Functions

void CloseTree ()
void CreateTree (const HCAL_HLX::LUMI_SECTION &localSection)
void FillTree (const HCAL_HLX::LUMI_SECTION &localSection)
void InsertInformation ()
template<class T>
void MakeBranch (const T &in, T **out, int HLXNum)

Protected Attributes

HCAL_HLX::LUMI_DETAIL * Detail
HCAL_HLX::ET_SUM_SECTION * EtSum
HCAL_HLX::ET_SUM_SECTION * EtSumPtr [HCAL_HLX_MAX_HLXS]
unsigned int fileCounter_
std::string fileName_
HCAL_HLX::LUMI_SECTION_HEADER * Header
HCAL_HLX::HLT * HLT
HCAL_HLX::LEVEL1_TRIGGER * L1Trigger
HCAL_HLX::LHC_SECTION * LHC
HCAL_HLX::LHC_SECTION * LHCPtr [HCAL_HLX_MAX_HLXS]
TFile * m_file
TTree * m_tree
HCAL_HLX::OCCUPANCY_SECTION * Occupancy
HCAL_HLX::OCCUPANCY_SECTION * OccupancyPtr [HCAL_HLX_MAX_HLXS]
std::string outputDir_
std::string outputFilePrefix_
HCAL_HLX::LUMI_HF_RING_SET * RingSet
HCAL_HLX::LUMI_SUMMARY * Summary
HCAL_HLX::LUMI_THRESHOLD * Threshold
HCAL_HLX::TRIGGER_DEADTIME * TriggerDeadtime


Detailed Description

Definition at line 21 of file ROOTFileBase.h.


Constructor & Destructor Documentation

HCAL_HLX::ROOTFileBase::ROOTFileBase (  ) 

Definition at line 21 of file ROOTFileBase.cc.

References GenMuonPlsPt100GeV_cfg::cout, Detail, lat::endl(), EtSum, fileCounter_, HLT, L1Trigger, LHC, m_file, NULL, Occupancy, outputDir_, outputFilePrefix_, RingSet, Summary, Threshold, and TriggerDeadtime.

00021                                   {
00022 #ifdef DEBUG
00023   std::cout << "Begin " << __PRETTY_FUNCTION__ << std::endl;
00024 #endif
00025 
00026   Header          = new HCAL_HLX::LUMI_SECTION_HEADER;
00027   Summary         = new HCAL_HLX::LUMI_SUMMARY;
00028   Detail          = new HCAL_HLX::LUMI_DETAIL;
00029 
00030   EtSum           = new HCAL_HLX::ET_SUM_SECTION[HCAL_HLX_MAX_HLXS];
00031   Occupancy       = new HCAL_HLX::OCCUPANCY_SECTION[HCAL_HLX_MAX_HLXS];
00032   LHC             = new HCAL_HLX::LHC_SECTION[HCAL_HLX_MAX_HLXS];
00033 
00034   Threshold       = new HCAL_HLX::LUMI_THRESHOLD;
00035   L1Trigger       = new HCAL_HLX::LEVEL1_TRIGGER;
00036   HLT             = new HCAL_HLX::HLT;
00037   TriggerDeadtime = new HCAL_HLX::TRIGGER_DEADTIME;
00038   RingSet         = new HCAL_HLX::LUMI_HF_RING_SET;
00039 
00040   outputDir_ = ".";
00041   outputFilePrefix_ = "CMS_LUMI_RAW";
00042 
00043   m_file = NULL;
00044 
00045   fileCounter_ = 0;
00046 
00047 #ifdef DEBUG
00048   std::cout << "End " << __PRETTY_FUNCTION__ << std::endl;
00049 #endif
00050 }

HCAL_HLX::ROOTFileBase::~ROOTFileBase (  ) 

Definition at line 52 of file ROOTFileBase.cc.

References GenMuonPlsPt100GeV_cfg::cout, Detail, lat::endl(), EtSum, HLT, L1Trigger, LHC, Occupancy, RingSet, Summary, Threshold, and TriggerDeadtime.

00052                                    {
00053 
00054 #ifdef DEBUG
00055   std::cout << "Begin " << __PRETTY_FUNCTION__ << std::endl;
00056 #endif
00057 
00058   delete Header;
00059   delete Summary;
00060   delete Detail;
00061 
00062   delete [] EtSum;
00063   delete [] Occupancy;
00064   delete [] LHC;
00065 
00066   delete Threshold;
00067   delete L1Trigger;
00068   delete HLT;
00069   delete TriggerDeadtime; 
00070   delete RingSet;
00071 
00072 #ifdef DEBUG
00073   std::cout << "End " << __PRETTY_FUNCTION__ << std::endl;
00074 #endif
00075 }


Member Function Documentation

void HCAL_HLX::ROOTFileBase::CloseTree (  )  [protected]

Definition at line 285 of file ROOTFileBase.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), fileName_, m_file, m_tree, and NULL.

Referenced by HCAL_HLX::ROOTFileMerger::Merge(), and HCAL_HLX::ROOTSchema::ProcessSection().

00285                                     {
00286 #ifdef DEBUG
00287   std::cout << "Begin " << __PRETTY_FUNCTION__ << std::endl;
00288 #endif
00289 
00290   if(fileName_ == ""){
00291     std::cout << "*** File Name was not set ***" << std::endl;
00292     return;
00293   }
00294 
00295   m_file->Write();
00296   m_file->Close();
00297 
00298   //delete m_tree; // NO!!! root does this when you delete m_file
00299   if(m_file != NULL){
00300     delete m_file;
00301     m_file = NULL;
00302     m_tree = NULL;
00303   }
00304 
00305 #ifdef DEBUG
00306   std::cout << "End " << __PRETTY_FUNCTION__ << std::endl;
00307 #endif
00308 }

std::string HCAL_HLX::ROOTFileBase::CreateLSFileName ( const unsigned int  runNumber,
const unsigned int  sectionNumber 
)

Definition at line 83 of file ROOTFileBase.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), outputDir_, outputFilePrefix_, HCAL_HLX::TimeStamp::TimeStampYYYYMM(), and HCAL_HLX::TimeStamp::TimeStampYYYYMMDD().

Referenced by HCAL_HLX::ROOTSchema::ProcessSection().

00083                                                                                                               {
00084 #ifdef DEBUG
00085   std::cout << "Begin " << __PRETTY_FUNCTION__ << std::endl;
00086 #endif
00087 
00088   std::ostringstream outputString;
00089 
00090   // Create directory name
00091   outputString << outputDir_ << "/"
00092                << TimeStampYYYYMM();
00093   mkdir(outputString.str().c_str(), 0777);
00094 
00095   outputString << "/" << std::setfill('0') << std::setw(9) << runNumber;
00096   
00097   // Create the directory that will contain the single lumi section file
00098   mkdir(outputString.str().c_str(), 0777);
00099   
00100   // Create file name
00101   outputString << "/"
00102                << outputFilePrefix_
00103                << "_"
00104                << TimeStampYYYYMMDD() 
00105                << "_"
00106                << std::setfill('0') << std::setw(9) << runNumber << "_"
00107                << std::setfill('0') << std::setw(4) << sectionNumber 
00108                << ".root";
00109 #ifdef DEBUG
00110   std::cout << "Output file is " << outputString.str() << std::endl;
00111   std::cout << "End " << __PRETTY_FUNCTION__ << std::endl;
00112 #endif
00113 
00114   return outputString.str();
00115 }

std::string HCAL_HLX::ROOTFileBase::CreateRunFileName ( const unsigned int  runNumber,
const unsigned int  firstSection 
)

Definition at line 117 of file ROOTFileBase.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), outputDir_, outputFilePrefix_, HCAL_HLX::TimeStamp::TimeStampYYYYMM(), and HCAL_HLX::TimeStamp::TimeStampYYYYMMDD().

Referenced by HCAL_HLX::ROOTFileMerger::Merge().

00117                                                                                                               {
00118 #ifdef DEBUG
00119   std::cout << "Begin " << __PRETTY_FUNCTION__ << std::endl;
00120 #endif
00121 
00122   std::ostringstream outputString;
00123 
00124   // Create file name
00125   outputString << outputDir_ << "/"
00126                << TimeStampYYYYMM()
00127                << "/"
00128                << outputFilePrefix_
00129                << "_"
00130                << TimeStampYYYYMMDD() 
00131                << "_"
00132                << std::setfill('0') << std::setw(9) << runNumber 
00133                << "_"
00134                << std::setfill('0') << std::setw(4) << firstSection
00135                << ".root";
00136   
00137 #ifdef DEBUG
00138   std::cout << "Output file is " <<  outputString.str() << std::endl;
00139   std::cout << "End " << __PRETTY_FUNCTION__ << std::endl;
00140 #endif
00141   
00142   return  outputString.str();
00143 
00144 }

void HCAL_HLX::ROOTFileBase::CreateTree ( const HCAL_HLX::LUMI_SECTION &  localSection  )  [protected]

Definition at line 146 of file ROOTFileBase.cc.

References GenMuonPlsPt100GeV_cfg::cout, Detail, lat::endl(), EtSum, EtSumPtr, cmsRelvalreport::exit, fileName_, HLT, i, L1Trigger, LHC, LHCPtr, m_file, m_tree, MakeBranch(), Occupancy, OccupancyPtr, RingSet, Summary, Threshold, and TriggerDeadtime.

Referenced by HCAL_HLX::ROOTFileMerger::Merge(), and HCAL_HLX::ROOTSchema::ProcessSection().

00146                                                                               {
00147 #ifdef DEBUG
00148   std::cout << "Begin " << __PRETTY_FUNCTION__ << std::endl;
00149 #endif
00150   
00151   if(fileName_ == ""){
00152     std::cout << "*** File Name was not set ***" << std::endl;
00153     return;
00154   }
00155 
00156   m_file = new TFile(fileName_.c_str(), "RECREATE");  
00157 
00158   if(!m_file){
00159     std::cout << " *** Couldn't make or open file: " << fileName_ << " *** " << std::endl;
00160     exit(1);
00161   } 
00162 
00163   m_file->cd();
00164   
00165   m_tree  = new TTree("LumiTree","");
00166 
00167   m_tree->Bronch("Header.",  "HCAL_HLX::LUMI_SECTION_HEADER", &Header,  1);
00168   m_tree->Bronch("Summary.", "HCAL_HLX::LUMI_SUMMARY",        &Summary, 1);
00169   m_tree->Bronch("Detail.",  "HCAL_HLX::LUMI_DETAIL",         &Detail,  1);
00170 
00171   m_tree->Bronch("Threshold.",        "HCAL_HLX::LUMI_THRESHOLD",   &Threshold, 1);
00172   m_tree->Bronch("Level1_Trigger.",   "HCAL_HLX::LEVEL1_TRIGGER",   &L1Trigger, 1);
00173   m_tree->Bronch("HLT.",              "HCAL_HLX::HLT",              &HLT,       1);
00174   m_tree->Bronch("Trigger_Deadtime.", "HCAL_HLX::TRIGGER_DEADTIME", &TriggerDeadtime, 1);
00175   m_tree->Bronch("HF_Ring_Set.",      "HCAL_HLX::LUMI_HF_RING_SET", &RingSet,1);
00176 
00177   for(int i = 0; i < HCAL_HLX_MAX_HLXS; i++){
00178     EtSumPtr[i] = &EtSum[i];
00179     MakeBranch(localSection.etSum[i], &EtSumPtr[i], i);
00180 
00181     OccupancyPtr[i] = &Occupancy[i];
00182     MakeBranch(localSection.occupancy[i], &OccupancyPtr[i], i);
00183 
00184     LHCPtr[i] = &LHC[i];
00185     MakeBranch(localSection.lhc[i], &LHCPtr[i], i);
00186   }
00187 
00188 #ifdef DEBUG
00189   std::cout << "End " << __PRETTY_FUNCTION__ << std::endl;
00190 #endif
00191 }

void HCAL_HLX::ROOTFileBase::FillTree ( const HCAL_HLX::LUMI_SECTION &  localSection  )  [protected]

Definition at line 193 of file ROOTFileBase.cc.

References GenMuonPlsPt100GeV_cfg::cout, Detail, lat::endl(), EtSum, fileName_, i, InsertInformation(), LHC, m_tree, Occupancy, and Summary.

Referenced by HCAL_HLX::ROOTFileMerger::Merge(), and HCAL_HLX::ROOTSchema::ProcessSection().

00193                                                                            {
00194   
00195 #ifdef DEBUG
00196   std::cout << "Begin " << __PRETTY_FUNCTION__ << std::endl;
00197 #endif
00198 
00199   if(fileName_ == ""){
00200     std::cout << "*** File Name was not set ***" << std::endl;
00201     return;
00202   }
00203   
00204   for(int i = 0; i < HCAL_HLX_MAX_HLXS; i++){
00205     memcpy(&EtSum[i],     &localSection.etSum[i],     sizeof(HCAL_HLX::ET_SUM_SECTION));
00206     memcpy(&Occupancy[i], &localSection.occupancy[i], sizeof(HCAL_HLX::OCCUPANCY_SECTION));
00207     memcpy(&LHC[i],       &localSection.lhc[i],       sizeof(HCAL_HLX::LHC_SECTION));
00208   }
00209 
00210   memcpy(Header,  &localSection.hdr,         sizeof (localSection.hdr));
00211   memcpy(Summary, &localSection.lumiSummary, sizeof(HCAL_HLX::LUMI_SUMMARY));
00212   memcpy(Detail,  &localSection.lumiDetail,  sizeof(HCAL_HLX::LUMI_DETAIL));
00213 
00214   InsertInformation(); // To be modified later.
00215 
00216   m_tree->Fill();
00217 
00218 #ifdef DEBUG
00219   //  m_tree->Print();
00220   std::cout << "End " << __PRETTY_FUNCTION__ << std::endl;
00221 #endif
00222 }

std::string HCAL_HLX::ROOTFileBase::GetFileName (  )  [inline]

Definition at line 28 of file ROOTFileBase.h.

References fileName_.

00028 { return fileName_; }

std::string HCAL_HLX::ROOTFileBase::GetOutputDir (  )  [inline]

Definition at line 31 of file ROOTFileBase.h.

References outputDir_.

00031 { return outputDir_; }

void HCAL_HLX::ROOTFileBase::InsertInformation (  )  [protected]

Definition at line 261 of file ROOTFileBase.cc.

References HLT, L1Trigger, RingSet, Threshold, and TriggerDeadtime.

Referenced by FillTree().

00261                                             {
00262   // This information will eventually come from the lms cell
00263   Threshold->OccThreshold1Set1 = 51;
00264   Threshold->OccThreshold2Set1 = 52;
00265   Threshold->OccThreshold1Set2 = 53;
00266   Threshold->OccThreshold2Set2 = 54;
00267   Threshold->ETSum             = 55;
00268 
00269   L1Trigger->L1lineNumber  = 71;
00270   L1Trigger->L1Scaler      = 72;
00271   L1Trigger->L1RateCounter = 73;
00272   
00273   HLT->TriggerPath    = 81;
00274   HLT->InputCount     = 82;
00275   HLT->AcceptCount    = 83;
00276   HLT->PrescaleFactor = 84;
00277 
00278   TriggerDeadtime->TriggerDeadtime = 91;
00279 
00280   RingSet->Set1Rings = "33L,34L";
00281   RingSet->Set2Rings = "35S,36S";
00282   RingSet->EtSumRings = "33L,34L,35S,36S";
00283 }

template<class T>
void HCAL_HLX::ROOTFileBase::MakeBranch ( const T &  in,
T **  out,
int  HLXNum 
) [inline, protected]

Definition at line 225 of file ROOTFileBase.cc.

References className(), GenMuonPlsPt100GeV_cfg::cout, lat::endl(), m_tree, and name.

Referenced by CreateTree().

00225                                                                      {
00226 
00227 #ifdef DEBUG
00228   std::cout << "Begin " << __PRETTY_FUNCTION__ << std::endl;
00229 #endif
00230   
00231   const std::string typeName = typeid(T).name();
00232   std::string className;
00233   std::string branchName;
00234   std::ostringstream numString;
00235 
00236   if(typeName == "N8HCAL_HLX11LHC_SECTIONE"){
00237     className = "HCAL_HLX::LHC_SECTION";
00238     branchName = "LHC";
00239   }else if(typeName == "N8HCAL_HLX17OCCUPANCY_SECTIONE"){
00240     className = "HCAL_HLX::OCCUPANCY_SECTION";
00241     branchName = "Occupancy";
00242   }else if(typeName == "N8HCAL_HLX14ET_SUM_SECTIONE"){
00243     className = "HCAL_HLX::ET_SUM_SECTION";
00244     branchName = "ETSum";
00245   }
00246 
00247 #ifdef DEBUG
00248   std::cout << "Class: " << className << std::endl;
00249   std::cout << "Class: " << typeid(T).name() << std::endl;
00250 #endif
00251   
00252   numString << std::setfill('0') << std::setw(2) << HLXNum;
00253   branchName = branchName + numString.str() + ".";
00254   m_tree->Bronch(branchName.c_str(), className.c_str(), out, 1);
00255 
00256 #ifdef DEBUG
00257   std::cout << "End " << __PRETTY_FUNCTION__ << std::endl;
00258 #endif
00259 }

void HCAL_HLX::ROOTFileBase::SetFileName ( const std::string &  fileName  ) 

Definition at line 77 of file ROOTFileBase.cc.

References fileName_.

Referenced by HCAL_HLX::ROOTFileMerger::Merge(), and HCAL_HLX::ROOTSchema::ProcessSection().

00077                                                                {
00078 
00079   fileName_ = fileName;
00080 
00081 } 

void HCAL_HLX::ROOTFileBase::SetOutputDir ( std::string  dir  )  [inline]

Definition at line 32 of file ROOTFileBase.h.

References outputDir_.

00032 { outputDir_ = dir; }


Member Data Documentation

HCAL_HLX::LUMI_DETAIL* HCAL_HLX::ROOTFileBase::Detail [protected]

Definition at line 52 of file ROOTFileBase.h.

Referenced by CreateTree(), FillTree(), ROOTFileBase(), and ~ROOTFileBase().

HCAL_HLX::ET_SUM_SECTION* HCAL_HLX::ROOTFileBase::EtSum [protected]

Definition at line 54 of file ROOTFileBase.h.

Referenced by CreateTree(), FillTree(), ROOTFileBase(), and ~ROOTFileBase().

HCAL_HLX::ET_SUM_SECTION* HCAL_HLX::ROOTFileBase::EtSumPtr[HCAL_HLX_MAX_HLXS] [protected]

Definition at line 58 of file ROOTFileBase.h.

Referenced by CreateTree().

unsigned int HCAL_HLX::ROOTFileBase::fileCounter_ [protected]

Definition at line 39 of file ROOTFileBase.h.

Referenced by ROOTFileBase().

std::string HCAL_HLX::ROOTFileBase::fileName_ [protected]

Definition at line 62 of file ROOTFileBase.h.

Referenced by CloseTree(), CreateTree(), FillTree(), GetFileName(), and SetFileName().

HCAL_HLX::LUMI_SECTION_HEADER* HCAL_HLX::ROOTFileBase::Header [protected]

Definition at line 50 of file ROOTFileBase.h.

HCAL_HLX::HLT* HCAL_HLX::ROOTFileBase::HLT [protected]

Definition at line 46 of file ROOTFileBase.h.

Referenced by CreateTree(), InsertInformation(), ROOTFileBase(), and ~ROOTFileBase().

HCAL_HLX::LEVEL1_TRIGGER* HCAL_HLX::ROOTFileBase::L1Trigger [protected]

Definition at line 45 of file ROOTFileBase.h.

Referenced by CreateTree(), InsertInformation(), ROOTFileBase(), and ~ROOTFileBase().

HCAL_HLX::LHC_SECTION* HCAL_HLX::ROOTFileBase::LHC [protected]

Definition at line 56 of file ROOTFileBase.h.

Referenced by CreateTree(), FillTree(), ROOTFileBase(), and ~ROOTFileBase().

HCAL_HLX::LHC_SECTION* HCAL_HLX::ROOTFileBase::LHCPtr[HCAL_HLX_MAX_HLXS] [protected]

Definition at line 60 of file ROOTFileBase.h.

Referenced by CreateTree().

TFile* HCAL_HLX::ROOTFileBase::m_file [protected]

Definition at line 42 of file ROOTFileBase.h.

Referenced by CloseTree(), CreateTree(), and ROOTFileBase().

TTree* HCAL_HLX::ROOTFileBase::m_tree [protected]

Definition at line 41 of file ROOTFileBase.h.

Referenced by CloseTree(), CreateTree(), FillTree(), and MakeBranch().

HCAL_HLX::OCCUPANCY_SECTION* HCAL_HLX::ROOTFileBase::Occupancy [protected]

Definition at line 55 of file ROOTFileBase.h.

Referenced by CreateTree(), FillTree(), ROOTFileBase(), and ~ROOTFileBase().

HCAL_HLX::OCCUPANCY_SECTION* HCAL_HLX::ROOTFileBase::OccupancyPtr[HCAL_HLX_MAX_HLXS] [protected]

Definition at line 59 of file ROOTFileBase.h.

Referenced by CreateTree().

std::string HCAL_HLX::ROOTFileBase::outputDir_ [protected]

Definition at line 63 of file ROOTFileBase.h.

Referenced by HCAL_HLX::ROOTFileMerger::CreateInputFileName(), CreateLSFileName(), CreateRunFileName(), GetOutputDir(), ROOTFileBase(), and SetOutputDir().

std::string HCAL_HLX::ROOTFileBase::outputFilePrefix_ [protected]

Definition at line 64 of file ROOTFileBase.h.

Referenced by HCAL_HLX::ROOTFileMerger::CreateInputFileName(), CreateLSFileName(), CreateRunFileName(), and ROOTFileBase().

HCAL_HLX::LUMI_HF_RING_SET* HCAL_HLX::ROOTFileBase::RingSet [protected]

Definition at line 48 of file ROOTFileBase.h.

Referenced by CreateTree(), InsertInformation(), ROOTFileBase(), and ~ROOTFileBase().

HCAL_HLX::LUMI_SUMMARY* HCAL_HLX::ROOTFileBase::Summary [protected]

Definition at line 51 of file ROOTFileBase.h.

Referenced by CreateTree(), FillTree(), ROOTFileBase(), and ~ROOTFileBase().

HCAL_HLX::LUMI_THRESHOLD* HCAL_HLX::ROOTFileBase::Threshold [protected]

Definition at line 44 of file ROOTFileBase.h.

Referenced by CreateTree(), InsertInformation(), ROOTFileBase(), and ~ROOTFileBase().

HCAL_HLX::TRIGGER_DEADTIME* HCAL_HLX::ROOTFileBase::TriggerDeadtime [protected]

Definition at line 47 of file ROOTFileBase.h.

Referenced by CreateTree(), InsertInformation(), ROOTFileBase(), and ~ROOTFileBase().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:47:23 2009 for CMSSW by  doxygen 1.5.4