CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HiTrivialConditionRetriever.cc
Go to the documentation of this file.
1 //
2 // Original Author: Yetkin Yilmaz
3 // Created: Wed May 2 21:41:30 EDT 2007
4 //
5 //
6 
7 // system include files
8 #include <iostream>
9 #include <fstream>
10 #include <sstream>
11 #include <vector>
12 #include <string>
13 
14 // user include files
23 
24 using namespace std;
25 
26 //
27 // class decleration
28 //
29 
31 public:
33 
34 protected:
35  //overriding from ContextRecordIntervalFinder
36  void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
37  const edm::IOVSyncValue&,
38  edm::ValidityInterval&) override;
39 
40 private:
41  virtual std::unique_ptr<CentralityTable> produceTable(const HeavyIonRcd&);
42  void printBin(const CentralityTable::CBin*);
43 
44  // ----------member data ---------------------------
45 
46  int verbose_;
48 };
49 
50 //
51 // constants, enums and typedefs
52 //
53 
54 //
55 // static data member definitions
56 //
57 
58 //
59 // constructors and destructor
60 //
62  setWhatProduced(this, &HiTrivialConditionRetriever::produceTable);
63  findingRecord<HeavyIonRcd>();
64 
65  //now do what ever initialization is needed
66  verbose_ = iConfig.getUntrackedParameter<int>("verbosity", 1);
67  inputFileName_ = iConfig.getParameter<string>("inputFile");
68 }
69 
70 std::unique_ptr<CentralityTable> HiTrivialConditionRetriever::produceTable(const HeavyIonRcd&) {
71  auto CT = std::make_unique<CentralityTable>();
72 
73  // Get values from text file
74  ifstream in(edm::FileInPath(inputFileName_).fullPath().c_str());
75  string line;
76 
77  int i = 0;
78  while (getline(in, line)) {
79  if (line.empty() || line[0] == '#') {
80  continue;
81  }
82  CentralityTable::CBin thisBin;
83  CT->m_table.push_back(thisBin);
84  istringstream ss(line);
85  ss >> CT->m_table[i].bin_edge >> CT->m_table[i].n_part.mean >> CT->m_table[i].n_part.var >>
86  CT->m_table[i].n_coll.mean >> CT->m_table[i].n_coll.var >> CT->m_table[i].n_hard.mean >>
87  CT->m_table[i].n_hard.var >> CT->m_table[i].b.mean >> CT->m_table[i].b.var;
88  i++;
89  }
90 
91  return CT;
92 }
93 
95  cout << "HF Cut = " << thisBin->bin_edge << endl;
96  cout << "Npart = " << thisBin->n_part.mean << endl;
97  cout << "sigma = " << thisBin->n_part.var << endl;
98  cout << "Ncoll = " << thisBin->n_coll.mean << endl;
99  cout << "sigma = " << thisBin->n_coll.var << endl;
100  cout << "B = " << thisBin->b.mean << endl;
101  cout << "sigma = " << thisBin->b.var << endl;
102  cout << "__________________________________________________" << endl;
103 }
104 
106  const edm::IOVSyncValue& iTime,
107  edm::ValidityInterval& oValidity) {
108  if (verbose_ >= 1)
109  std::cout << "HiTrivialConditionRetriever::setIntervalFor(): record key = " << rk.name()
110  << "\ttime: " << iTime.time().value() << std::endl;
111  //For right now, we will just use an infinite interval of validity
113 }
114 
115 //define this as a plug-in
void printBin(const CentralityTable::CBin *)
T getUntrackedParameter(std::string const &, T const &) const
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
virtual std::unique_ptr< CentralityTable > produceTable(const HeavyIonRcd &)
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:91
HiTrivialConditionRetriever(const edm::ParameterSet &)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const Timestamp & time() const
Definition: IOVSyncValue.h:42
tuple cout
Definition: gather_cfg.py:144
TimeValue_t value() const
Definition: Timestamp.h:45