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