CMS 3D CMS Logo

ESDcsInfoTask.cc
Go to the documentation of this file.
1 #include <iostream>
2 
5 
8 
10 
12 
14 
15 using namespace cms;
16 using namespace edm;
17 using namespace std;
18 
20  dqmStore_ = Service<DQMStore>().operator->();
21 
22  prefixME_ = ps.getUntrackedParameter<string>("prefixME", "");
23 
24  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
25 
26  dcsStatustoken_ = consumes<DcsStatusCollection>(ps.getParameter<InputTag>("DcsStatusLabel"));
27 
28  meESDcsFraction_ = nullptr;
29  meESDcsActiveMap_ = nullptr;
30 }
31 
33 
35  char histo[200];
36 
37  if (dqmStore_) {
38  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
39 
40  sprintf(histo, "DCSSummary");
41  meESDcsFraction_ = dqmStore_->bookFloat(histo);
42  meESDcsFraction_->Fill(-1.0);
43 
44  sprintf(histo, "DCSSummaryMap");
45  meESDcsActiveMap_ = dqmStore_->book1D(histo, histo, 2, 0., 2.);
46  meESDcsActiveMap_->setAxisTitle("(ES+/ES-)", 1);
47  }
48 }
49 
50 void ESDcsInfoTask::endJob(void) {}
51 
53  this->reset();
54 
55  for (int i = 0; i < 2; i++) {
56  meESDcsActiveMap_->setBinContent(i + 1, -1.0);
57  }
58 }
59 
61  if (meESDcsFraction_)
62  meESDcsFraction_->Reset();
63 
64  if (meESDcsActiveMap_)
65  meESDcsActiveMap_->Reset();
66 }
67 
68 void ESDcsInfoTask::analyze(const Event& e, const EventSetup& c) {
69  ievt_++;
70 
71  float ESpDcsStatus = 0;
72  float ESmDcsStatus = 0;
73 
75  e.getByToken(dcsStatustoken_, dcsStatus);
76  if (dcsStatus.isValid()) {
77  for (DcsStatusCollection::const_iterator dcsStatusItr = dcsStatus->begin(); dcsStatusItr != dcsStatus->end();
78  ++dcsStatusItr) {
79  ESpDcsStatus = dcsStatusItr->ready(DcsStatus::ESp);
80  ESmDcsStatus = dcsStatusItr->ready(DcsStatus::ESm);
81  }
82 
83  ESpDcsStatus = (ESpDcsStatus + float(ievt_ - 1) * meESDcsActiveMap_->getBinContent(1)) / float(ievt_);
84  ESmDcsStatus = (ESmDcsStatus + float(ievt_ - 1) * meESDcsActiveMap_->getBinContent(2)) / float(ievt_);
85  }
86 
87  meESDcsActiveMap_->setBinContent(1, ESpDcsStatus);
88  meESDcsActiveMap_->setBinContent(2, ESmDcsStatus);
89 
90  meESDcsFraction_->Fill((ESpDcsStatus + ESmDcsStatus) / 2.);
91 }
92 
93 //define this as a plug-in
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
void beginJob(void) override
BeginJob.
ESDcsInfoTask(const edm::ParameterSet &ps)
Constructor.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
bool isValid() const
Definition: HandleBase.h:70
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Analyze.
Namespace of DDCMS conversion namespace.
void beginLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup) override
BeginLuminosityBlock.
void endJob(void) override
EndJob.
~ESDcsInfoTask() override
Destructor.
HLT enums.
void reset(void)
Reset.
void reset(double vett[256])
Definition: TPedValues.cc:11