CMS 3D CMS Logo

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  while (getline(in, line)) {
78  if (line.empty() || line[0] == '#') {
79  continue;
80  }
81  CentralityTable::CBin thisBin;
82  istringstream ss(line);
83  ss >> thisBin.bin_edge >> thisBin.n_part.mean >> thisBin.n_part.var >> thisBin.n_coll.mean >> thisBin.n_coll.var >>
84  thisBin.n_hard.mean >> thisBin.n_hard.var >> thisBin.b.mean >> thisBin.b.var;
85  CT->m_table.push_back(thisBin);
86  }
87 
88  return CT;
89 }
90 
92  cout << "HF Cut = " << thisBin->bin_edge << endl;
93  cout << "Npart = " << thisBin->n_part.mean << endl;
94  cout << "sigma = " << thisBin->n_part.var << endl;
95  cout << "Ncoll = " << thisBin->n_coll.mean << endl;
96  cout << "sigma = " << thisBin->n_coll.var << endl;
97  cout << "B = " << thisBin->b.mean << endl;
98  cout << "sigma = " << thisBin->b.var << endl;
99  cout << "__________________________________________________" << endl;
100 }
101 
103  const edm::IOVSyncValue& iTime,
104  edm::ValidityInterval& oValidity) {
105  if (verbose_ >= 1)
106  std::cout << "HiTrivialConditionRetriever::setIntervalFor(): record key = " << rk.name()
107  << "\ttime: " << iTime.time().value() << std::endl;
108  //For right now, we will just use an infinite interval of validity
110 }
111 
112 //define this as a plug-in
void printBin(const CentralityTable::CBin *)
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
T getUntrackedParameter(std::string const &, T const &) const
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:92
TimeValue_t value() const
Definition: Timestamp.h:38
HiTrivialConditionRetriever(const edm::ParameterSet &)
const Timestamp & time() const
Definition: IOVSyncValue.h:42