CMS 3D CMS Logo

DetStatus.cc
Go to the documentation of this file.
10 
11 class DetStatus : public edm::stream::EDFilter<> {
12 public:
14  ~DetStatus() override;
15 
16  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
17 
18 private:
19  bool filter(edm::Event&, edm::EventSetup const&) override;
20 
21  bool verbose_;
23  bool AndOr_;
24  std::vector<std::string> DetNames_;
25  std::bitset<DcsStatus::nPartitions> requestedPartitions_;
26  unsigned int DetMap_;
29 
30  bool checkForDCSStatus(const DcsStatusCollection& dcsStatus);
31  bool checkForDCSRecord(const DCSRecord& dcsRecod);
32 };
33 
34 using namespace std;
35 
36 //
37 // -- Constructor
38 //
40  verbose_ = pset.getUntrackedParameter<bool>("DebugOn", false);
41  AndOr_ = pset.getParameter<bool>("AndOr");
42  applyfilter_ = pset.getParameter<bool>("ApplyFilter");
43  DetNames_ = pset.getParameter<std::vector<std::string>>("DetectorType");
44 
45  // build a map
46  DetMap_ = 0;
47 
48  for (unsigned int detreq = 0; detreq < DetNames_.size(); detreq++) {
49  for (unsigned int detlist = 0; detlist < DcsStatus::nPartitions; detlist++) {
50  if (DetNames_[detreq] == DcsStatus::partitionName[detlist]) {
51  //edm::LogPrint("DetStatus") << __PRETTY_FUNCTION__ << " requested:" << DetNames_[detreq] << std::endl;
52 
53  // set for DCSRecord
54  requestedPartitions_.set(detlist, true);
55 
56  // set for DCSStatus
57  DetMap_ |= (1 << DcsStatus::partitionList[detlist]);
58 
59  if (verbose_) {
60  edm::LogInfo("DetStatus") << "DCSStatus filter: asked partition " << DcsStatus::partitionName[detlist]
61  << " bit " << DcsStatus::partitionList[detlist] << std::endl;
62  }
63  }
64  }
65  }
66  scalersToken_ = consumes<DcsStatusCollection>(edm::InputTag("scalersRawToDigi"));
67  dcsRecordToken_ = consumes<DCSRecord>(edm::InputTag("onlineMetaDataDigis"));
68 }
69 
70 //
71 // -- Destructor
72 //
74 
75 //*********************************************************************//
77 //*********************************************************************//
78 {
79  if (verbose_) {
80  edm::LogInfo("DetStatus") << "Using FED#735 for reading DCS bits" << std::endl;
81  }
82 
83  bool accepted = false;
84  unsigned int curr_dcs = (dcsStatus)[0].ready();
85  if (verbose_) {
86  edm::LogVerbatim("DetStatus") << "curr_dcs = " << curr_dcs << std::endl;
87  }
88 
89  if (AndOr_)
90  accepted = ((DetMap_ & curr_dcs) == DetMap_);
91  else
92  accepted = ((DetMap_ & curr_dcs) != 0);
93 
94  if (verbose_) {
95  edm::LogInfo("DetStatus") << "DCSStatus filter: requested map: " << DetMap_ << " dcs in event: " << curr_dcs
96  << " filter: " << accepted << "( AndOr: " << AndOr_ << ")" << std::endl;
97  edm::LogVerbatim("DetStatus") << "Partitions ON: ";
98  for (unsigned int detlist = 0; detlist < DcsStatus::nPartitions; detlist++) {
99  if ((dcsStatus)[0].ready(DcsStatus::partitionList[detlist])) {
100  edm::LogVerbatim("DetStatus") << " " << DcsStatus::partitionName[detlist];
101  }
102  }
103  edm::LogVerbatim("DetStatus") << std::endl;
104  }
105  return accepted;
106 }
107 
108 //*********************************************************************//
110 //*********************************************************************//
111 {
112  bool accepted = false;
113 
114  if (verbose_) {
115  edm::LogInfo("DetStatus") << "Using softFED#1022 for reading DCS bits" << std::endl;
116  }
117 
118  for (unsigned int detlist = 0; detlist < DcsStatus::nPartitions; detlist++) {
119  if (requestedPartitions_.test(detlist)) {
120  if (AndOr_) {
121  accepted = (accepted & dcsRecord.highVoltageReady(detlist));
122  } else {
123  accepted = (accepted || dcsRecord.highVoltageReady(detlist));
124  }
125  }
126  }
127 
128  if (verbose_) {
129  edm::LogInfo("DetStatus") << "DCSStatus filter: " << accepted << "( AndOr: " << AndOr_ << ")" << std::endl;
130  edm::LogVerbatim("DetStatus") << "Partitions ON: ";
131  for (unsigned int detlist = 0; detlist < DcsStatus::nPartitions; detlist++) {
132  if ((dcsRecord.highVoltageReady(detlist))) {
133  edm::LogVerbatim("DetStatus") << " " << DcsStatus::partitionName[detlist];
134  }
135  }
136  edm::LogVerbatim("DetStatus") << std::endl;
137  }
138 
139  return accepted;
140 }
141 
142 //*********************************************************************//
144 //*********************************************************************//
145 {
146  bool accepted = false;
147 
148  // If FED#735 is available use it to extract DcsStatusCollection.
149  // If not, use softFED#1022 to extract DCSRecord.
150  // Populate DCS Bits array with received information.
151 
153  evt.getByToken(scalersToken_, dcsStatus);
155  evt.getByToken(dcsRecordToken_, dcsRecord);
156 
157  if (dcsStatus.isValid() && !dcsStatus->empty()) {
158  accepted = checkForDCSStatus(*dcsStatus);
159  } else if (dcsRecord.isValid()) {
160  if (evt.eventAuxiliary().isRealData()) {
161  // in case of real data check for DCS
162  accepted = checkForDCSRecord(*dcsRecord);
163  } else {
164  // in case of MC accept in any case
165  accepted = true;
166  }
167  } else {
168  edm::LogError("DetStatus")
169  << "Error! can't get the product, neither DCSRecord, nor scalersRawToDigi: accept in any case!";
170  accepted = true;
171  }
172 
173  if (!applyfilter_) {
174  accepted = true;
175  }
176 
177  return accepted;
178 }
179 
180 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
183  desc.addUntracked<bool>("DebugOn", false);
184  desc.add<bool>("AndOr", true);
185  desc.add<bool>("ApplyFilter", true);
186  desc.add<std::vector<std::string>>("DetectorType", {});
187  descriptions.add("detStatus", desc);
188 }
189 
ConfigurationDescriptions.h
Handle.h
DetStatus::scalersToken_
edm::EDGetTokenT< DcsStatusCollection > scalersToken_
Definition: DetStatus.cc:27
MessageLogger.h
DcsStatus.h
DcsStatus::partitionName
static const char *const partitionName[]
Definition: DcsStatus.h:31
edm::EDGetTokenT< DcsStatusCollection >
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
DCSRecord
Class to contain DCS information from soft FED 1022.
Definition: DCSRecord.h:20
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
DetStatus::DetStatus
DetStatus(const edm::ParameterSet &)
Definition: DetStatus.cc:39
edm::Handle
Definition: AssociativeIterator.h:50
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
DetStatus::checkForDCSStatus
bool checkForDCSStatus(const DcsStatusCollection &dcsStatus)
Definition: DetStatus.cc:76
ParameterSetDescription.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
DetStatus::requestedPartitions_
std::bitset< DcsStatus::nPartitions > requestedPartitions_
Definition: DetStatus.cc:25
DQMOffline_cff.dcsRecord
dcsRecord
Definition: DQMOffline_cff.py:27
edm::EventSetup
Definition: EventSetup.h:57
DetStatus::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: DetStatus.cc:181
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
DetStatus::DetMap_
unsigned int DetMap_
Definition: DetStatus.cc:26
DetStatus::dcsRecordToken_
edm::EDGetTokenT< DCSRecord > dcsRecordToken_
Definition: DetStatus.cc:28
DetStatus
Definition: DetStatus.cc:11
DcsStatus::partitionList
static const int partitionList[]
Definition: DcsStatus.h:30
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
edm::Event::eventAuxiliary
EventAuxiliary const & eventAuxiliary() const override
Definition: Event.h:95
DetStatus::verbose_
bool verbose_
Definition: DetStatus.cc:21
DetStatus::checkForDCSRecord
bool checkForDCSRecord(const DCSRecord &dcsRecod)
Definition: DetStatus.cc:109
DCSRecord.h
DcsStatus::nPartitions
Definition: DcsStatus.h:59
EDFilter.h
ParameterSet.h
DetStatus::~DetStatus
~DetStatus() override
Definition: DetStatus.cc:73
edm::EventAuxiliary::isRealData
bool isRealData() const
Definition: EventAuxiliary.h:74
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::stream::EDFilter
Definition: EDFilter.h:38
edm::Event
Definition: Event.h:73
DcsStatusCollection
std::vector< DcsStatus > DcsStatusCollection
Definition: DcsStatus.h:110
edm::InputTag
Definition: InputTag.h:15
DetStatus::DetNames_
std::vector< std::string > DetNames_
Definition: DetStatus.cc:24
DetStatus::AndOr_
bool AndOr_
Definition: DetStatus.cc:23
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
DetStatus::applyfilter_
bool applyfilter_
Definition: DetStatus.cc:22
DetStatus::filter
bool filter(edm::Event &, edm::EventSetup const &) override
Definition: DetStatus.cc:143