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).size()==0)
53  {
54  // it's probably a MC event, accepet it in any case
55  edm::LogError("DetStatus") << "Error! dcsStatus has size 0, accept in any case" ;
56  accepted=true;
57  }
58  else
59  {
60  unsigned int curr_dcs=(*dcsStatus)[0].ready();
61  if (verbose_)
62  std::cout << "curr_dcs = " << curr_dcs << std::endl;
63  if(AndOr_)
64  accepted=((DetMap_ & curr_dcs)== DetMap_);
65  else
66  accepted=((DetMap_ & curr_dcs)!= 0);
67 
68  if (verbose_)
69 
70  {
71  std::cout << "DCSStatus filter: requested map: " << DetMap_ << " dcs in event: " <<curr_dcs << " filter: " << accepted << std::endl;
72  std::cout << "Partitions ON: " ;
73  for (unsigned int detlist=0;detlist<DcsStatus::nPartitions;detlist++)
74  {
75  if ((*dcsStatus)[0].ready(DcsStatus::partitionList[detlist]))
76  {
77  std::cout << " " << DcsStatus::partitionName[detlist];
78  }
79  }
80  std::cout << std::endl ;
81  }
82  }
83  }
84  else
85  {
86  edm::LogError("DetStatus") << "Error! can't get the product: scalersRawToDigi, accept in any case" ;
87  accepted=true;
88  }
89 
90  if (! applyfilter_) accepted=true;
91  return accepted;
92 }
93 
96 
97 
DetStatus(const edm::ParameterSet &)
Definition: DetStatus.cc:13
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
static const char * partitionName[]
Definition: DcsStatus.h:33
~DetStatus()
Definition: DetStatus.cc:40
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
bool filter(edm::Event &, edm::EventSetup const &)
Definition: DetStatus.cc:43
tuple cout
Definition: gather_cfg.py:41
static const int partitionList[]
Definition: DcsStatus.h:32