CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | 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

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 ()
 
- Public Member Functions inherited from HCAL_HLX::ROOTFileBase
std::string GetDir ()
 
std::string GetFileName ()
 
 ROOTFileBase ()
 
void SetDate (const std::string &date)
 
void SetDir (const std::string &dir)
 
void SetEtSumOnly (bool bEtSumOnly)
 
void SetFileName (const HCAL_HLX::LUMI_SECTION &lumiSection)
 
void SetFileName (unsigned int runNumber, unsigned int sectionNumber)
 
void SetFileType (const std::string &type)
 
virtual ~ROOTFileBase ()
 

Protected Member Functions

void CreateTree ()
 
void InsertInformation ()
 
template<class T >
void MakeBranch (const T &in, T **out, int HLXNum)
 
- Protected Member Functions inherited from HCAL_HLX::ROOTFileBase
void CleanUp ()
 
void Init ()
 

Protected Attributes

bool bMerge_
 
TFile * m_file
 
TTree * m_tree
 
- Protected Attributes inherited from HCAL_HLX::ROOTFileBase
bool bEtSumOnly_
 
std::string date_
 
HCAL_HLX::LUMI_DETAILDetail_
 
std::string dirName_
 
HCAL_HLX::ET_SUM_SECTIONEtSumPtr_ [36]
 
std::string fileName_
 
std::string filePrefix_
 
std::string fileType_
 
HCAL_HLX::LUMI_SECTION_HEADERHeader_
 
HCAL_HLX::LHC_SECTIONLHCPtr_ [36]
 
HCAL_HLX::LUMI_SECTIONlumiSection_
 
HCAL_HLX::OCCUPANCY_SECTIONOccupancyPtr_ [36]
 
HCAL_HLX::LUMI_SUMMARYSummary_
 

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().

21  :bMerge_(false){
22 
23  Init(); // ROOTFileBase
24 }
HCAL_HLX::ROOTFileWriter::~ROOTFileWriter ( )

Definition at line 26 of file ROOTFileWriter.cc.

26  {
27 
28  CleanUp(); // ROOTFileBase
29 }

Member Function Documentation

bool HCAL_HLX::ROOTFileWriter::CloseFile ( )

Definition at line 112 of file ROOTFileWriter.cc.

References NULL.

112  {
113 
114  m_tree->Write();
115  m_file->Close();
116 
117  if(m_file != NULL){
118  delete m_file;
119  //delete m_tree; // NO!!! root does this when you delete m_file
120  m_file = NULL;
121  m_tree = NULL;
122  }
123 
124  return true;
125 }
#define NULL
Definition: scimark2.h:8
void HCAL_HLX::ROOTFileWriter::CreateTree ( )
protectedvirtual

Implements HCAL_HLX::ROOTFileBase.

Definition at line 53 of file ROOTFileWriter.cc.

