CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
HCAL_HLX::ROOTFileReader Class Reference

#include <ROOTFileReader.h>

Inheritance diagram for HCAL_HLX::ROOTFileReader:
HCAL_HLX::ROOTFileBase

Public Member Functions

int CreateFileNameList ()
 
unsigned int GetEntries ()
 
int GetEntry (int entry)
 
int GetLumiSection (HCAL_HLX::LUMI_SECTION &section)
 
 ROOTFileReader ()
 
int SetFileName (const std::string &fileName)
 
 ~ROOTFileReader ()
 
- 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 ()
 

Private Member Functions

void CreateTree ()
 
int ReplaceFile (const std::vector< std::string > &fileNames)
 

Private Attributes

TBranch * b_Detail
 
TBranch * b_ETSum [NUM_HLXS]
 
TBranch * b_Header
 
TBranch * b_LHC [NUM_HLXS]
 
TBranch * b_Occupancy [NUM_HLXS]
 
TBranch * b_Summary
 
TChain * mChain_
 

Static Private Attributes

static const unsigned int NUM_HLXS = 36
 

Additional Inherited Members

- Protected Member Functions inherited from HCAL_HLX::ROOTFileBase
void CleanUp ()
 
void Init ()
 
- 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 21 of file ROOTFileReader.h.

Constructor & Destructor Documentation

HCAL_HLX::ROOTFileReader::ROOTFileReader ( )

Definition at line 20 of file ROOTFileReader.cc.

References HCAL_HLX::ROOTFileBase::Init(), and mChain_.

20  {
21 
22  mChain_ = new TChain("LumiTree");
23  Init();
24 }
HCAL_HLX::ROOTFileReader::~ROOTFileReader ( )

Definition at line 26 of file ROOTFileReader.cc.

26  {
27 
28  CleanUp();
29  delete mChain_;
30 }

Member Function Documentation

int HCAL_HLX::ROOTFileReader::CreateFileNameList ( )

Definition at line 32 of file ROOTFileReader.cc.

References linker::DIR, LaserDQM_cfg::fileNames, NULL, and python.multivaluedict::sort().

32  {
33 
34  // Look for files that follow the standard naming convention.
35  DIR *dp;
36  struct dirent *dirp;
37  std::string tempFileName;
38 
39  std::vector< std::string > fileNames;
40  fileNames.clear();
41 
42  if( dirName_ == ""){
43  return false;
44  }
45 
46  // Check directory existance.
47  if( ( dp = opendir( dirName_.c_str() ) ) == NULL ){
48  return false;
49  }
50 
51  while( (dirp = readdir(dp)) != NULL ){
52  tempFileName = dirp->d_name;
53  if(tempFileName.substr(0,8) == "CMS_LUMI" ){
54  fileNames.push_back( dirName_ + tempFileName);
55  }
56  }
57  closedir(dp);
58 
59  if( fileNames.size() == 0 ){
60  return false;
61  }
62 
63  sort(fileNames.begin(), fileNames.end());
64  return ReplaceFile( fileNames );
65 }
#define NULL
Definition: scimark2.h:8
int ReplaceFile(const std::vector< std::string > &fileNames)
list DIR
Definition: linker.py:124
tuple fileNames
Definition: LaserDQM_cfg.py:34
void HCAL_HLX::ROOTFileReader::CreateTree ( )
privatevirtual

Implements HCAL_HLX::ROOTFileBase.

Definition at line 94 of file ROOTFileReader.cc.

