CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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:
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",
31  edm::FileInPath(SiStripDetInfoFileReader::kDefaultFile))),
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->createNewIOV<SiStripPedestals>(obj,mydbservice->currentTime(),"SiStripPedestalsRcd");
79  mydbservice->appendOneIOV<SiStripPedestals>(obj, mydbservice->currentTime(), "SiStripPedestalsRcd");
80  }
81  } else {
82  edm::LogError("SiStripPedestalsBuilder") << "Service is unavailable" << std::endl;
83  }
84 }
85 
88 
RunNumber_t run() const
Definition: EventID.h:38
#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 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)
bool isAvailable() const
Definition: Service.h:40
tuple reader
Definition: DQM.py:105
SiStripDetInfo read(std::string filePath)
Log< level::Info, false > LogInfo
bool put(const uint32_t &detID, InputVector &input)
edm::EventID id() const
Definition: EventBase.h:59
void setData(float ped, InputVector &vped)
std::string fullPath() const
Definition: FileInPath.cc:161
static constexpr char const *const kDefaultFile
~SiStripPedestalsBuilder() override=default
SiStripPedestalsBuilder(const edm::ParameterSet &iConfig)