CMS 3D CMS Logo

SiStripPedestalsBuilder.cc
Go to the documentation of this file.
9 
10 #include "CLHEP/Random/RandFlat.h"
11 #include "CLHEP/Random/RandGauss.h"
12 
13 #include <iostream>
14 #include <fstream>
15 
17 public:
18  explicit SiStripPedestalsBuilder(const edm::ParameterSet& iConfig);
19 
20  ~SiStripPedestalsBuilder() override = default;
21 
22  void analyze(const edm::Event&, const edm::EventSetup&) override;
23 
24 private:
26  uint32_t printdebug_;
27 };
28 
30  : fp_(iConfig.getUntrackedParameter<edm::FileInPath>("file",
32  printdebug_(iConfig.getUntrackedParameter<uint32_t>("printDebug", 1)) {}
33 
35  unsigned int run = evt.id().run();
36 
37  edm::LogInfo("SiStripPedestalsBuilder")
38  << "... creating dummy SiStripPedestals Data for Run " << run << "\n " << std::endl;
39 
41 
42  int count = -1;
43 
45  const auto& DetInfos = reader.getAllData();
46 
47  for (const auto& it : DetInfos) {
48  const auto& nAPVs = it.second.nApvs;
49 
50  count++;
51  //Generate Pedestal for det detid
52  SiStripPedestals::InputVector theSiStripVector;
53  for (int strip = 0; strip < 128 * nAPVs; ++strip) {
54  float MeanPed = 100;
55  float RmsPed = 5;
56 
57  float ped = CLHEP::RandGauss::shoot(MeanPed, RmsPed);
58 
59  if (count < static_cast<int>(printdebug_))
60  edm::LogInfo("SiStripPedestalsBuilder") << "detid " << it.first << " \t"
61  << " strip " << strip << " \t" << ped << " \t" << std::endl;
62  obj.setData(ped, theSiStripVector);
63  }
64 
65  //SiStripPedestals::Range range(theSiStripVector.begin(),theSiStripVector.end());
66  if (!obj.put(it.first, theSiStripVector))
67  edm::LogError("SiStripPedestalsBuilder")
68  << "[SiStripPedestalsBuilder::analyze] detid already exists" << std::endl;
69  }
70 
71  //End now write sistrippedestals data in DB
73 
74  if (mydbservice.isAvailable()) {
75  if (mydbservice->isNewTagRequest("SiStripPedestalsRcd")) {
76  mydbservice->createOneIOV<SiStripPedestals>(obj, mydbservice->beginOfTime(), "SiStripPedestalsRcd");
77  } else {
78  mydbservice->appendOneIOV<SiStripPedestals>(obj, mydbservice->currentTime(), "SiStripPedestalsRcd");
79  }
80  } else {
81  edm::LogError("SiStripPedestalsBuilder") << "Service is unavailable" << std::endl;
82  }
83 }
84 
87 
std::string fullPath() const
Definition: FileInPath.cc:161
reader
Definition: DQM.py:105
Log< level::Error, false > LogError
void createOneIOV(const T &payload, cond::Time_t firstSinceTime, const std::string &recordName)
void analyze(const edm::Event &, const edm::EventSetup &) override
void appendOneIOV(const T &payload, cond::Time_t sinceTime, const std::string &recordName)
std::vector< uint16_t > InputVector
bool isNewTagRequest(const std::string &recordName)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EventID id() const
Definition: EventBase.h:63
SiStripDetInfo read(std::string filePath)
Log< level::Info, false > LogInfo
RunNumber_t run() const
Definition: EventID.h:38
HLT enums.
static constexpr char const *const kDefaultFile
bool isAvailable() const
Definition: Service.h:40
~SiStripPedestalsBuilder() override=default
SiStripPedestalsBuilder(const edm::ParameterSet &iConfig)