CMS 3D CMS Logo

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

#include <HPDNoiseReader.h>

Public Types

typedef int Handle
 

Public Member Functions

std::vector< std::string > allNames () const
 all HPD instances in the library More...
 
float dischargeRate (Handle fHandle) const
 discharge rate for the instance More...
 
float emissionRate (Handle fHandle) const
 ithermal/field emission rate for the instance More...
 
void getEntry (Handle fHandle, HPDNoiseData **fData)
 retrive one entry from the sequentially More...
 
void getEntry (Handle fHandle, unsigned long fEntry, HPDNoiseData **fData)
 retrive one entry from the library directly More...
 
Handle getHandle (const std::string &fName)
 get handle to access data for one HPD instance More...
 
 HPDNoiseReader (const std::string &fFileName)
 
float ionFeedbackFirstPeakRate (Handle fHandle) const
 ionfeedback rate for the instance More...
 
float ionFeedbackSecondPeakRate (Handle fHandle) const
 
unsigned long totalEntries (Handle fHandle) const
 total number of noise events for the HPD instance in the library More...
 
bool valid (Handle fHandle) const
 test if handle is valid More...
 
 ~HPDNoiseReader ()
 

Private Member Functions

void grabEntry (Handle fHandle, unsigned long fEntry)
 
 HPDNoiseReader (const HPDNoiseReader &)
 
HPDNoiseReaderoperator= (const HPDNoiseReader &)
 

Private Attributes

HPDNoiseDatamBuffer
 
std::vector< size_t > mCurrentEntry
 
std::vector< float > mDischargeRate
 
std::vector< float > mElectronEmissionRate
 
TFile * mFile
 
std::vector< float > mIonFeedbackFirstPeakRate
 
std::vector< float > mIonFeedbackSecondPeakRate
 
std::vector< TTree * > mTrees
 

Detailed Description

Definition at line 18 of file HPDNoiseReader.h.

Member Typedef Documentation

Definition at line 20 of file HPDNoiseReader.h.

Constructor & Destructor Documentation

HPDNoiseReader::HPDNoiseReader ( const std::string &  fFileName)

Definition at line 19 of file HPDNoiseReader.cc.

References HPDNoiseDataCatalog::allNames(), validate_alignment_devdb10_cfg::catalog, ExpressReco_HICollisions_FallBack::cerr, HPDNoiseDataCatalog::getDischargeRate(), HPDNoiseDataCatalog::getElectronEmissionRate(), HPDNoiseDataCatalog::getIonFeedbackFirstPeakRate(), HPDNoiseDataCatalog::getIonFeedbackSecondPeakRate(), i, mBuffer, mCurrentEntry, mDischargeRate, mElectronEmissionRate, mFile, mIonFeedbackFirstPeakRate, mIonFeedbackSecondPeakRate, mTrees, h::names, HPDNoiseDataCatalog::objectName(), and diffTreeTool::tree.

19  {
20  mFile = new TFile (fFileName.c_str(), "READ");
21  mBuffer = new HPDNoiseData ();
23  mFile->GetObject (HPDNoiseDataCatalog::objectName(), catalog);
24  if (catalog) {
25  // initiate trees
26  const std::vector<std::string> names = catalog->allNames();
27  for (size_t i = 0; i < names.size(); ++i) {
28  TTree* tree = (TTree*) mFile->Get (names[i].c_str());
29  if (tree) {
30  mTrees.push_back (tree);
31  mDischargeRate.push_back (catalog->getDischargeRate (i));
34  mElectronEmissionRate.push_back(catalog->getElectronEmissionRate(i));
35  mCurrentEntry.push_back (0);
36  }
37  else {
38  std::cerr << "HPDNoiseReader::HPDNoiseReader-> Can not open tree " << names[i] << " in file " << fFileName << std::endl;
39  }
40  }
41  }
42  else {
43  std::cerr << "HPDNoiseReader::HPDNoiseReader-> Can not open catalog infile " << fFileName << std::endl;
44  }
45 }
int i
Definition: DBlmapReader.cc:9
float getElectronEmissionRate(size_t i) const
get thermal electron emission noise rate for the HPD instance
std::vector< float > mElectronEmissionRate
static const char * objectName()
object name
std::vector< float > mIonFeedbackSecondPeakRate
float getIonFeedbackSecondPeakRate(size_t i) const
float getIonFeedbackFirstPeakRate(size_t i) const
get ion feedback noise rate for the HPD instance
HPDNoiseData * mBuffer
const std::vector< std::string > & allNames() const
all HPD instance names
std::vector< float > mIonFeedbackFirstPeakRate
float getDischargeRate(size_t i) const
get noise rate for the HPD instance
std::vector< TTree * > mTrees
static const HistoName names[]
std::vector< size_t > mCurrentEntry
std::vector< float > mDischargeRate
HPDNoiseReader::~HPDNoiseReader ( )

