CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DetStatus.cc
Go to the documentation of this file.
6 #include <iostream>
7 
8 using namespace std;
9 
10 //
11 // -- Constructor
12 //
14  verbose_ = pset.getUntrackedParameter<bool>( "DebugOn", false );
15  AndOr_ = pset.getParameter<bool>( "AndOr");
16  applyfilter_ = pset.getParameter<bool>( "ApplyFilter");
17  DetNames_ = pset.getParameter<std::vector<std::string> >( "DetectorType" );
18 
19  // build a map
20  DetMap_=0;
21  for (unsigned int detreq=0;detreq<DetNames_.size();detreq++)
22  {
23  for (unsigned int detlist=0;detlist<DcsStatus::nPartitions;detlist++)
24  {
25 
26  if (DetNames_[detreq]==DcsStatus::partitionName[detlist])
27  {
28  DetMap_|=(1 << DcsStatus::partitionList[detlist]);
29  if (verbose_)
30  std::cout << "DCSStatus filter: asked partition " << DcsStatus::partitionName[detlist] << " bit " << DcsStatus::partitionList[detlist] << std::endl;
31 
32  }
33  }
34  }
35 }
36 
37 //
38 // -- Destructor
39 //
41 }
42 
43 bool DetStatus::filter( edm::Event & evt, edm::EventSetup const& es) {
44 
45  bool accepted=false;
46 
48  evt.getByLabel("scalersRawToDigi", dcsStatus);
49 
50  if (dcsStatus.isValid())
51  {
52  if (dcsStatus->empty())
53  {
54  // Only complain in case it's real data. Accept in any case.
55  if (evt.eventAuxiliary().isRealData())
56  edm::LogError("DetStatus") << "Error! dcsStatus has size 0, accept in any case" ;
57  accepted=true;
58  }
59  else
60  {
61  unsigned int curr_dcs=(*dcsStatus)[0].ready();
62  if (verbose_)
63  std::cout << "curr_dcs = " << curr_dcs << std::endl;
64  if(AndOr_)
65  accepted=((DetMap_ & curr_dcs)== DetMap_);
66  else
67  accepted=((DetMap_ & curr_dcs)!= 0);
68 
69  if (verbose_)
70 
71  {
72  std::cout << "DCSStatus filter: requested map: " << DetMap_ << " dcs in event: " <<curr_dcs << " filter: " << accepted << std::endl;
73  std::cout << "Partitions ON: " ;
74  for (unsigned int detlist=0;detlist<DcsStatus::nPartitions;detlist++)
75  {
76  if ((*dcsStatus)[0].ready(DcsStatus::partitionList[detlist]))
77  {
78  std::cout << " " << DcsStatus::partitionName[detlist];
79  }
80  }
81  std::cout << std::endl ;
82  }
83  }
84  }
85  else
86  {
87  edm::LogError("DetStatus") << "Error! can't get the product: scalersRawToDigi, accept in any case" ;
88  accepted=true;
89  }
90 
91  if (! applyfilter_) accepted=true;
92  return accepted;
93 }
94 
97 
98 
DetStatus(const edm::ParameterSet &)
Definition: DetStatus.cc:13
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool isRealData() const
static const char * partitionName[]
Definition: DcsStatus.h:33
~DetStatus()
Definition: DetStatus.cc:40
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
bool filter(edm::Event &, edm::EventSetup const &) override
Definition: DetStatus.cc:43
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
EventAuxiliary const & eventAuxiliary() const
Definition: Event.h:72
tuple cout
Definition: gather_cfg.py:121
volatile std::atomic< bool > shutdown_flag false
static const int partitionList[]
Definition: DcsStatus.h:32