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  for (unsigned int detreq=0;detreq<DetNames_.size();detreq++)
21  {
22  for (unsigned int detlist=0;detlist<DcsStatus::nPartitions;detlist++)
23  {
24 
25  if (DetNames_[detreq]==DcsStatus::partitionName[detlist])
26  {
27  DetMap_|=(1 << DcsStatus::partitionList[detlist]);
28  if (verbose_)
29  std::cout << "DCSStatus filter: asked partition " << DcsStatus::partitionName[detlist] << " bit " << DcsStatus::partitionList[detlist] << std::endl;
30 
31  }
32  }
33  }
34  edm::InputTag scalersTag("scalersRawToDigi");
35  scalersToken_=consumes<DcsStatusCollection>(scalersTag);
36 }
37 
38 //
39 // -- Destructor
40 //
42 }
43 
44 bool DetStatus::filter( edm::Event & evt, edm::EventSetup const& es) {
45 
46  bool accepted=false;
47 
49  evt.getByToken(scalersToken_, dcsStatus);
50 
51  if (dcsStatus.isValid())
52  {
53  if (dcsStatus->empty())
54  {
55  // Only complain in case it's real data. Accept in any case.
56  if (evt.eventAuxiliary().isRealData())
57  edm::LogError("DetStatus") << "Error! dcsStatus has size 0, accept in any case" ;
58  accepted=true;
59  }
60  else
61  {
62  unsigned int curr_dcs=(*dcsStatus)[0].ready();
63  if (verbose_)
64  std::cout << "curr_dcs = " << curr_dcs << std::endl;
65  if(AndOr_)
66  accepted=((DetMap_ & curr_dcs)== DetMap_);
67  else
68  accepted=((DetMap_ & curr_dcs)!= 0);
69 
70  if (verbose_)
71 
72  {
73  std::cout << "DCSStatus filter: requested map: " << DetMap_ << " dcs in event: " <<curr_dcs << " filter: " << accepted << std::endl;
74  std::cout << "Partitions ON: " ;
75  for (unsigned int detlist=0;detlist<DcsStatus::nPartitions;detlist++)
76  {
77  if ((*dcsStatus)[0].ready(DcsStatus::partitionList[detlist]))
78  {
79  std::cout << " " << DcsStatus::partitionName[detlist];
80  }
81  }
82  std::cout << std::endl ;
83  }
84  }
85  }
86  else
87  {
88  edm::LogError("DetStatus") << "Error! can't get the product: scalersRawToDigi, accept in any case" ;
89  accepted=true;
90  }
91 
92  if (! applyfilter_) accepted=true;
93  return accepted;
94 }
95 
98 
99 
DetStatus(const edm::ParameterSet &)
Definition: DetStatus.cc:12
~DetStatus() override
Definition: DetStatus.cc:41
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool isRealData() const
EventAuxiliary const & eventAuxiliary() const override
Definition: Event.h:83
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
bool filter(edm::Event &, edm::EventSetup const &) override
Definition: DetStatus.cc:44
static const char *const partitionName[]
Definition: DcsStatus.h:33
bool isValid() const
Definition: HandleBase.h:74
static const int partitionList[]
Definition: DcsStatus.h:32