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 
8 // system include files
9 #include <iostream>
10 #include <fstream>
11 #include <sstream>
12 #include <vector>
13 #include <string>
14 
15 // user include files
24 
25 using namespace std;
26 
27 //
28 // class decleration
29 //
30 
33 {
34 public:
36 
37 protected:
38  //overriding from ContextRecordIntervalFinder
39  void setIntervalFor( const edm::eventsetup::EventSetupRecordKey&,
40  const edm::IOVSyncValue& ,
41  edm::ValidityInterval& ) override ;
42 
43  private:
44  virtual std::unique_ptr<CentralityTable> produceTable( const HeavyIonRcd& );
45  void printBin(const CentralityTable::CBin*);
46 
47  // ----------member data ---------------------------
48 
49  int verbose_;
50  string inputFileName_;
51 };
52 
53 //
54 // constants, enums and typedefs
55 //
56 
57 //
58 // static data member definitions
59 //
60 
61 //
62 // constructors and destructor
63 //
65 
66  setWhatProduced(this, &HiTrivialConditionRetriever::produceTable);
67  findingRecord<HeavyIonRcd>();
68 
69  //now do what ever initialization is needed
70  verbose_ = iConfig.getUntrackedParameter<int>("verbosity",1);
71  inputFileName_ = iConfig.getParameter<string>("inputFile");
72 }
73 
74 std::unique_ptr<CentralityTable>
76 
77  auto CT = std::make_unique<CentralityTable>();
78 
79  // Get values from text file
80  ifstream in( edm::FileInPath(inputFileName_).fullPath().c_str() );
81  string line;
82 
83  int i = 0;
84  while ( getline( in, line ) ) {
85  if ( line.empty() || line[0]=='#' ) { continue; }
86  CentralityTable::CBin thisBin;
87  CT->m_table.push_back(thisBin);
88  istringstream ss(line);
89  ss>>CT->m_table[i].bin_edge
90  >>CT->m_table[i].n_part.mean
91  >>CT->m_table[i].n_part.var
92  >>CT->m_table[i].n_coll.mean
93  >>CT->m_table[i].n_coll.var
94  >>CT->m_table[i].n_hard.mean
95  >>CT->m_table[i].n_hard.var
96  >>CT->m_table[i].b.mean
97  >>CT->m_table[i].b.var;
98  i++;
99  }
100 
101  return std::move(CT);
102 }
103 
105  cout<<"HF Cut = "<<thisBin->bin_edge<<endl;
106  cout<<"Npart = "<<thisBin->n_part.mean<<endl;
107  cout<<"sigma = "<<thisBin->n_part.var<<endl;
108  cout<<"Ncoll = "<<thisBin->n_coll.mean<<endl;
109  cout<<"sigma = "<<thisBin->n_coll.var<<endl;
110  cout<<"B = "<<thisBin->b.mean<<endl;
111  cout<<"sigma = "<<thisBin->b.var<<endl;
112  cout<<"__________________________________________________"<<endl;
113 }
114 
115 void
117  const edm::IOVSyncValue& iTime,
118  edm::ValidityInterval& oValidity)
119 {
120  if(verbose_>=1) std::cout << "HiTrivialConditionRetriever::setIntervalFor(): record key = " << rk.name() << "\ttime: " << iTime.time().value() << std::endl;
121  //For right now, we will just use an infinite interval of validity
123 }
124 
125 //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
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:97
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:19
virtual std::unique_ptr< CentralityTable > produceTable(const HeavyIonRcd &)
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
TimeValue_t value() const
Definition: Timestamp.h:56
def move(src, dest)
Definition: eostools.py:510