Definition at line 47 of file HPDNoiseReader.cc.

References i, mBuffer, mFile, and mTrees.

47  {
48  for (size_t i = 0; i < mTrees.size(); ++i) {
49  delete mTrees[i];
50  }
51  delete mFile;
52  delete mBuffer;
53 }
int i
Definition: DBlmapReader.cc:9
HPDNoiseData * mBuffer
std::vector< TTree * > mTrees
HPDNoiseReader::HPDNoiseReader ( const HPDNoiseReader )
private

Member Function Documentation

std::vector< std::string > HPDNoiseReader::allNames ( ) const

all HPD instances in the library

Definition at line 56 of file HPDNoiseReader.cc.

References i, mTrees, and query::result.

Referenced by HPDNoiseLibraryReader::HPDNoiseLibraryReader().

56  {
57  std::vector<std::string> result;
58  for (size_t i = 0; i < mTrees.size(); ++i) result.push_back (mTrees[i]->GetName ());
59  return result;
60 }
int i
Definition: DBlmapReader.cc:9
tuple result
Definition: query.py:137
std::vector< TTree * > mTrees
float HPDNoiseReader::dischargeRate ( Handle  fHandle) const

discharge rate for the instance

Definition at line 69 of file HPDNoiseReader.cc.

References mDischargeRate, and valid().

Referenced by HPDNoiseLibraryReader::fillRates().

69  {
70  if (!valid (fHandle)) return 0;
71  return mDischargeRate[fHandle];
72 }
bool valid(Handle fHandle) const
test if handle is valid
std::vector< float > mDischargeRate
float HPDNoiseReader::emissionRate ( Handle  fHandle) const

ithermal/field emission rate for the instance

Definition at line 81 of file HPDNoiseReader.cc.

References mElectronEmissionRate, and valid().

81  {
82  if (!valid (fHandle)) return 0;
83  return mElectronEmissionRate[fHandle];
84 }
std::vector< float > mElectronEmissionRate
bool valid(Handle fHandle) const
test if handle is valid
void HPDNoiseReader::getEntry ( Handle  fHandle,
HPDNoiseData **  fData 
)

retrive one entry from the sequentially

Definition at line 99 of file HPDNoiseReader.cc.

References grabEntry(), mBuffer, mCurrentEntry, totalEntries(), and valid().

Referenced by HPDNoiseLibraryReader::getNoiseData().

99  {
100  if (!valid (fHandle)) return;
101  unsigned int entry = mCurrentEntry [fHandle];
102  if (++entry >= totalEntries (fHandle)) entry = 0; // roll over
103  grabEntry (fHandle, entry);
104  *fData = mBuffer;
105 }
unsigned long totalEntries(Handle fHandle) const
total number of noise events for the HPD instance in the library
bool valid(Handle fHandle) const
test if handle is valid
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
HPDNoiseData * mBuffer
std::vector< size_t > mCurrentEntry
void grabEntry(Handle fHandle, unsigned long fEntry)
void HPDNoiseReader::getEntry ( Handle  fHandle,
unsigned long  fEntry,
HPDNoiseData **  fData 
)

retrive one entry from the library directly

Definition at line 107 of file HPDNoiseReader.cc.

References grabEntry(), and mBuffer.

107  {
108  grabEntry (fHandle, fEntry);
109  *fData = mBuffer;
110 }
HPDNoiseData * mBuffer
std::pair< double, double > fEntry
Definition: CrossSection.h:40
void grabEntry(Handle fHandle, unsigned long fEntry)
HPDNoiseReader::Handle HPDNoiseReader::getHandle ( const std::string &  fName)

get handle to access data for one HPD instance

Definition at line 62 of file HPDNoiseReader.cc.

References i, and mTrees.

Referenced by HPDNoiseLibraryReader::fillRates(), and HPDNoiseLibraryReader::getNoiseData().

