CMS 3D CMS Logo

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