CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EEDcsInfoTask.cc
Go to the documentation of this file.
1 /*
2  * \file EEDcsInfoTask.cc
3  *
4  * $Date: 2010/08/11 14:57:34 $
5  * $Revision: 1.17 $
6  * \author E. Di Marco
7  *
8 */
9 
10 #include <iostream>
11 
16 
18 
21 
24 
26 
28 
30 
32 
33  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
34 
35  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
36 
37  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
38 
39  meEEDcsFraction_ = 0;
41  for (int i = 0; i < 18; i++) {
42  meEEDcsActive_[i] = 0;
43  }
44 
45 }
46 
48 
49 }
50 
52 
53  char histo[200];
54 
55  if ( dqmStore_ ) {
56 
57  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
58 
59  sprintf(histo, "DCSSummary");
61  meEEDcsFraction_->Fill(0.0);
62 
63  sprintf(histo, "DCSSummaryMap");
64  meEEDcsActiveMap_ = dqmStore_->book2D(histo,histo, 200, 0., 200., 100, 0., 100.);
67 
68  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/DCSContents");
69 
70  for (int i = 0; i < 18; i++) {
71  sprintf(histo, "EcalEndcap_%s", Numbers::sEE(i+1).c_str());
73  meEEDcsActive_[i]->Fill(-1.0);
74  }
75 
76  }
77 
78 }
79 
81 
82  if ( enableCleanup_ ) this->cleanup();
83 
84 }
85 
87 
88  // information is by run, so fill the same for the run and for every lumi section
89  for ( int itx = 0; itx < 40; itx++ ) {
90  for ( int ity = 0; ity < 20; ity++ ) {
91  readyLumi[itx][ity] = 1;
92  }
93  }
94 
95  if ( !iSetup.find( edm::eventsetup::EventSetupRecordKey::makeKey<EcalDCSTowerStatusRcd>() ) ) {
96  edm::LogWarning("EEDcsInfoTask") << "EcalDCSTowerStatus record not found";
97  return;
98  }
99 
101  iSetup.get<EcalDCSTowerStatusRcd>().get(pDCSStatus);
102  if ( !pDCSStatus.isValid() ) {
103  edm::LogWarning("EEDcsInfoTask") << "EcalDCSTowerStatus record not valid";
104  return;
105  }
106  const EcalDCSTowerStatus* dcsStatus = pDCSStatus.product();
107 
108  for(int iz=-1; iz<=1; iz+=2) {
109  for(int itx=0 ; itx<20; itx++) {
110  for(int ity=0 ; ity<20; ity++) {
111  if (EcalScDetId::validDetId(itx+1,ity+1,iz )){
112 
113  EcalScDetId eeid(itx+1,ity+1,iz);
114 
115  uint16_t dbStatus = 0; // 0 = good
116  EcalDCSTowerStatus::const_iterator dcsStatusIt = dcsStatus->find( eeid.rawId() );
117  if ( dcsStatusIt != dcsStatus->end() ) dbStatus = dcsStatusIt->getStatusCode();
118 
119  if ( dbStatus > 0 ) {
120  int offsetSC = (iz > 0) ? 0 : 20;
121  readyRun[offsetSC+itx][ity] = 0;
122  readyLumi[offsetSC+itx][ity] = 0;
123  }
124 
125  }
126  }
127  }
128  }
129 
130 }
131 
133 
135 
136 }
137 
139 
140  if ( ! mergeRuns_ ) this->reset();
141 
142  for ( int itx = 0; itx < 40; itx++ ) {
143  for ( int ity = 0; ity < 20; ity++ ) {
144  readyRun[itx][ity] = 1;
145  }
146  }
147 
148 }
149 
151 
153 
154 }
155 
157 
159 
160  for (int i = 0; i < 18; i++) {
161  if ( meEEDcsActive_[i] ) meEEDcsActive_[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 < 18; i++) {
183  }
184 
185  }
186 
187 }
188 
189 void EEDcsInfoTask::fillMonitorElements(int ready[40][20]) {
190 
191  float readySum[18];
192  int nValidChannels[18];
193  for ( int ism = 0; ism < 18; ism++ ) {
194  readySum[ism] = 0;
195  nValidChannels[ism] = 0;
196  }
197  float readySumTot = 0.;
198  int nValidChannelsTot = 0;
199 
200  for ( int iz = -1; iz < 2; iz+=2 ) {
201  for ( int itx = 0; itx < 20; itx++ ) {
202  for ( int ity = 0; ity < 20; ity++ ) {
203  for ( int h = 0; h < 5; h++ ) {
204  for ( int k = 0; k < 5; k++ ) {
205 
206  int ix = 5*itx + h;
207  int iy = 5*ity + k;
208 
209  int offsetSC = (iz > 0) ? 0 : 20;
210  int offset = (iz > 0) ? 0 : 100;
211 
212  if( EEDetId::validDetId(ix+1, iy+1, iz) ) {
213 
214  if(meEEDcsActiveMap_) meEEDcsActiveMap_->setBinContent( offset+ix+1, iy+1, ready[offsetSC+itx][ity] );
215 
216  EEDetId id = EEDetId(ix+1, iy+1, iz, EEDetId::XYMODE);
217 
218  int ism = Numbers::iSM(id);
219  if(ready[offsetSC+itx][ity]) {
220  readySum[ism-1]++;
221  readySumTot++;
222  }
223 
224  nValidChannels[ism-1]++;
225  nValidChannelsTot++;
226 
227  } else {
228  if(meEEDcsActiveMap_) meEEDcsActiveMap_->setBinContent( offset+ix+1, iy+1, -1.0 );
229  }
230 
231  }
232  }
233  }
234  }
235  }
236 
237  for ( int ism = 0; ism < 18; ism++ ) {
238  if( meEEDcsActive_[ism] ) meEEDcsActive_[ism]->Fill( readySum[ism]/float(nValidChannels[ism]) );
239  }
240 
241  if( meEEDcsFraction_ ) meEEDcsFraction_->Fill( readySumTot/float(nValidChannelsTot) );
242 
243 }
244 
246 
247 }
static bool validDetId(int ix, int iy, int iz)
Definition: EcalScDetId.cc:63
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 reset(void)
Reset.
Some &quot;id&quot; conversions.
void beginLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup)
BeginLuminosityBlock.
static std::string sEE(const int ism)
Definition: Numbers.cc:199
static const int XYMODE
Definition: EEDetId.h:316
void cleanup(void)
Cleanup.
tuple histo
Definition: trackerHits.py:12
EEDcsInfoTask(const edm::ParameterSet &ps)
Constructor.
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.cc:562
const_iterator find(uint32_t rawId) const
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:456
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:82
void Fill(long long x)
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
int readyLumi[40][20]
Definition: EEDcsInfoTask.h:73
MonitorElement * meEEDcsActiveMap_
Definition: EEDcsInfoTask.h:70
static int iSM(const int ism, const EcalSubdetector subdet)
Definition: Numbers.cc:216
void fillMonitorElements(int ready[40][20])
void beginJob(void)
BeginJob.
void removeElement(const std::string &name)
Definition: DQMStore.cc:2338
int readyRun[40][20]
Definition: EEDcsInfoTask.h:72
void endJob(void)
EndJob.
DQMStore * dqmStore_
Definition: EEDcsInfoTask.h:60
MonitorElement * meEEDcsFraction_
Definition: EEDcsInfoTask.h:68
std::string getName(Reflex::Type &cc)
Definition: ClassFiller.cc:18
unsigned int offset(bool)
int k[5][pyjets_maxn]
virtual ~EEDcsInfoTask()
Destructor.
void endLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup)
EndLuminosityBlock.
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.
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
MonitorElement * meEEDcsActive_[18]
Definition: EEDcsInfoTask.h:69
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:647
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:47
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:237
Definition: Run.h:31
std::string prefixME_
Definition: EEDcsInfoTask.h:62