62  {
63  for (size_t i = 0; i < mTrees.size(); ++i) {
64  if (std::string (mTrees[i]->GetName ()) == fName) return i;
65  }
66  return -1;
67 }
int i
Definition: DBlmapReader.cc:9
std::vector< TTree * > mTrees
void HPDNoiseReader::grabEntry ( Handle  fHandle,
unsigned long  fEntry 
)
private

Definition at line 91 of file HPDNoiseReader.cc.

References HPDNoiseData::branchName(), mBuffer, mCurrentEntry, mTrees, and valid().

Referenced by getEntry().

91  {
92  if (!valid (fHandle)) return;
93  TBranch* branch = mTrees[fHandle]->GetBranch (HPDNoiseData::branchName());
94  branch->SetAddress (&mBuffer);
95  branch->GetEntry (fEntry);
96  mCurrentEntry [fHandle] = fEntry;
97 }
bool valid(Handle fHandle) const
test if handle is valid
HPDNoiseData * mBuffer
static const char * branchName()
branch name
Definition: HPDNoiseData.h:37
std::pair< double, double > fEntry
Definition: CrossSection.h:40
std::vector< TTree * > mTrees
std::vector< size_t > mCurrentEntry
float HPDNoiseReader::ionFeedbackFirstPeakRate ( Handle  fHandle) const

ionfeedback rate for the instance

Definition at line 73 of file HPDNoiseReader.cc.

References mIonFeedbackFirstPeakRate, and valid().

Referenced by HPDNoiseLibraryReader::fillRates().

73  {
74  if (!valid (fHandle)) return 0;
75  return mIonFeedbackFirstPeakRate[fHandle];
76 }
bool valid(Handle fHandle) const
test if handle is valid
std::vector< float > mIonFeedbackFirstPeakRate
float HPDNoiseReader::ionFeedbackSecondPeakRate ( Handle  fHandle) const

Definition at line 77 of file HPDNoiseReader.cc.

References mIonFeedbackSecondPeakRate, and valid().

Referenced by HPDNoiseLibraryReader::fillRates().

77  {
78  if (!valid (fHandle)) return 0;
79  return mIonFeedbackSecondPeakRate[fHandle];
80 }
bool valid(Handle fHandle) const
test if handle is valid
std::vector< float > mIonFeedbackSecondPeakRate
HPDNoiseReader& HPDNoiseReader::operator= ( const HPDNoiseReader )
private
unsigned long HPDNoiseReader::totalEntries ( Handle  fHandle) const

total number of noise events for the HPD instance in the library

Definition at line 86 of file HPDNoiseReader.cc.

References mTrees, and valid().

Referenced by getEntry(), and HPDNoiseLibraryReader::getNoiseData().

86  {
87  if (!valid (fHandle)) return 0;
88  return mTrees[fHandle]->GetEntries ();
89 }
bool valid(Handle fHandle) const
test if handle is valid
std::vector< TTree * > mTrees
bool HPDNoiseReader::valid ( Handle  fHandle) const
inline

Member Data Documentation

HPDNoiseData* HPDNoiseReader::mBuffer
private

Definition at line 56 of file HPDNoiseReader.h.

Referenced by getEntry(), grabEntry(), HPDNoiseReader(), and ~HPDNoiseReader().

std::vector<size_t> HPDNoiseReader::mCurrentEntry
private

Definition at line 55 of file HPDNoiseReader.h.

Referenced by getEntry(), grabEntry(), and HPDNoiseReader().

std::vector<float> HPDNoiseReader::mDischargeRate
private

Definition at line 51 of file HPDNoiseReader.h.

Referenced by dischargeRate(), and HPDNoiseReader().

std::vector<float> HPDNoiseReader::mElectronEmissionRate
private

Definition at line 54 of file HPDNoiseReader.h.

Referenced by emissionRate(), and HPDNoiseReader().

TFile* HPDNoiseReader::mFile
private

Definition at line 49 of file HPDNoiseReader.h.

Referenced by HPDNoiseReader(), and ~HPDNoiseReader().

std::vector<float> HPDNoiseReader::mIonFeedbackFirstPeakRate
private

Definition at line 52 of file HPDNoiseReader.h.

Referenced by HPDNoiseReader(), and ionFeedbackFirstPeakRate().

std::vector<float> HPDNoiseReader::mIonFeedbackSecondPeakRate
private

Definition at line 53 of file HPDNoiseReader.h.

Referenced by HPDNoiseReader(), and ionFeedbackSecondPeakRate().

std::vector<TTree*> HPDNoiseReader::mTrees
private