CMS 3D CMS Logo

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

List of all members.

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

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

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_.

                                      {
  
  mChain_ = new TChain("LumiTree");
  Init();
}
HCAL_HLX::ROOTFileReader::~ROOTFileReader ( )

Definition at line 26 of file ROOTFileReader.cc.

                                       {

  CleanUp();
  delete mChain_;  
}

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

                                              {

  // Look for files that follow the standard naming convention.
  DIR *dp;
  struct dirent *dirp;
  std::string tempFileName;

  std::vector< std::string > fileNames;
  fileNames.clear();

  if( dirName_ == ""){
    return false;
  }
  
  // Check directory existance.
  if( ( dp = opendir( dirName_.c_str() )  ) == NULL ){
    closedir(dp);
    return false;
  }

  while( (dirp = readdir(dp)) != NULL ){
    tempFileName = dirp->d_name;
    if(tempFileName.substr(0,8) == "CMS_LUMI" ){
      fileNames.push_back( dirName_ + tempFileName);
    }
  }
  closedir(dp);

  if( fileNames.size() == 0 ){
    return false;
  }

  sort(fileNames.begin(), fileNames.end());
  return ReplaceFile( fileNames );
}
void HCAL_HLX::ROOTFileReader::CreateTree ( ) [private, virtual]

Implements HCAL_HLX::ROOTFileBase.

Definition at line 95 of file ROOTFileReader.cc.

                                       {

  Header_  = &(lumiSection_->hdr);
  Summary_ = &(lumiSection_->lumiSummary);
  Detail_  = &(lumiSection_->lumiDetail);

  mChain_->SetBranchAddress("Header.",  &Header_,  &b_Header);

  if( !bEtSumOnly_ ){
    mChain_->SetBranchAddress("Summary.", &Summary_, &b_Summary);
    mChain_->SetBranchAddress("Detail.",  &Detail_,  &b_Detail);
  }

  for(unsigned int iHLX = 0; iHLX < 36; ++iHLX){
    std::stringstream branchName;

    EtSumPtr_[iHLX] = &(lumiSection_->etSum[iHLX]);
    branchName.str(std::string());
    branchName << "ETSum" << std::setw(2) << std::setfill('0') << iHLX << ".";
    mChain_->SetBranchAddress(branchName.str().c_str(), &EtSumPtr_[iHLX], &b_ETSum[iHLX]);

    if( !bEtSumOnly_ ){
      OccupancyPtr_[iHLX] = &(lumiSection_->occupancy[iHLX]);
      branchName.str(std::string());
      branchName << "Occupancy" << std::setw(2) << std::setfill('0') << iHLX << ".";
      mChain_->SetBranchAddress(branchName.str().c_str(), &OccupancyPtr_[iHLX], &b_Occupancy[iHLX]);
      
      LHCPtr_[iHLX] = &(lumiSection_->lhc[iHLX]);
      branchName.str(std::string());
      branchName << "LHC" << std::setw(2) << std::setfill('0') << iHLX << ".";
      mChain_->SetBranchAddress(branchName.str().c_str(), &LHCPtr_[iHLX], &b_LHC[iHLX]);
    }

  }

}
unsigned int HCAL_HLX::ROOTFileReader::GetEntries ( )

Definition at line 132 of file ROOTFileReader.cc.

                                               {

  return mChain_->GetEntries();
}
int HCAL_HLX::ROOTFileReader::GetEntry ( int  entry)

Definition at line 137 of file ROOTFileReader.cc.

                                               {

  int bytes =  mChain_->GetEntry(entry);
  return bytes;
}
int HCAL_HLX::ROOTFileReader::GetLumiSection ( HCAL_HLX::LUMI_SECTION section)

Definition at line 143 of file ROOTFileReader.cc.

                                                                             {

  memcpy(&localSection, lumiSection_, sizeof(HCAL_HLX::LUMI_SECTION));
  return 0;
}
int HCAL_HLX::ROOTFileReader::ReplaceFile ( const std::vector< std::string > &  fileNames) [private]

Definition at line 78 of file ROOTFileReader.cc.

                                                                             {
  // ReplaceFile is called by either SetFileName or CreateFileNameList.
  
  delete mChain_;
  mChain_ = new TChain("LumiTree");
  
  for( std::vector< std::string >::const_iterator VoS = fileNames.begin(); 
       VoS != fileNames.end(); 
       ++VoS){
    mChain_->Add((*VoS).c_str());
  }

  CreateTree();

  return mChain_->GetEntries();
}
int HCAL_HLX::ROOTFileReader::SetFileName ( const std::string &  fileName)

Definition at line 68 of file ROOTFileReader.cc.

                                                                {  

  std::vector< std::string > tempVecOfStrings;

  tempVecOfStrings.clear();
  tempVecOfStrings.push_back( dirName_ + fileName);

  return ReplaceFile( tempVecOfStrings );
}

Member Data Documentation

Definition at line 47 of file ROOTFileReader.h.

Definition at line 51 of file ROOTFileReader.h.

Definition at line 45 of file ROOTFileReader.h.

Definition at line 53 of file ROOTFileReader.h.

Definition at line 52 of file ROOTFileReader.h.

Definition at line 46 of file ROOTFileReader.h.

Definition at line 41 of file ROOTFileReader.h.

Referenced by ROOTFileReader().

const unsigned int HCAL_HLX::ROOTFileReader::NUM_HLXS = 36 [static, private]

Definition at line 49 of file ROOTFileReader.h.