CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EBDcsInfoTask.cc
Go to the documentation of this file.
1 /*
2  * \file EBDcsInfoTask.cc
3  *
4  * \author E. Di Marco
5  *
6 */
7 
8 #include <iostream>
9 
14 
17 
20 
22 
24 
26 
28 
29  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
30 
31  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
32 
33  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
34 
35  meEBDcsFraction_ = 0;
37  for (int i = 0; i < 36; i++) {
38  meEBDcsActive_[i] = 0;
39  }
40 
41 }
42 
44 
45 }
46 
48 
50 
51  if ( dqmStore_ ) {
52 
53  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
54 
55  name = "DCSSummary";
57  meEBDcsFraction_->Fill(0.0);
58 
59  name = "DCSSummaryMap";
60  meEBDcsActiveMap_ = dqmStore_->book2D(name, name, 72, 0., 72., 34, 0., 34.);
61  meEBDcsActiveMap_->setAxisTitle("jphi", 1);
62  meEBDcsActiveMap_->setAxisTitle("jeta", 2);
63 
64  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/DCSContents");
65 
66  for (int i = 0; i < 36; i++) {
67  name = "EcalBarrel_" + Numbers::sEB(i+1);
69  meEBDcsActive_[i]->Fill(-1.0);
70  }
71 
72  }
73 
74 }
75 
77 
78  if ( enableCleanup_ ) this->cleanup();
79 
80 }
81 
83 
84  // information is by run, so fill the same for the run and for every lumi section
85  for ( int iett = 0; iett < 34; iett++ ) {
86  for ( int iptt = 0; iptt < 72; iptt++ ) {
87  readyLumi[iptt][iett] = 1;
88  }
89  }
90 
91  if ( !iSetup.find( edm::eventsetup::EventSetupRecordKey::makeKey<EcalDCSTowerStatusRcd>() ) ) {
92  edm::LogWarning("EBDcsInfoTask") << "EcalDCSTowerStatus record not found";
93  return;
94  }
95 
97  iSetup.get<EcalDCSTowerStatusRcd>().get(pDCSStatus);
98  if ( !pDCSStatus.isValid() ) {
99  edm::LogWarning("EBDcsInfoTask") << "EcalDCSTowerStatus record not valid";
100  return;
101  }
102  const EcalDCSTowerStatus* dcsStatus = pDCSStatus.product();
103 
104  for(int iz=-1; iz<=1; iz+=2) {
105  for(int iptt=0 ; iptt<72; iptt++) {
106  for(int iett=0 ; iett<17; iett++) {
107  if (EcalTrigTowerDetId::validDetId(iz,EcalBarrel,iett+1,iptt+1 )){
108 
109  EcalTrigTowerDetId ebid(iz,EcalBarrel,iett+1,iptt+1);
110 
111  uint16_t dbStatus = 0; // 0 = good
112  EcalDCSTowerStatus::const_iterator dcsStatusIt = dcsStatus->find( ebid.rawId() );
113  if ( dcsStatusIt != dcsStatus->end() ) dbStatus = dcsStatusIt->getStatusCode();
114 
115  if ( dbStatus > 0 ) {
116  int ipttEB = iptt;
117  int iettEB = (iz==-1) ? iett : 17+iett;
118  readyRun[ipttEB][iettEB] = 0;
119  readyLumi[ipttEB][iettEB] = 0;
120  }
121 
122  }
123  }
124  }
125  }
126 
127 
128 }
129 
131 
133 
134 }
135 
137 
138  if ( ! mergeRuns_ ) this->reset();
139 
140  for ( int iett = 0; iett < 34; iett++ ) {
141  for ( int iptt = 0; iptt < 72; iptt++ ) {
142  readyRun[iptt][iett] = 1;
143  }
144  }
145 
146 }
147 
149 
151 
152 }
153 
155 
157 
158  for (int i = 0; i < 36; i++) {
159  if ( meEBDcsActive_[i] ) meEBDcsActive_[i]->Reset();
160  }
161 
163 
164 }
165 
166 
168 
169  if ( dqmStore_ ) {
170 
171  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
172 
174 
176 
177  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/DCSContents");
178 
179  for (int i = 0; i < 36; i++) {
180  if ( meEBDcsActive_[i] ) dqmStore_->removeElement( meEBDcsActive_[i]->getName() );
181  }
182 
183  }
184 
185 }
186 
187 void EBDcsInfoTask::fillMonitorElements(int ready[72][34]) {
188 
189  float readySum[36];
190  for ( int ism = 0; ism < 36; ism++ ) readySum[ism] = 0;
191  float readySumTot = 0.;
192 
193  for ( int iett = 0; iett < 34; iett++ ) {
194  for ( int iptt = 0; iptt < 72; iptt++ ) {
195 
196  if(meEBDcsActiveMap_) meEBDcsActiveMap_->setBinContent( iptt+1, iett+1, ready[iptt][iett] );
197 
198  int ism = ( iett<17 ) ? iptt/4 : 18+iptt/4;
199  if(ready[iptt][iett]) {
200  readySum[ism]++;
201  readySumTot++;
202  }
203 
204  }
205  }
206 
207  for ( int ism = 0; ism < 36; ism++ ) {
208  if( meEBDcsActive_[ism] ) meEBDcsActive_[ism]->Fill( readySum[ism]/68. );
209  }
210 
211  if( meEBDcsFraction_ ) meEBDcsFraction_->Fill(readySumTot/34./72.);
212 
213 }
214 
216 
217 }
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
int i
Definition: DBlmapReader.cc:9
void setBinContent(int binx, double content)
set content of bin (1-D)
void endJob(void)
EndJob.
EBDcsInfoTask(const edm::ParameterSet &ps)
Constructor.
virtual ~EBDcsInfoTask()
Destructor.
MonitorElement * meEBDcsActive_[36]
Definition: EBDcsInfoTask.h:67
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
MonitorElement * meEBDcsActiveMap_
Definition: EBDcsInfoTask.h:68
Some &quot;id&quot; conversions.
int readyLumi[72][34]
Definition: EBDcsInfoTask.h:71
void reset(void)
Reset.
static std::string sEB(const unsigned ism)
Definition: Numbers.cc:91
void fillMonitorElements(int ready[72][34])
DQMStore * dqmStore_
Definition: EBDcsInfoTask.h:58
const_iterator find(uint32_t rawId) const
void beginJob(void)
BeginJob.
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:809
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:90
void Fill(long long x)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
void removeElement(const std::string &name)
Definition: DQMStore.cc:2772
void cleanup(void)
Cleanup.
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
void beginLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup)
BeginLuminosityBlock.
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
static bool validDetId(int iz, EcalSubdetector sd, int i, int j)
check if a valid index combination
MonitorElement * meEBDcsFraction_
Definition: EBDcsInfoTask.h:66
std::string prefixME_
Definition: EBDcsInfoTask.h:60
bool isValid() const
Definition: ESHandle.h:37
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1000
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
void endLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup)
EndLuminosityBlock.
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void Reset(void)
reset ME (ie. contents, errors, etc)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
int readyRun[72][34]
Definition: EBDcsInfoTask.h:70
Definition: Run.h:41