53  {
54 
55  m_tree = new TTree("LumiTree","");
56 
57  Header_ = &(lumiSection_->hdr);
60 
61  m_tree->Bronch("Header.", "HCAL_HLX::LUMI_SECTION_HEADER", &Header_, 1);
62 
63  if( !bEtSumOnly_ ){
64  m_tree->Bronch("Summary.", "HCAL_HLX::LUMI_SUMMARY", &Summary_, 1);
65  m_tree->Bronch("Detail.", "HCAL_HLX::LUMI_DETAIL", &Detail_, 1);
66  }
67 
68  for( unsigned int iHLX = 0; iHLX < 36; ++iHLX ){
69  EtSumPtr_[iHLX] = &( lumiSection_->etSum[iHLX] );
70  MakeBranch(lumiSection_->etSum[iHLX], &EtSumPtr_[iHLX], iHLX);
71 
72  if( !bEtSumOnly_ ){
73  OccupancyPtr_[iHLX] = &(lumiSection_->occupancy[iHLX]);
74  MakeBranch(lumiSection_->occupancy[iHLX], &OccupancyPtr_[iHLX], iHLX);
75 
76  LHCPtr_[iHLX] = &(lumiSection_->lhc[iHLX]);
77  MakeBranch(lumiSection_->lhc[iHLX], &LHCPtr_[iHLX], iHLX);
78  }
79  }
80 }
HCAL_HLX::LUMI_SECTION * lumiSection_
Definition: ROOTFileBase.h:55
HCAL_HLX::LUMI_DETAIL * Detail_
Definition: ROOTFileBase.h:59
ET_SUM_SECTION etSum[HCAL_HLX_MAX_HLXS]
HCAL_HLX::LUMI_SUMMARY * Summary_
Definition: ROOTFileBase.h:58
HCAL_HLX::LHC_SECTION * LHCPtr_[36]
Definition: ROOTFileBase.h:63
LHC_SECTION lhc[HCAL_HLX_MAX_HLXS]
HCAL_HLX::OCCUPANCY_SECTION * OccupancyPtr_[36]
Definition: ROOTFileBase.h:62
HCAL_HLX::LUMI_SECTION_HEADER * Header_
Definition: ROOTFileBase.h:57
HCAL_HLX::ET_SUM_SECTION * EtSumPtr_[36]
Definition: ROOTFileBase.h:61
OCCUPANCY_SECTION occupancy[HCAL_HLX_MAX_HLXS]
void MakeBranch(const T &in, T **out, int HLXNum)
void HCAL_HLX::ROOTFileWriter::FillTree ( const HCAL_HLX::LUMI_SECTION localSection)

Definition at line 106 of file ROOTFileWriter.cc.

106  {
107 
108  memcpy( lumiSection_, &localSection, sizeof(HCAL_HLX::LUMI_SECTION));
109  m_tree->Fill();
110 }
HCAL_HLX::LUMI_SECTION * lumiSection_
Definition: ROOTFileBase.h:55
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.

83  {
84 
85  const std::string typeName = typeid(T).name();
86  std::string className;
87  std::string branchName;
88  std::ostringstream numString;
89 
90  if(typeName == "N8HCAL_HLX11LHC_SECTIONE"){
91  className = "HCAL_HLX::LHC_SECTION";
92  branchName = "LHC";
93  }else if(typeName == "N8HCAL_HLX17OCCUPANCY_SECTIONE"){
94  className = "HCAL_HLX::OCCUPANCY_SECTION";
95  branchName = "Occupancy";
96  }else if(typeName == "N8HCAL_HLX14ET_SUM_SECTIONE"){
97  className = "HCAL_HLX::ET_SUM_SECTION";
98  branchName = "ETSum";
99  }
100 
101  numString << std::setfill('0') << std::setw(2) << HLXNum;
102  branchName = branchName + numString.str() + ".";
103  m_tree->Bronch(branchName.c_str(), className.c_str(), out, 1);
104 }
tuple out
Definition: dbtoconf.py:99
long double T
std::string className(const T &t)
Definition: ClassName.h:30
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.

31  {
32 
33  return OpenFile( localSection.hdr.runNumber,
34  localSection.hdr.sectionNumber);
35 }
bool OpenFile(const HCAL_HLX::LUMI_SECTION &lumiSection)
bool HCAL_HLX::ROOTFileWriter::OpenFile ( const unsigned int  runNumber,
const unsigned int  sectionNumber 
)

Definition at line 37 of file ROOTFileWriter.cc.

38  {
39 
40  SetFileName( runNumber, sectionNumber);
41 
42  m_file = new TFile( (dirName_ + fileName_).c_str(), "RECREATE");
43  if( !m_file ){
44  return false;
45  }
46 
47  m_file->cd();
48  CreateTree();
49 
50  return true;
51 }
void SetFileName(const HCAL_HLX::LUMI_SECTION &lumiSection)
Definition: ROOTFileBase.cc:70
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().

36 { bMerge_ = bMerge; }

Member Data Documentation

bool HCAL_HLX::ROOTFileWriter::bMerge_
protected

Definition at line 49 of file ROOTFileWriter.h.

Referenced by SetMerge().

TFile* HCAL_HLX::ROOTFileWriter::m_file
protected

Definition at line 46 of file ROOTFileWriter.h.

TTree* HCAL_HLX::ROOTFileWriter::m_tree
protected

Definition at line 47 of file ROOTFileWriter.h.