CMS 3D CMS Logo

ROOTFileReader.cc

Go to the documentation of this file.
00001 #include "RecoLuminosity/ROOTSchema/interface/ROOTFileReader.h"
00002 #include <TROOT.h>
00003 #include <TFile.h>
00004 
00005 #include <iomanip>
00006 #include <sstream>
00007 
00008 HCAL_HLX::ROOTFileReader::ROOTFileReader(){
00009 #ifdef DEBUG
00010   std::cout << "Begin " << __PRETTY_FUNCTION__ << std::endl;
00011 #endif
00012   
00013   mFileName_ = "";
00014 
00015   mChain_ = new TChain("LumiTree");
00016 
00017   lumiSection_ = new HCAL_HLX::LUMI_SECTION;
00018   Threshold_       = new HCAL_HLX::LUMI_THRESHOLD;
00019   L1Trigger_       = new HCAL_HLX::LEVEL1_TRIGGER;
00020   HLT_             = new HCAL_HLX::HLT;
00021   TriggerDeadtime_ = new HCAL_HLX::TRIGGER_DEADTIME;
00022   RingSet_         = new HCAL_HLX::LUMI_HF_RING_SET;
00023 
00024 
00025 #ifdef DEBUG
00026   std::cout << "End " << __PRETTY_FUNCTION__ << std::endl;
00027 #endif
00028 }
00029 
00030 HCAL_HLX::ROOTFileReader::~ROOTFileReader(){
00031 #ifdef DEBUG
00032   std::cout << "Begin " << __PRETTY_FUNCTION__ << std::endl;
00033 #endif
00034   
00035   delete mChain_;
00036   
00037   delete Threshold_;
00038   delete L1Trigger_;
00039   delete HLT_;
00040   delete TriggerDeadtime_;
00041   delete RingSet_;
00042 
00043   delete lumiSection_;
00044 
00045 #ifdef DEBUG
00046   std::cout << "End " << __PRETTY_FUNCTION__ << std::endl;
00047 #endif
00048 }
00049 
00050 int HCAL_HLX::ROOTFileReader::ReplaceFile(const std::string& fileName){
00051   // replacing a file changes the run number and section number automatically.
00052 
00053 #ifdef DEBUG
00054   std::cout << "Begin " << __PRETTY_FUNCTION__ << std::endl;
00055 #endif
00056   
00057   std::stringstream branchName;
00058   
00059   delete mChain_;
00060 
00061   mChain_ = new TChain("LumiTree");
00062 
00063   mChain_->Add(fileName.c_str());
00064   
00065 
00066   // HCAL_HLX::LUMI_SECTION 
00067   
00068   Header_  = &(lumiSection_->hdr);
00069   Summary_ = &(lumiSection_->lumiSummary);
00070   Detail_  = &(lumiSection_->lumiDetail);
00071 
00072   mChain_->SetBranchAddress("Header.",  &Header_,  &b_Header);
00073   mChain_->SetBranchAddress("Summary.", &Summary_, &b_Summary);
00074   mChain_->SetBranchAddress("Detail.",  &Detail_,  &b_Detail);
00075 
00076   for(int HLXnum = 0; HLXnum < HCAL_HLX_MAX_HLXS; HLXnum++){
00077     EtSumPtr[HLXnum] = &(lumiSection_->etSum[HLXnum]);
00078     branchName.str(std::string());
00079     branchName << "ETSum" << std::setw(2) << std::setfill('0') << HLXnum << ".";
00080     mChain_->SetBranchAddress(branchName.str().c_str(), &EtSumPtr[HLXnum], &b_ETSum[HLXnum]);
00081 
00082     OccupancyPtr[HLXnum] = &(lumiSection_->occupancy[HLXnum]);
00083     branchName.str(std::string());
00084     branchName << "Occupancy" << std::setw(2) << std::setfill('0') << HLXnum << ".";
00085     mChain_->SetBranchAddress(branchName.str().c_str(), &OccupancyPtr[HLXnum], &b_Occupancy[HLXnum]);
00086 
00087     LHCPtr[HLXnum] = &(lumiSection_->lhc[HLXnum]);
00088     branchName.str(std::string());
00089     branchName << "LHC" << std::setw(2) << std::setfill('0') << HLXnum << ".";
00090     mChain_->SetBranchAddress(branchName.str().c_str(), &LHCPtr[HLXnum], &b_LHC[HLXnum]);
00091   }
00092 
00093   // OTHER
00094   mChain_->SetBranchAddress("Threshold.",        &Threshold_,       &b_Threshold);
00095   mChain_->SetBranchAddress("Level1_Trigger.",   &L1Trigger_,       &b_L1Trigger);
00096   mChain_->SetBranchAddress("HLT.",              &HLT_,             &b_HLT);
00097   mChain_->SetBranchAddress("Trigger_Deadtime.", &TriggerDeadtime_, &b_TriggerDeadtime);
00098   mChain_->SetBranchAddress("HF_Ring_Set.",      &RingSet_,         &b_RingSet);
00099   
00100   // Get run and section number.
00101   mChain_->GetEntry(0);
00102     
00103   runNumber_     = lumiSection_->hdr.runNumber;
00104   sectionNumber_ = lumiSection_->hdr.sectionNumber;
00105 
00106 #ifdef DEBUG
00107   std::cout << "***** Run Number: " << runNumber_ << " *****" << std::endl;
00108   std::cout << "***** Section Number: " << sectionNumber_ << " *****" << std::endl;
00109   std::cout << "End " << __PRETTY_FUNCTION__ << std::endl;
00110 #endif
00111 
00112   return 0;
00113 }
00114 
00115 int HCAL_HLX::ROOTFileReader::GetEntry(int entry){
00116 
00117   return mChain_->GetEntry(entry);
00118 }
00119 
00120 int HCAL_HLX::ROOTFileReader::GetNumEntries(){
00121 
00122   return mChain_->GetEntries();
00123 }
00124 
00125 int HCAL_HLX::ROOTFileReader::GetLumiSection(HCAL_HLX::LUMI_SECTION& localSection){
00126 
00127   memcpy(&localSection, lumiSection_, sizeof(HCAL_HLX::LUMI_SECTION));
00128 
00129   return 0;
00130 }
00131 
00132 int HCAL_HLX::ROOTFileReader::GetThreshold(HCAL_HLX::LUMI_THRESHOLD&  localThreshold){
00133 
00134   memcpy(&localThreshold, Threshold_, sizeof(localThreshold));
00135   return 0;
00136 }
00137 
00138 int HCAL_HLX::ROOTFileReader::GetHFRingSet(HCAL_HLX::LUMI_HF_RING_SET& localRingSet){
00139 
00140   memcpy(&localRingSet, RingSet_, sizeof(localRingSet));
00141   return 0;
00142 }
00143 
00144 
00145 int HCAL_HLX::ROOTFileReader::GetL1Trigger(HCAL_HLX::LEVEL1_TRIGGER& localL1Trigger){
00146 
00147   memcpy(&localL1Trigger, L1Trigger_, sizeof(localL1Trigger));
00148   return 0;
00149 }
00150 
00151 int HCAL_HLX::ROOTFileReader::GetHLT(HCAL_HLX::HLT& localHLT){
00152 
00153   memcpy(&localHLT, HLT_, sizeof(localHLT));
00154   return 0;
00155 }
00156 
00157 int HCAL_HLX::ROOTFileReader::GetTriggerDeadtime(HCAL_HLX::TRIGGER_DEADTIME& localTD){
00158 
00159   memcpy(&localTD, TriggerDeadtime_, sizeof(localTD));
00160   return 0;
00161 }

Generated on Tue Jun 9 17:44:04 2009 for CMSSW by  doxygen 1.5.4