CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SiStripThresholdBuilder.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  ~SiStripThresholdBuilder() 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", 3)) {}
33 
35  unsigned int run = evt.id().run();
36 
37  edm::LogInfo("SiStripThresholdBuilder")
38  << "... creating dummy SiStripThreshold Data for Run " << run << "\n " << std::endl;
39 
41 
43  const auto& DetInfos = reader.getAllData();
44 
45  int count = -1;
46  for (const auto& it : DetInfos) {
47  count++;
48  //Generate Pedestal for det detid
49  SiStripThreshold::Container theSiStripVector;
50  uint16_t strip = 0;
51  while (strip < 128 * it.second.nApvs) {
52  float lTh = (CLHEP::RandFlat::shoot(1.) * 64) / 5;
53  float hTh = (CLHEP::RandFlat::shoot(1.) * 64) / 5;
54  if (hTh < lTh) {
55  float tmp = hTh;
56  hTh = lTh;
57  lTh = tmp;
58  }
59  float cTh = (CLHEP::RandFlat::shoot(1.) * 30.);
60 
61  obj.setData(strip, lTh, hTh, cTh, theSiStripVector);
62  if (count < (int)printdebug_) {
63  std::stringstream ss;
64  theSiStripVector.back().print(ss);
65  edm::LogInfo("SiStripThresholdBuilder")
66  << "detid: " << it.first << " \n"
67  << "firstStrip: " << strip << " \t"
68  << "lTh: " << lTh << " \t"
69  << "hTh: " << hTh << " \t"
70  << "cTh: " << cTh << " \t"
71  << "FirstStrip_and_Hth: " << theSiStripVector.back().FirstStrip_and_Hth << " \n"
72  << ss.str() << std::endl;
73  }
74  obj.setData(strip + 1, lTh, hTh, theSiStripVector);
75  strip = (uint16_t)(CLHEP::RandFlat::shoot(strip + 2, 128 * it.second.nApvs));
76  }
77  if (!obj.put(it.first, theSiStripVector))
78  edm::LogError("SiStripThresholdBuilder")
79  << "[SiStripThresholdBuilder::analyze] detid already exists" << std::endl;
80  }
81 
82  //End now write sistrippedestals data in DB
84 
85  if (mydbservice.isAvailable()) {
86  if (mydbservice->isNewTagRequest("SiStripThresholdRcd")) {
87  mydbservice->createOneIOV<SiStripThreshold>(obj, mydbservice->beginOfTime(), "SiStripThresholdRcd");
88  } else {
89  mydbservice->appendOneIOV<SiStripThreshold>(obj, mydbservice->currentTime(), "SiStripThresholdRcd");
90  }
91  } else {
92  edm::LogError("SiStripThresholdBuilder") << "Service is unavailable" << std::endl;
93  }
94 }
95 
98 
RunNumber_t run() const
Definition: EventID.h:38
bool put(const uint32_t &detID, const InputVector &vect)
#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)
std::vector< Data > Container
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
SiStripThresholdBuilder(const edm::ParameterSet &iConfig)
~SiStripThresholdBuilder() override=default
void setData(const uint16_t &strip, const float &lTh, const float &hTh, Container &vthr)
edm::EventID id() const
Definition: EventBase.h:59
std::string fullPath() const
Definition: FileInPath.cc:161
static constexpr char const *const kDefaultFile
tmp
align.sh
Definition: createJobs.py:716
void analyze(const edm::Event &, const edm::EventSetup &) override