CMS 3D CMS Logo

ESDcsInfoTask.cc
Go to the documentation of this file.
1 #include <iostream>
2 
5 
8 
10 
13 
15 
16 using namespace cms;
17 using namespace edm;
18 using namespace std;
19 
21 
22  dqmStore_ = Service<DQMStore>().operator->();
23 
24  prefixME_ = ps.getUntrackedParameter<string>("prefixME", "");
25 
26  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
27 
28  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
29 
30  dcsStatustoken_ = consumes<DcsStatusCollection>(ps.getParameter<InputTag>("DcsStatusLabel"));
31 
32  meESDcsFraction_ = nullptr;
33  meESDcsActiveMap_ = nullptr;
34 
35 }
36 
38 
39 }
40 
42 
43  char histo[200];
44 
45  if ( dqmStore_ ) {
46 
47  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
48 
49  sprintf(histo, "DCSSummary");
50  meESDcsFraction_ = dqmStore_->bookFloat(histo);
51  meESDcsFraction_->Fill(-1.0);
52 
53  sprintf(histo, "DCSSummaryMap");
54  meESDcsActiveMap_ = dqmStore_->book1D(histo,histo, 2, 0., 2.);
55  meESDcsActiveMap_->setAxisTitle("(ES+/ES-)", 1);
56 
57 
58  }
59 
60 }
61 
63 
64  if ( enableCleanup_ ) this->cleanup();
65 
66 }
67 
69 
70  this->reset();
71 
72  for( int i = 0; i < 2; i++) {
73  meESDcsActiveMap_->setBinContent(i+1 , -1.0);
74  }
75 
76 }
77 
78 
80 
81  if ( meESDcsFraction_ ) meESDcsFraction_->Reset();
82 
83  if ( meESDcsActiveMap_ ) meESDcsActiveMap_->Reset();
84 
85 }
86 
87 
89 
90  if ( dqmStore_ ) {
91 
92  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
93 
94  if ( meESDcsFraction_ ) dqmStore_->removeElement( meESDcsFraction_->getName() );
95 
96  if ( meESDcsActiveMap_ ) dqmStore_->removeElement( meESDcsActiveMap_->getName() );
97 
98  }
99 
100 }
101 
102 void ESDcsInfoTask::analyze(const Event& e, const EventSetup& c){
103 
104  ievt_++;
105 
106  float ESpDcsStatus = 0;
107  float ESmDcsStatus = 0;
108 
109  Handle<DcsStatusCollection> dcsStatus;
110  e.getByToken(dcsStatustoken_, dcsStatus);
111  if (dcsStatus.isValid()) {
112  for (DcsStatusCollection::const_iterator dcsStatusItr = dcsStatus->begin(); dcsStatusItr != dcsStatus->end(); ++dcsStatusItr) {
113  ESpDcsStatus = dcsStatusItr->ready(DcsStatus::ESp);
114  ESmDcsStatus = dcsStatusItr->ready(DcsStatus::ESm);
115  }
116 
117  ESpDcsStatus = (ESpDcsStatus + float(ievt_-1)*meESDcsActiveMap_->getBinContent(1))/float(ievt_);
118  ESmDcsStatus = (ESmDcsStatus + float(ievt_-1)*meESDcsActiveMap_->getBinContent(2))/float(ievt_);
119  }
120 
121  meESDcsActiveMap_->setBinContent(1, ESpDcsStatus);
122  meESDcsActiveMap_->setBinContent(2, ESmDcsStatus);
123 
124  meESDcsFraction_->Fill( (ESpDcsStatus + ESmDcsStatus)/2. );
125 
126 }
127 
128 //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:517
static void cleanup(const Factory::MakerMap::value_type &v)
Definition: Factory.cc:12
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:74
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
void cleanup(void)
Cleanup.