CMS 3D CMS Logo

SiStripPedestalsBuilder.cc
Go to the documentation of this file.
12 
13 #include "CLHEP/Random/RandFlat.h"
14 #include "CLHEP/Random/RandGauss.h"
15 
16 #include <iostream>
17 #include <fstream>
18 
20 public:
21  explicit SiStripPedestalsBuilder(const edm::ParameterSet& iConfig);
22 
23  ~SiStripPedestalsBuilder() override = default;
24 
25  void analyze(const edm::Event&, const edm::EventSetup&) override;
26 
27 private:
29  uint32_t printdebug_;
30 };
31 
33  : fp_(iConfig.getUntrackedParameter<edm::FileInPath>("file",
35  printdebug_(iConfig.getUntrackedParameter<uint32_t>("printDebug", 1)) {}
36 
38  unsigned int run = evt.id().run();
39 
40  edm::LogInfo("SiStripPedestalsBuilder")
41  << "... creating dummy SiStripPedestals Data for Run " << run << "\n " << std::endl;
42 
44 
45  int count = -1;
46 
48  const auto& DetInfos = reader.getAllData();
49 
50  for (const auto& it : DetInfos) {
51  const auto& nAPVs = it.second.nApvs;
52 
53  count++;
54  //Generate Pedestal for det detid
55  SiStripPedestals::InputVector theSiStripVector;
56  for (int strip = 0; strip < 128 * nAPVs; ++strip) {
57  float MeanPed = 100;
58  float RmsPed = 5;
59 
60  float ped = CLHEP::RandGauss::shoot(MeanPed, RmsPed);
61 
62  if (count < static_cast<int>(printdebug_))
63  edm::LogInfo("SiStripPedestalsBuilder") << "detid " << it.first << " \t"
64  << " strip " << strip << " \t" << ped << " \t" << std::endl;
65  obj.setData(ped, theSiStripVector);
66  }
67 
68  //SiStripPedestals::Range range(theSiStripVector.begin(),theSiStripVector.end());
69  if (!obj.put(it.first, theSiStripVector))
70  edm::LogError("SiStripPedestalsBuilder")
71  << "[SiStripPedestalsBuilder::analyze] detid already exists" << std::endl;
72  }
73 
74  //End now write sistrippedestals data in DB
76 
77  if (mydbservice.isAvailable()) {
78  if (mydbservice->isNewTagRequest("SiStripPedestalsRcd")) {
79  mydbservice->createOneIOV<SiStripPedestals>(obj, mydbservice->beginOfTime(), "SiStripPedestalsRcd");
80  } else {
81  mydbservice->appendOneIOV<SiStripPedestals>(obj, mydbservice->currentTime(), "SiStripPedestalsRcd");
82  }
83  } else {
84  edm::LogError("SiStripPedestalsBuilder") << "Service is unavailable" << std::endl;
85  }
86 }
87 
90 
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)