test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
QGLikelihoodSystematicsDBWriter.cc
Go to the documentation of this file.
1 // Author: Benedikt Hegner, Tom Cornelis
2 // Email: benedikt.hegner@cern.ch, tom.cornelis@cern.ch
3 
4 #include <vector>
5 #include <memory>
6 #include <string>
7 #include <fstream>
17 
19  public:
21  virtual void beginJob() override;
22  virtual void analyze(const edm::Event&, const edm::EventSetup&) override {}
23  virtual void endJob() override {}
25 
26  private:
29 };
30 
31 // Constructor
33  fileName = pSet.getParameter<std::string>("src");
34  payloadTag = pSet.getParameter<std::string>("payload");
35 }
36 
37 // Begin Job
39 
41  payload->data.clear();
42 
43  std::ifstream database;
44  database.open(edm::FileInPath(fileName.c_str()).fullPath().c_str(),std::ios::in);
45  if(!database.is_open()){ edm::LogError("FileNotFound") << "Could not open file "<< fileName << std::endl; return;}
47  while(std::getline(database,line)){
48  float ptMin, ptMax, etaMin, etaMax, rhoMin, rhoMax, a_q, b_q, a_g, b_g, lmin, lmax;
49  char tag[1023],leadchar;
50  sscanf(line.c_str(),"%c",&leadchar);
51  if((leadchar=='#') || (leadchar=='!')) continue; //Skip those lines
52  sscanf(line.c_str(),"%s %f %f %f %f %f %f %f %f %f %f %f %f", &tag[0], &ptMin, &ptMax, &rhoMin, &rhoMax, &etaMin, &etaMax, &a_q, &b_q, &a_g, &b_g, &lmin, &lmax);
53 
55  category.RhoMin = rhoMin;
56  category.RhoMax = rhoMax;
57  category.PtMin = ptMin;
58  category.PtMax = ptMax;
59  category.EtaMin = etaMin;
60  category.EtaMax = etaMax;
61  category.QGIndex = 0;
62  category.VarIndex = -1;
63 
64  //quark entry
66  quarkEntry.systCategory = category;
67  quarkEntry.a = a_q;
68  quarkEntry.b = b_q;
69  quarkEntry.lmin = lmin;
70  quarkEntry.lmax = lmax;
71 
72  //gluon entry
73  QGLikelihoodSystematicsObject::Entry gluonEntry = quarkEntry;
74  gluonEntry.systCategory.QGIndex = 1;
75  gluonEntry.a = a_g;
76  gluonEntry.b = b_g;
77 
78  payload->data.push_back(quarkEntry);
79  payload->data.push_back(gluonEntry);
80  }
81  database.close();
82 
83  // Now write it into the DB
84  edm::LogInfo("UserOutput") << "Opening PoolDBOutputService" << std::endl;
86  if(s.isAvailable()){
87  edm::LogInfo("UserOutput") << "Setting up payload with " << payload->data.size() << " entries and tag " << payloadTag << std::endl;
90  }
91  edm::LogInfo("UserOutput") << "Wrote in CondDB QGLikelihoodSystematic payload label: " << payloadTag << std::endl;
92 }
93 
94 
T getParameter(std::string const &) const
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void appendSinceTime(T *payloadObj, cond::Time_t sinceTime, const std::string &recordName, bool withlogging=false)
QGLikelihoodSystematicsDBWriter(const edm::ParameterSet &)
bool isNewTagRequest(const std::string &recordName)
bool isAvailable() const
Definition: Service.h:46
Category structure: ranges associated with QGLikelihood histograms.
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
QGLikelihoodSystematicsObject containing the parameters for the systematic smearing.