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  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
CentralityTable::CBin
Definition: CentralityTable.h:16
HiTrivialConditionRetriever::verbose_
int verbose_
Definition: HiTrivialConditionRetriever.cc:46
mps_fire.i
i
Definition: mps_fire.py:428
CentralityTable::CBin::n_coll
BinValues n_coll
Definition: CentralityTable.h:19
contentValuesFiles.fullPath
fullPath
Definition: contentValuesFiles.py:64
CentralityTable::CBin::n_part
BinValues n_part
Definition: CentralityTable.h:18
CentralityTable.h
gather_cfg.cout
cout
Definition: gather_cfg.py:144
CentralityTable::CBin::bin_edge
float bin_edge
Definition: CentralityTable.h:17
edm::ValidityInterval
Definition: ValidityInterval.h:28
ESProducer.h
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::Timestamp::value
TimeValue_t value() const
Definition: Timestamp.h:45
edm::EventSetupRecordIntervalFinder
Definition: EventSetupRecordIntervalFinder.h:33
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
HeavyIonRcd.h
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
edm::FileInPath
Definition: FileInPath.h:61
MakerMacros.h
HiTrivialConditionRetriever::HiTrivialConditionRetriever
HiTrivialConditionRetriever(const edm::ParameterSet &)
Definition: HiTrivialConditionRetriever.cc:61
HiTrivialConditionRetriever::inputFileName_
string inputFileName_
Definition: HiTrivialConditionRetriever.cc:47
CentralityTable::BinValues::var
float var
Definition: CentralityTable.h:11
edm::eventsetup::EventSetupRecordKey::name
const char * name() const
Definition: EventSetupRecordKey.h:46
edm::IOVSyncValue
Definition: IOVSyncValue.h:31
DEFINE_FWK_EVENTSETUP_SOURCE
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:91
EventSetupRecordIntervalFinder.h
HiTrivialConditionRetriever::printBin
void printBin(const CentralityTable::CBin *)
Definition: HiTrivialConditionRetriever.cc:94
SourceFactory.h
edm::ParameterSet
Definition: ParameterSet.h:47
edm::IOVSyncValue::endOfTime
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
HiTrivialConditionRetriever
Definition: HiTrivialConditionRetriever.cc:30
recoMuon::in
Definition: RecoMuonEnumerators.h:6
CentralityTable::BinValues::mean
float mean
Definition: CentralityTable.h:10
HiTrivialCondRetriever_cfi.HiTrivialConditionRetriever
HiTrivialConditionRetriever
Definition: HiTrivialCondRetriever_cfi.py:3
edm::IOVSyncValue::time
const Timestamp & time() const
Definition: IOVSyncValue.h:42
cond::ValidityInterval
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
std
Definition: JetResolutionObject.h:76
CentralityTable::CBin::b
BinValues b
Definition: CentralityTable.h:21
edm::IOVSyncValue::beginOfTime
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ESProducer
Definition: ESProducer.h:104
HiTrivialConditionRetriever::produceTable
virtual std::unique_ptr< CentralityTable > produceTable(const HeavyIonRcd &)
Definition: HiTrivialConditionRetriever.cc:70
HeavyIonRcd
Definition: HeavyIonRcd.h:24
ParameterSet.h
HiTrivialConditionRetriever::setIntervalFor
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
Definition: HiTrivialConditionRetriever.cc:105
mps_splice.line
line
Definition: mps_splice.py:76