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  * $Date: 2012/04/27 13:46:02 $
5  * $Revision: 1.21 $
6  * \author E. Di Marco
7  *
8 */
9 
10 #include <iostream>
11 
16 
19 
22 
24 
26 
28 
30 
31  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
32 
33  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
34 
35  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
36 
37  meEBDcsFraction_ = 0;
39  for (int i = 0; i < 36; i++) {
40  meEBDcsActive_[i] = 0;
41  }
42 
43 }
44 
46 
47 }
48 
50 
52 
53  if ( dqmStore_ ) {
54 
55  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
56 
57  name = "DCSSummary";
59  meEBDcsFraction_->Fill(0.0);
60 
61  name = "DCSSummaryMap";
62  meEBDcsActiveMap_ = dqmStore_->book2D(name, name, 72, 0., 72., 34, 0., 34.);
63  meEBDcsActiveMap_->setAxisTitle("jphi", 1);
64  meEBDcsActiveMap_->setAxisTitle("jeta", 2);
65 
66  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/DCSContents");
67 
68  for (int i = 0; i < 36; i++) {
69  name = "EcalBarrel_" + Numbers::sEB(i+1);
71  meEBDcsActive_[i]->Fill(-1.0);
72  }
73 
74  }
75 
76 }
77 
79 
80  if ( enableCleanup_ ) this->cleanup();
81 
82 }
83 
85 
86  // information is by run, so fill the same for the run and for every lumi section
87  for ( int iett = 0; iett < 34; iett++ ) {
88  for ( int iptt = 0; iptt < 72; iptt++ ) {
89  readyLumi[iptt][iett] = 1;
90  }
91  }
92 
93  if ( !iSetup.find( edm::eventsetup::EventSetupRecordKey::makeKey<EcalDCSTowerStatusRcd>() ) ) {
94  edm::LogWarning("EBDcsInfoTask") << "EcalDCSTowerStatus record not found";
95  return;
96  }
97 
99  iSetup.get<EcalDCSTowerStatusRcd>().get(pDCSStatus);
100  if ( !pDCSStatus.isValid() ) {
101  edm::LogWarning("EBDcsInfoTask") << "EcalDCSTowerStatus record not valid";
102  return;
103  }
104  const EcalDCSTowerStatus* dcsStatus = pDCSStatus.product();
105 
106  for(int iz=-1; iz<=1; iz+=2) {
107  for(int iptt=0 ; iptt<72; iptt++) {
108  for(int iett=0 ; iett<17; iett++) {
109  if (EcalTrigTowerDetId::validDetId(iz,EcalBarrel,iett+1,iptt+1 )){
110 
111  EcalTrigTowerDetId ebid(iz,EcalBarrel,iett+1,iptt+1);
112 
113  uint16_t dbStatus = 0; // 0 = good
114  EcalDCSTowerStatus::const_iterator dcsStatusIt = dcsStatus->find( ebid.rawId() );
115  if ( dcsStatusIt != dcsStatus->end() ) dbStatus = dcsStatusIt->getStatusCode();
116 
117  if ( dbStatus > 0 ) {
118  int ipttEB = iptt;
119  int iettEB = (iz==-1) ? iett : 17+iett;
120  readyRun[ipttEB][iettEB] = 0;
121  readyLumi[ipttEB][iettEB] = 0;
122  }
123 
124  }
125  }
126  }
127  }
128 
129 
130 }
131 
133 
135 
136 }
137 
139 
140  if ( ! mergeRuns_ ) this->reset();
141 
142  for ( int iett = 0; iett < 34; iett++ ) {
143  for ( int iptt = 0; iptt < 72; iptt++ ) {
144  readyRun[iptt][iett] = 1;
145  }
146  }
147 
148 }
149 
151 
153 
154 }
155 
157 
159 
160  for (int i = 0; i < 36; i++) {
161  if ( meEBDcsActive_[i] ) meEBDcsActive_[i]->Reset();
162  }
163 
165 
166 }
167 
168 
170 
171  if ( dqmStore_ ) {
172 
173  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
174 
176 
178 
179  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/DCSContents");
180 
181  for (int i = 0; i < 36; i++) {
182  if ( meEBDcsActive_[i] ) dqmStore_->removeElement( meEBDcsActive_[i]->getName() );
183  }
184 
185  }
186 
187 }
188 
189 void EBDcsInfoTask::fillMonitorElements(int ready[72][34]) {
190 
191  float readySum[36];
192  for ( int ism = 0; ism < 36; ism++ ) readySum[ism] = 0;
193  float readySumTot = 0.;
194 
195  for ( int iett = 0; iett < 34; iett++ ) {
196  for ( int iptt = 0; iptt < 72; iptt++ ) {
197 
198  if(meEBDcsActiveMap_) meEBDcsActiveMap_->setBinContent( iptt+1, iett+1, ready[iptt][iett] );
199 
200  int ism = ( iett<17 ) ? iptt/4 : 18+iptt/4;
201  if(ready[iptt][iett]) {
202  readySum[ism]++;
203  readySumTot++;
204  }
205 
206  }
207  }
208 
209  for ( int ism = 0; ism < 36; ism++ ) {
210  if( meEBDcsActive_[ism] ) meEBDcsActive_[ism]->Fill( readySum[ism]/68. );
211  }
212 
213  if( meEBDcsFraction_ ) meEBDcsFraction_->Fill(readySumTot/34./72.);
214 
215 }
216 
218 
219 }
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:69
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
MonitorElement * meEBDcsActiveMap_
Definition: EBDcsInfoTask.h:70
Some &quot;id&quot; conversions.
int readyLumi[72][34]
Definition: EBDcsInfoTask.h:73
void reset(void)
Reset.
static std::string sEB(const unsigned ism)
Definition: Numbers.cc:94
void fillMonitorElements(int ready[72][34])
DQMStore * dqmStore_
Definition: EBDcsInfoTask.h:60
const_iterator find(uint32_t rawId) const
void beginJob(void)
BeginJob.
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:659
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:45
void removeElement(const std::string &name)
Definition: DQMStore.cc:2577
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:68
std::string prefixME_
Definition: EBDcsInfoTask.h:62
std::vector< Item >::const_iterator const_iterator
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:850
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:434
int readyRun[72][34]
Definition: EBDcsInfoTask.h:72
Definition: Run.h:36