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
CDFRunInfo Class Reference

Per-run or per-file information. More...

#include <CDFRunInfo.h>

Public Member Functions

 CDFRunInfo ()
 
 CDFRunInfo (TFile *fromFile)
 
const char * get (const char *key) const
 Get some run info by name. More...
 
double getDouble (const char *key) const
 Get a run info item by name and convert it to a double. More...
 
int getInt (const char *key) const
 Get a run info item by name and convert it to an integer. More...
 
int getKeys (const char **buffer, int nbufs)
 fill the given array with key name pointers More...
 
int getSize () const
 get the number of items More...
 
bool hasKey (const char *key) const
 test for thr presence of given key More...
 
void print () const
 print all information to the terminal More...
 
void setInfo (const char *key, const char *value)
 add some information to the run info More...
 
void store (TFile *toFile)
 

Private Member Functions

bool load (TFile *fromFile)
 

Private Attributes

std::map< std::string,
std::string > 
m_mapData
 

Static Private Attributes

static const char * RootVariableName = "CDFRunInfo"
 

Detailed Description

Per-run or per-file information.

This class allows access to per-run or per-file information as opposed to per-event information such as CDFEventInfo. The information is stored in the form of string -> string pairs. There are utility methods for decoding string values as integers and doubles.

Definition at line 15 of file CDFRunInfo.h.

Constructor & Destructor Documentation

CDFRunInfo::CDFRunInfo ( )

Definition at line 8 of file CDFRunInfo.cc.

8  {
9 }
CDFRunInfo::CDFRunInfo ( TFile *  fromFile)

Definition at line 11 of file CDFRunInfo.cc.

References load().

11  {
12  load(file);
13 }
bool load(TFile *fromFile)
Definition: CDFRunInfo.cc:50

Member Function Documentation

const char * CDFRunInfo::get ( const char *  key) const

Get some run info by name.

Definition at line 15 of file CDFRunInfo.cc.

References i, m_mapData, and NULL.

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), and betterConfigParser.BetterConfigParser::getResultingSection().

15  {
16  std::map<std::string,std::string>::const_iterator i=m_mapData.find(key);
17  if (i==m_mapData.end()) return NULL;
18  return i->second.c_str();
19 }
int i
Definition: DBlmapReader.cc:9
#define NULL
Definition: scimark2.h:8
std::map< std::string, std::string > m_mapData
Definition: CDFRunInfo.h:42
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
double CDFRunInfo::getDouble ( const char *  key) const

Get a run info item by name and convert it to a double.

Definition at line 27 of file CDFRunInfo.cc.

References relval_2017::k, relval_steps::key, and NULL.

27  {
28  const char* k=get(key);
29  if (k==NULL) return 0;
30  return atof(k);
31 }
#define NULL
Definition: scimark2.h:8
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
int CDFRunInfo::getInt ( const char *  key) const

Get a run info item by name and convert it to an integer.

Definition at line 21 of file CDFRunInfo.cc.

References relval_2017::k, relval_steps::key, and NULL.

21  {
22  const char* k=get(key);
23  if (k==NULL) return 0;
24  return atoi(k);
25 }
#define NULL
Definition: scimark2.h:8
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
int CDFRunInfo::getKeys ( const char **  buffer,
int  nbufs 
)

fill the given array with key name pointers

Definition at line 33 of file CDFRunInfo.cc.

References i, j, and m_mapData.

33  {
34  int j=0;
35  for (std::map<std::string,std::string>::const_iterator i=m_mapData.begin(); i!=m_mapData.end() && j<nbufs; i++, j++) {
36  buffer[j]=i->first.c_str();
37  }
38  return j;
39 }
int i
Definition: DBlmapReader.cc:9
std::map< std::string, std::string > m_mapData
Definition: CDFRunInfo.h:42
int j
Definition: DBlmapReader.cc:9
int CDFRunInfo::getSize ( ) const
inline

get the number of items

Definition at line 27 of file CDFRunInfo.h.

