CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TKStatus.cc
Go to the documentation of this file.
6 #include <iostream>
7 
8 using namespace edm;
9 
11  dcsTkFileName_ = ps.getParameter<ParameterSet>("BeamFitter").getUntrackedParameter<std::string>("DIPFileName");
12  {
13  std::string tmpname = dcsTkFileName_;
14  tmpname.insert(dcsTkFileName_.length() - 4, "_TkStatus");
15  dcsTkFileName_ = std::move(tmpname);
16  }
17  dcsStatus_ = consumes<DcsStatusCollection>(ps.getUntrackedParameter<std::string>("DCSStatus", "scalersRawToDigi"));
18 }
19 
20 // ----------------------------------------------------------
21 void TKStatus::analyze(const Event& iEvent, const EventSetup& iSetup) {
22  int nthlumi = iEvent.luminosityBlock();
23  if (nthlumi > lastlumi_) { // check every LS
24  lastlumi_ = nthlumi;
25  // Checking TK status
27  iEvent.getByToken(dcsStatus_, dcsStatus);
28 
29  std::array<bool, 6> dcsTk;
30  for (auto& e : dcsTk) {
31  e = true;
32  }
33 
34  for (auto const& status : *dcsStatus) {
35  if (!status.ready(DcsStatus::BPIX))
36  dcsTk[0] = false;
37  if (!status.ready(DcsStatus::FPIX))
38  dcsTk[1] = false;
39  if (!status.ready(DcsStatus::TIBTID))
40  dcsTk[2] = false;
41  if (!status.ready(DcsStatus::TOB))
42  dcsTk[3] = false;
43  if (!status.ready(DcsStatus::TECp))
44  dcsTk[4] = false;
45  if (!status.ready(DcsStatus::TECm))
46  dcsTk[5] = false;
47  }
48  dumpTkDcsStatus(dcsTkFileName_, iEvent.run(), dcsTk);
49  }
50 }
51 
52 //--------------------------------------------------------
53 void TKStatus::dumpTkDcsStatus(std::string const& fileName, edm::RunNumber_t runnum, std::array<bool, 6> const& dcsTk) {
54  std::ofstream outFile;
55 
56  outFile.open(fileName.c_str());
57  outFile << "BPIX " << (dcsTk[0] ? "On" : "Off") << std::endl;
58  outFile << "FPIX " << (dcsTk[1] ? "On" : "Off") << std::endl;
59  outFile << "TIBTID " << (dcsTk[2] ? "On" : "Off") << std::endl;
60  outFile << "TOB " << (dcsTk[3] ? "On" : "Off") << std::endl;
61  outFile << "TECp " << (dcsTk[4] ? "On" : "Off") << std::endl;
62  outFile << "TECm " << (dcsTk[5] ? "On" : "Off") << std::endl;
63  bool AllTkOn = true;
64  for (auto status : dcsTk) {
65  if (!status) {
66  AllTkOn = false;
67  break;
68  }
69  }
70  outFile << "WholeTrackerOn " << (AllTkOn ? "Yes" : "No") << std::endl;
71  outFile << "Runnumber " << runnum << std::endl;
72 
73  outFile.close();
74 }
75 
T getUntrackedParameter(std::string const &, T const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
list status
Definition: mps_update.py:107
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:61
int iEvent
Definition: GenABIO.cc:224
def move
Definition: eostools.py:511
RunNumber_t run() const
Definition: Event.h:109
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TKStatus(const edm::ParameterSet &)
Definition: TKStatus.cc:10
unsigned int RunNumber_t
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Definition: TKStatus.cc:21
void dumpTkDcsStatus(std::string const &, edm::RunNumber_t, std::array< bool, 6 > const &)
Definition: TKStatus.cc:53