CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ESDaqInfoTask.cc
Go to the documentation of this file.
1 #include <iostream>
2 
7 
10 
12 
16 
19 
21 
23 
25 
26 using namespace cms;
27 using namespace edm;
28 using namespace std;
29 
31 
32  dqmStore_ = Service<DQMStore>().operator->();
33 
34  prefixME_ = ps.getUntrackedParameter<string>("prefixME", "");
35 
36  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
37 
38  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
39 
40  ESFedRangeMin_ = ps.getUntrackedParameter<int>("ESFedRangeMin", 520);
41  ESFedRangeMax_ = ps.getUntrackedParameter<int>("ESFedRangeMax", 575);
42 
43  meESDaqFraction_ = 0;
44  meESDaqActiveMap_ = 0;
45  meESDaqError_ = 0;
46 
47  for (int i = 0; i < 56; i++) {
48  meESDaqActive_[i] = 0;
49  }
50 
51  if (ps.exists("esMapping")){
52  edm::ParameterSet esMap=ps.getParameter<edm::ParameterSet>("esMapping");
53  es_mapping_ = new ESElectronicsMapper(esMap);
54  }else{
55  edm::LogError("ESDaqInfoTask")<<"preshower mapping pointer not initialized. Temporary.";
56  es_mapping_=0;
57  }
58 
59 
60 
61 }
62 
64  delete es_mapping_;
65 }
66 
68 
69  char histo[200];
70 
71  if ( dqmStore_ ) {
72 
73  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
74 
75  sprintf(histo, "DAQSummary");
76  meESDaqFraction_ = dqmStore_->bookFloat(histo);
77  meESDaqFraction_->Fill(0.0);
78 
79  sprintf(histo, "DAQSummaryMap");
80  meESDaqActiveMap_ = dqmStore_->book2D(histo,histo, 80, 0.5, 80.5, 80, 0.5, 80.5);
81  meESDaqActiveMap_->setAxisTitle("Si X", 1);
82  meESDaqActiveMap_->setAxisTitle("Si Y", 2);
83 
84  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/DAQContents");
85 
86  for (int i = 0; i < 56; i++) {
87  sprintf(histo, "EcalPreshower_%d", ESFedRangeMin_+i);
88  meESDaqActive_[i] = dqmStore_->bookFloat(histo);
89  meESDaqActive_[i]->Fill(0.0);
90 
91  ESOnFed_[i] = false;
92  for ( int x = 0; x < 80; x++ ) {
93  for ( int y = 0; y < 80; y++ ) {
94  if(getFEDNumber(x, y) == ESFedRangeMin_+i){
95  ESOnFed_[i] = true;
96  break;
97  }
98  }
99  if(ESOnFed_[i] == true) break;
100  }
101  }
102 
103  dqmStore_->setCurrentFolder(prefixME_ + "/ESIntegrityTask");
104  sprintf(histo, "DAQError");
105  meESDaqError_ = dqmStore_->book1D(histo, histo, 56, ESFedRangeMin_-0.5, ESFedRangeMax_+0.5);
106  meESDaqError_->setAxisTitle("FedID", 1);
107 
108  }
109 
110 }
111 
113 
114  if ( enableCleanup_ ) this->cleanup();
115 
116 }
117 
119 
120  this->reset();
121 
122  for (int x = 0; x < 80; ++x) {
123  for (int y = 0; y < 80; ++y) {
124  if( getFEDNumber(x, y) > 0 ) meESDaqActiveMap_->setBinContent( x+1, y+1, 0.0 );
125  else meESDaqActiveMap_->setBinContent( x+1, y+1, -1.0 );
126  }
127  }
128 
129  for (int i = 0; i < 56; i++) {
130  if ( meESDaqError_ ) meESDaqError_->setBinContent(i, 0.0);
131  }
132 
134 
135  if( iSetup.find( recordKey ) ) {
136 
137  edm::ESHandle<RunInfo> sumFED;
138  iSetup.get<RunInfoRcd>().get(sumFED);
139 
140  std::vector<int> FedsInIds= sumFED->m_fed_in;
141 
142  float ESFedCount = 0.;
143 
144  for( unsigned int fedItr=0; fedItr<FedsInIds.size(); ++fedItr ) {
145 
146  int fedID=FedsInIds[fedItr];
147 
148  if ( fedID >= ESFedRangeMin_ && fedID <= ESFedRangeMax_ ) {
149 
150  if( ESOnFed_[fedID - ESFedRangeMin_] ) ESFedCount++;
151 
152  if ( meESDaqActive_[fedID-ESFedRangeMin_] ) meESDaqActive_[fedID-ESFedRangeMin_]->Fill(1.0);
153 
154  if( meESDaqActiveMap_ ) {
155 
156  for (int x = 0; x < 80; x++) {
157  for (int y = 0; y < 80; y++) {
158  if (fedID == getFEDNumber(x, y))
159  meESDaqActiveMap_->setBinContent( x+1, y+1, 1.0 );
160  }
161  }
162 
163  }
164 
165  if( meESDaqFraction_ ) meESDaqFraction_->Fill( ESFedCount/40. );
166 
167  if( meESDaqError_ ){
168  for( int i = 0; i < 56; i++){
169  if( ESOnFed_[fedID-ESFedRangeMin_] ) meESDaqError_->setBinContent(i+1, 1.0);
170  else meESDaqError_->setBinContent(i+1, 2.0);
171  }
172  }
173 
174  }
175 
176  }
177 
178  } else {
179 
180  LogWarning("ESDaqInfoTask") << "Cannot find any RunInfoRcd" << endl;
181 
182  }
183 
184 }
185 
187 
188 }
189 
191 
192  if ( meESDaqFraction_ ) meESDaqFraction_->Reset();
193 
194  for (int i = 0; i < 56; i++) {
195  if ( meESDaqActive_[i] ) meESDaqActive_[i]->Reset();
196  }
197 
198  if ( meESDaqActiveMap_ ) meESDaqActiveMap_->Reset();
199 
200  if ( meESDaqError_ ) meESDaqError_->Reset();
201 
202 }
203 
204 
206 
207  if ( dqmStore_ ) {
208 
209  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
210 
211  if ( meESDaqFraction_ ) dqmStore_->removeElement( meESDaqFraction_->getName() );
212 
213  if ( meESDaqActiveMap_ ) dqmStore_->removeElement( meESDaqActiveMap_->getName() );
214 
215  if ( meESDaqError_ ) dqmStore_->removeElement( meESDaqError_->getName() );
216 
217  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/DAQContents");
218 
219  for (int i = 0; i < 56; i++) {
220  if ( meESDaqActive_[i] ) dqmStore_->removeElement( meESDaqActive_[i]->getName() );
221  }
222 
223  }
224 
225 }
226 
227 void ESDaqInfoTask::analyze(const Event& e, const EventSetup& c){
228 
229 }
230 
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void beginJob(void)
BeginJob.
void cleanup(void)
Cleanup.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
bool exists(std::string const &parameterName) const
checks if a parameter exists
static void cleanup(const Factory::MakerMap::value_type &v)
Definition: Factory.cc:12
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:91
T x() const
Cartesian x coordinate.
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
void reset(void)
Reset.
const T & get() const
Definition: EventSetup.h:56
void endJob(void)
EndJob.
void beginLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup)
BeginLuminosityBlock.
void reset(double vett[256])
Definition: TPedValues.cc:11
ESDaqInfoTask(const edm::ParameterSet &ps)
Constructor.
void endLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup)
EndLuminosityBlock.
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
Definition: HCTypeTag.cc:125
virtual ~ESDaqInfoTask()
Destructor.