CMS 3D CMS Logo

DetStatus.cc
Go to the documentation of this file.
5 #include <iostream>
6 
7 using namespace std;
8 
9 //
10 // -- Constructor
11 //
13  verbose_ = pset.getUntrackedParameter<bool>("DebugOn", false);
14  AndOr_ = pset.getParameter<bool>("AndOr");
15  applyfilter_ = pset.getParameter<bool>("ApplyFilter");
16  DetNames_ = pset.getParameter<std::vector<std::string> >("DetectorType");
17 
18  // build a map
19  DetMap_ = 0;
20 
21  for (unsigned int detreq = 0; detreq < DetNames_.size(); detreq++) {
22  for (unsigned int detlist = 0; detlist < DcsStatus::nPartitions; detlist++) {
23  if (DetNames_[detreq] == DcsStatus::partitionName[detlist]) {
24  //edm::LogPrint("DetStatus") << __PRETTY_FUNCTION__ << " requested:" << DetNames_[detreq] << std::endl;
25 
26  // set for DCSRecord
27  requestedPartitions_.set(detlist, true);
28 
29  // set for DCSStatus
30  DetMap_ |= (1 << DcsStatus::partitionList[detlist]);
31 
32  if (verbose_) {
33  edm::LogInfo("DetStatus") << "DCSStatus filter: asked partition " << DcsStatus::partitionName[detlist]
34  << " bit " << DcsStatus::partitionList[detlist] << std::endl;
35  }
36  }
37  }
38  }
39  scalersToken_ = consumes<DcsStatusCollection>(edm::InputTag("scalersRawToDigi"));
40  dcsRecordToken_ = consumes<DCSRecord>(edm::InputTag("onlineMetaDataDigis"));
41 }
42 
43 //
44 // -- Destructor
45 //
47 
48 //*********************************************************************//
50 //*********************************************************************//
51 {
52  if (verbose_) {
53  edm::LogInfo("DetStatus") << "Using FED#735 for reading DCS bits" << std::endl;
54  }
55 
56  bool accepted = false;
57  unsigned int curr_dcs = (dcsStatus)[0].ready();
58  if (verbose_) {
59  edm::LogVerbatim("DetStatus") << "curr_dcs = " << curr_dcs << std::endl;
60  }
61 
62  if (AndOr_)
63  accepted = ((DetMap_ & curr_dcs) == DetMap_);
64  else
65  accepted = ((DetMap_ & curr_dcs) != 0);
66 
67  if (verbose_) {
68  edm::LogInfo("DetStatus") << "DCSStatus filter: requested map: " << DetMap_ << " dcs in event: " << curr_dcs
69  << " filter: " << accepted << "( AndOr: " << AndOr_ << ")" << std::endl;
70  edm::LogVerbatim("DetStatus") << "Partitions ON: ";
71  for (unsigned int detlist = 0; detlist < DcsStatus::nPartitions; detlist++) {
72  if ((dcsStatus)[0].ready(DcsStatus::partitionList[detlist])) {
73  edm::LogVerbatim("DetStatus") << " " << DcsStatus::partitionName[detlist];
74  }
75  }
76  edm::LogVerbatim("DetStatus") << std::endl;
77  }
78  return accepted;
79 }
80 
81 //*********************************************************************//
83 //*********************************************************************//
84 {
85  bool accepted = false;
86 
87  if (verbose_) {
88  edm::LogInfo("DetStatus") << "Using softFED#1022 for reading DCS bits" << std::endl;
89  }
90 
91  for (unsigned int detlist = 0; detlist < DcsStatus::nPartitions; detlist++) {
92  if (requestedPartitions_.test(detlist)) {
93  if (AndOr_) {
94  accepted = (accepted & dcsRecord.highVoltageReady(detlist));
95  } else {
96  accepted = (accepted || dcsRecord.highVoltageReady(detlist));
97  }
98  }
99  }
100 
101  if (verbose_) {
102  edm::LogInfo("DetStatus") << "DCSStatus filter: " << accepted << "( AndOr: " << AndOr_ << ")" << std::endl;
103  edm::LogVerbatim("DetStatus") << "Partitions ON: ";
104  for (unsigned int detlist = 0; detlist < DcsStatus::nPartitions; detlist++) {
105  if ((dcsRecord.highVoltageReady(detlist))) {
106  edm::LogVerbatim("DetStatus") << " " << DcsStatus::partitionName[detlist];
107  }
108  }
109  edm::LogVerbatim("DetStatus") << std::endl;
110  }
111 
112  return accepted;
113 }
114 
115 //*********************************************************************//
117 //*********************************************************************//
118 {
119  bool accepted = false;
120 
121  // If FED#735 is available use it to extract DcsStatusCollection.
122  // If not, use softFED#1022 to extract DCSRecord.
123  // Populate DCS Bits array with received information.
124 
126  evt.getByToken(scalersToken_, dcsStatus);
128  evt.getByToken(dcsRecordToken_, dcsRecord);
129 
130  if (dcsStatus.isValid() && !dcsStatus->empty()) {
131  accepted = checkForDCSStatus(*dcsStatus);
132  } else if (dcsRecord.isValid()) {
133  if (evt.eventAuxiliary().isRealData()) {
134  // in case of real data check for DCS
135  accepted = checkForDCSRecord(*dcsRecord);
136  } else {
137  // in case of MC accept in any case
138  accepted = true;
139  }
140  } else {
141  edm::LogError("DetStatus")
142  << "Error! can't get the product, neither DCSRecord, nor scalersRawToDigi: accept in any case!";
143  accepted = true;
144  }
145 
146  if (!applyfilter_) {
147  accepted = true;
148  }
149 
150  return accepted;
151 }
152 
Handle.h
MessageLogger.h
DcsStatus::partitionName
static const char *const partitionName[]
Definition: DcsStatus.h:31
edm::LogInfo
Definition: MessageLogger.h:254
DCSRecord
Class to contain DCS information from soft FED 1022.
Definition: DCSRecord.h:20
DetStatus::DetStatus
DetStatus(const edm::ParameterSet &)
Definition: DetStatus.cc:12
edm::Handle
Definition: AssociativeIterator.h:50
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
cms::dd::accepted
bool accepted(std::vector< std::regex > const &, std::string_view)
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
DetStatus.h
DetStatus::checkForDCSStatus
bool checkForDCSStatus(const DcsStatusCollection &dcsStatus)
Definition: DetStatus.cc:49
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
Event.h
edm::LogVerbatim
Definition: MessageLogger.h:297
DQMOffline_cff.dcsRecord
dcsRecord
Definition: DQMOffline_cff.py:27
edm::EventSetup
Definition: EventSetup.h:57
DetStatus
Definition: DetStatus.h:9
DcsStatus::partitionList
static const int partitionList[]
Definition: DcsStatus.h:30
std
Definition: JetResolutionObject.h:76
edm::Event::eventAuxiliary
EventAuxiliary const & eventAuxiliary() const override
Definition: Event.h:94
DetStatus::checkForDCSRecord
bool checkForDCSRecord(const DCSRecord &dcsRecod)
Definition: DetStatus.cc:82
DcsStatus::nPartitions
Definition: DcsStatus.h:59
DetStatus::~DetStatus
~DetStatus() override
Definition: DetStatus.cc:46
edm::EventAuxiliary::isRealData
bool isRealData() const
Definition: EventAuxiliary.h:74
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
DcsStatusCollection
std::vector< DcsStatus > DcsStatusCollection
Definition: DcsStatus.h:110
edm::InputTag
Definition: InputTag.h:15
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
DetStatus::filter
bool filter(edm::Event &, edm::EventSetup const &) override
Definition: DetStatus.cc:116