CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Protected Attributes

HCAL_HLX::ROOTFileWriter Class Reference

#include <ROOTFileWriter.h>

Inheritance diagram for HCAL_HLX::ROOTFileWriter:
HCAL_HLX::ROOTFileBase

List of all members.

Public Member Functions

bool CloseFile ()
void FillTree (const HCAL_HLX::LUMI_SECTION &localSection)
bool OpenFile (const HCAL_HLX::LUMI_SECTION &lumiSection)
bool OpenFile (const unsigned int runNumber, const unsigned int sectionNumber)
 ROOTFileWriter ()
void SetMerge (const bool bMerge)
 ~ROOTFileWriter ()

Protected Member Functions

void CreateTree ()
void InsertInformation ()
template<class T >
void MakeBranch (const T &in, T **out, int HLXNum)

Protected Attributes

bool bMerge_
TFile * m_file
TTree * m_tree

Detailed Description

Definition at line 22 of file ROOTFileWriter.h.


Constructor & Destructor Documentation

HCAL_HLX::ROOTFileWriter::ROOTFileWriter ( )

Definition at line 21 of file ROOTFileWriter.cc.

References HCAL_HLX::ROOTFileBase::Init().

                                      :bMerge_(false){

  Init(); // ROOTFileBase
}
HCAL_HLX::ROOTFileWriter::~ROOTFileWriter ( )

Definition at line 26 of file ROOTFileWriter.cc.

                                       {

  CleanUp(); // ROOTFileBase
}

Member Function Documentation

bool HCAL_HLX::ROOTFileWriter::CloseFile ( )

Definition at line 112 of file ROOTFileWriter.cc.

References NULL.

                                      {
  
  m_tree->Write();
  m_file->Close();
  
  if(m_file != NULL){
    delete m_file;
    //delete m_tree; // NO!!! root does this when you delete m_file
    m_file = NULL;
    m_tree = NULL;
  }
  
  return true;
}
void HCAL_HLX::ROOTFileWriter::CreateTree ( ) [protected, virtual]

Implements HCAL_HLX::ROOTFileBase.

Definition at line 53 of file ROOTFileWriter.cc.

                                       {
  
  m_tree   = new TTree("LumiTree","");

  Header_  = &(lumiSection_->hdr);
  Summary_ = &(lumiSection_->lumiSummary);
  Detail_  = &(lumiSection_->lumiDetail);
  
  m_tree->Bronch("Header.",  "HCAL_HLX::LUMI_SECTION_HEADER", &Header_,  1);

  if( !bEtSumOnly_ ){
    m_tree->Bronch("Summary.", "HCAL_HLX::LUMI_SUMMARY",        &Summary_, 1);
    m_tree->Bronch("Detail.",  "HCAL_HLX::LUMI_DETAIL",         &Detail_,  1);
  }

  for( unsigned int iHLX = 0; iHLX < 36; ++iHLX ){
    EtSumPtr_[iHLX] = &( lumiSection_->etSum[iHLX] );
    MakeBranch(lumiSection_->etSum[iHLX], &EtSumPtr_[iHLX], iHLX);
    
    if( !bEtSumOnly_ ){
      OccupancyPtr_[iHLX] = &(lumiSection_->occupancy[iHLX]);
      MakeBranch(lumiSection_->occupancy[iHLX], &OccupancyPtr_[iHLX], iHLX);
      
      LHCPtr_[iHLX] = &(lumiSection_->lhc[iHLX]);
      MakeBranch(lumiSection_->lhc[iHLX], &LHCPtr_[iHLX], iHLX);
    }
  }
}
void HCAL_HLX::ROOTFileWriter::FillTree ( const HCAL_HLX::LUMI_SECTION localSection)

Definition at line 106 of file ROOTFileWriter.cc.

                                                                             {

  memcpy( lumiSection_, &localSection, sizeof(HCAL_HLX::LUMI_SECTION));
  m_tree->Fill();
}
void HCAL_HLX::ROOTFileWriter::InsertInformation ( ) [protected]
template<class T >
void HCAL_HLX::ROOTFileWriter::MakeBranch ( const T in,
T **  out,
int  HLXNum 
) [protected]

Definition at line 83 of file ROOTFileWriter.cc.

References className(), mergeVDriftHistosByStation::name, and dbtoconf::out.

                                                                             {
  
  const std::string typeName = typeid(T).name();
  std::string className;
  std::string branchName;
  std::ostringstream numString;

  if(typeName == "N8HCAL_HLX11LHC_SECTIONE"){
    className = "HCAL_HLX::LHC_SECTION";
    branchName = "LHC";
  }else if(typeName == "N8HCAL_HLX17OCCUPANCY_SECTIONE"){
    className = "HCAL_HLX::OCCUPANCY_SECTION";
    branchName = "Occupancy";
  }else if(typeName == "N8HCAL_HLX14ET_SUM_SECTIONE"){
    className = "HCAL_HLX::ET_SUM_SECTION";
    branchName = "ETSum";
  }
  
  numString << std::setfill('0') << std::setw(2) << HLXNum;
  branchName = branchName + numString.str() + ".";
  m_tree->Bronch(branchName.c_str(), className.c_str(), out, 1);
}
bool HCAL_HLX::ROOTFileWriter::OpenFile ( const unsigned int  runNumber,
const unsigned int  sectionNumber 
)

Definition at line 37 of file ROOTFileWriter.cc.

                                                                          {

  SetFileName( runNumber, sectionNumber);

  m_file = new TFile( (dirName_ + fileName_).c_str(), "RECREATE");
  if( !m_file ){
    return false;
  }

  m_file->cd();
  CreateTree();

  return true;
}
bool HCAL_HLX::ROOTFileWriter::OpenFile ( const HCAL_HLX::LUMI_SECTION lumiSection)

Definition at line 31 of file ROOTFileWriter.cc.

References HCAL_HLX::LUMI_SECTION::hdr, HCAL_HLX::LUMI_SECTION_HEADER::runNumber, and HCAL_HLX::LUMI_SECTION_HEADER::sectionNumber.

                                                                             {

  return OpenFile( localSection.hdr.runNumber,
                   localSection.hdr.sectionNumber);
}
void HCAL_HLX::ROOTFileWriter::SetMerge ( const bool  bMerge) [inline]

Definition at line 36 of file ROOTFileWriter.h.

References bMerge_.

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

{ bMerge_ = bMerge; }

Member Data Documentation

Definition at line 49 of file ROOTFileWriter.h.

Referenced by SetMerge().

Definition at line 46 of file ROOTFileWriter.h.

Definition at line 47 of file ROOTFileWriter.h.