CMS 3D CMS Logo

SiStripSummaryBuilder.cc
Go to the documentation of this file.
1 // system include files
2 #include <iostream>
3 #include <fstream>
4 
5 // user include files
13 
14 #include "CLHEP/Random/RandFlat.h"
15 #include "CLHEP/Random/RandGauss.h"
16 
18 public:
19  explicit SiStripSummaryBuilder(const edm::ParameterSet& iConfig);
20 
21  ~SiStripSummaryBuilder() override = default;
22 
23  void analyze(const edm::Event&, const edm::EventSetup&) override;
24 
25 private:
28 
30 };
31 
33  : fp_(iConfig.getUntrackedParameter<edm::FileInPath>(
34  "file", edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"))),
35  printdebug_(iConfig.getUntrackedParameter<uint32_t>("printDebug", 1)),
36  iConfig_(iConfig) {}
37 
39  unsigned int run = evt.id().run();
40  edm::LogInfo("SiStripSummaryBuilder") << "... creating dummy SiStripSummary Data for Run " << run << "\n "
41  << std::endl;
42 
44  obj.setRunNr(run);
45 
46  //* DISCOVER SET OF HISTOGRAMS & QUANTITIES TO BE UPLOADED*//
47 
48  std::vector<std::string> userDBContent;
49  typedef std::vector<edm::ParameterSet> VParameters;
50  VParameters histoList = iConfig_.getParameter<VParameters>("histoList");
51  VParameters::iterator ithistoList = histoList.begin();
52  VParameters::iterator ithistoListEnd = histoList.end();
53 
54  for (; ithistoList != ithistoListEnd; ++ithistoList) {
55  std::string keyName = ithistoList->getUntrackedParameter<std::string>("keyName");
56  std::vector<std::string> Quantities =
57  ithistoList->getUntrackedParameter<std::vector<std::string> >("quantitiesToExtract");
58  for (size_t i = 0; i < Quantities.size(); ++i) {
59  if (Quantities[i] == "landau") {
60  userDBContent.push_back(keyName + std::string("@") + std::string("landauPeak"));
61  userDBContent.push_back(keyName + std::string("@") + std::string("landauPeakErr"));
62  userDBContent.push_back(keyName + std::string("@") + std::string("landauSFWHM"));
63  userDBContent.push_back(keyName + std::string("@") + std::string("landauChi2NDF"));
64  } else if (Quantities[i] == "gauss") {
65  userDBContent.push_back(keyName + std::string("@") + std::string("gaussMean"));
66  userDBContent.push_back(keyName + std::string("@") + std::string("gaussSigma"));
67  userDBContent.push_back(keyName + std::string("@") + std::string("gaussChi2NDF"));
68  } else if (Quantities[i] == "stat") {
69  userDBContent.push_back(keyName + std::string("@") + std::string("entries"));
70  userDBContent.push_back(keyName + std::string("@") + std::string("mean"));
71  userDBContent.push_back(keyName + std::string("@") + std::string("rms"));
72  } else {
73  edm::LogError("SiStripSummaryBuilder")
74  << "Quantity " << Quantities[i] << " cannot be handled\nAllowed quantities are"
75  << "\n 'stat' that includes: entries, mean, rms"
76  << "\n 'landau' that includes: landauPeak, landauPeakErr, landauSFWHM, landauChi2NDF"
77  << "\n 'gauss' that includes: gaussMean, gaussSigma, gaussChi2NDF" << std::endl;
78  }
79  }
80  }
81  obj.setUserDBContent(userDBContent);
82 
83  std::stringstream ss1;
84  ss1 << "QUANTITIES TO BE INSERTED IN DB :"
85  << " \n";
86  std::vector<std::string> userDBContentA = obj.getUserDBContent();
87  for (size_t i = 0; i < userDBContentA.size(); ++i)
88  ss1 << userDBContentA[i] << std::endl;
89  edm::LogInfo("SiStripSummaryBuilder") << ss1.str();
90 
91  //* Loop over detids and create dummy data for each *//
92 
93  std::stringstream ss2;
94  for (uint32_t detid = 0; detid < 430; detid++) {
96  for (unsigned int i = 0; i < userDBContent.size(); i++)
97  values.push_back((float)CLHEP::RandGauss::shoot(50., 30.));
98 
99  ss2 << "\n\tdetid " << detid;
100  for (size_t j = 0; j < values.size(); ++j)
101  ss2 << "\n\t\t " << userDBContent[j] << " " << values[j];
102 
103  obj.put(detid, values, userDBContent);
104 
105  // See CondFormats/SiStripObjects/SiStripSummary.h for detid definitions
106 
107  if (detid == 4)
108  detid = 10;
109  if (detid == 14)
110  detid = 20;
111  if (detid == 26)
112  detid = 30;
113  if (detid == 32)
114  detid = 40;
115  if (detid == 42)
116  detid = 310;
117  if (detid == 313)
118  detid = 320;
119  if (detid == 323)
120  detid = 410;
121  if (detid == 419)
122  detid = 420;
123  }
124 
125  edm::LogInfo("SiStripSummaryBuilder") << ss2.str();
126 
127  //* Insert summary informations in the DB *//
128 
130 
131  if (mydbservice.isAvailable()) {
132  if (mydbservice->isNewTagRequest("SiStripSummaryRcd")) {
133  mydbservice->createOneIOV<SiStripSummary>(obj, mydbservice->beginOfTime(), "SiStripSummaryRcd");
134  } else {
135  mydbservice->appendOneIOV<SiStripSummary>(obj, mydbservice->currentTime(), "SiStripSummaryRcd");
136  }
137  } else {
138  edm::LogError("SiStripSummaryBuilder") << "Service is unavailable" << std::endl;
139  }
140 }
141 
144 
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Log< level::Error, false > LogError
void createOneIOV(const T &payload, cond::Time_t firstSinceTime, const std::string &recordName)
void appendOneIOV(const T &payload, cond::Time_t sinceTime, const std::string &recordName)
~SiStripSummaryBuilder() override=default
bool isNewTagRequest(const std::string &recordName)
SiStripSummaryBuilder(const edm::ParameterSet &iConfig)
edm::EventID id() const
Definition: EventBase.h:59
std::vector< float > InputVector
Log< level::Info, false > LogInfo
RunNumber_t run() const
Definition: EventID.h:38
void analyze(const edm::Event &, const edm::EventSetup &) override
HLT enums.
bool isAvailable() const
Definition: Service.h:40