References m_mapData.

27 { return m_mapData.size(); }
std::map< std::string, std::string > m_mapData
Definition: CDFRunInfo.h:42
bool CDFRunInfo::hasKey ( const char *  key) const

test for thr presence of given key

Definition at line 41 of file CDFRunInfo.cc.

References i, and m_mapData.

41  {
42  std::map<std::string,std::string>::const_iterator i=m_mapData.find(key);
43  return (i!=m_mapData.end());
44 }
int i
Definition: DBlmapReader.cc:9
std::map< std::string, std::string > m_mapData
Definition: CDFRunInfo.h:42
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
bool CDFRunInfo::load ( TFile *  fromFile)
private

Definition at line 50 of file CDFRunInfo.cc.

References a, b, i, m_mapData, NULL, connectstrParser::o, RootVariableName, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by CDFRunInfo().

50  {
51  m_mapData.clear();
52  if (f==NULL) return false;
53  TMap* pMap=(TMap*)f->Get(RootVariableName);
54  if (pMap==NULL) return false;
55  TIterator* i=pMap->MakeIterator();
56  TObject* o;
57 
58  while ((o=i->Next())!=NULL) {
59  std::string a(o->GetName());
60  std::string b(pMap->GetValue(o)->GetName());
61  m_mapData.insert(std::pair<std::string,std::string>(a,b));
62  }
63  return true;
64 }
int i
Definition: DBlmapReader.cc:9
#define NULL
Definition: scimark2.h:8
std::map< std::string, std::string > m_mapData
Definition: CDFRunInfo.h:42
double f[11][100]
static const char * RootVariableName
Definition: CDFRunInfo.h:41
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
void CDFRunInfo::print ( void  ) const

print all information to the terminal

Definition at line 76 of file CDFRunInfo.cc.

References i, and m_mapData.

76  {
77  for (std::map<std::string,std::string>::const_iterator i=m_mapData.begin(); i!=m_mapData.end(); i++)
78  printf(" '%s' => '%s' \n",i->first.c_str(),i->second.c_str());
79 
80 }
int i
Definition: DBlmapReader.cc:9
std::map< std::string, std::string > m_mapData
Definition: CDFRunInfo.h:42
void CDFRunInfo::setInfo ( const char *  key,
const char *  value 
)

add some information to the run info

Definition at line 46 of file CDFRunInfo.cc.

References relval_steps::key, m_mapData, and relativeConstraints::value.

Referenced by HcalTBWriter::analyze(), and HcalTBWriter::endJob().

46  {
48 }
std::map< std::string, std::string > m_mapData
Definition: CDFRunInfo.h:42
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
void CDFRunInfo::store ( TFile *  toFile)

Definition at line 66 of file CDFRunInfo.cc.

References i, m_mapData, and RootVariableName.

Referenced by HcalTBWriter::endJob().

66  {
67  f->cd();
68  TMap* myMap=new TMap();
69  for (std::map<std::string,std::string>::iterator i=m_mapData.begin(); i!=m_mapData.end(); i++) {
70  myMap->Add(new TObjString(i->first.c_str()), new TObjString(i->second.c_str()));
71  }
72  myMap->SetName(RootVariableName);
73  myMap->Write(RootVariableName,TObject::kSingleKey);
74 }
int i
Definition: DBlmapReader.cc:9
std::map< std::string, std::string > m_mapData
Definition: CDFRunInfo.h:42
double f[11][100]
static const char * RootVariableName
Definition: CDFRunInfo.h:41

Member Data Documentation

std::map<std::string,std::string> CDFRunInfo::m_mapData
private

Definition at line 42 of file CDFRunInfo.h.

Referenced by get(), getKeys(), getSize(), hasKey(), load(), print(), setInfo(), and store().

const char * CDFRunInfo::RootVariableName = "CDFRunInfo"
staticprivate

Definition at line 41 of file CDFRunInfo.h.

Referenced by load(), and store().