CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SiPixelHLTSource.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiPixelMonitorRawData
4 // Class: SiPixelHLTSource
5 //
17 //
18 // Original Author: Andrew York
19 //
20 // Framework
24 // DQM Framework
29 // Geometry
35 // DataFormats
43 //
44 #include <cstdlib>
45 #include <string>
46 
47 using namespace std;
48 using namespace edm;
49 
51  : conf_(iConfig),
52  rawin_(consumes<FEDRawDataCollection>(conf_.getParameter<edm::InputTag>("RawInput"))),
53  errin_(consumes<edm::DetSetVector<SiPixelRawDataError>>(conf_.getParameter<edm::InputTag>("ErrorInput"))),
55  saveFile(conf_.getUntrackedParameter<bool>("saveFile", false)),
56  slowDown(conf_.getUntrackedParameter<bool>("slowDown", false)),
57  dirName_(conf_.getUntrackedParameter<string>("DirName", "Pixel/FEDIntegrity/")) {
58  firstRun = true;
59  LogInfo("PixelDQM") << "SiPixelHLTSource::SiPixelHLTSource: Got DQM BackEnd interface" << endl;
60 }
61 
63  // do anything here that needs to be done at desctruction time
64  // (e.g. close files, deallocate resources etc.)
65  LogInfo("PixelDQM") << "SiPixelHLTSource::~SiPixelHLTSource: Destructor" << endl;
66 }
67 
69  LogInfo("PixelDQM") << " SiPixelHLTSource::beginJob - Initialisation ... " << std::endl;
70 
71  if (firstRun) {
72  eventNo = 0;
73 
74  firstRun = false;
75  }
76 }
77 
79  // Book Monitoring Elements
80  bookMEs(iBooker);
81 }
82 
83 //------------------------------------------------------------------
84 // Method called for every event
85 //------------------------------------------------------------------
87  eventNo++;
89  // get raw input data
91  iEvent.getByToken(rawin_, rawinput);
92  // get error input data
94  iEvent.getByToken(errin_, errorinput);
95  if (!errorinput.isValid())
96  return;
97 
98  int fedId;
99 
100  for (fedId = 0; fedId <= 39; fedId++) {
101  // get event data for this fed
102  const FEDRawData &fedRawData = rawinput->FEDData(fedId);
103  if (fedRawData.size() != 0)
104  (meRawWords_)->Fill(fedId);
105  } // end for
106 
108 
109  for (TrackerGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++) {
110  if (GeomDetEnumerators::isTrackerPixel((*it)->subDetector())) {
111  uint32_t detId = (*it)->geographicalId();
112  edm::DetSetVector<SiPixelRawDataError>::const_iterator isearch = errorinput->find(detId);
113  if (isearch != errorinput->end()) {
114  for (di = isearch->data.begin(); di != isearch->data.end(); di++) {
115  fedId = di->getFedId(); // FED the error came from
116  int errorType = di->getType(); // type of error
117  switch (errorType) {
118  case (35):
119  (meNErrors_)->Fill(fedId);
120  break;
121  case (36):
122  (meNErrors_)->Fill(fedId);
123  break;
124  case (37):
125  (meNErrors_)->Fill(fedId);
126  break;
127  case (38):
128  (meNErrors_)->Fill(fedId);
129  break;
130  default:
131  break;
132  }; // end switch
133  } // end for(di
134  } // end if( isearch
135  } // end if( ((*it)->subDetector()
136  } // for(TrackerGeometry
137 
138  edm::DetSetVector<SiPixelRawDataError>::const_iterator isearch = errorinput->find(0xffffffff);
139 
140  if (isearch != errorinput->end()) { // Not at empty iterator
141  for (di = isearch->data.begin(); di != isearch->data.end(); di++) {
142  fedId = di->getFedId(); // FED the error came from
143  int errorType = di->getType(); // type of error
144  switch (errorType) {
145  case (35):
146  (meNErrors_)->Fill(fedId);
147  break;
148  case (36):
149  (meNErrors_)->Fill(fedId);
150  break;
151  case (37):
152  (meNErrors_)->Fill(fedId);
153  break;
154  case (38):
155  (meNErrors_)->Fill(fedId);
156  break;
157  case (39):
158  (meNCRCs_)->Fill(fedId);
159  break;
160  default:
161  break;
162  }; // end switch
163  } // end for(di
164  } // end if( isearch
165  // slow down...
166  if (slowDown)
167  usleep(100000);
168 }
169 
170 //------------------------------------------------------------------
171 // Book MEs
172 //------------------------------------------------------------------
174  iBooker.cd();
175  iBooker.setCurrentFolder(dirName_);
176 
177  std::string rawhid;
178  std::string errhid;
179  // Get collection name and instantiate Histo Id builder
180  edm::InputTag rawin = conf_.getParameter<edm::InputTag>("RawInput");
181  SiPixelHistogramId *RawHistogramId = new SiPixelHistogramId(rawin.label());
182  edm::InputTag errin = conf_.getParameter<edm::InputTag>("ErrorInput");
183  SiPixelHistogramId *ErrorHistogramId = new SiPixelHistogramId(errin.label());
184 
185  // Is a FED sending raw data
186  meRawWords_ = iBooker.book1D("FEDEntries", "Number of raw words", 40, -0.5, 39.5);
187  meRawWords_->setAxisTitle("Number of raw words", 1);
188 
189  // Number of CRC errors
190  meNCRCs_ = iBooker.book1D("FEDFatal", "Number of fatal errors", 40, -0.5, 39.5);
191  meNCRCs_->setAxisTitle("Number of fatal errors", 1);
192 
193  // Number of translation error words
194  meNErrors_ = iBooker.book1D("FEDNonFatal", "Number of non-fatal errors", 40, -0.5, 39.5);
195  meNErrors_->setAxisTitle("Number of non-fatal errors", 1);
196 
197  delete RawHistogramId;
198  delete ErrorHistogramId;
199 }
200 
edm::ParameterSet conf_
SiPixelHLTSource(const edm::ParameterSet &conf)
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
MonitorElement * meNErrors_
edm::EDGetTokenT< edm::DetSetVector< SiPixelRawDataError > > errin_
MonitorElement * meNCRCs_
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeomToken_
virtual void bookMEs(DQMStore::IBooker &)
std::string dirName_
int iEvent
Definition: GenABIO.cc:224
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
bool isValid() const
Definition: HandleBase.h:70
edm::EDGetTokenT< FEDRawDataCollection > rawin_
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:325
MonitorElement * meRawWords_
Log< level::Info, false > LogInfo
void dqmBeginRun(const edm::Run &, edm::EventSetup const &) override
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::string const & label() const
Definition: InputTag.h:36
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:314
~SiPixelHLTSource() override
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
collection_type::const_iterator const_iterator
Definition: DetSet.h:31
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:102
void analyze(const edm::Event &, const edm::EventSetup &) override
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
Pixel error – collection of errors and error information.
Definition: Run.h:45
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)