94  {
95 
96  Header_ = &(lumiSection_->hdr);
99 
100  mChain_->SetBranchAddress("Header.", &Header_, &b_Header);
101 
102  if( !bEtSumOnly_ ){
103  mChain_->SetBranchAddress("Summary.", &Summary_, &b_Summary);
104  mChain_->SetBranchAddress("Detail.", &Detail_, &b_Detail);
105  }
106 
107  for(unsigned int iHLX = 0; iHLX < 36; ++iHLX){
108  std::stringstream branchName;
109 
110  EtSumPtr_[iHLX] = &(lumiSection_->etSum[iHLX]);
111  branchName.str(std::string());
112  branchName << "ETSum" << std::setw(2) << std::setfill('0') << iHLX << ".";
113  mChain_->SetBranchAddress(branchName.str().c_str(), &EtSumPtr_[iHLX], &b_ETSum[iHLX]);
114 
115  if( !bEtSumOnly_ ){
116  OccupancyPtr_[iHLX] = &(lumiSection_->occupancy[iHLX]);
117  branchName.str(std::string());
118  branchName << "Occupancy" << std::setw(2) << std::setfill('0') << iHLX << ".";
119  mChain_->SetBranchAddress(branchName.str().c_str(), &OccupancyPtr_[iHLX], &b_Occupancy[iHLX]);
120 
121  LHCPtr_[iHLX] = &(lumiSection_->lhc[iHLX]);
122  branchName.str(std::string());
123  branchName << "LHC" << std::setw(2) << std::setfill('0') << iHLX << ".";
124  mChain_->SetBranchAddress(branchName.str().c_str(), &LHCPtr_[iHLX], &b_LHC[iHLX]);
125  }
126 
127  }
128 
129 }
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
TBranch * b_Occupancy[NUM_HLXS]
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]
TBranch * b_ETSum[NUM_HLXS]
TBranch * b_LHC[NUM_HLXS]
unsigned int HCAL_HLX::ROOTFileReader::GetEntries ( )

Definition at line 131 of file ROOTFileReader.cc.

131  {
132 
133  return mChain_->GetEntries();
134 }
int HCAL_HLX::ROOTFileReader::GetEntry ( int  entry)

Definition at line 136 of file ROOTFileReader.cc.

136  {
137 
138  int bytes = mChain_->GetEntry(entry);
139  return bytes;
140 }
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
int HCAL_HLX::ROOTFileReader::GetLumiSection ( HCAL_HLX::LUMI_SECTION section)

Definition at line 142 of file ROOTFileReader.cc.

142  {
143 
144  memcpy(&localSection, lumiSection_, sizeof(HCAL_HLX::LUMI_SECTION));
145  return 0;
146 }
HCAL_HLX::LUMI_SECTION * lumiSection_
Definition: ROOTFileBase.h:55
int HCAL_HLX::ROOTFileReader::ReplaceFile ( const std::vector< std::string > &  fileNames)
private

Definition at line 77 of file ROOTFileReader.cc.

77  {
78  // ReplaceFile is called by either SetFileName or CreateFileNameList.
79 
80  delete mChain_;
81  mChain_ = new TChain("LumiTree");
82 
83  for( std::vector< std::string >::const_iterator VoS = fileNames.begin();
84  VoS != fileNames.end();
85  ++VoS){
86  mChain_->Add((*VoS).c_str());
87  }
88 
89  CreateTree();
90 
91  return mChain_->GetEntries();
92 }
tuple fileNames
Definition: LaserDQM_cfg.py:34
int HCAL_HLX::ROOTFileReader::SetFileName ( const std::string &  fileName)

Definition at line 67 of file ROOTFileReader.cc.

67  {
68 
69  std::vector< std::string > tempVecOfStrings;
70 
71  tempVecOfStrings.clear();
72  tempVecOfStrings.push_back( dirName_ + fileName);
73 
74  return ReplaceFile( tempVecOfStrings );
75 }
int ReplaceFile(const std::vector< std::string > &fileNames)

Member Data Documentation

TBranch* HCAL_HLX::ROOTFileReader::b_Detail
private

Definition at line 47 of file ROOTFileReader.h.

TBranch* HCAL_HLX::ROOTFileReader::b_ETSum[NUM_HLXS]
private

Definition at line 51 of file ROOTFileReader.h.

TBranch* HCAL_HLX::ROOTFileReader::b_Header
private

Definition at line 45 of file ROOTFileReader.h.

TBranch* HCAL_HLX::ROOTFileReader::b_LHC[NUM_HLXS]
private

Definition at line 53 of file ROOTFileReader.h.

TBranch* HCAL_HLX::ROOTFileReader::b_Occupancy[NUM_HLXS]
private

Definition at line 52 of file ROOTFileReader.h.

TBranch* HCAL_HLX::ROOTFileReader::b_Summary
private

Definition at line 46 of file ROOTFileReader.h.

TChain* HCAL_HLX::ROOTFileReader::mChain_
private

Definition at line 41 of file ROOTFileReader.h.

Referenced by ROOTFileReader().

const unsigned int HCAL_HLX::ROOTFileReader::NUM_HLXS = 36
staticprivate

Definition at line 49 of file ROOTFileReader.h.