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