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 align_tpl::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  closedir(dp);
49  return false;
50  }
51 
52  while( (dirp = readdir(dp)) != NULL ){
53  tempFileName = dirp->d_name;
54  if(tempFileName.substr(0,8) == "CMS_LUMI" ){
55  fileNames.push_back( dirName_ + tempFileName);
56  }
57  }
58  closedir(dp);
59 
60  if( fileNames.size() == 0 ){
61  return false;
62  }
63 
64  sort(fileNames.begin(), fileNames.end());
65  return ReplaceFile( fileNames );
66 }
tuple fileNames
Definition: align_tpl.py:17
#define NULL
Definition: scimark2.h:8
int ReplaceFile(const std::vector< std::string > &fileNames)
void HCAL_HLX::ROOTFileReader::CreateTree ( )
privatevirtual

Implements HCAL_HLX::ROOTFileBase.

Definition at line 95 of file ROOTFileReader.cc.

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

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

Definition at line 137 of file ROOTFileReader.cc.

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

Definition at line 143 of file ROOTFileReader.cc.

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

Definition at line 78 of file ROOTFileReader.cc.

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

Definition at line 68 of file ROOTFileReader.cc.

68  {
69 
70  std::vector< std::string > tempVecOfStrings;
71 
72  tempVecOfStrings.clear();
73  tempVecOfStrings.push_back( dirName_ + fileName);
74 
75  return ReplaceFile( tempVecOfStrings );
76 }
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.