CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ESFEDIntegrityTask.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <fstream>
3 #include <vector>
4 
10 
14 
24 
25 using namespace cms;
26 using namespace edm;
27 using namespace std;
28 
30 
31  init_ = false;
32 
33  dqmStore_ = Service<DQMStore>().operator->();
34 
35  prefixME_ = ps.getUntrackedParameter<string>("prefixME", "");
36  fedDirName_ = ps.getUntrackedParameter<string>("FEDDirName", "FEDIntegrity");
37  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
38  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
39  debug_ = ps.getUntrackedParameter<bool>("debug", false);
40 
41  dccCollections_ = ps.getParameter<InputTag>("ESDCCCollections");
42  kchipCollections_ = ps.getParameter<InputTag>("ESKChipCollections");
43  FEDRawDataCollection_ = ps.getParameter<edm::InputTag>("FEDRawDataCollection");
44 
45  meESFedsEntries_ = 0;
46  meESFedsFatal_ = 0;
47  meESFedsNonFatal_ = 0;
48 
49 }
50 
52 
53 }
54 
56 
57  ievt_ = 0;
58 
59  if ( dqmStore_ ) {
60  dqmStore_->setCurrentFolder(prefixME_ + "/" + fedDirName_);
61  dqmStore_->rmdir(prefixME_ + "/" + fedDirName_);
62  }
63 
64 }
65 
67 
68  if ( ! mergeRuns_ ) this->reset();
69 
70 }
71 
73 
74 }
75 
77 
78  if ( meESFedsEntries_ ) meESFedsEntries_->Reset();
79  if ( meESFedsFatal_ ) meESFedsFatal_->Reset();
80  if ( meESFedsNonFatal_ ) meESFedsNonFatal_->Reset();
81 
82 }
83 
85 
86  init_ = true;
87 
88  char histo[200];
89 
90  if ( dqmStore_ ) {
91  dqmStore_->setCurrentFolder(prefixME_ + "/" + fedDirName_);
92 
93  sprintf(histo, "FEDEntries");
94  meESFedsEntries_ = dqmStore_->book1D(histo, histo, 56, 520, 576);
95 
96  sprintf(histo, "FEDFatal");
97  meESFedsFatal_ = dqmStore_->book1D(histo, histo, 56, 520, 576);
98 
99  sprintf(histo, "FEDNonFatal");
100  meESFedsNonFatal_ = dqmStore_->book1D(histo, histo, 56, 520, 576);
101  }
102 
103 }
104 
106 
107  if ( ! init_ ) return;
108 
109  if ( dqmStore_ ) {
110  dqmStore_->setCurrentFolder(prefixME_ + "/" + fedDirName_);
111 
112  if ( meESFedsEntries_ ) dqmStore_->removeElement( meESFedsEntries_->getName() );
113  meESFedsEntries_ = 0;
114 
115  if ( meESFedsFatal_ ) dqmStore_->removeElement( meESFedsFatal_->getName() );
116  meESFedsFatal_ = 0;
117 
118  if ( meESFedsNonFatal_ ) dqmStore_->removeElement( meESFedsNonFatal_->getName() );
119  meESFedsNonFatal_ = 0;
120 
121  }
122 
123  init_ = false;
124 
125 }
126 
128 
129  LogInfo("ESFEDIntegrityTask") << "analyzed " << ievt_ << " events";
130 
131  if ( enableCleanup_ ) this->cleanup();
132 
133 }
134 
136 
137  if ( ! init_ ) this->setup();
138 
139  ievt_++;
140 
141  int gt_L1A = 0, gt_OrbitNumber = 0, gt_BX = 0;
142  int esDCC_L1A_MostFreqCounts = 0;
143  int esDCC_BX_MostFreqCounts = 0;
144  int esDCC_OrbitNumber_MostFreqCounts = 0;
145  int gtFedDataSize = 0;
146 
148  Handle<FEDRawDataCollection> allFedRawData;
149 
150  if ( e.getByLabel(FEDRawDataCollection_, allFedRawData) ) {
151 
152  // ES FEDs
153  for (int esFED=520; esFED<=575; ++esFED) {
154 
155  const FEDRawData& fedData = allFedRawData->FEDData(esFED);
156  int length = fedData.size()/sizeof(uint64_t);
157 
158  if ( length > 0 )
159  if ( meESFedsEntries_ ) meESFedsEntries_->Fill(esFED);
160  }
161 
162  // GT FED data
163  const FEDRawData& gtFedData = allFedRawData->FEDData(812);
164 
165  gtFedDataSize = gtFedData.size()/sizeof(uint64_t);
166 
167  if ( gtFedDataSize > 0 ) {
168 
169  FEDHeader header(gtFedData.data());
170 
171  gt_L1A = header.lvl1ID();
172  gt_OrbitNumber = e.orbitNumber();
173  gt_BX = e.bunchCrossing();
174  } else {
175 
176  map<int, int> esDCC_L1A_FreqMap;
177  map<int, int> esDCC_BX_FreqMap;
178  map<int, int> esDCC_OrbitNumber_FreqMap;
179 
180  if ( e.getByLabel(dccCollections_, dccs) ) {
181 
182  for (ESRawDataCollection::const_iterator dccItr = dccs->begin(); dccItr != dccs->end(); ++dccItr) {
183  ESDCCHeaderBlock esdcc = (*dccItr);
184 
185  esDCC_L1A_FreqMap[esdcc.getLV1()]++;
186  esDCC_BX_FreqMap[esdcc.getBX()]++;
187  esDCC_OrbitNumber_FreqMap[esdcc.getOrbitNumber()]++;
188 
189  if (esDCC_L1A_FreqMap[esdcc.getLV1()] > esDCC_L1A_MostFreqCounts) {
190  esDCC_L1A_MostFreqCounts = esDCC_L1A_FreqMap[esdcc.getLV1()];
191  gt_L1A = esdcc.getLV1();
192  }
193 
194  if (esDCC_BX_FreqMap[esdcc.getBX()] > esDCC_BX_MostFreqCounts) {
195  esDCC_BX_MostFreqCounts = esDCC_BX_FreqMap[esdcc.getBX()];
196  gt_BX = esdcc.getBX();
197  }
198 
199  if (esDCC_OrbitNumber_FreqMap[esdcc.getOrbitNumber()] > esDCC_OrbitNumber_MostFreqCounts) {
200  esDCC_OrbitNumber_MostFreqCounts = esDCC_OrbitNumber_FreqMap[esdcc.getOrbitNumber()];
201  gt_OrbitNumber = esdcc.getOrbitNumber();
202  }
203 
204  }
205  } else {
206  LogWarning("ESFEDIntegrityTask") << dccCollections_ << " not available";
207  }
208 
209  }
210 
211  } else {
212  LogWarning("ESFEDIntegrityTask") << FEDRawDataCollection_ << " not available";
213  }
214 
215  vector<int> fiberStatus;
216  if ( e.getByLabel(dccCollections_, dccs) ) {
217  for (ESRawDataCollection::const_iterator dccItr = dccs->begin(); dccItr != dccs->end(); ++dccItr) {
218  ESDCCHeaderBlock dcc = (*dccItr);
219 
220  if (dcc.getDCCErrors() > 0) {
221 
222  if ( meESFedsFatal_ ) meESFedsFatal_->Fill(dcc.fedId());
223 
224  } else {
225  if (debug_) cout<<dcc.fedId()<<" "<<dcc.getOptoRX0()<<" "<<dcc.getOptoRX1()<<" "<<dcc.getOptoRX2()<<endl;
226  fiberStatus = dcc.getFEChannelStatus();
227 
228  if (dcc.getOptoRX0() == 128) {
229  meESFedsNonFatal_->Fill(dcc.fedId(), 1./3.);
230  } else if (dcc.getOptoRX0() == 129) {
231  for (unsigned int i=0; i<12; ++i) {
232  if (fiberStatus[i]==8 || fiberStatus[i]==10 || fiberStatus[i]==11 || fiberStatus[i]==12)
233  if ( meESFedsNonFatal_ ) meESFedsNonFatal_->Fill(dcc.fedId(), 1./12.);
234  }
235  }
236  if (dcc.getOptoRX1() == 128) {
237  meESFedsNonFatal_->Fill(dcc.fedId(), 1./3.);
238  } else if (dcc.getOptoRX1() == 129) {
239  for (unsigned int i=12; i<24; ++i) {
240  if (fiberStatus[i]==8 || fiberStatus[i]==10 || fiberStatus[i]==11 || fiberStatus[i]==12)
241  if ( meESFedsNonFatal_ ) meESFedsNonFatal_->Fill(dcc.fedId(), 1./12.);
242  }
243  }
244  if (dcc.getOptoRX2() == 128) {
245  meESFedsNonFatal_->Fill(dcc.fedId(), 1./3.);
246  } else if (dcc.getOptoRX2() == 129){
247  for (unsigned int i=24; i<36; ++i) {
248  if (fiberStatus[i]==8 || fiberStatus[i]==10 || fiberStatus[i]==11 || fiberStatus[i]==12)
249  if ( meESFedsNonFatal_ ) meESFedsNonFatal_->Fill(dcc.fedId(), 1./12.);
250  }
251  }
252  }
253 
254  if (dcc.getLV1() != gt_L1A) meESFedsNonFatal_->Fill(dcc.fedId());
255  //if (dcc.getBX() != gt_BX) meESFedsNonFatal_->Fill(dcc.fedId());
256  //if (dcc.getOrbitNumber() != gt_OrbitNumber) meESFedsNonFatal_->Fill(dcc.fedId());
257  }
258  }
259 
260  //for (ESLocalRawDataCollection::const_iterator kItr = kchips->begin(); kItr != kchips->end(); ++kItr) {
261 
262  //ESKCHIPBlock kchip = (*kItr);
263 
264  //Int_t nErr = 0;
265  //if (kchip.getFlag1() > 0) nErr++;
266  //if (kchip.getFlag2() > 0) nErr++;
267  //if (kchip.getBC() != kchip.getOptoBC()) nErr++;
268  //if (kchip.getEC() != kchip.getOptoEC()) nErr++;
269  //if (nErr>0) meESFedsNonFatal_->Fill(dcc.fedId());
270  //}
271 
272 }
273 
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
int getLV1() const
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< T >::const_iterator const_iterator
static void cleanup(const Factory::MakerMap::value_type &v)
Definition: Factory.cc:12
int bunchCrossing() const
Definition: EventBase.h:62
int getOptoRX0() const
int getOptoRX1() const
tuple histo
Definition: trackerHits.py:12
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
const std::vector< int > & getFEChannelStatus() const
void endJob(void)
EndJob.
void setup(void)
Setup.
int getBX() const
void beginJob(void)
BeginJob.
void cleanup(void)
Cleanup.
void reset(void)
Reset.
ESFEDIntegrityTask(const edm::ParameterSet &ps)
int getOrbitNumber() const
int orbitNumber() const
Definition: EventBase.h:63
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
unsigned long long uint64_t
Definition: Time.h:15
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
int getDCCErrors() const
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:29
tuple cout
Definition: gather_cfg.py:41
const int fedId() const
int lvl1ID()
Level-1 event number generated by the TTC system.
Definition: FEDHeader.cc:22
int getOptoRX2() const
void reset(double vett[256])
Definition: TPedValues.cc:11
Definition: Run.h:31