CMS 3D CMS Logo

SiStripFedCablingBuilder.cc
Go to the documentation of this file.
1 // sytem include files
2 #include <iostream>
3 #include <fstream>
4 #include <sstream>
5 
6 // user include files
23 
24 class SiStripFedCablingBuilder : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
25 public:
27 
28  ~SiStripFedCablingBuilder() override = default;
29 
30  void beginRun(const edm::Run&, const edm::EventSetup&) override;
31  void analyze(const edm::Event&, const edm::EventSetup&) override {}
32  void endRun(const edm::Run&, const edm::EventSetup&) override {}
33 
34 private:
35  const bool printFecCabling_;
36  const bool printDetCabling_;
37  const bool printRegionCabling_;
43 };
44 
45 // -----------------------------------------------------------------------------
46 //
48  : printFecCabling_(pset.getUntrackedParameter<bool>("PrintFecCabling", false)),
49  printDetCabling_(pset.getUntrackedParameter<bool>("PrintDetCabling", false)),
50  printRegionCabling_(pset.getUntrackedParameter<bool>("PrintRegionCabling", false)),
51  fedCablingToken_(esConsumes<edm::Transition::BeginRun>()),
52  fecCablingToken_(esConsumes<edm::Transition::BeginRun>()),
53  detCablingToken_(esConsumes<edm::Transition::BeginRun>()),
54  regionCablingToken_(esConsumes<edm::Transition::BeginRun>()),
55  tTopoToken_(esConsumes<edm::Transition::BeginRun>()) {}
56 
57 // -----------------------------------------------------------------------------
58 //
60  edm::LogInfo("SiStripFedCablingBuilder")
61  << "... creating dummy SiStripFedCabling Data for Run " << run.run() << "\n " << std::endl;
62 
63  edm::LogVerbatim("SiStripFedCablingBuilder") << "[SiStripFedCablingBuilder::" << __func__ << "]"
64  << " Retrieving FED cabling...";
65  auto fed = setup.getHandle(fedCablingToken_);
66 
67  edm::LogVerbatim("SiStripFedCablingBuilder") << "[SiStripFedCablingBuilder::" << __func__ << "]"
68  << " Retrieving FEC cabling...";
69  auto fec = setup.getHandle(fecCablingToken_);
70 
71  edm::LogVerbatim("SiStripFedCablingBuilder") << "[SiStripFedCablingBuilder::" << __func__ << "]"
72  << " Retrieving DET cabling...";
73  auto det = setup.getHandle(detCablingToken_);
74 
75  edm::LogVerbatim("SiStripFedCablingBuilder") << "[SiStripFedCablingBuilder::" << __func__ << "]"
76  << " Retrieving REGION cabling...";
77  auto region = setup.getHandle(regionCablingToken_);
78 
79  if (!fed.isValid()) {
80  edm::LogError("SiStripFedCablingBuilder") << " Invalid handle to FED cabling object: ";
81  return;
82  }
83 
84  const auto tTopo = &setup.getData(tTopoToken_);
85  {
86  std::stringstream ss;
87  ss << "[SiStripFedCablingBuilder::" << __func__ << "]"
88  << " VERBOSE DEBUG" << std::endl;
89  fed->print(ss, tTopo);
90  ss << std::endl;
91  if (printFecCabling_ && fec.isValid()) {
92  fec->print(ss);
93  }
94  ss << std::endl;
95  if (printDetCabling_ && det.isValid()) {
96  det->print(ss);
97  }
98  ss << std::endl;
99  if (printRegionCabling_ && region.isValid()) {
100  region->print(ss);
101  }
102  ss << std::endl;
103  edm::LogVerbatim("SiStripFedCablingBuilder") << ss.str();
104  }
105 
106  {
107  std::stringstream ss;
108  ss << "[SiStripFedCablingBuilder::" << __func__ << "]"
109  << " TERSE DEBUG" << std::endl;
110  fed->terse(ss);
111  ss << std::endl;
112  edm::LogVerbatim("SiStripFedCablingBuilder") << ss.str();
113  }
114 
115  {
116  std::stringstream ss;
117  ss << "[SiStripFedCablingBuilder::" << __func__ << "]"
118  << " SUMMARY DEBUG" << std::endl;
119  fed->summary(ss, tTopo);
120  ss << std::endl;
121  edm::LogVerbatim("SiStripFedCablingBuilder") << ss.str();
122  }
123 
124  edm::LogVerbatim("SiStripFedCablingBuilder") << "[SiStripFedCablingBuilder::" << __func__ << "]"
125  << " Copying FED cabling...";
126  SiStripFedCabling obj(*(fed.product()));
127 
128  //End now write sistripnoises data in DB
130 
131  if (mydbservice.isAvailable()) {
132  if (mydbservice->isNewTagRequest("SiStripFedCablingRcd")) {
133  mydbservice->createOneIOV<SiStripFedCabling>(obj, mydbservice->beginOfTime(), "SiStripFedCablingRcd");
134  } else {
135  mydbservice->appendOneIOV<SiStripFedCabling>(obj, mydbservice->currentTime(), "SiStripFedCablingRcd");
136  }
137  } else {
138  edm::LogError("SiStripFedCablingBuilder") << "Service is unavailable" << std::endl;
139  }
140 }
141 
144 
Log< level::Info, true > LogVerbatim
void analyze(const edm::Event &, const edm::EventSetup &) override
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
const edm::ESGetToken< SiStripDetCabling, SiStripDetCablingRcd > detCablingToken_
const edm::ESGetToken< SiStripFedCabling, SiStripFedCablingRcd > fedCablingToken_
~SiStripFedCablingBuilder() override=default
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
Log< level::Error, false > LogError
void beginRun(const edm::Run &, const edm::EventSetup &) override
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)
bool isNewTagRequest(const std::string &recordName)
Transition
Definition: Transition.h:12
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Log< level::Info, false > LogInfo
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
void endRun(const edm::Run &, const edm::EventSetup &) override
HLT enums.
SiStripFedCablingBuilder(const edm::ParameterSet &iConfig)
bool isAvailable() const
Definition: Service.h:40
const edm::ESGetToken< SiStripRegionCabling, SiStripRegionCablingRcd > regionCablingToken_
const edm::ESGetToken< SiStripFecCabling, SiStripFecCablingRcd > fecCablingToken_
Definition: Run.h:45