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 //
17 //
18 
19 
20 // system include files
21 #include <iostream>
22 #include <fstream>
23 #include <sstream>
24 #include <vector>
25 #include <string>
26 
27 // user include files
36 
37 using namespace std;
38 
39 //
40 // class decleration
41 //
42 
45 {
46 public:
48 
49 protected:
50  //overriding from ContextRecordIntervalFinder
51  virtual void setIntervalFor( const edm::eventsetup::EventSetupRecordKey&,
52  const edm::IOVSyncValue& ,
53  edm::ValidityInterval& ) override ;
54 
55  private:
56  virtual std::auto_ptr<CentralityTable> produceTable( const HeavyIonRcd& );
57  void printBin(const CentralityTable::CBin*);
58 
59  // ----------member data ---------------------------
60 
61  int verbose_;
62  string inputFileName_;
63 };
64 
65 //
66 // constants, enums and typedefs
67 //
68 
69 //
70 // static data member definitions
71 //
72 
73 //
74 // constructors and destructor
75 //
77 
78  setWhatProduced(this, &HiTrivialConditionRetriever::produceTable);
79  findingRecord<HeavyIonRcd>();
80 
81  //now do what ever initialization is needed
82  verbose_ = iConfig.getUntrackedParameter<int>("verbosity",1);
83  inputFileName_ = iConfig.getParameter<string>("inputFile");
84 }
85 
86 std::auto_ptr<CentralityTable>
88 
89  std::auto_ptr<CentralityTable> CT(new CentralityTable()) ;
90 
91  // Get values from text file
92  ifstream in( edm::FileInPath(inputFileName_).fullPath().c_str() );
93  string line;
94 
95  int i = 0;
96  while ( getline( in, line ) ) {
97  if ( !line.size() || line[0]=='#' ) { continue; }
98  CentralityTable::CBin thisBin;
99  CT->m_table.push_back(thisBin);
100  istringstream ss(line);
101  ss>>CT->m_table[i].bin_edge
102  >>CT->m_table[i].n_part.mean
103  >>CT->m_table[i].n_part.var
104  >>CT->m_table[i].n_coll.mean
105  >>CT->m_table[i].n_coll.var
106  >>CT->m_table[i].n_hard.mean
107  >>CT->m_table[i].n_hard.var
108  >>CT->m_table[i].b.mean
109  >>CT->m_table[i].b.var;
110  i++;
111  }
112 
113  return CT;
114 }
115 
117  cout<<"HF Cut = "<<thisBin->bin_edge<<endl;
118  cout<<"Npart = "<<thisBin->n_part.mean<<endl;
119  cout<<"sigma = "<<thisBin->n_part.var<<endl;
120  cout<<"Ncoll = "<<thisBin->n_coll.mean<<endl;
121  cout<<"sigma = "<<thisBin->n_coll.var<<endl;
122  cout<<"B = "<<thisBin->b.mean<<endl;
123  cout<<"sigma = "<<thisBin->b.var<<endl;
124  cout<<"__________________________________________________"<<endl;
125 }
126 
127 void
129  const edm::IOVSyncValue& iTime,
130  edm::ValidityInterval& oValidity)
131 {
132  if(verbose_>=1) std::cout << "HiTrivialConditionRetriever::setIntervalFor(): record key = " << rk.name() << "\ttime: " << iTime.time().value() << std::endl;
133  //For right now, we will just use an infinite interval of validity
135 }
136 
137 //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
virtual void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
static const IOVSyncValue & beginOfTime()
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:92
HiTrivialConditionRetriever(const edm::ParameterSet &)
const Timestamp & time() const
Definition: IOVSyncValue.h:44
tuple cout
Definition: gather_cfg.py:121
virtual std::auto_ptr< CentralityTable > produceTable(const HeavyIonRcd &)
TimeValue_t value() const
Definition: Timestamp.h:56