CMS 3D CMS Logo

SiStripDetVOffFakeBuilder.cc
Go to the documentation of this file.
1 // system include files
2 #include <memory>
3 
4 // user include files
5 
7 
9 
15 
17 
18 using namespace std;
19 using namespace cms;
20 
22  : printdebug_(iConfig.getUntrackedParameter<bool>("printDebug", false)) {}
23 
25 
28  iSetup.get<TrackerDigiGeometryRecord>().get(pDD);
29  edm::LogInfo("SiStripDetVOffFakeBuilder") << " There are " << pDD->detUnits().size() << " detectors" << std::endl;
30 
31  for (const auto& it : pDD->detUnits()) {
32  if (dynamic_cast<StripGeomDetUnit const*>(it) != nullptr) {
33  uint32_t detid = (it->geographicalId()).rawId();
34  const StripTopology& p = dynamic_cast<StripGeomDetUnit const*>(it)->specificTopology();
35  unsigned short Nstrips = p.nstrips();
36  if (Nstrips < 1 || Nstrips > 768) {
37  edm::LogError("SiStripDetVOffFakeBuilder")
38  << " Problem with Number of strips in detector.. " << p.nstrips() << " Exiting program" << endl;
39  exit(1);
40  }
41  detids.push_back(detid);
42  if (printdebug_)
43  edm::LogInfo("SiStripDetVOffFakeBuilder") << "detid " << detid;
44  }
45  }
46 }
47 
49  initialize(iSetup);
50 
51  unsigned int run = evt.id().run();
52 
53  edm::LogInfo("SiStripDetVOffFakeBuilder")
54  << "... creating dummy SiStripDetVOff Data for Run " << run << "\n " << std::endl;
55 
56  SiStripDetVOff* SiStripDetVOff_ = new SiStripDetVOff();
57 
58  // std::vector<uint32_t> TheDetIdHVVector;
59 
60  for (std::vector<uint32_t>::const_iterator it = detids.begin(); it != detids.end(); it++) {
61  //Generate HV and LV for each channel, if at least one of the two is off fill the value
62  int hv = rand() % 20;
63  int lv = rand() % 20;
64  if (hv <= 2) {
65  edm::LogInfo("SiStripDetVOffFakeBuilder") << "detid: " << *it << " HV\t OFF" << std::endl;
66  SiStripDetVOff_->put(*it, 1, -1);
67  // TheDetIdHVVector.push_back(*it);
68  }
69  if (lv <= 2) {
70  edm::LogInfo("SiStripDetVOffFakeBuilder") << "detid: " << *it << " LV\t OFF" << std::endl;
71  SiStripDetVOff_->put(*it, -1, 1);
72  // TheDetIdHVVector.push_back(*it);
73  }
74  if (lv <= 2 || hv <= 2)
75  edm::LogInfo("SiStripDetVOffFakeBuilder") << "detid: " << *it << " V\t OFF" << std::endl;
76  }
77 
78  // SiStripDetVOff_->put(TheDetIdHVVector);
79 
80  //End now write DetVOff data in DB
82 
83  if (mydbservice.isAvailable()) {
84  try {
85  if (mydbservice->isNewTagRequest("SiStripDetVOffRcd")) {
86  mydbservice->createNewIOV<SiStripDetVOff>(
87  SiStripDetVOff_, mydbservice->beginOfTime(), mydbservice->endOfTime(), "SiStripDetVOffRcd");
88  } else {
89  mydbservice->appendSinceTime<SiStripDetVOff>(SiStripDetVOff_, mydbservice->currentTime(), "SiStripDetVOffRcd");
90  }
91  } catch (const cond::Exception& er) {
92  edm::LogError("SiStripDetVOffFakeBuilder") << er.what() << std::endl;
93  } catch (const std::exception& er) {
94  edm::LogError("SiStripDetVOffFakeBuilder") << "caught std::exception " << er.what() << std::endl;
95  }
96  } else {
97  edm::LogError("SiStripDetVOffFakeBuilder") << "Service is unavailable" << std::endl;
98  }
99 }
electrons_cff.bool
bool
Definition: electrons_cff.py:372
StripGeomDetUnit.h
funct::false
false
Definition: Factorize.h:34
TrackerGeometry.h
cond::service::PoolDBOutputService::beginOfTime
cond::Time_t beginOfTime() const
Definition: PoolDBOutputService.cc:187
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::LogInfo
Definition: MessageLogger.h:254
SiStripDetVOffFakeBuilder.h
cond::service::PoolDBOutputService::appendSinceTime
void appendSinceTime(const T *payloadObj, cond::Time_t sinceTime, const std::string &recordName)
Definition: PoolDBOutputService.h:135
StripTopology.h
cms::Exception::what
char const * what() const noexcept override
Definition: Exception.cc:103
SiStripDetVOffFakeBuilder::printdebug_
bool printdebug_
Definition: SiStripDetVOffFakeBuilder.h:24
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
SiStripDetVOffFakeBuilder::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: SiStripDetVOffFakeBuilder.cc:48
PoolDBOutputService.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
cond::service::PoolDBOutputService::createNewIOV
void createNewIOV(const T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t, const std::string &recordName)
Definition: PoolDBOutputService.h:110
TrackerGeometry::detUnits
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
Definition: TrackerGeometry.h:61
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
edm::ESHandle< TrackerGeometry >
SiStripDetVOffFakeBuilder::SiStripDetVOffFakeBuilder
SiStripDetVOffFakeBuilder(const edm::ParameterSet &iConfig)
Definition: SiStripDetVOffFakeBuilder.cc:21
edm::EventID::run
RunNumber_t run() const
Definition: EventID.h:38
SiStripDetVOffFakeBuilder::initialize
virtual void initialize(const edm::EventSetup &)
Definition: SiStripDetVOffFakeBuilder.cc:26
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
TrackerDigiGeometryRecord.h
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
SiStripDetVOffFakeBuilder::detids
std::vector< uint32_t > detids
Definition: SiStripDetVOffFakeBuilder.h:25
edm::Service< cond::service::PoolDBOutputService >
SiStripDetVOff::put
bool put(const uint32_t DetId, const int HVoff, const int LVoff)
Insert information for a single detId.
Definition: SiStripDetVOff.cc:24
SiStripDetVOff
Definition: SiStripDetVOff.h:31
cond::persistency::Exception
Base exception class for the object to relational access.
Definition: Exception.h:11
edm::EventSetup
Definition: EventSetup.h:57
rand
Signal rand(Signal arg)
Definition: vlib.cc:379
get
#define get
cond::service::PoolDBOutputService::endOfTime
cond::Time_t endOfTime() const
Definition: PoolDBOutputService.cc:185
GeomDet.h
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
edm::EventBase::id
edm::EventID id() const
Definition: EventBase.h:59
cond::service::PoolDBOutputService::isNewTagRequest
bool isNewTagRequest(const std::string &recordName)
Definition: PoolDBOutputService.cc:100
SiStripDetVOffFakeBuilder::~SiStripDetVOffFakeBuilder
~SiStripDetVOffFakeBuilder() override
Definition: SiStripDetVOffFakeBuilder.cc:24
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:53
SiStripDetVOff.h
edm::Event
Definition: Event.h:73
StripTopology
Definition: StripTopology.h:11
cond::service::PoolDBOutputService::currentTime
cond::Time_t currentTime() const
Definition: PoolDBOutputService.cc:189
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21