CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HiTrivialConditionRetriever.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HiTrivialConditionRetriever
4 // Class: HiTrivialConditionRetriever
5 //
13 //
14 // Original Author: Yetkin Yilmaz
15 // Created: Wed May 2 21:41:30 EDT 2007
16 // $Id: HiTrivialConditionRetriever.cc,v 1.1 2010/03/23 21:56:39 yilmaz Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <iostream>
23 #include <fstream>
24 #include <sstream>
25 #include <vector>
26 #include <string>
27 
28 // user include files
37 
38 using namespace std;
39 
40 //
41 // class decleration
42 //
43 
46 {
47 public:
49 
50 protected:
51  //overriding from ContextRecordIntervalFinder
52  virtual void setIntervalFor( const edm::eventsetup::EventSetupRecordKey&,
53  const edm::IOVSyncValue& ,
55 
56  private:
57  virtual std::auto_ptr<CentralityTable> produceTable( const HeavyIonRcd& );
58  void printBin(const CentralityTable::CBin*);
59 
60  // ----------member data ---------------------------
61 
62  int verbose_;
63  string inputFileName_;
64 };
65 
66 //
67 // constants, enums and typedefs
68 //
69 
70 //
71 // static data member definitions
72 //
73 
74 //
75 // constructors and destructor
76 //
78 
79  setWhatProduced(this, &HiTrivialConditionRetriever::produceTable);
80  findingRecord<HeavyIonRcd>();
81 
82  //now do what ever initialization is needed
83  verbose_ = iConfig.getUntrackedParameter<int>("verbosity",1);
84  inputFileName_ = iConfig.getParameter<string>("inputFile");
85 }
86 
87 std::auto_ptr<CentralityTable>
89 
90  std::auto_ptr<CentralityTable> CT(new CentralityTable()) ;
91 
92  // Get values from text file
93  ifstream in( edm::FileInPath(inputFileName_).fullPath().c_str() );
94  string line;
95 
96  int i = 0;
97  while ( getline( in, line ) ) {
98  if ( !line.size() || line[0]=='#' ) { continue; }
99  CentralityTable::CBin thisBin;
100  CT->m_table.push_back(thisBin);
101  istringstream ss(line);
102  ss>>CT->m_table[i].bin_edge
103  >>CT->m_table[i].n_part.mean
104  >>CT->m_table[i].n_part.var
105  >>CT->m_table[i].n_coll.mean
106  >>CT->m_table[i].n_coll.var
107  >>CT->m_table[i].n_hard.mean
108  >>CT->m_table[i].n_hard.var
109  >>CT->m_table[i].b.mean
110  >>CT->m_table[i].b.var;
111  i++;
112  }
113 
114  return CT;
115 }
116 
118  cout<<"HF Cut = "<<thisBin->bin_edge<<endl;
119  cout<<"Npart = "<<thisBin->n_part.mean<<endl;
120  cout<<"sigma = "<<thisBin->n_part.var<<endl;
121  cout<<"Ncoll = "<<thisBin->n_coll.mean<<endl;
122  cout<<"sigma = "<<thisBin->n_coll.var<<endl;
123  cout<<"B = "<<thisBin->b.mean<<endl;
124  cout<<"sigma = "<<thisBin->b.var<<endl;
125  cout<<"__________________________________________________"<<endl;
126 }
127 
128 void
130  const edm::IOVSyncValue& iTime,
131  edm::ValidityInterval& oValidity)
132 {
133  if(verbose_>=1) std::cout << "HiTrivialConditionRetriever::setIntervalFor(): record key = " << rk.name() << "\ttime: " << iTime.time().value() << std::endl;
134  //For right now, we will just use an infinite interval of validity
136 }
137 
138 //define this as a plug-in
void printBin(const CentralityTable::CBin *)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:97
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:19
static const IOVSyncValue & beginOfTime()
TimeValue_t value() const
Definition: Timestamp.cc:72
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:82
HiTrivialConditionRetriever(const edm::ParameterSet &)
virtual void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &)
const Timestamp & time() const
Definition: IOVSyncValue.h:44
tuple cout
Definition: gather_cfg.py:121
virtual std::auto_ptr< CentralityTable > produceTable(const HeavyIonRcd &)